Skip to content

Commit

Permalink
Merge pull request #3623 from cisagov/acet/date-translation
Browse files Browse the repository at this point in the history
Acet/date translation
  • Loading branch information
randywoods authored Nov 6, 2023
2 parents 1f6ad8c + 43313b1 commit 73872bf
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
</th>
<th *ngIf="isTSA" style="width: 5%;">Source</th>
<th aria-label="{{ t('assessment type')}}" mat-sort-header="type" style="width:15%;">{{ t('assessment type')}}</th>
<th *ngIf="showColumn('ise-submitted')" aria-label="ise-submitted">{{ t('acet.submitted') }}</th>
<th *ngIf="showColumn('ise-submitted')" mat-sort-header="ise-submitted" aria-label="ise-submitted">{{ t('acet.submitted') }}</th>
<th aria-label="{{ t('last modified')}}" mat-sort-header="date" style="width:15%;">{{ t('last modified')}}</th>
<th *ngIf="showColumn('primary-assessor')" aria-label="assessor" mat-sort-header="assessor"
style="width:15%;">{{t('primary assessor')}}</th>
<th aria-label="{{t('status')}}" mat-sort-header="{{t('status')}}" style="width:15%;">{{t('status')}}</th>
<th aria-label="{{t('status')}}" mat-sort-header="status" style="width:15%;">{{t('status')}}</th>
<th aria-label="delete assessment" style="width:5%; min-width:25px;"></th>
<th aria-label="export assessment" style="width:5%;"></th>
<th aria-label="Analytics" style="width:5%;" *ngIf="showColumn('analytics')"></th>
Expand All @@ -210,10 +210,10 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
'CSET' :
'TSA' }}</td>
<td>{{assessment.type}}</td>
<td *ngIf="!this.ncuaSvc.switchStatus">{{this.systemTimeTranslator(assessment.lastModifiedDate)
| date:'dd-MMM-yyyy'}}</td>
<td *ngIf="!this.ncuaSvc.switchStatus">{{reportSvc.translatedDate(assessment.lastModifiedDate)}}</td>
<td *ngIf="showColumn('ise-submitted')">
<ng-container *ngIf="assessment.iseSubmitted">{{ assessment.submittedDate | date: 'M/dd/yy' }}</ng-container>
<!-- <ng-container *ngIf="assessment.iseSubmitted">{{ assessment.submittedDate | date: 'M/dd/yy' }}</ng-container> -->
<ng-container *ngIf="assessment.iseSubmitted">{{ assessSvc.translatedDate(assessment.submittedDate, 'l') }}</ng-container>
</td>
<td *ngIf="this.ncuaSvc.switchStatus">{{systemTimeTranslator(assessment.lastModifiedDate)}}</td>

Expand Down Expand Up @@ -279,7 +279,7 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
{{assessment.assessmentName}}
</button>
</td>
<td>{{assessment.lastModifiedDate | date:'dd-MMM-yyyy'}}</td>
<td>{{systemTimeTranslator(assessment.lastModifiedDate)}}</td>
<td class="text-nowrap pl-1">
<button tabindex="0" class="icon-link-button-dark btn bgc-trans my-0 mx-1 p-0"
(click)="removeAssessment(assessment, i)"
Expand Down Expand Up @@ -313,7 +313,7 @@ <h2 class="mt-0" *ngIf="sortedAssessments?.length == 0">
</button>
</td>
<td>{{assessment.type}}</td>
<td>{{assessment.lastModifiedDate | date:'medium'}}</td>
<td>{{systemTimeTranslator(assessment.lastModifiedDate)}}</td>
<td>
<div *ngIf="assessment.selectedMaturityModel != 'CIS'">
<span *ngIf="assessment.totalAvailableQuestionsCount > 0; else blankAssessment">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ export class MyAssessmentsComponent implements OnInit {
private ncuaSvc: NCUAService,
public layoutSvc: LayoutService,
public dateAdapter: DateAdapter<any>,
public datePipe: DatePipe
public datePipe: DatePipe,
public reportSvc: ReportService
) { }

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
">

