Project

General

Profile

« Previous | Next » 

Revision 62554

Added by John Balasis over 1 year ago

removed probably unnecessary subscription

View differences:

modules/uoa-repository-dashboard-gui/trunk/src/app/pages/repository/dashboard/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

  
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/repository/repository.component.ts
44 44
      this.loadingMessage = 'Retrieving datasource info';
45 45
      this.repoService.getRepositoryById(this.repositoryId).subscribe(
46 46
        repository => {
47
          console.log("Repository component - Repository id: " + repository.id);
47
          console.log('Repository component - Repository id: ' + repository.id);
48 48
          this.sharedService.setRepository(repository);
49 49
          this.loadingMessage = '';
50 50
        },
modules/uoa-repository-dashboard-gui/trunk/src/app/pages/sources/sources-register/register-existing-datasource.component.ts
347 347
  }
348 348

  
349 349
  saveNewInterfaces() {
350
    if (this.repoInterfaces && (this.repoInterfaces.length > 0)) {
351
      from(this.repoInterfaces).pipe(
352
        concatMap(intrf => {
353
          if (intrf.id) {
354
            let req;
355
            if (this.interfacesToDelete.some(id => id === intrf.id)) {
356
              req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby);
357
            } else {
358
              // console.log('comments', intrf.comments);
359
              req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf);
360
            }
361
            return req;
362
          } else {
363
            // console.log('comments', intrf.comments);
364
            return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf);
365
          }
366
        })
367
      ).subscribe(
368
        res => console.log('after save interfaces', JSON.stringify(res)),
369
        er => {
370
          console.log(er);
371
          this.loadingMessage = '';
372
          this.errorMessage = 'Not all changes were saved. Please try again';
373
          window.scrollTo(1, 1);
374
        },
375
        () => {
376
          this.loadingMessage = '';
377
          this.datasourceId = null;
378
          this.repo = null;
379
          this.repoInterfaces = [];
380
          this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`);
381
        }
382
      );
350
    console.log('saving Interfaces');
351
    for (let i = 0; i < this.interfacesArray.length; i++) {
352
      console.log(i);
353
      this.interfacesArray[i].saveInterface();
383 354
    }
355
    this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`);
356
    // if (this.repoInterfaces && (this.repoInterfaces.length > 0)) {
357
    //   from(this.repoInterfaces).pipe(
358
    //     concatMap(intrf => {
359
    //       if (intrf.id) {
360
    //         let req;
361
    //         if (this.interfacesToDelete.some(id => id === intrf.id)) {
362
    //           req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby);
363
    //         } else {
364
    //           // console.log('comments', intrf.comments);
365
    //           req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf);
366
    //         }
367
    //         return req;
368
    //       } else {
369
    //         // console.log('comments', intrf.comments);
370
    //         return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf);
371
    //       }
372
    //     })
373
    //   ).subscribe(
374
    //     res => console.log('after save interfaces', JSON.stringify(res)),
375
    //     er => {
376
    //       console.log(er);
377
    //       this.loadingMessage = '';
378
    //       this.errorMessage = 'Not all changes were saved. Please try again';
379
    //       window.scrollTo(1, 1);
380
    //     },
381
    //     () => {
382
    //       this.loadingMessage = '';
383
    //       this.datasourceId = null;
384
    //       this.repo = null;
385
    //       this.repoInterfaces = [];
386
    //       this.router.navigateByUrl(`/sources/register/${this.datasourceType}?step=finish`);
387
    //     }
388
    //   );
389
    // }
384 390
  }
385 391
}
modules/uoa-repository-dashboard-gui/trunk/src/app/services/shared.service.ts
6 6
export class SharedService {
7 7

  
8 8
  private repositoryCopy: Repository;
9
  private repository: Subject<Repository> = new Subject<Repository>();
9
  public repository: Subject<Repository> = new Subject<Repository>();
10 10

  
11 11
  private repositoriesOfUserCopy: RepositorySnippet[];
12 12
  private repositoriesOfUser: Subject<RepositorySnippet[]> = new Subject<RepositorySnippet[]>();

Also available in: Unified diff