mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #4270 from oscar-escire/Issue/4204
fixed flash and translate problems on statistics
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
@for (header of headers; track header) {
|
||||
<th scope="col"
|
||||
class="{{header}}-header">
|
||||
{{ header }}
|
||||
{{ 'statistics.table.header.' + header | translate }}
|
||||
</th>
|
||||
}
|
||||
</tr>
|
||||
@@ -19,7 +19,7 @@
|
||||
<tr
|
||||
class="{{point.id}}-data">
|
||||
<th scope="row" data-test="statistics-label">
|
||||
{{ getLabel(point) | async }}
|
||||
{{ point.label }}
|
||||
</th>
|
||||
@for (header of headers; track header) {
|
||||
<td
|
||||
|
@@ -83,9 +83,9 @@ describe('StatisticsTableComponent', () => {
|
||||
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');
|
||||
|
@@ -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<string> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user