Skip to content

Commit

Permalink
Merge pull request #4226 from cisagov/feat/chartUpdate
Browse files Browse the repository at this point in the history
Updates to pull sector for assessors
  • Loading branch information
randywoods authored Nov 12, 2024
2 parents 465c3a9 + b588fb9 commit bdff560
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
<div class="row">
<div class="col-sm">
<mat-card>
<mat-card-header class="d-flex justify-content-center"><h2>Analytics</h2></mat-card-header>
<mat-card-header class="d-flex justify-content-center">
<h2>Analytics</h2>
</mat-card-header>
<div class="p-4">
<mat-button-toggle-group [(ngModel)]="dataType" (change)="toggleData($event)">
<mat-button-toggle value="mySector">My Sector</mat-button-toggle>
<mat-button-toggle [value]="'mySector'" [disabled]="!showSector" matTooltip="Select a sector from demographics"
[matTooltipDisabled]="showSector">
My Sector: {{sectorTitle}}
</mat-button-toggle>
<mat-button-toggle value="allSectors">All Sectors</mat-button-toggle>
</mat-button-toggle-group>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,43 @@ import Chart, { ChartConfiguration, ChartType, registerables } from 'chart.js/au
import { AssessmentService } from '../../../services/assessment.service';
import { AggregationService } from '../../../services/aggregation.service';
import { AssessmentDetail } from '../../../models/assessment-info.model';
import { DemographicService } from '../../../services/demographic.service';
import { DemographicIodService } from '../../../services/demographic-iod.service';

Chart.register(...registerables);

interface Sector {
sectorId: number;
sectorName: string;
}

interface DemographicsIod {
listSectors: listSectors[];
}

interface listSectors {
optionValue: number;
optionText: string;
}
@Component({
selector: 'app-analytics-results',
templateUrl: './analytics-results.component.html',
styleUrls: ['./analytics-results.component.scss']
})
export class AnalyticsResultsComponent implements OnInit {

sectorId: any;
sectorId: number;
assessmentId: any;
modelId: any;
minData: number[] = [];
medianData: number[] = [];
maxData: number[] = [];
currentUserData: number[] = [];
labels: string[] = [];
sectorsList: Sector[];
sectorTitle: string;
showSector: boolean = true;


@ViewChild('barCanvas') private barCanvas!: ElementRef<HTMLCanvasElement>;
private barChart!: Chart;
Expand All @@ -34,17 +53,48 @@ export class AnalyticsResultsComponent implements OnInit {
public navSvc: NavigationService,
public analyticsSvc: AnalyticsService,
public assessSvc: AssessmentService,
public aggregSvc: AggregationService
public aggregSvc: AggregationService,
public demoSvc: DemographicService,
public demoIodSvc: DemographicIodService
) { }

ngOnInit(): void {
this.assessSvc.getAssessmentDetail().subscribe((resp: AssessmentDetail) => {
this.assessmentId = resp.id;
this.sectorId = resp.sectorId;
this.modelId = resp.maturityModel.modelId;
if (this.sectorId == null){
this.showSector = false;
this.dataType = "allSectors"
}
let isCISA = this.analyticsSvc.isCisaAssessorMode()
if (isCISA){
this.demoIodSvc.getDemographics().subscribe((resp: DemographicsIod) => {
resp.listSectors.forEach(sector => {
if (sector.optionValue == this.sectorId){
this.sectorTitle = sector.optionText
}
});
})
} else {
this.demoSvc.getAllSectors().subscribe(
(data: Sector[]) => {
this.sectorsList = data;
this.sectorsList.forEach(sector => {
if (sector.sectorId == this.sectorId){
this.sectorTitle = sector.sectorName
}
});
}
)
}


// Fetch initial data after getting assessment details
this.getAnalyticsResults();
});


}

ngAfterViewInit(): void {
Expand Down
4 changes: 4 additions & 0 deletions CSETWebNg/src/app/services/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class AnalyticsService {
return this.http.get(this.apiUrl + 'getAggregation');
}

isCisaAssessorMode() {
return this.configSvc.installationMode == "IOD";
}


getAnalyticResults(assessmentId: any, maturityModelId: any, sectorId?: any): any {
let url = this.configSvc.config.csetAnalyticsUrl
Expand Down

0 comments on commit bdff560

Please sign in to comment.