-
Notifications
You must be signed in to change notification settings - Fork 539
Expand file tree
/
Copy pathstatistics-table.component.ts
More file actions
71 lines (62 loc) · 1.64 KB
/
statistics-table.component.ts
File metadata and controls
71 lines (62 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import {
Component,
Input,
OnInit,
} from '@angular/core';
import { DSONameService } from '@dspace/core/breadcrumbs/dso-name.service';
import { DSpaceObjectDataService } from '@dspace/core/data/dspace-object-data.service';
import { UsageReport } from '@dspace/core/statistics/models/usage-report.model';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
/**
* Component representing a statistics table for a given usage report.
*/
@Component({
selector: 'ds-statistics-table',
templateUrl: './statistics-table.component.html',
styleUrls: ['./statistics-table.component.scss'],
imports: [
TranslateModule,
],
})
export class StatisticsTableComponent implements OnInit {
/**
* The usage report to display a statistics table for
*/
@Input()
report: UsageReport;
/**
* Boolean indicating whether the usage report has data
*/
hasData: boolean;
/**
* The table headers
*/
headers: string[];
/**
* Object header label
*/
objectHeaderLabel: string;
constructor(
protected dsoService: DSpaceObjectDataService,
protected nameService: DSONameService,
protected translateService: TranslateService,
) {
}
ngOnInit() {
this.hasData = this.report.points.length > 0;
if (this.hasData) {
this.headers = Object.keys(this.report.points[0].values);
}
this.objectHeaderLabel = this.getObjectHeaderLabel(this.report.reportType);
}
/**
* Defines a dynamic label for the object column
* @param reportType
*/
getObjectHeaderLabel(reportType: string): string {
return this.translateService.instant('statistics.table.header.' + reportType);
}
}