removed probably unnecessary subscription
This commit is contained in:
parent
af8437ef2f
commit
a4c0f7f32f
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||||
import { AuthenticationService } from '../../../services/authentication.service';
|
import { AuthenticationService } from '../../../services/authentication.service';
|
||||||
import { RepositoryService } from '../../../services/repository.service';
|
import { RepositoryService } from '../../../services/repository.service';
|
||||||
import {
|
import {
|
||||||
|
@ -16,15 +16,15 @@ import {DashboardService} from '../../../services/dashboard.service';
|
||||||
import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser';
|
import {DomSanitizer, SafeResourceUrl} from '@angular/platform-browser';
|
||||||
import {PiwikService} from '../../../services/piwik.service';
|
import {PiwikService} from '../../../services/piwik.service';
|
||||||
import {ValidatorService} from '../../../services/validator.service';
|
import {ValidatorService} from '../../../services/validator.service';
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {SharedService} from "../../../services/shared.service";
|
import {SharedService} from '../../../services/shared.service';
|
||||||
|
|
||||||
@Component ({
|
@Component ({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
templateUrl: 'dashboard.component.html'
|
templateUrl: 'dashboard.component.html'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DashboardComponent implements OnInit {
|
export class DashboardComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
repository: Repository = null;
|
repository: Repository = null;
|
||||||
errorMessage: string;
|
errorMessage: string;
|
||||||
|
@ -88,29 +88,25 @@ export class DashboardComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
if(this.sharedService.getRepository()) {
|
if (this.sharedService.getRepository()) {
|
||||||
this.repository = this.sharedService.getRepository();
|
this.repository = this.sharedService.getRepository();
|
||||||
this.getSelectedRepositorySummaryInfo(this.repository);
|
this.getSelectedRepositorySummaryInfo(this.repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sharedService.repository$.subscribe(
|
const body = document.getElementsByTagName('body')[0];
|
||||||
r => {
|
body.classList.remove('top_bar_active');
|
||||||
this.repository = r;
|
body.classList.remove('page_heading_active');
|
||||||
// console.log("RepositoryID: ", this.repository.id);
|
body.classList.remove('landing');
|
||||||
this.getSelectedRepositorySummaryInfo(this.repository);
|
body.classList.add('dashboard');
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
let body = document.getElementsByTagName('body')[0];
|
|
||||||
body.classList.remove("top_bar_active");
|
|
||||||
body.classList.remove("page_heading_active");
|
|
||||||
body.classList.remove("landing");
|
|
||||||
body.classList.add("dashboard");
|
|
||||||
|
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
this.currentDate = currentTime.getFullYear() + '-' + (currentTime.getMonth() + 1);
|
this.currentDate = currentTime.getFullYear() + '-' + (currentTime.getMonth() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
// this.sharedService.repository.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
getSelectedRepositorySummaryInfo(repository: Repository) {
|
getSelectedRepositorySummaryInfo(repository: Repository) {
|
||||||
|
|
||||||
// Aggregations
|
// Aggregations
|
||||||
|
@ -218,16 +214,16 @@ export class DashboardComponent implements OnInit {
|
||||||
|
|
||||||
this.brokerSummary = brokerSummary;
|
this.brokerSummary = brokerSummary;
|
||||||
|
|
||||||
if(this.brokerSummary.userSubs==null)
|
if (this.brokerSummary.userSubs == null)
|
||||||
this.noSubscriptions = noTopicsFound;
|
this.noSubscriptions = noTopicsFound;
|
||||||
if(this.brokerSummary.topicsForDatasource==null)
|
if (this.brokerSummary.topicsForDatasource == null)
|
||||||
this.noTopics = noSubscriptionsFound;
|
this.noTopics = noSubscriptionsFound;
|
||||||
|
|
||||||
this.totalNumberOfEvents = 0;
|
this.totalNumberOfEvents = 0;
|
||||||
this.totalMore = 0;
|
this.totalMore = 0;
|
||||||
this.totalMissing = 0;
|
this.totalMissing = 0;
|
||||||
if(brokerSummary.topicsForDatasource) {
|
if (brokerSummary.topicsForDatasource) {
|
||||||
for (let browseEntry of brokerSummary.topicsForDatasource) {
|
for (const browseEntry of brokerSummary.topicsForDatasource) {
|
||||||
this.totalNumberOfEvents += browseEntry.size;
|
this.totalNumberOfEvents += browseEntry.size;
|
||||||
if (browseEntry.value.startsWith('ENRICH/MORE')) {
|
if (browseEntry.value.startsWith('ENRICH/MORE')) {
|
||||||
this.totalMore += browseEntry.size;
|
this.totalMore += browseEntry.size;
|
||||||
|
@ -272,13 +268,13 @@ export class DashboardComponent implements OnInit {
|
||||||
|
|
||||||
getViewsUrl () {
|
getViewsUrl () {
|
||||||
|
|
||||||
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"}}}');
|
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"}}}');
|
||||||
this.viewsUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.repoMetrics.diagramsBaseURL}chart?json=${encodedURL}`);
|
this.viewsUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.repoMetrics.diagramsBaseURL}chart?json=${encodedURL}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDownloadsUrl () {
|
getDownloadsUrl () {
|
||||||
|
|
||||||
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"}}}');
|
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"}}}');
|
||||||
this.downloadsUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.repoMetrics.diagramsBaseURL}chart?json=${encodedURL}`);
|
this.downloadsUrl = this.sanitizer.bypassSecurityTrustResourceUrl(`${this.repoMetrics.diagramsBaseURL}chart?json=${encodedURL}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class RepositoryComponent implements OnInit {
|
||||||
this.loadingMessage = 'Retrieving datasource info';
|
this.loadingMessage = 'Retrieving datasource info';
|
||||||
this.repoService.getRepositoryById(this.repositoryId).subscribe(
|
this.repoService.getRepositoryById(this.repositoryId).subscribe(
|
||||||
repository => {
|
repository => {
|
||||||
console.log("Repository component - Repository id: " + repository.id);
|
console.log('Repository component - Repository id: ' + repository.id);
|
||||||
this.sharedService.setRepository(repository);
|
this.sharedService.setRepository(repository);
|
||||||
this.loadingMessage = '';
|
this.loadingMessage = '';
|
||||||
},
|
},
|
||||||
|
|
|
@ -347,39 +347,45 @@ export class RegisterExistingDatasourceComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveNewInterfaces() {
|
saveNewInterfaces() {
|
||||||
if (this.repoInterfaces && (this.repoInterfaces.length > 0)) {
|
console.log('saving Interfaces');
|
||||||
from(this.repoInterfaces).pipe(
|
for (let i = 0; i < this.interfacesArray.length; i++) {
|
||||||
concatMap(intrf => {
|
console.log(i);
|
||||||
if (intrf.id) {
|
this.interfacesArray[i].saveInterface();
|
||||||
let req;
|
|
||||||
if (this.interfacesToDelete.some(id => id === intrf.id)) {
|
|
||||||
req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby);
|
|
||||||
} else {
|
|
||||||
// console.log('comments', intrf.comments);
|
|
||||||
req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf);
|
|
||||||
}
|
|
||||||
return req;
|
|
||||||
} else {
|
|
||||||
// console.log('comments', intrf.comments);
|
|
||||||
return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
).subscribe(
|
|
||||||
res => console.log('after save interfaces', JSON.stringify(res)),
|
|
||||||
er => {
|
|
||||||
console.log(er);
|
|
||||||
this.loadingMessage = '';
|
|
||||||
this.errorMessage = 'Not all changes were saved. Please try again';
|
|
||||||
window.scrollTo(1, 1);
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.loadingMessage = '';
|
|
||||||
this.datasourceId = null;
|
|
||||||
this.repo = null;
|
|
||||||
this.repoInterfaces = [];
|
|
||||||
this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`);
|
||||||
|
// if (this.repoInterfaces && (this.repoInterfaces.length > 0)) {
|
||||||
|
// from(this.repoInterfaces).pipe(
|
||||||
|
// concatMap(intrf => {
|
||||||
|
// if (intrf.id) {
|
||||||
|
// let req;
|
||||||
|
// if (this.interfacesToDelete.some(id => id === intrf.id)) {
|
||||||
|
// req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby);
|
||||||
|
// } else {
|
||||||
|
// // console.log('comments', intrf.comments);
|
||||||
|
// req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf);
|
||||||
|
// }
|
||||||
|
// return req;
|
||||||
|
// } else {
|
||||||
|
// // console.log('comments', intrf.comments);
|
||||||
|
// return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// ).subscribe(
|
||||||
|
// res => console.log('after save interfaces', JSON.stringify(res)),
|
||||||
|
// er => {
|
||||||
|
// console.log(er);
|
||||||
|
// this.loadingMessage = '';
|
||||||
|
// this.errorMessage = 'Not all changes were saved. Please try again';
|
||||||
|
// window.scrollTo(1, 1);
|
||||||
|
// },
|
||||||
|
// () => {
|
||||||
|
// this.loadingMessage = '';
|
||||||
|
// this.datasourceId = null;
|
||||||
|
// this.repo = null;
|
||||||
|
// this.repoInterfaces = [];
|
||||||
|
// this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {Subject} from 'rxjs/internal/Subject';
|
||||||
export class SharedService {
|
export class SharedService {
|
||||||
|
|
||||||
private repositoryCopy: Repository;
|
private repositoryCopy: Repository;
|
||||||
private repository: Subject<Repository> = new Subject<Repository>();
|
public repository: Subject<Repository> = new Subject<Repository>();
|
||||||
|
|
||||||
private repositoriesOfUserCopy: RepositorySnippet[];
|
private repositoriesOfUserCopy: RepositorySnippet[];
|
||||||
private repositoriesOfUser: Subject<RepositorySnippet[]> = new Subject<RepositorySnippet[]>();
|
private repositoriesOfUser: Subject<RepositorySnippet[]> = new Subject<RepositorySnippet[]>();
|
||||||
|
|
Loading…
Reference in New Issue