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

View File

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

View File

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

View File

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