1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {ActivatedRoute, Router} from '@angular/router';
3 import {Location} from '@angular/common';
4 import {OrgService} from '@eg/core/org.service';
5 import {AuthService} from '@eg/core/auth.service';
6 import {PcrudService} from '@eg/core/pcrud.service';
7 import {LocaleService} from '@eg/core/locale.service';
8 import {PrintService} from '@eg/share/print/print.service';
11 selector: 'eg-staff-nav-bar',
12 styleUrls: ['nav.component.css'],
13 templateUrl: 'nav.component.html'
16 export class StaffNavComponent implements OnInit {
18 // Locales that have Angular staff translations
22 // When active, show a link to the experimental Angular staff catalog
23 showAngularCatalog: boolean;
26 private router: Router,
27 private org: OrgService,
28 private auth: AuthService,
29 private pcrud: PcrudService,
30 private locale: LocaleService,
31 private printer: PrintService
38 this.locale.supportedLocales().subscribe(
39 l => this.locales.push(l),
42 this.currentLocale = this.locales.filter(
43 l => l.code() === this.locale.currentLocaleCode())[0];
47 // NOTE: this can eventually go away.
48 // Avoid attempts to fetch org settings if the user has not yet
49 // logged in (e.g. this is the login page).
51 this.org.settings('ui.staff.angular_catalog.enabled')
52 .then(settings => this.showAngularCatalog =
53 Boolean(settings['ui.staff.angular_catalog.enabled']));
58 return this.auth.user() ? this.auth.user().usrname() : '';
62 return this.auth.user() ? this.auth.workstation() : '';
65 setLocale(locale: any) {
66 this.locale.setLocale(locale.code());
69 opChangeActive(): boolean {
70 return this.auth.opChangeIsActive();
73 // Broadcast to all tabs that we're logging out.
74 // Redirect to the login page, which performs the remaining
77 this.auth.broadcastLogout();
78 this.router.navigate(['/staff/login']);
82 this.printer.reprintLast();