Revision 62554
Added by John Balasis over 1 year ago
dashboard.component.ts | ||
---|---|---|
1 |
import { Component, OnInit } from '@angular/core';
|
|
1 |
import {Component, OnDestroy, OnInit} from '@angular/core';
|
|
2 | 2 |
import { AuthenticationService } from '../../../services/authentication.service'; |
3 | 3 |
import { RepositoryService } from '../../../services/repository.service'; |
4 | 4 |
import { |
... | ... | |
16 | 16 |
import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser'; |
17 | 17 |
import {PiwikService} from '../../../services/piwik.service'; |
18 | 18 |
import {ValidatorService} from '../../../services/validator.service'; |
19 |
import {ActivatedRoute} from "@angular/router";
|
|
20 |
import {SharedService} from "../../../services/shared.service";
|
|
19 |
import {ActivatedRoute} from '@angular/router';
|
|
20 |
import {SharedService} from '../../../services/shared.service';
|
|
21 | 21 |
|
22 | 22 |
@Component ({ |
23 | 23 |
selector: 'app-dashboard', |
24 | 24 |
templateUrl: 'dashboard.component.html' |
25 | 25 |
}) |
26 | 26 |
|
27 |
export class DashboardComponent implements OnInit { |
|
27 |
export class DashboardComponent implements OnInit, OnDestroy {
|
|
28 | 28 |
|
29 | 29 |
repository: Repository = null; |
30 | 30 |
errorMessage: string; |
... | ... | |
88 | 88 |
|
89 | 89 |
ngOnInit() { |
90 | 90 |
|
91 |
if(this.sharedService.getRepository()) { |
|
91 |
if (this.sharedService.getRepository()) {
|
|
92 | 92 |
this.repository = this.sharedService.getRepository(); |
93 | 93 |
this.getSelectedRepositorySummaryInfo(this.repository); |
94 | 94 |
} |
95 | 95 |
|
96 |
this.sharedService.repository$.subscribe( |
|
97 |
r => { |
|
98 |
this.repository = r; |
|
99 |
// console.log("RepositoryID: ", this.repository.id); |
|
100 |
this.getSelectedRepositorySummaryInfo(this.repository); |
|
101 |
} |
|
102 |
); |
|
96 |
const body = document.getElementsByTagName('body')[0]; |
|
97 |
body.classList.remove('top_bar_active'); |
|
98 |
body.classList.remove('page_heading_active'); |
|
99 |
body.classList.remove('landing'); |
|
100 |
body.classList.add('dashboard'); |
|
103 | 101 |
|
104 |
let body = document.getElementsByTagName('body')[0]; |
|
105 |
body.classList.remove("top_bar_active"); |
|
106 |
body.classList.remove("page_heading_active"); |
|
107 |
body.classList.remove("landing"); |
|
108 |
body.classList.add("dashboard"); |
|
109 |
|
|
110 | 102 |
const currentTime = new Date(); |
111 | 103 |
this.currentDate = currentTime.getFullYear() + '-' + (currentTime.getMonth() + 1); |
112 | 104 |
} |
113 | 105 |
|
106 |
ngOnDestroy() { |
|
107 |
// this.sharedService.repository.unsubscribe(); |
|
108 |
} |
|
109 |
|
|
114 | 110 |
getSelectedRepositorySummaryInfo(repository: Repository) { |
115 | 111 |
|
116 | 112 |
// Aggregations |
... | ... | |
218 | 214 |
|
219 | 215 |
this.brokerSummary = brokerSummary; |
220 | 216 |
|
221 |
if(this.brokerSummary.userSubs==null)
|
|
217 |
if (this.brokerSummary.userSubs == null)
|
|
222 | 218 |
this.noSubscriptions = noTopicsFound; |
223 |
if(this.brokerSummary.topicsForDatasource==null)
|
|
219 |
if (this.brokerSummary.topicsForDatasource == null)
|
|
224 | 220 |
this.noTopics = noSubscriptionsFound; |
225 | 221 |
|
226 | 222 |
this.totalNumberOfEvents = 0; |
227 | 223 |
this.totalMore = 0; |
228 | 224 |
this.totalMissing = 0; |
229 |
if(brokerSummary.topicsForDatasource) { |
|
230 |
for (let browseEntry of brokerSummary.topicsForDatasource) {
|
|
225 |
if (brokerSummary.topicsForDatasource) {
|
|
226 |
for (const browseEntry of brokerSummary.topicsForDatasource) {
|
|
231 | 227 |
this.totalNumberOfEvents += browseEntry.size; |
232 | 228 |
if (browseEntry.value.startsWith('ENRICH/MORE')) { |
233 | 229 |
this.totalMore += browseEntry.size; |
... | ... | |
272 | 268 |
|
273 | 269 |
getViewsUrl () { |
274 | 270 |
|
275 |
let encodedURL = encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"line","query":{"name":"usagestats.views.monthly", "parameters":["' + this.piwik.openaireId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":""},"subtitle":{},"yAxis":{"title":{"text":"Monthly views"}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
|
|
271 |
const encodedURL = encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"line","query":{"name":"usagestats.views.monthly", "parameters":["' + this.piwik.openaireId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":""},"subtitle":{},"yAxis":{"title":{"text":"Monthly views"}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
|
|
276 | 272 |
this.viewsUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.repoMetrics.diagramsBaseURL}chart?json=${encodedURL}`); |
277 | 273 |
} |
278 | 274 |
|
279 | 275 |
getDownloadsUrl () { |
280 | 276 |
|
281 |
let encodedURL = encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"line","query":{"name":"usagestats.downloads.monthly", "parameters":["' + this.piwik.openaireId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":""},"subtitle":{},"yAxis":{"title":{"text":"Monthly downloads"}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
|
|
277 |
const encodedURL = encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"line","query":{"name":"usagestats.downloads.monthly", "parameters":["' + this.piwik.openaireId + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":""},"subtitle":{},"yAxis":{"title":{"text":"Monthly downloads"}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":"Created by OpenAIRE via HighCharts"}}}');
|
|
282 | 278 |
this.downloadsUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.repoMetrics.diagramsBaseURL}chart?json=${encodedURL}`); |
283 | 279 |
} |
284 | 280 |
|
Also available in: Unified diff
removed probably unnecessary subscription