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
|
|
10
|
@Component ({
|
11
|
selector: 'app-metrics-instructions',
|
12
|
templateUrl: 'metrics-instructions.component.html'
|
13
|
})
|
14
|
|
15
|
export class MetricsInstructionsComponent implements OnInit {
|
16
|
piwik: PiwikInfo;
|
17
|
errorMessage: string;
|
18
|
|
19
|
constructor(
|
20
|
private route: ActivatedRoute,
|
21
|
private router: Router,
|
22
|
private piwikService: PiwikService,
|
23
|
private authService: AuthenticationService) {}
|
24
|
|
25
|
ngOnInit() {
|
26
|
this.getPiwik();
|
27
|
}
|
28
|
|
29
|
getPiwik(): void {
|
30
|
const id = this.route.snapshot.paramMap.get('id');
|
31
|
this.piwikService.getPiwikInfo(id).subscribe(
|
32
|
piwik => this.piwik = piwik,
|
33
|
error => console.log(error),
|
34
|
() => {
|
35
|
if ( this.authService.activateFrontAuthorization &&
|
36
|
(this.authService.getUserEmail() !== this.piwik.requestorEmail.trim()) ) {
|
37
|
this.router.navigateByUrl('/403-forbidden', { skipLocationChange: true });
|
38
|
}
|
39
|
}
|
40
|
);
|
41
|
}
|
42
|
|
43
|
}
|