forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathstatistics-table.component.ts
More file actions
92 lines (86 loc) · 2.65 KB
/
Copy pathstatistics-table.component.ts
File metadata and controls
92 lines (86 loc) · 2.65 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import {
AsyncPipe,
DOCUMENT,
NgClass,
SlicePipe,
} from '@angular/common';
import {
Component,
Inject,
OnInit,
PLATFORM_ID,
} from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import {
NativeWindowRef,
NativeWindowService,
} from '../../../../core/services/window.service';
import { REPORT_DATA } from '../../../../core/statistics/data-report.service';
import { UsageReport } from '../../../../core/statistics/models/usage-report.model';
import { EntityTypeEnum } from '../../../../cris-layout/enums/entity-type.enum';
import { AlertComponent } from '../../../../shared/alert/alert.component';
import { BtnDisabledDirective } from '../../../../shared/btn-disabled.directive';
import { CreateLinkPipe } from '../../statistics-pipes/create-link.pipe';
import { StatisticsChartDataComponent } from '../statistics-chart-data/statistics-chart-data.component';
@Component({
selector: 'ds-statistics-table',
templateUrl: './statistics-table.component.html',
styleUrls: ['./statistics-table.component.scss'],
imports: [
AlertComponent,
AsyncPipe,
BtnDisabledDirective,
CreateLinkPipe,
NgClass,
SlicePipe,
TranslateModule,
],
})
/**
* Component that represents a table for report
*/
export class StatisticsTableComponent extends StatisticsChartDataComponent implements OnInit {
/**
* Boolean indicating whether the usage report has data
*/
hasData: boolean;
/**
* The table headers
*/
headers: string[] = [];
/**
* Array to store entity types that need to be converted to link,
* in order to check from the template if point's label it should be a simple label or a link
* @memberof StatisticsTableComponent
*/
entityTypesToConvertToLink = [
EntityTypeEnum.Item,
EntityTypeEnum.Bitstream,
EntityTypeEnum.Collection,
EntityTypeEnum.Community,
];
constructor(
@Inject(REPORT_DATA) public report: UsageReport,
@Inject('categoryType') public categoryType: string,
@Inject(PLATFORM_ID) protected platformId: any,
@Inject(NativeWindowService) protected _window: NativeWindowRef,
@Inject(DOCUMENT) protected document: any,
) {
super(report, categoryType, platformId, _window, document);
}
/**
* Check if report has information and if data is present to show in the view
* Insert table headers
*/
ngOnInit() {
this.hasData = !!this.report && (this.report.points?.length ?? 0) > 0;
if (this.hasData) {
const point = this.report.points[0];
this.headers.push(point.type);
const pointValues = point.values;
for (const valueKey of Object.keys(pointValues)) {
this.headers.push(valueKey);
}
}
}
}