1 |
54479
|
myrto.kouk
|
import { Component, OnInit } from '@angular/core';
|
2 |
58098
|
stefania.m
|
import { Repository } from '../../../domain/typeScriptClasses';
|
3 |
54479
|
myrto.kouk
|
import { ActivatedRoute, Router } from '@angular/router';
|
4 |
58098
|
stefania.m
|
import { RepositoryService } from '../../../services/repository.service';
|
5 |
|
|
import { AuthenticationService } from '../../../services/authentication.service';
|
6 |
|
|
import { loadingRepoMessage } from '../../../domain/shared-messages';
|
7 |
|
|
import { SharedService } from "../../../services/shared.service";
|
8 |
54479
|
myrto.kouk
|
|
9 |
|
|
@Component({
|
10 |
|
|
selector: 'metrics-usagestats-report',
|
11 |
|
|
templateUrl: './metrics-usagestats-report.component.html'
|
12 |
|
|
})
|
13 |
|
|
|
14 |
|
|
export class MetricsUsagestatsReportComponent implements OnInit {
|
15 |
|
|
|
16 |
|
|
errorMessage: string;
|
17 |
|
|
loadingMessage: string;
|
18 |
|
|
title: string;
|
19 |
|
|
|
20 |
|
|
repo: Repository;
|
21 |
58098
|
stefania.m
|
// repoId: string;
|
22 |
54479
|
myrto.kouk
|
shownRepoId: string;
|
23 |
|
|
shownOpenaireId: string;
|
24 |
|
|
useCurrentRepo: boolean;
|
25 |
|
|
issnToShow = '';
|
26 |
|
|
chosen_report: string;
|
27 |
|
|
|
28 |
|
|
userEmail: string;
|
29 |
|
|
beginDate = '';
|
30 |
|
|
endDate = '';
|
31 |
|
|
itemIdentifier = '';
|
32 |
|
|
itemDataType = '';
|
33 |
|
|
granularity = 'Monthly';
|
34 |
|
|
|
35 |
|
|
constructor(private repoService: RepositoryService,
|
36 |
58098
|
stefania.m
|
private sharedService: SharedService,
|
37 |
54479
|
myrto.kouk
|
private route: ActivatedRoute,
|
38 |
|
|
private router: Router,
|
39 |
|
|
private authService: AuthenticationService) {}
|
40 |
|
|
|
41 |
|
|
ngOnInit() {
|
42 |
58098
|
stefania.m
|
|
43 |
|
|
if(this.sharedService.getRepository()) {
|
44 |
|
|
this.repo = this.sharedService.getRepository();
|
45 |
|
|
this.getInfo();
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
this.sharedService.repository$.subscribe(
|
49 |
|
|
r => {
|
50 |
|
|
this.repo = r;
|
51 |
|
|
this.getInfo();
|
52 |
|
|
}
|
53 |
|
|
);
|
54 |
|
|
|
55 |
57129
|
stefania.m
|
let body = document.getElementsByTagName('body')[0];
|
56 |
|
|
body.classList.remove("top_bar_active"); //remove the class
|
57 |
57150
|
stefania.m
|
body.classList.remove("page_heading_active");
|
58 |
58065
|
stefania.m
|
body.classList.remove("landing");
|
59 |
|
|
body.classList.add("dashboard");
|
60 |
54479
|
myrto.kouk
|
}
|
61 |
|
|
|
62 |
58098
|
stefania.m
|
getInfo() {
|
63 |
|
|
this.getParams();
|
64 |
|
|
this.getUserEmail();
|
65 |
|
|
if (this.repo.piwikInfo) {
|
66 |
|
|
this.shownOpenaireId = this.convertToDisplayedFormat(this.repo.piwikInfo.openaireId);
|
67 |
|
|
}
|
68 |
|
|
if (this.repo.issn && this.repo.issn !== 'null') {
|
69 |
|
|
this.shownRepoId = this.repo.issn.slice(0, 4) + '-' + this.repo.issn.toString().slice(4);
|
70 |
|
|
}
|
71 |
62388
|
andreas.ma
|
this.title = `${this.chosen_report} report for ${this.repo.officialname}`;
|
72 |
58098
|
stefania.m
|
}
|
73 |
|
|
|
74 |
54479
|
myrto.kouk
|
getParams() {
|
75 |
58098
|
stefania.m
|
// this.repoId = this.route.snapshot.paramMap.get('id');
|
76 |
54479
|
myrto.kouk
|
this.chosen_report = this.route.snapshot.paramMap.get('reportID');
|
77 |
58098
|
stefania.m
|
this.shownRepoId = this.convertToDisplayedFormat(this.repo.id);
|
78 |
|
|
console.log(`shownRepoId is ${this.repo.id}`);
|
79 |
54479
|
myrto.kouk
|
this.title = `${this.chosen_report} report`;
|
80 |
|
|
if (this.chosen_report !== 'RR1') {
|
81 |
|
|
this.useCurrentRepo = true;
|
82 |
|
|
}
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
convertToDisplayedFormat(input: string) {
|
86 |
58098
|
stefania.m
|
const tempArray = this.repo.id.split('____::');
|
87 |
54479
|
myrto.kouk
|
return tempArray[0] + ':' + tempArray[1];
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
getUserEmail() {
|
91 |
|
|
this.userEmail = this.authService.getUserEmail();
|
92 |
|
|
}
|
93 |
|
|
|
94 |
58098
|
stefania.m
|
// getRepo() {
|
95 |
|
|
// this.loadingMessage = loadingRepoMessage;
|
96 |
|
|
// this.repoService.getRepositoryById(this.repoId).subscribe(
|
97 |
|
|
// repo => this.repo = repo,
|
98 |
|
|
// error => {
|
99 |
|
|
// console.log(error);
|
100 |
|
|
// this.loadingMessage = '';
|
101 |
|
|
// this.errorMessage = 'The repository could not be retrieved';
|
102 |
|
|
// },
|
103 |
|
|
// () => {
|
104 |
|
|
// this.loadingMessage = '';
|
105 |
|
|
// if (this.repo.piwikInfo) {
|
106 |
|
|
// this.shownOpenaireId = this.convertToDisplayedFormat(this.repo.piwikInfo.openaireId);
|
107 |
|
|
// }
|
108 |
|
|
// if (this.repo.issn && this.repo.issn !== 'null') {
|
109 |
|
|
// this.shownRepoId = this.repo.issn.slice(0, 4) + '-' + this.repo.issn.toString().slice(4);
|
110 |
|
|
// }
|
111 |
|
|
// this.title = `${this.chosen_report} report for ${this.repo.officialName}`;
|
112 |
|
|
// }
|
113 |
|
|
// );
|
114 |
|
|
// }
|
115 |
54479
|
myrto.kouk
|
|
116 |
|
|
updateBeginDate(event: any) {
|
117 |
|
|
this.beginDate = event.target.value;
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
updateEndDate(event: any) {
|
121 |
|
|
this.endDate = event.target.value;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
updateItemDataType(event: any) {
|
125 |
|
|
this.itemDataType = event.target.value;
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
updateItemIdentifier(event: any) {
|
129 |
|
|
this.itemIdentifier = event.target.value;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
updateGranularity(event: any) {
|
133 |
|
|
this.granularity = event.target.value;
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
updateUseCurrentRepo(event: any) {
|
137 |
|
|
this.useCurrentRepo = event.target.value;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
goToReport() {
|
141 |
|
|
if (!this.useCurrentRepo) { this.shownRepoId = ''; }
|
142 |
58108
|
stefania.m
|
this.router.navigate(['usagestats-report-results'], {
|
143 |
|
|
relativeTo: this.route.parent,
|
144 |
54479
|
myrto.kouk
|
queryParams: {
|
145 |
|
|
report: this.chosen_report,
|
146 |
|
|
beginDate: this.beginDate,
|
147 |
|
|
endDate: this.endDate,
|
148 |
|
|
repoId: this.shownRepoId,
|
149 |
|
|
itemDataType: this.itemDataType,
|
150 |
|
|
itemIdentifier: this.itemIdentifier,
|
151 |
|
|
granularity: this.granularity
|
152 |
|
|
}
|
153 |
|
|
});
|
154 |
|
|
|
155 |
|
|
/*const params = new URLSearchParams();
|
156 |
|
|
|
157 |
|
|
params.append('Report', this.chosen_report);
|
158 |
|
|
params.append('Release', '4');
|
159 |
|
|
params.append('RequestorID', this.authService.getUserEmail());
|
160 |
|
|
params.append('BeginDate', this.beginDate);
|
161 |
|
|
params.append('EndDate', this.endDate);
|
162 |
|
|
params.append('RepositoryIdentifier', this.shownRepoId);
|
163 |
|
|
if (this.itemIdentifier) {
|
164 |
|
|
params.append('ItemIdentifier', this.itemIdentifier);
|
165 |
|
|
}
|
166 |
|
|
if (this.itemDataType) {
|
167 |
|
|
params.append('ItemDataType', this.itemDataType);
|
168 |
|
|
}
|
169 |
|
|
params.append('Pretty', 'Pretty');
|
170 |
|
|
|
171 |
|
|
let url = `http://beta.services.openaire.eu/usagestats/sushilite/GetReport/?${params}`;
|
172 |
|
|
console.log(`going to: ${url}`);
|
173 |
|
|
|
174 |
|
|
window.location.href = url;*/
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
}
|