Skip to content
Snippets Groups Projects
navbar.component.ts 1.51 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * 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.
     */
    
    
    François Agneray's avatar
    WIP
    François Agneray committed
    import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
    
    
    import { Instance } from 'src/app/metamodel/models';
    
    François Agneray's avatar
    WIP
    François Agneray committed
    import { UserProfile } from 'src/app/auth/user-profile.model';
    
    
    /**
     * @class
     * @classdesc Navbar component.
     */
    
    François Agneray's avatar
    WIP
    François Agneray committed
    @Component({
    
        selector: 'app-navbar',
        templateUrl: 'navbar.component.html',
        styleUrls: [ 'navbar.component.scss' ],
    
    François Agneray's avatar
    WIP
    François Agneray committed
        changeDetection: ChangeDetectionStrategy.OnPush
    })
    
    export class NavbarComponent {
        @Input() links: {label: string, icon: string, routerLink: string}[];
    
    François Agneray's avatar
    WIP
    François Agneray committed
        @Input() isAuthenticated: boolean;
        @Input() userProfile: UserProfile = null;
    
        @Input() baseHref: string;
        @Input() authenticationEnabled: boolean;
    
        @Input() apiUrl: string;
    
        @Input() instance: Instance;
    
    François Agneray's avatar
    WIP
    François Agneray committed
        @Output() login: EventEmitter<any> = new EventEmitter();
        @Output() logout: EventEmitter<any> = new EventEmitter();
        @Output() openEditProfile: EventEmitter<any> = new EventEmitter();
    
        /**
         * Returns logo href.
         *
         * @return  string
         */
        getLogoHref(): string {
    
            if (this.instance.config.design.design_logo) {
    
                return `${this.apiUrl}/download-instance-file/${this.instance.name}/${this.instance.config.design.design_logo}`;
    
            return 'assets/cesam_anis40.png';
    
    François Agneray's avatar
    WIP
    François Agneray committed
    }