Newer
Older
/**
* This file is part of Anis Client.
*
* @copyright Laboratoire d'Astrophysique de Marseille / CNRS
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { Instance } from 'src/app/metamodel/models';
/**
* @class
* @classdesc Navbar component.
*/
selector: 'app-navbar',
templateUrl: 'navbar.component.html',
styleUrls: [ 'navbar.component.scss' ],
export class NavbarComponent {
@Input() links: {label: string, icon: string, routerLink: string}[];
@Input() isAuthenticated: boolean;
@Input() userProfile: UserProfile = null;
@Input() baseHref: string;
@Input() authenticationEnabled: boolean;
@Input() adminRoles: string[];
@Input() url: string;
@Output() login: EventEmitter<any> = new EventEmitter();
@Output() logout: EventEmitter<any> = new EventEmitter();
@Output() openEditProfile: EventEmitter<any> = new EventEmitter();
/**
* Returns true if user is admin
*
* @returns boolean
*/
isAdmin() {
let admin = false;
for (let i = 0; i < this.adminRoles.length; i++) {
admin = this.userRoles.includes(this.adminRoles[i]);
if (admin) break;
}
return admin;
}
isPortalRoute() {
return this.url.includes('portal');
}
isAdminRoute() {
return this.url.includes('admin');
}
/**
* Returns logo href.
*
* @return string
*/
getLogoHref(): string {
return `${this.apiUrl}/instance/${this.instance.name}/file-explorer${this.instance.design_logo}`;