2021-01-11 10:21:42 +01:00
|
|
|
import {Component, Input, OnInit} from '@angular/core';
|
|
|
|
import {Session, User} from "../../../login/utils/helper.class";
|
|
|
|
import {UserManagementService} from "../../../services/user-management.service";
|
|
|
|
import {Subscriber} from "rxjs";
|
|
|
|
import {ActivatedRoute} from "@angular/router";
|
2021-12-09 14:52:39 +01:00
|
|
|
import { properties } from 'src/environments/environment';
|
2021-01-11 10:21:42 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'admin-tabs',
|
|
|
|
template: `
|
|
|
|
<ul class="uk-tab customTabs admin uk-flex uk-flex-center uk-flex-left@m">
|
2021-01-26 17:21:55 +01:00
|
|
|
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'portal'"><a routerLink="../portals"><span class="title">Portals</span></a></li>
|
|
|
|
<li [class.uk-active]="tab === 'page'"><a routerLink="../pages"><span class="title">Pages</span></a></li>
|
|
|
|
<li [class.uk-active]="tab === 'entity'"><a routerLink="../entities"><span class="title">Entities</span></a></li>
|
2022-01-13 14:46:22 +01:00
|
|
|
<li *ngIf="env === 'development' && portal" [class.uk-active]="tab === 'menu'"><a routerLink="../menu"><span class="title">Menu</span></a></li>
|
2021-01-26 17:21:55 +01:00
|
|
|
<li *ngIf="isPortalAdmin && !portal" [class.uk-active]="tab === 'class'"><a routerLink="../classes"><span class="title">Classes</span></a></li>
|
2021-01-11 10:21:42 +01:00
|
|
|
</ul>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
export class AdminTabsComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
public type: string;
|
|
|
|
@Input()
|
|
|
|
portal = null;
|
|
|
|
@Input()
|
|
|
|
public user: User;
|
|
|
|
@Input()
|
2021-12-09 14:52:39 +01:00
|
|
|
public tab: "portal" | "page" | "entity" | "menu" | "class" = 'page';
|
|
|
|
|
|
|
|
public env = properties.environment;
|
2021-01-11 10:21:42 +01:00
|
|
|
|
|
|
|
private subscriptions: any[] = [];
|
|
|
|
constructor(private route: ActivatedRoute, private userManagementService: UserManagementService) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
|
|
|
this.user = user;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
|
|
this.subscriptions.forEach(value => {
|
|
|
|
if (value instanceof Subscriber) {
|
|
|
|
value.unsubscribe();
|
|
|
|
} else if (value instanceof Function) {
|
|
|
|
value();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public get isPortalAdmin() {
|
|
|
|
return Session.isPortalAdministrator(this.user) || Session.isCurator(this.type, this.user);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|