2022-07-27 11:34:10 +02:00
|
|
|
import {Component, OnDestroy, OnInit} from "@angular/core";
|
|
|
|
import {Subscriber} from "rxjs";
|
|
|
|
import {properties} from "../../../../environments/environment";
|
|
|
|
import {ActivatedRoute, Router} from "@angular/router";
|
|
|
|
import {HelperService} from "../../utils/helper/helper.service";
|
2022-07-29 11:15:54 +02:00
|
|
|
import {Meta, Title} from "@angular/platform-browser";
|
|
|
|
import {SEOService} from "../../sharedComponents/SEO/SEO.service";
|
|
|
|
import {ResourcesService} from "../services/resources.service";
|
2022-08-29 15:30:12 +02:00
|
|
|
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
|
2022-07-27 11:34:10 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'indicators-page',
|
2022-08-02 22:13:12 +02:00
|
|
|
template: `
|
2022-08-29 15:30:12 +02:00
|
|
|
<div class="uk-container uk-container-large uk-section uk-section-small uk-padding-remove-bottom">
|
|
|
|
<div class="uk-padding-small uk-padding-remove-horizontal">
|
|
|
|
<breadcrumbs [breadcrumbs]="breadcrumbs"></breadcrumbs>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-02 22:13:12 +02:00
|
|
|
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0" [texts]="pageContents['top']"></helper>
|
|
|
|
`
|
2022-07-27 11:34:10 +02:00
|
|
|
})
|
|
|
|
export class IndicatorsComponent implements OnInit, OnDestroy {
|
|
|
|
private subscriptions: any[] = [];
|
2022-07-29 11:15:54 +02:00
|
|
|
public types = ResourcesService.types;
|
2022-07-27 11:34:10 +02:00
|
|
|
public properties = properties;
|
|
|
|
public pageContents;
|
2022-08-29 15:30:12 +02:00
|
|
|
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources'}];
|
2022-07-27 11:34:10 +02:00
|
|
|
|
|
|
|
constructor(private helper: HelperService,
|
2022-07-29 11:15:54 +02:00
|
|
|
private resourcesService: ResourcesService,
|
2022-07-27 11:34:10 +02:00
|
|
|
private router: Router,
|
2022-07-29 11:15:54 +02:00
|
|
|
private meta: Meta,
|
|
|
|
private title: Title,
|
|
|
|
private seoService: SEOService,
|
2022-07-27 11:34:10 +02:00
|
|
|
private route: ActivatedRoute) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.subscriptions.push(this.route.params.subscribe(params => {
|
2022-08-29 15:57:04 +02:00
|
|
|
if(params['type']) {
|
2022-07-29 11:15:54 +02:00
|
|
|
let type = this.types.find(type => type.value === params['type']);
|
|
|
|
if(type) {
|
|
|
|
this.getPageContents(type.value);
|
2022-08-02 22:13:12 +02:00
|
|
|
const description = "Monitor | Indicators for " + type.label;
|
|
|
|
const title = "Monitor | Indicators for " + type.label;
|
2022-07-29 11:15:54 +02:00
|
|
|
this.metaTags(title, description);
|
2022-08-29 15:30:12 +02:00
|
|
|
this.breadcrumbs[2] = {name: type.label};
|
2022-07-29 11:15:54 +02:00
|
|
|
}
|
2022-07-27 11:34:10 +02:00
|
|
|
}
|
2022-08-29 15:57:04 +02:00
|
|
|
this.breadcrumbs[0].route = '/' + (params['stakeholder']?params['stakeholder']:'');
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscriber) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
2022-07-27 11:34:10 +02:00
|
|
|
}
|
|
|
|
|
2022-07-29 11:15:54 +02:00
|
|
|
metaTags(title, description) {
|
|
|
|
const url = properties.domain + properties.baseLink + this.router.url;
|
|
|
|
this.seoService.createLinkForCanonicalURL(url, false);
|
|
|
|
this.meta.updateTag({content: url}, "property='og:url'");
|
|
|
|
this.meta.updateTag({content: description}, "name='description'");
|
|
|
|
this.meta.updateTag({content: description}, "property='og:description'");
|
|
|
|
this.meta.updateTag({content: title}, "property='og:title'");
|
|
|
|
this.title.setTitle(title);
|
|
|
|
}
|
|
|
|
|
2022-07-27 11:34:10 +02:00
|
|
|
public getPageContents(type: string) {
|
2022-07-29 11:15:54 +02:00
|
|
|
this.subscriptions.push(this.resourcesService.isPagesEnabled().subscribe(status => {
|
2022-08-02 22:13:12 +02:00
|
|
|
let index = this.types.findIndex(t => t.value === type);
|
|
|
|
if(index !== -1 && status[index]) {
|
2022-07-27 11:34:10 +02:00
|
|
|
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'monitor', '/indicators/' + type, 'monitor').subscribe(contents => {
|
|
|
|
this.pageContents = contents;
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
this.navigateToError();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
private navigateToError() {
|
|
|
|
this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.properties.baseLink + this.router.url}});
|
|
|
|
}
|
|
|
|
}
|