Skip to content

Commit

Permalink
clickable metrics (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
ab-smith authored Nov 29, 2024
2 parents 086ea2f + d819964 commit 282df7b
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 101 deletions.
15 changes: 12 additions & 3 deletions backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
from iam.models import Folder, Permission, RoleAssignment, User
from library.helpers import get_referential_translation

from statistics import mean
import math

from .models import *
from .utils import camel_case

Expand Down Expand Up @@ -889,6 +892,10 @@ def viewable_items(model):

viewable_controls = viewable_items(AppliedControl)
controls_count = viewable_controls.count()
progress_avg = math.ceil(
mean([x.progress() for x in viewable_items(ComplianceAssessment)] or [0])
)

data = {
"controls": {
"total": controls_count,
Expand All @@ -908,17 +915,19 @@ def viewable_items(model):
"acceptances": viewable_items(RiskAcceptance).count(),
},
"compliance": {
"used_frameworks": viewable_items(ComplianceAssessment)
.values("framework_id")
.distinct()
.count(),
"audits": viewable_items(ComplianceAssessment).count(),
"active_audits": viewable_items(ComplianceAssessment)
.filter(status__in=["in_progress", "in_review", "done"])
.count(),
"evidences": viewable_items(Evidence).count(),
"compliant_items": viewable_items(RequirementAssessment)
.filter(result="compliant")
.count(),
"non_compliant_items": viewable_items(RequirementAssessment)
.filter(result="non_compliant")
.count(),
"progress_avg": progress_avg,
},
"audits_stats": build_audits_stats(user),
"csf_functions": csf_functions(user),
Expand Down
17 changes: 9 additions & 8 deletions frontend/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -808,14 +808,15 @@
"sumpageToDo": "to do",
"sumpageInProgress": "in progress",
"sumpageOnHold": "on hold",
"sumpageActiveAudits": "active audits",
"sumpageCompliantItems": "compliant items",
"sumpageNonCompliantItems": "non compliant items",
"sumpageEvidences": "evidences",
"sumpageAssessments": "assessments",
"sumpageScenarios": "scenarios",
"sumpageMappedThreats": "mapped threats",
"sumpageRiskAccepted": "risks accepted",
"sumpageActiveAudits": "Active audits",
"sumpageCompliantItems": "Compliant items",
"sumpageNonCompliantItems": "Non compliant items",
"sumpageEvidences": "Evidences",
"sumpageAvgProgress": "Average progress",
"sumpageAssessments": "Assessments",
"sumpageScenarios": "Scenarios",
"sumpageMappedThreats": "Mapped threats",
"sumpageRiskAccepted": "Risks accepted",
"sumpageSectionControls": "controls",
"sumpageTitleComplianceOverview": "Compliance overview",
"sumpageTitleCurrentRisks": "Current risks",
Expand Down
31 changes: 16 additions & 15 deletions frontend/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,21 +791,22 @@
"fillSSOSLOURLx509cert": "Option 2 : Remplissez l'URL SSO, l'URL SLO et le certificat x509",
"licenseAboutToExpireWarning": "Il reste {days_left} jours avant l'expiration de votre licence.",
"noExpirationDateSet": "Aucune date d'expiration définie",
"sumpageTotal": "total",
"sumpageActive": "actif",
"sumpageDeprecated": "obsolète",
"sumpageToDo": "à faire",
"sumpageInProgress": "en cours",
"sumpageOnHold": "en attente",
"sumpageActiveAudits": "audits actifs",
"sumpageCompliantItems": "items conformes",
"sumpageNonCompliantItems": "items non conformes",
"sumpageEvidences": "preuves",
"sumpageAssessments": "évaluations",
"sumpageScenarios": "scénarios",
"sumpageMappedThreats": "menaces mappées",
"sumpageRiskAccepted": "risques acceptés",
"sumpageSectionControls": "mesures",
"sumpageTotal": "Total",
"sumpageActive": "Actif",
"sumpageDeprecated": "Obsolète",
"sumpageToDo": "A faire",
"sumpageInProgress": "En cours",
"sumpageOnHold": "En attente",
"sumpageActiveAudits": "Audits actifs",
"sumpageCompliantItems": "Exigences conformes",
"sumpageNonCompliantItems": "Exigences non conformes",
"sumpageEvidences": "Preuves",
"sumpageAvgProgress": "Avancement moyenné",
"sumpageAssessments": "Analyses",
"sumpageScenarios": "Scénarios",
"sumpageMappedThreats": "Menaces mappées",
"sumpageRiskAccepted": "Risques acceptés",
"sumpageSectionControls": "Mesures",
"sumpageTitleComplianceOverview": "Aperçu conformité",
"sumpageTitleCurrentRisks": "Risques actuels",
"sumpageTitleResidualRisks": "Risques résiduels",
Expand Down
9 changes: 5 additions & 4 deletions frontend/src/lib/components/DataViz/Card.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
export let count: string = '0';
export let label: string;
// export let href: string | undefined = undefined;
export let href: string = '#';
// export let help: string;
export let icon: string;
export let section: string;
Expand All @@ -12,18 +12,19 @@
}
</script>

<div
<a
{href}
class="flex flex-col shadow-lg text-purple-800 p-2 h-28 bg-white hover:bg-violet-50 {cEmphasis}"
>
<div class="text-xs">
<span><i class={icon}></i></span>
<span>{section}</span>
</div>
<div class="mt-auto">
<div class="text-4xl font-bold text-left">{count}</div>
<p class="text-4xl font-bold text-left">{count}</p>
<div class="text-sm">{label}</div>
</div>
</div>
</a>

<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
Expand Down
19 changes: 0 additions & 19 deletions frontend/src/lib/components/ModelTable/ModelTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -307,25 +307,6 @@
{#if key !== 'meta'}
{@const component = field_component_map[key]}
<td class={regionCell} role="gridcell">
{#if taggedKeys.has(key)}
{@const _tagList = tagMap[key]}
{@const tagList = Object.keys(_tagList.keys).map((key) => ({
key: { [key]: _tagList.keys[key] }
}))}
{#each tagList as tag}
{@const tagKey = tag.key && Object.keys(tag.key)[0]}
{@const tagValue = meta[tagKey]}
{@const tagData = tag.key?.[tagKey]?.[tagValue]}
{#if tagData && tags}
{@const { text, cssClasses } = tagData}
<span class="space-x-1">
<span class={cssClasses}>
{safeTranslate(text)}
</span>
</span>
{/if}
{/each}
{/if}
{#if component}
<svelte:component this={component} {meta} cell={value} />
{:else}
Expand Down
18 changes: 6 additions & 12 deletions frontend/src/lib/components/SideBar/navData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,6 @@ export const navData = {
{
name: 'extra',
items: [
{
name: 'inspect',
fa_icon: 'fa-brands fa-searchengin',
href: '/x-rays/inspect',
permissions: ['view_riskassessment', 'view_assessment']
},
{
name: 'backupRestore',
fa_icon: 'fa-solid fa-floppy-disk',
href: '/backup-restore',
permissions: ['backup']
},
{
name: 'labels',
fa_icon: 'fa-solid fa-tag',
Expand All @@ -246,6 +234,12 @@ export const navData = {
href: '/settings',
permissions: ['change_globalsettings']
},
{
name: 'backupRestore',
fa_icon: 'fa-solid fa-floppy-disk',
href: '/backup-restore',
permissions: ['backup']
},
{
name: 'Experimental',
fa_icon: 'fa-solid fa-flask',
Expand Down
24 changes: 14 additions & 10 deletions frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,23 +301,25 @@ export const listViewFields: ListViewFieldsConfig = {
'risk-scenarios': {
head: [
'ref_id',
'name',
'threats',
'riskAssessment',
'name',
'existingAppliedControls',
'currentLevel',
'extraAppliedControls',
'residualLevel'
'residualLevel',
'treatment',
'riskAssessment'
],
body: [
'ref_id',
'name',
'threats',
'risk_assessment',
'name',
'existing_applied_controls',
'current_level',
'applied_controls',
'residual_level'
'residual_level',
'treatment',
'risk_assessment'
],
filters: {
folder: { ...DOMAIN_FILTER_FROM_PROJECT, alwaysDisplay: true },
Expand All @@ -341,7 +343,8 @@ export const listViewFields: ListViewFieldsConfig = {
head: [
'ref_id',
'name',
'description',
'priority',
'status',
'category',
'csfFunction',
'eta',
Expand All @@ -352,7 +355,8 @@ export const listViewFields: ListViewFieldsConfig = {
body: [
'ref_id',
'name',
'description',
'priority',
'status',
'category',
'csf_function',
'eta',
Expand Down Expand Up @@ -394,8 +398,8 @@ export const listViewFields: ListViewFieldsConfig = {
assets: {
head: [
'name',
'type',
'description',
'businessValue',
'securityObjectives',
'disasterRecoveryObjectives',
'owner',
Expand All @@ -404,8 +408,8 @@ export const listViewFields: ListViewFieldsConfig = {
],
body: [
'name',
'type',
'description',
'business_value',
'security_objectives',
'disaster_recovery_objectives',
'owner',
Expand Down
Loading

0 comments on commit 282df7b

Please sign in to comment.