<div class="title-page-name">{{response?.information?.assessment_Name}}</div>
<div class="title-page-content">{{response?.information?.assessment_Date |
date:'dd-MMM-yyyy'}}
</div>
<div class="title-page-content">{{reportSvc.translatedDate(response?.information?.assessment_Date)}}</div>
<div class="title-page-content">{{response?.information?.assessor_Name}}</div>
<div class="title-page-content">{{response?.information?.assets | currency}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
">

<div class="title-page-name">{{response?.information?.assessment_Name}}</div>
<div class="title-page-content">{{response?.information?.assessment_Date |
date:'dd-MMM-yyyy'}}
</div>
<div class="title-page-content">{{reportSvc.translatedDate(response?.information?.assessment_Date)}}</div>
<div class="title-page-content">{{response?.information?.assessor_Name}}</div>
<div class="title-page-content">{{response?.information?.assets | currency}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
">

<div class="title-page-name">{{response?.information?.assessment_Name}}</div>
<div class="title-page-content">{{response?.information?.assessment_Date |
date:'dd-MMM-yyyy'}}
</div>
<div class="title-page-content">{{reportSvc.translatedDate(response?.information?.assessment_Date)}}</div>
<div class="title-page-content">{{response?.information?.assessor_Name}}</div>
<div class="title-page-content">{{response?.information?.assets | currency}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@
">

<div class="title-page-name">{{response?.information?.assessment_Name}}</div>
<div class="title-page-content">{{response?.information?.assessment_Date |
date:'dd-MMM-yyyy'}}
</div>
<div class="title-page-content">{{reportSvc.translatedDate(response?.information?.assessment_Date)}}</div>
<div class="title-page-content">{{response?.information?.assessor_Name}}</div>
<div class="title-page-content">{{response?.information?.assets | currency}}</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
">

<div class="title-page-name">{{response?.information?.assessment_Name}}</div>
<div class="title-page-content">{{response?.information?.assessment_Date | date:'dd-MMM-yyyy'}}</div>
<div class="title-page-content">{{reportSvc.translatedDate(response?.information?.assessment_Date)}}</div>
<div class="title-page-content">{{response?.information?.assessor_Name}}</div>
<div class="title-page-content">{{response?.information?.assets | currency}}</div>
</div>
Expand All @@ -74,7 +74,7 @@ <h1 class="page-header">
</tr>
<tr>
<td>{{ 'assessment date' | transloco }}:</td>
<td>{{response?.information?.assessment_Date | date:'dd-MMM-yyyy'}}</td>
<td>{{reportSvc.translatedDate(response?.information?.assessment_Date)}}</td>
</tr>
<tr>
<td>{{ 'acet.credit union' | transloco }}:</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h1>{{ 'reports.site information' | transloco }}</h1>
<td class="tint2" style="width: 25%">{{ t('importance') }}:</td>
<td style="width: 25%">{{ 'level.' + finding.importance.toLowerCase() | transloco }}</td>
<td class="tint2" style="width: 25%">{{ t('resolution date') }}:</td>
<td style="width: 25%">{{finding.resolutionDate | date:'dd-MMM-yyyy'}}</td>
<td style="width: 25%">{{reportSvc.translatedDate(finding.resolutionDate)}}</td>
</tr>
<tr>
<td class="tint2">{{ t('issue') }}:</td>
Expand Down
15 changes: 14 additions & 1 deletion CSETWebNg/src/app/services/assessment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import { Router } from '@angular/router';
import { NavigationService } from './navigation/navigation.service';
import { Observable } from 'rxjs';
import { DemographicExtendedService } from './demographic-extended.service';
import moment from 'moment';
import { TranslocoService } from '@ngneat/transloco';


export interface Role {
Expand Down Expand Up @@ -85,7 +87,8 @@ export class AssessmentService {
private http: HttpClient,
private configSvc: ConfigService,
private router: Router,
private extDemoSvc: DemographicExtendedService
private extDemoSvc: DemographicExtendedService,
private tSvc: TranslocoService
) {
if (!this.initialized) {
this.apiUrl = this.configSvc.apiUrl;
Expand Down Expand Up @@ -619,4 +622,14 @@ export class AssessmentService {
getEncryptPreference() {
return this.http.get(this.apiUrl + 'getPreventEncrypt');
}

/**
* changes a date into the active Transloco locale format
* @param date
* @returns
*/
translatedDate(date: string, format: string) {
moment.locale(this.tSvc.getActiveLang());
return moment(date).format(format);
}
}
9 changes: 8 additions & 1 deletion CSETWebNg/src/app/services/report.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { ConfigService } from './config.service';
import moment from 'moment';
import { TranslocoService } from '@ngneat/transloco';

const headers = {
headers: new HttpHeaders().set('Content-Type', 'application/json'),
Expand All @@ -37,7 +39,7 @@ export class ReportService {
/**
*
*/
constructor(private http: HttpClient, private configSvc: ConfigService) {
constructor(private http: HttpClient, private configSvc: ConfigService, private tSvc: TranslocoService) {
if (!this.initialized) {
this.apiUrl = this.configSvc.apiUrl;
this.initialized = true;
Expand Down Expand Up @@ -200,6 +202,11 @@ export class ReportService {
validateCisaAssessorFields() {
return this.http.get(this.configSvc.apiUrl + 'reports/CisaAssessorWorkflowValidateFields');
}

translatedDate(date: string) {
moment.locale(this.tSvc.getActiveLang());
return moment(date).format('DD-MMM-yyyy');
}

/**
* Switches that define what to show on Module Content Reports
Expand Down

0 comments on commit 73872bf

Please sign in to comment.