1 import {Component, OnInit, ViewChild} from '@angular/core';
2 import {ActivatedRoute, Router} from '@angular/router';
3 import {Location} from '@angular/common';
4 import {AuthService} from '@eg/core/auth.service';
5 import {PcrudService} from '@eg/core/pcrud.service';
6 import {LocaleService} from '@eg/core/locale.service';
7 import {PrintService} from '@eg/share/print/print.service';
10 selector: 'eg-staff-nav-bar',
11 styleUrls: ['nav.component.css'],
12 templateUrl: 'nav.component.html'
15 export class StaffNavComponent implements OnInit {
17 // Locales that have Angular staff translations
22 private router: Router,
23 private auth: AuthService,
24 private pcrud: PcrudService,
25 private locale: LocaleService,
26 private printer: PrintService
33 this.locale.supportedLocales().subscribe(
34 l => this.locales.push(l),
37 this.currentLocale = this.locales.filter(
38 l => l.code() === this.locale.currentLocaleCode())[0];
44 return this.auth.user() ? this.auth.user().usrname() : '';
48 return this.auth.user() ? this.auth.workstation() : '';
51 setLocale(locale: any) {
52 this.locale.setLocale(locale.code());
55 opChangeActive(): boolean {
56 return this.auth.opChangeIsActive();
59 // Broadcast to all tabs that we're logging out.
60 // Redirect to the login page, which performs the remaining
63 this.auth.broadcastLogout();
64 this.router.navigate(['/staff/login']);
68 this.printer.reprintLast();