Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Question Group Headings translated in API #3734

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,23 @@
},
{
"key": "58",
"value": "[UK]Detect"
"value": "Виявлення"
},
{
"key": "59",
"value": "[UK]Identify"
"value": "Ідентифікація"
},
{
"key": "60",
"value": "[UK]Protect"
"value": "Захист"
},
{
"key": "61",
"value": "Disaster Recovery"
},
{
"key": "62",
"value": "[UK]Respond"
"value": "Реагування"
},
{
"key": "63",
Expand Down Expand Up @@ -310,7 +310,7 @@
},
{
"key": "80",
"value": "[UK]Recover"
"value": "Відновлення"
},
{
"key": "81",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public Model.Question.KeyValuePair GetValue(string collection, string key, strin
{
GenericTranslation langPack = null;

// trying to get out cheaply and not waste time looking up English
if (lang == "en")
{
return null;
Expand Down
12 changes: 7 additions & 5 deletions CSETWebApi/CSETWeb_Api/CSETWebCore.Model/Analysis/ChartData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ public class ChartData
public string backgroundColor { get; set; }
public string borderColor { get; set; }
public string borderWidth { get; set; }
public List<double> data { get; set; }
public List<String> Labels { get; set; }
public List<double> data { get; set; } = [];
public List<String> Labels { get; set; } = [];
public List<string> EnglishLabels { get; set; } = [];
public int ComponentCount { get; set; }
public List<DataRows> DataRows { get; set; }
public List<DataRowsPie> DataRowsPie { get; set; }
public List<string> Colors { get; set; }
public List<DataRows> DataRows { get; set; } = [];
public List<DataRowsPie> DataRowsPie { get; set; } = [];
public List<string> Colors { get; set; } = [];

public ChartData()
{
data = new List<double>();
Labels = new List<string>();
EnglishLabels = new List<string>();
dataSets = new List<ChartData>();
DataRows = new List<DataRows>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace CSETWebCore.Model.Analysis
public class usp_getRankedCategories
{
public String Question_Group_Heading { get; set; }
public int QGH_Id { get; set; }
public int? qc { get; set; }
public int? cr { get; set; }
public int? Total { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,8 @@ public IActionResult GetDashboard()
{
string label = j.Item1;

if (lang != "en")
{
var val = _overlay.GetValue("GENERIC", j.Item1, lang)?.Value;
if (val != null)
{
label = val;
}
}


overallBars.Labels.Add(label);
overallBars.EnglishLabels.Add(j.Item1);
overallBars.Labels.Add(_overlay.GetValue("GENERIC", j.Item1, lang)?.Value ?? j.Item1);
overallBars.data.Add(j.Item2);
}

Expand Down Expand Up @@ -376,6 +367,8 @@ public IActionResult GetTopCategories(int? total)
}

int assessmentId = _tokenManager.AssessmentForUser();
var lang = _tokenManager.GetCurrentLanguage();

ChartData chartData = null;

var results = new RankedCategoriesMultiResult();
Expand Down Expand Up @@ -403,7 +396,7 @@ public IActionResult GetTopCategories(int? total)
foreach (usp_getRankedCategories c in results.Result1.Take((int)total))
{
chartData.data.Add((double)c.prc);
chartData.Labels.Add(c.Question_Group_Heading);
chartData.Labels.Add(_overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value ?? c.Question_Group_Heading);
}
}

Expand Down Expand Up @@ -489,6 +482,8 @@ private ChartData TransformToChart(GetCombinedOveralls c)
public IActionResult GetOverallRankedCategories()
{
int assessmentId = _tokenManager.AssessmentForUser();
var lang = _tokenManager.GetCurrentLanguage();

ChartData chartData = null;

var results = new RankedCategoriesMultiResult();
Expand Down Expand Up @@ -517,14 +512,14 @@ public IActionResult GetOverallRankedCategories()
foreach (usp_getRankedCategories c in results.Result1)
{
chartData.data.Add((double)(c.prc ?? 0));
chartData.Labels.Add(c.Question_Group_Heading);
chartData.Labels.Add(_overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value ?? c.Question_Group_Heading);

chartData.DataRows.Add(new DataRows()
{
failed = (c.nuCount ?? 0),
percent = (c.prc ?? 0),
total = (c.qc ?? 0),
title = c.Question_Group_Heading,
title = _overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value ?? c.Question_Group_Heading,
rank = i++
});

Expand Down Expand Up @@ -821,18 +816,8 @@ orderby an.Question_Group_Heading
chartData.DataRows = new List<DataRows>();
foreach (var c in labels)
{
var label = c.Question_Group_Heading.ToString();

if (lang != "en")
{
var val = _overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value;
if (val != null)
{
label = val;
}
}

chartData.Labels.Add(label);
chartData.Labels.Add(_overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value ??
c.Question_Group_Heading);
}

ColorsList colors = new ColorsList();
Expand All @@ -852,24 +837,14 @@ orderby an.Question_Group_Heading
nextChartData.backgroundColor = colors.getNext(set.Set_Name);
foreach (usp_getStandardsResultsByCategory c in nextSet)
{
if (lang != "en")
{
var val = _overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value;
if (val != null)
{
c.Question_Group_Heading = val;
}
}


nextChartData.data.Add((double)c.prc);
nextChartData.Labels.Add(c.Question_Group_Heading);
nextChartData.Labels.Add(_overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value ?? c.Question_Group_Heading);
nextChartData.DataRows.Add(new DataRows()
{
failed = c.yaCount,
percent = c.prc,
total = c.Actualcr,
title = c.Question_Group_Heading
title = _overlay.GetValue("QUESTION_GROUP_HEADING", c.QGH_Id.ToString(), lang)?.Value ?? c.Question_Group_Heading
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
////////////////////////////////
import { Component, OnInit } from '@angular/core';
import Chart from 'chart.js/auto';
import { Router } from '../../../../../../node_modules/@angular/router';
import { AssessmentService } from '../../../../services/assessment.service';
import { AnalysisService } from './../../../../services/analysis.service';
import { ConfigService } from '../../../../services/config.service';
import { NavigationService } from '../../../../services/navigation/navigation.service';
import { TranslocoService } from '@ngneat/transloco';
declare var $: any;

@Component({
Expand Down Expand Up @@ -58,7 +58,7 @@ export class DashboardComponent implements OnInit {
public assessSvc: AssessmentService,
public navSvc: NavigationService,
public configSvc: ConfigService,
private router: Router) { }
private tSvc: TranslocoService) { }

ngOnInit() {
this.analysisSvc.getDashboard().subscribe(x => this.setupPage(x));
Expand All @@ -75,10 +75,12 @@ export class DashboardComponent implements OnInit {
this.overallScoreDisplay = this.getScore(x.overallBars, 'Overall').toFixed(0) + '%';

this.standardBasedScore = this.getScore(x.overallBars, 'Standards');
this.standardBasedScoreDisplay = this.standardBasedScore > 0 ? this.standardBasedScore.toFixed(0) + '%' : 'No Standards Answers';
this.standardBasedScoreDisplay = this.standardBasedScore > 0 ?
this.standardBasedScore.toFixed(0) + '%' : this.tSvc.translate('reports.core.dashboard.no standards answers');

this.componentBasedScore = this.getScore(x.overallBars, 'Components');
this.componentBasedScoreDisplay = this.componentBasedScore > 0 ? this.componentBasedScore.toFixed(0) + '%' : 'No Components Answers';
this.componentBasedScoreDisplay = this.componentBasedScore > 0 ?
this.componentBasedScore.toFixed(0) + '%' : this.tSvc.translate('reports.core.dashboard.no components answers');


// Assessment Compliance
Expand Down Expand Up @@ -131,12 +133,12 @@ export class DashboardComponent implements OnInit {


/**
* Returns the 'data' element that corresponds to the position of the 'Label.'
* Returns the 'data' element that corresponds to the position of the English 'Label.'
* @param overallBars
*/
getScore(overallBars, label) {
for (let i = 0; i < overallBars.labels.length; i++) {
if (overallBars.labels[i].toLowerCase() === label.toLowerCase()) {
for (let i = 0; i < overallBars.englishLabels.length; i++) {
if (overallBars.englishLabels[i].toLowerCase() === label.toLowerCase()) {
return overallBars.data[i];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export class QuestionFiltersComponent implements OnInit {

@Output() filterChanged = new EventEmitter<any>();

question = "Question";

/**
* Holds the word "questions" or "statements"
Expand Down Expand Up @@ -75,7 +74,6 @@ export class QuestionFiltersComponent implements OnInit {
*/
ngOnInit(): any {
if (this.configSvc.installationMode === 'ACET') {
this.question = "Statement";
this.skin = "ncua";
if (this.assessSvc.isISE()) {
this.observations = "issues";
Expand Down
4 changes: 3 additions & 1 deletion CSETWebNg/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@
"score": "Score",
"overall score": "Overall Score",
"standard based": "Standard Based",
"component based": "Component Based"
"component based": "Component Based",
"no standards answers": "No Standards Answers",
"no components answers": "No Components Answers"
},
"executive summary": {
"executive summary": "Executive Summary",
Expand Down
4 changes: 3 additions & 1 deletion CSETWebNg/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,9 @@
"score": "Puntaje",
"overall score": "Puntuación general",
"standard based": "Basada en estándares",
"component based": "Basada en componentes"
"component based": "Basada en componentes",
"no standards answers": "[ES]No Standards Answers",
"no components answers": "[ES]No Components Answers"
},
"executive summary": {
"executive summary": "Resumen ejecutivo",
Expand Down
8 changes: 5 additions & 3 deletions CSETWebNg/src/assets/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@
"question": "Питання",
"assessment compliance text": "Ця діаграма показує загальні відсоткові бали. <br> Будь ласка, зверніть увагу, що питання без відповіді зараховуються як відповідь НІ в цих балах.",
"ranked categories text": "На цій діаграмі показано найпоширеніші проблемні сфери. Вони розраховуються на основі зваженої оцінки ризику на основі складності атаки. Вага атаки має найбільшу вагу для легких атак і меншу для більш складних для атаки.",
"passed": "[UK]Passed",
"failed": "Не вдалося",
"passed": "Пройшло",
"failed": "Невдачі",
"total": "Всього",
"percent": "Відсоток",
"number": "кількість",
Expand Down Expand Up @@ -466,7 +466,9 @@
"score": "Оцінка",
"overall score": "Загальний рахунок",
"standard based": "Стандартна оцінка",
"component based": "На основі компонентів"
"component based": "На основі компонентів",
"no standards answers": "Немає стандартних відповідей",
"no components answers": "Компоненти відповіді відсутні"
},
"executive summary": {
"executive summary": "Резюме",
Expand Down
Loading