mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
fixed flash and translate problems on statistics
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
@for (header of headers; track header) {
|
@for (header of headers; track header) {
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
class="{{header}}-header">
|
class="{{header}}-header">
|
||||||
{{ header }}
|
{{ 'statistics.table.header.' + header | translate }}
|
||||||
</th>
|
</th>
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<tr
|
<tr
|
||||||
class="{{point.id}}-data">
|
class="{{point.id}}-data">
|
||||||
<th scope="row" data-test="statistics-label">
|
<th scope="row" data-test="statistics-label">
|
||||||
{{ getLabel(point) | async }}
|
{{ point.label }}
|
||||||
</th>
|
</th>
|
||||||
@for (header of headers; track header) {
|
@for (header of headers; track header) {
|
||||||
<td
|
<td
|
||||||
|
@@ -83,9 +83,9 @@ describe('StatisticsTableComponent', () => {
|
|||||||
expect(de.query(By.css('table'))).toBeTruthy();
|
expect(de.query(By.css('table'))).toBeTruthy();
|
||||||
|
|
||||||
expect(de.query(By.css('th.views-header')).nativeElement.innerText)
|
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)
|
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)
|
expect(de.query(By.css('td.item_1-views-data')).nativeElement.innerText)
|
||||||
.toEqual('7');
|
.toEqual('7');
|
||||||
|
@@ -4,27 +4,11 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import {
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
TranslateModule,
|
|
||||||
TranslateService,
|
|
||||||
} from '@ngx-translate/core';
|
|
||||||
import {
|
|
||||||
Observable,
|
|
||||||
of,
|
|
||||||
} from 'rxjs';
|
|
||||||
import { map } from 'rxjs/operators';
|
|
||||||
|
|
||||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import {
|
import { UsageReport } from '../../core/statistics/models/usage-report.model';
|
||||||
getFinishedRemoteData,
|
|
||||||
getRemoteDataPayload,
|
|
||||||
} from '../../core/shared/operators';
|
|
||||||
import {
|
|
||||||
Point,
|
|
||||||
UsageReport,
|
|
||||||
} from '../../core/statistics/models/usage-report.model';
|
|
||||||
import { isEmpty } from '../../shared/empty.util';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component representing a statistics table for a given usage report.
|
* Component representing a statistics table for a given usage report.
|
||||||
@@ -57,7 +41,6 @@ export class StatisticsTableComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
protected dsoService: DSpaceObjectDataService,
|
protected dsoService: DSpaceObjectDataService,
|
||||||
protected nameService: DSONameService,
|
protected nameService: DSONameService,
|
||||||
private translateService: TranslateService,
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -68,23 +51,4 @@ export class StatisticsTableComponent implements OnInit {
|
|||||||
this.headers = Object.keys(this.report.points[0].values);
|
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