1 |
57592
|
stefania.m
|
/**
|
2 |
|
|
* Created by stefania on 7/17/17.
|
3 |
|
|
*/
|
4 |
|
|
import { Component, Input, OnInit } from '@angular/core';
|
5 |
|
|
import { Content, PageContent } from '../../domain/page-content';
|
6 |
|
|
import { HelpContentService } from '../../services/help-content.service';
|
7 |
|
|
import { ActivatedRoute, Router } from '@angular/router';
|
8 |
|
|
|
9 |
|
|
@Component({
|
10 |
|
|
selector: 'help-content',
|
11 |
|
|
template: `
|
12 |
|
|
<ng-template [ngIf]="contents && contents.length>0">
|
13 |
|
|
<ng-template ngFor let-content [ngForOf]="contents">
|
14 |
|
|
<div [innerHTML]="content.content" class="uk-margin-medium-bottom"></div>
|
15 |
|
|
</ng-template>
|
16 |
|
|
</ng-template>
|
17 |
|
|
`,
|
18 |
|
|
})
|
19 |
|
|
|
20 |
|
|
export class HelpContentComponent implements OnInit {
|
21 |
|
|
|
22 |
|
|
@Input('position')
|
23 |
|
|
position: string;
|
24 |
|
|
|
25 |
|
|
contents: Content[];
|
26 |
|
|
errorMessage: string = null;
|
27 |
|
|
|
28 |
|
|
constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) {
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
ngOnInit() {
|
32 |
|
|
this.errorMessage = null;
|
33 |
|
|
setTimeout(() => {
|
34 |
|
|
this._helpContentService.getActivePageContent( this.router.url ).subscribe(
|
35 |
|
|
pageContent => this.shiftThroughContent(pageContent),
|
36 |
|
|
error => this.handleError(<any>error)
|
37 |
|
|
);
|
38 |
|
|
}, 50);
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
shiftThroughContent(pageContent: PageContent) {
|
42 |
|
|
this.contents = pageContent.content[this.position];
|
43 |
|
|
/*console.log(`help-service for ${this.router.url} -> ${this.position} responded: ${JSON.stringify(this.contents)}`);*/
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
isPresent() {
|
47 |
|
|
return (this.contents && this.contents.length > 0);
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
handleError(error) {
|
51 |
|
|
this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')';
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
@Component({
|
56 |
|
|
selector: 'aside-help-content',
|
57 |
|
|
template: `
|
58 |
|
|
<ng-template [ngIf]="contents && contents.length>0">
|
59 |
|
|
<ng-template ngFor let-content [ngForOf]="contents">
|
60 |
|
|
<div [innerHTML]="content.content" class="uk-card uk-card-body uk-card-default sidemenu uk-margin-bottom"></div>
|
61 |
|
|
</ng-template>
|
62 |
|
|
</ng-template>
|
63 |
|
|
`,
|
64 |
|
|
})
|
65 |
|
|
export class AsideHelpContentComponent extends HelpContentComponent {
|
66 |
|
|
|
67 |
|
|
}
|