-
Notifications
You must be signed in to change notification settings - Fork 171
/
group-details.component.ts
52 lines (45 loc) · 1.51 KB
/
group-details.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Component, OnInit, ChangeDetectorRef, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { getPathParams, linkManager } from '@kyma-project/luigi-client';
import {
LuigiContextService,
IContextMessage
} from '../../../../services/luigi-context.service';
import { toTitleCase } from '../../../../services/helpers';
@Component({
selector: 'app-group-details',
templateUrl: './group-details.component.html',
styleUrls: ['./group-details.component.css']
})
export class GroupDetailsComponent implements OnInit, OnDestroy {
public linkManager = linkManager;
public pathParams: { [key: string]: string };
public groupLabel: string;
private lcSubscription: Subscription;
constructor(
private luigiService: LuigiContextService,
private cdr: ChangeDetectorRef
) {}
ngOnInit() {
this.lcSubscription = this.luigiService
.getContext()
.subscribe((ctx: IContextMessage) => {
// We can directly access our custom specified context value here
this.groupLabel = toTitleCase(ctx.context.currentGroup);
// Default way, if context is not specified in node configuration
this.pathParams = getPathParams();
this.groupLabel =
this.pathParams &&
this.pathParams.group &&
toTitleCase(this.pathParams.group);
if (!this.cdr['destroyed']) {
this.cdr.detectChanges();
}
});
}
ngOnDestroy() {
if (this.lcSubscription) {
this.lcSubscription.unsubscribe();
}
}
}