From 3c1d51480730992c563865b0963510f763abd8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Chaco=CC=81n?= Date: Mon, 28 Apr 2025 23:42:38 -0600 Subject: [PATCH] fixed flash and translate problems on statistics --- .../statistics/models/usage-report.model.ts | 2 +- .../statistics-table.component.html | 4 +- .../statistics-table.component.spec.ts | 4 +- .../statistics-table.component.ts | 40 +------------------ 4 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/app/core/statistics/models/usage-report.model.ts b/src/app/core/statistics/models/usage-report.model.ts index a4924f3a3d..ea8262065b 100644 --- a/src/app/core/statistics/models/usage-report.model.ts +++ b/src/app/core/statistics/models/usage-report.model.ts @@ -32,7 +32,7 @@ export class UsageReport extends HALResource { id: string; @autoserializeAs('report-type') - reportType: string; + reportType: string; @autoserialize points: Point[]; diff --git a/src/app/statistics-page/statistics-table/statistics-table.component.html b/src/app/statistics-page/statistics-table/statistics-table.component.html index 4a0f87076c..0cc4f5bfbc 100644 --- a/src/app/statistics-page/statistics-table/statistics-table.component.html +++ b/src/app/statistics-page/statistics-table/statistics-table.component.html @@ -11,7 +11,7 @@ @for (header of headers; track header) { - {{ header }} + {{ 'statistics.table.header.' + header | translate }} } @@ -19,7 +19,7 @@ - {{ getLabel(point) | async }} + {{ point.label }} @for (header of headers; track header) { { expect(de.query(By.css('table'))).toBeTruthy(); expect(de.query(By.css('th.views-header')).nativeElement.innerText) - .toEqual('views'); + .toEqual('statistics.table.header.views'); expect(de.query(By.css('th.downloads-header')).nativeElement.innerText) - .toEqual('downloads'); + .toEqual('statistics.table.header.downloads'); expect(de.query(By.css('td.item_1-views-data')).nativeElement.innerText) .toEqual('7'); diff --git a/src/app/statistics-page/statistics-table/statistics-table.component.ts b/src/app/statistics-page/statistics-table/statistics-table.component.ts index 9f59e33fa8..d3cf80330e 100644 --- a/src/app/statistics-page/statistics-table/statistics-table.component.ts +++ b/src/app/statistics-page/statistics-table/statistics-table.component.ts @@ -4,27 +4,11 @@ import { Input, OnInit, } from '@angular/core'; -import { - TranslateModule, - TranslateService, -} from '@ngx-translate/core'; -import { - Observable, - of, -} from 'rxjs'; -import { map } from 'rxjs/operators'; +import { TranslateModule } from '@ngx-translate/core'; import { DSONameService } from '../../core/breadcrumbs/dso-name.service'; import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; -import { - getFinishedRemoteData, - getRemoteDataPayload, -} from '../../core/shared/operators'; -import { - Point, - UsageReport, -} from '../../core/statistics/models/usage-report.model'; -import { isEmpty } from '../../shared/empty.util'; +import { UsageReport } from '../../core/statistics/models/usage-report.model'; /** * Component representing a statistics table for a given usage report. @@ -57,7 +41,6 @@ export class StatisticsTableComponent implements OnInit { constructor( protected dsoService: DSpaceObjectDataService, protected nameService: DSONameService, - private translateService: TranslateService, ) { } @@ -68,23 +51,4 @@ export class StatisticsTableComponent implements OnInit { this.headers = Object.keys(this.report.points[0].values); } } - - /** - * Get the row label to display for a statistics point. - * @param point the statistics point to get the label for - */ - getLabel(point: Point): Observable { - switch (this.report.reportType) { - case 'TotalVisits': - return this.dsoService.findById(point.id).pipe( - getFinishedRemoteData(), - getRemoteDataPayload(), - map((item) => !isEmpty(item) ? this.nameService.getName(item) : this.translateService.instant('statistics.table.no-name')), - ); - case 'TopCities': - case 'topCountries': - default: - return of(point.label); - } - } }