1
|
import {Component, Input, OnInit} from '@angular/core';
|
2
|
import {Session, User} from "../../../login/utils/helper.class";
|
3
|
import {UserManagementService} from "../../../services/user-management.service";
|
4
|
import {Subscriber} from "rxjs";
|
5
|
import {ActivatedRoute} from "@angular/router";
|
6
|
import {HelperFunctions} from "../../../utils/HelperFunctions.class";
|
7
|
|
8
|
@Component({
|
9
|
selector: 'admin-tabs',
|
10
|
template: `
|
11
|
<ul class="uk-tab customTabs admin uk-flex uk-flex-center uk-flex-left@m">
|
12
|
<li *ngIf="isPortalAdmin && (!portal )" class="uk-disabled" > <span class = "uk-margin-small-right" uk-icon="cog"></span></li>
|
13
|
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'portal'"><a routerLink="../../portals"><span class="title">Portals</span></a></li>
|
14
|
<li [class.uk-active]="tab === 'page'"><a routerLink="../../pages" [queryParams]="(portal? {communityId:portal}:{})" ><span class="title">Pages</span></a></li>
|
15
|
<li [class.uk-active]="tab === 'entity'"><a routerLink="../../entities" [queryParams]="(portal? {communityId:portal}:{})"><span class="title">Entities</span></a></li>
|
16
|
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'class'"><a routerLink="../../classes"><span class="title">Class Ids</span></a></li>
|
17
|
</ul>
|
18
|
`
|
19
|
})
|
20
|
export class AdminTabsComponent implements OnInit {
|
21
|
|
22
|
@Input()
|
23
|
public type: string;
|
24
|
@Input()
|
25
|
portal = null;
|
26
|
@Input()
|
27
|
public user: User;
|
28
|
@Input()
|
29
|
public tab: "portal"| "page" | "entity" | "class" = 'page';
|
30
|
|
31
|
private subscriptions: any[] = [];
|
32
|
constructor(private route: ActivatedRoute, private userManagementService: UserManagementService) {
|
33
|
}
|
34
|
|
35
|
ngOnInit() {
|
36
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
37
|
this.user = user;
|
38
|
|
39
|
}));
|
40
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
41
|
HelperFunctions.scroll();
|
42
|
this.portal = params['communityId'];
|
43
|
|
44
|
}));
|
45
|
}
|
46
|
ngOnDestroy(): void {
|
47
|
this.subscriptions.forEach(value => {
|
48
|
if (value instanceof Subscriber) {
|
49
|
value.unsubscribe();
|
50
|
} else if (value instanceof Function) {
|
51
|
value();
|
52
|
}
|
53
|
});
|
54
|
}
|
55
|
|
56
|
|
57
|
public get isPortalAdmin() {
|
58
|
return Session.isPortalAdministrator(this.user) || Session.isCurator(this.type, this.user);
|
59
|
}
|
60
|
|
61
|
}
|