-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #717 from setchy/feature/dashboard-violations
feat(dashboard): policy violations by state and classification cards
- Loading branch information
Showing
6 changed files
with
170 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/views/dashboard/ChartPolicyViolationsClassification.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<script> | ||
import common from "../../shared/common" | ||
import { Line } from 'vue-chartjs' | ||
import { getStyle } from '@coreui/coreui/dist/js/coreui-utilities' | ||
import { CustomTooltips } from '@coreui/coreui-plugin-chartjs-custom-tooltips' | ||
export default { | ||
extends: Line, | ||
props: { | ||
height: Number | ||
}, | ||
methods: { | ||
render: function(metrics) { | ||
const securityStyle = getStyle('--notification-fail'); | ||
const operationalStyle = getStyle('--notification-warn'); | ||
const licenseStyle = getStyle('--notification-info'); | ||
let labels = []; | ||
let securityData = []; | ||
let operationalData = []; | ||
let licenseData = []; | ||
for (let i = 0; i < metrics.length; i++) { | ||
labels.push(common.formatTimestamp(metrics[i].firstOccurrence)); | ||
securityData.push(metrics[i].policyViolationsSecurityTotal); | ||
operationalData.push(metrics[i].policyViolationsOperationalTotal); | ||
licenseData.push(metrics[i].policyViolationsLicenseTotal); | ||
if (i === metrics.length - 1) { | ||
labels.push(common.formatTimestamp(metrics[i].lastOccurrence)); | ||
securityData.push(metrics[i].policyViolationsSecurityTotal); | ||
operationalData.push(metrics[i].policyViolationsOperationalTotal); | ||
licenseData.push(metrics[i].policyViolationsLicenseTotal); | ||
} | ||
} | ||
this.renderChart({ | ||
labels: labels, | ||
datasets: [ | ||
{ | ||
label: this.$t('policy_violation.security'), | ||
backgroundColor: 'transparent', | ||
borderColor: securityStyle, | ||
pointHoverBackgroundColor: '#fff', | ||
data: securityData | ||
}, | ||
{ | ||
label: this.$t('policy_violation.operational'), | ||
backgroundColor: 'transparent', | ||
borderColor: operationalStyle, | ||
pointHoverBackgroundColor: '#fff', | ||
data: operationalData | ||
}, | ||
{ | ||
label: this.$t('policy_violation.license'), | ||
backgroundColor: 'transparent', | ||
borderColor: licenseStyle, | ||
pointHoverBackgroundColor: '#fff', | ||
data: licenseData | ||
} | ||
] | ||
}, { | ||
tooltips: { | ||
enabled: false, | ||
custom: CustomTooltips, | ||
intersect: true, | ||
mode: 'index', | ||
position: 'nearest', | ||
callbacks: { | ||
labelColor: function (tooltipItem, chart) { | ||
return { backgroundColor: chart.data.datasets[tooltipItem.datasetIndex].borderColor } | ||
} | ||
} | ||
}, | ||
maintainAspectRatio: false, | ||
legend: { | ||
display: false | ||
}, | ||
scales: { | ||
xAxes: [{ | ||
gridLines: { | ||
drawOnChartArea: false | ||
} | ||
}], | ||
yAxes: [{ | ||
ticks: { | ||
beginAtZero: true, | ||
maxTicksLimit: 1 | ||
}, | ||
gridLines: { | ||
display: true | ||
} | ||
}] | ||
}, | ||
elements: { | ||
line: { | ||
tension: 0.1, | ||
borderWidth: 2 | ||
}, | ||
point: { | ||
radius: 0, | ||
hitRadius: 20, | ||
hoverRadius: 4, | ||
hoverBorderWidth: 3 | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters