clusterscan detail fixes

This commit is contained in:
Nancy Butler 2020-09-22 10:07:47 -07:00
parent c3647902c4
commit af3d6c63bf
4 changed files with 27 additions and 23 deletions

View File

@ -5,7 +5,6 @@ import { defaultAsyncData } from '@/components/ResourceDetail';
import { CIS } from '@/config/types';
import { STATE } from '@/config/table-headers';
import { randomStr } from '@/utils/string';
import { get } from '@/utils/object';
export default {
components: {
@ -35,27 +34,25 @@ export default {
},
computed: {
parsedReport() {
const report = this.clusterReport?.parsedReport;
parsedData() {
const reportJSON = get(this.clusterReport, 'spec.reportJSON');
return reportJSON ? JSON.parse(reportJSON) : null;
return report;
},
reportNodes() {
// return this.parsedData ? this.parsedData.nodes : {};
return { master: ['node1', 'node2'] };
return this.clusterReport?.nodes || null;
},
results() {
if (!this.clusterReport) {
if (!this.clusterReport || !this.clusterReport.aggregatedTests) {
return [];
}
return this.clusterReport.aggregatedTests.map((check) => {
check.testStateSort = this.testStateSort(check.state);
if (!!check.node_type) {
check.nodes = check.node_type.reduce((nodes, type) => {
const nodes = check.node_type.reduce((nodes, type) => {
if (this.reportNodes[type]) {
this.reportNodes[type].forEach(name => nodes.push({
type, name, id: randomStr(4), state: check.state
@ -64,6 +61,8 @@ export default {
return nodes;
}, []);
check.nodes = nodes;
}
return check;
@ -71,7 +70,7 @@ export default {
},
details() {
if (!this.parsedData) {
if (!this.parsedReport) {
return [];
}
@ -90,23 +89,23 @@ export default {
},
{
label: this.t('cis.scan.total'),
value: this.parsedData.total
value: this.parsedReport.total
},
{
label: this.t('cis.scan.passed'),
value: this.parsedData.pass
value: this.parsedReport.pass
},
{
label: this.t('cis.scan.skipped'),
value: this.parsedData.skip
value: this.parsedReport.skip
},
{
label: this.t('cis.scan.failed'),
value: this.parsedData.fail
value: this.parsedReport.fail
},
{
label: this.t('cis.scan.notApplicable'),
value: this.parsedData.notApplicable
value: this.parsedReport.notApplicable
},
{
label: this.t('cis.scan.lastScanTime'),
@ -159,10 +158,10 @@ export default {
methods: {
testStateSort(state) {
const SORT_ORDER = {
failed: 1,
skipped: 2,
fail: 1,
skip: 2,
notApplicable: 3,
passed: 4,
pass: 4,
other: 5,
};
@ -199,7 +198,7 @@ export default {
key-field="id"
>
<template #sub-row="{row, fullColspan}">
<tr>
<tr v-if="row.nodes && row.nodes.length">
<td :colspan="fullColspan">
<SortableTable
class="sub-table"

View File

@ -76,7 +76,7 @@ export default {
defaultProfile() {
if (this.defaultConfigMap) {
const profiles = this.defaultConfigMap.data;
const provider = this.currentCluster.provider;
const provider = this.currentCluster.status.provider;
return profiles[provider] || profiles.default;
}

View File

@ -1,6 +1,6 @@
export default {
aggregatedTests() {
const json = this.reportJSON;
const json = this.parsedReport;
const results = json?.results;
return results ? results.reduce((all, each) => {
@ -13,10 +13,10 @@ export default {
},
nodes() {
return this.reportJSON ? this.reportJSON.nodes : {};
return this.parsedReport ? this.parsedReport.nodes : {};
},
reportJSON() {
parsedReport() {
try {
const json = this.spec?.reportJSON;
@ -24,6 +24,7 @@ export default {
return parsed;
} catch (e) {
console.error(e);
}
}
};

View File

@ -86,6 +86,7 @@ const STATES = {
erroring: { color: 'error', icon: 'error' },
expired: { color: 'warning', icon: 'error' },
failed: { color: 'error', icon: 'error' },
fail: { color: 'error', icon: 'error' },
healthy: { color: 'success', icon: 'dot-open' },
inactive: { color: 'error', icon: 'dot' },
initializing: { color: 'warning', icon: 'error' },
@ -93,7 +94,9 @@ const STATES = {
migrating: { color: 'info', icon: 'info' },
modified: { color: 'warning', icon: 'edit' },
notapplied: { color: 'warning', icon: 'tag' },
notApplicable: { color: 'warning', icon: 'tag' },
passed: { color: 'success', icon: 'dot-dotfill' },
pass: { color: 'success', icon: 'dot-dotfill' },
paused: { color: 'info', icon: 'info' },
pending: { color: 'info', icon: 'tag' },
provisioning: { color: 'info', icon: 'dot' },
@ -111,6 +114,7 @@ const STATES = {
restoring: { color: 'info', icon: 'medicalcross' },
running: { color: 'success', icon: 'dot-open' },
skipped: { color: 'info', icon: 'dot-open' },
skip: { color: 'info', icon: 'dot-open' },
starting: { color: 'info', icon: 'adjust' },
stopped: { color: 'error', icon: 'dot' },
stopping: { color: 'info', icon: 'adjust' },