Project

General

Profile

1
/**
2
 * Created by myrto on 11/24/17.
3
 */
4
import { Component, OnInit } from '@angular/core';
5
import { PiwikInfo } from '../../domain/typeScriptClasses';
6
import { ActivatedRoute, Router } from '@angular/router';
7
import { PiwikService } from '../../services/piwik.service';
8
import { AuthenticationService } from '../../services/authentication.service';
9
import { loadingUserRepoInfoError } from '../../domain/shared-messages';
10

    
11
@Component ({
12
  selector: 'app-metrics-instructions',
13
  templateUrl: 'metrics-instructions.component.html'
14
})
15

    
16
export class MetricsInstructionsComponent implements OnInit {
17
  piwik: PiwikInfo;
18
  errorMessage: string;
19
  loadingMessage: string;
20

    
21
  constructor(
22
    private route: ActivatedRoute,
23
    private router: Router,
24
    private piwikService: PiwikService,
25
    private authService: AuthenticationService) {}
26

    
27
  ngOnInit() {
28
    this.getPiwik();
29
  }
30

    
31
  getPiwik(): void {
32
    this.loadingMessage = 'Retrieving instructions ...';
33
    const id = this.route.snapshot.paramMap.get('id');
34
    this.piwikService.getPiwikInfo(id).subscribe(
35
      piwik => this.piwik = piwik,
36
      error => {
37
        console.log(error);
38
        this.loadingMessage = '';
39
        this.errorMessage = loadingUserRepoInfoError;
40
      },
41
      () => {
42
        this.loadingMessage = '';
43
      }
44
    );
45
  }
46

    
47
}
(4-4/17)