Project

General

Profile

« Previous | Next » 

Revision 58098

Second commit for the new layout provided by the UX team

View differences:

metrics-show.component.ts
1 1
import { Component, OnInit } from '@angular/core';
2 2
import { ActivatedRoute, Router } from '@angular/router';
3
import { MetricsInfo, PiwikInfo } from '../../domain/typeScriptClasses';
4
import { PiwikService } from '../../services/piwik.service';
5
import { RepositoryService } from '../../services/repository.service';
6
import { loadingMetrics, loadingMetricsError } from '../../domain/shared-messages';
3
import { MetricsInfo, PiwikInfo } from '../../../domain/typeScriptClasses';
4
import { PiwikService } from '../../../services/piwik.service';
5
import { RepositoryService } from '../../../services/repository.service';
6
import { loadingMetrics, loadingMetricsError } from '../../../domain/shared-messages';
7 7
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
8
import { AuthenticationService } from '../../services/authentication.service';
8
import { AuthenticationService } from '../../../services/authentication.service';
9
import { SharedService } from "../../../services/shared.service";
9 10

  
10 11
@Component ({
11 12
  selector: 'metrics-show',
......
31 32
    private sanitizer: DomSanitizer,
32 33
    private piwikService: PiwikService,
33 34
    private repoService: RepositoryService,
34
    private authService: AuthenticationService) {}
35
    private authService: AuthenticationService,
36
    private sharedService: SharedService) {}
35 37

  
36 38
  ngOnInit() {
37
    this.repoId = this.route.snapshot.paramMap.get('id');
38
    this.getPiwik();
39

  
40
    if(this.sharedService.getRepository()) {
41
      this.repoId = this.sharedService.getRepository().id;
42
      this.piwik = this.sharedService.getRepository().piwikInfo;
43
      this.getMetrics();
44
    }
45

  
46
    this.sharedService.repository$.subscribe(
47
      r => {
48
        this.repoId = r.id;
49
        this.piwik = r.piwikInfo;
50
        this.getMetrics();
51
      }
52
    );
53

  
39 54
    let body = document.getElementsByTagName('body')[0];
40 55
    body.classList.remove("top_bar_active");   //remove the class
41 56
    body.classList.remove("page_heading_active");
......
43 58
    body.classList.add("dashboard");
44 59
  }
45 60

  
46

  
47
  getPiwik() {
48
    this.loadingMessage = loadingMetrics;
49
    this.piwikService.getPiwikInfo(this.repoId).subscribe(
50
      piwik => this.piwik = piwik,
51
      error => {
52
        this.loadingMessage = '';
53
        this.errorMessage = loadingMetricsError;
54
        console.log(error);
55
      },
56
      () => {
57
        this.loadingMessage = '';
58
        this.errorMessage = '';
59
        this.getMetrics();
60
      }
61
    );
62
  }
63

  
64 61
  getMetrics() {
65 62
    this.loadingMessage = loadingMetrics;
66 63
    this.repoService.getMetricsInfoForRepository(this.repoId).subscribe(

Also available in: Unified diff