From 3cec3802714b37c2d4931788a507926b5da70236 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 24 May 2018 17:54:14 -0400 Subject: [PATCH] LP#1775466 ng-line updates continued Signed-off-by: Bill Erickson --- .../app/share/grid/grid-column-width.component.ts | 2 +- .../src/app/share/grid/grid-column.component.ts | 2 +- .../src/app/share/grid/grid-header.component.ts | 19 ++++++------ .../share/grid/grid-toolbar-action.component.ts | 2 +- .../share/grid/grid-toolbar-button.component.ts | 2 +- .../src/app/share/grid/grid-toolbar.component.ts | 4 +-- .../src/eg2/src/app/share/grid/grid.component.ts | 11 +++---- .../app/share/org-select/org-select.component.ts | 34 ++++++++++++---------- .../eg2/src/app/share/string/string.component.ts | 4 +-- .../src/eg2/src/app/share/string/string.service.ts | 11 +++---- .../src/eg2/src/app/share/toast/toast.component.ts | 2 +- .../src/eg2/src/app/share/toast/toast.service.ts | 6 ++-- Open-ILS/src/eg2/src/app/staff/common.module.ts | 3 +- Open-ILS/src/eg2/src/app/staff/login.component.ts | 14 ++++----- Open-ILS/src/eg2/src/app/staff/resolver.service.ts | 10 ++++--- .../staff/share/link-table/link-table.component.ts | 11 +++---- .../staff/share/op-change/op-change.component.ts | 9 +++--- Open-ILS/src/eg2/src/app/staff/splash.component.ts | 2 +- Open-ILS/src/eg2/src/app/staff/staff.component.ts | 25 ++++++++++------ 19 files changed, 94 insertions(+), 79 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts index 36ffa136bd..2ff482f259 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-column-width.component.ts @@ -25,7 +25,7 @@ export class EgGridColumnWidthComponent implements OnInit { } shrinkColumn(col: EgGridColumn) { - if (col.flex > 1) col.flex--; + if (col.flex > 1) { col.flex--; } } } diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts index 3c7101b2ac..09f84322ea 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-column.component.ts @@ -33,7 +33,7 @@ export class EgGridColumnComponent implements OnInit { return; } - let col = new EgGridColumn(); + const col = new EgGridColumn(); col.name = this.name; col.path = this.path; col.label = this.label; diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.ts index 3d5cd8c4bc..7340633f05 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-header.component.ts @@ -17,8 +17,9 @@ export class EgGridHeaderComponent implements OnInit { ngOnInit() {} onColumnDragEnter($event: any, col: any) { - if (this.dragColumn && this.dragColumn.name != col.name) + if (this.dragColumn && this.dragColumn.name !== col.name) { col.isDragTarget = true; + } $event.preventDefault(); } @@ -34,9 +35,9 @@ export class EgGridHeaderComponent implements OnInit { sortOneColumn(col: EgGridColumn) { let dir = 'ASC'; - let sort = this.gridContext.dataSource.sort; + const sort = this.gridContext.dataSource.sort; - if (sort.length && sort[0].name == col.name && sort[0].dir == 'ASC') { + if (sort.length && sort[0].name === col.name && sort[0].dir === 'ASC') { dir = 'DESC'; } @@ -47,8 +48,8 @@ export class EgGridHeaderComponent implements OnInit { // Returns true if the provided column is sorting in the // specified direction. isColumnSorting(col: EgGridColumn, dir: string): boolean { - let sort = this.gridContext.dataSource.sort.filter(c => c.name == col.name)[0]; - return sort && sort.dir == dir; + const sort = this.gridContext.dataSource.sort.filter(c => c.name === col.name)[0]; + return sort && sort.dir === dir; } handleBatchSelect($event) { @@ -64,14 +65,14 @@ export class EgGridHeaderComponent implements OnInit { } selectAll() { - let rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager); - let indexes = rows.map(r => this.gridContext.getRowIndex(r)); + const rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager); + const indexes = rows.map(r => this.gridContext.getRowIndex(r)); this.gridContext.rowSelector.select(indexes); } allRowsAreSelected(): boolean { - let rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager); - let indexes = rows.map(r => this.gridContext.getRowIndex(r)); + const rows = this.gridContext.dataSource.getPageOfRows(this.gridContext.pager); + const indexes = rows.map(r => this.gridContext.getRowIndex(r)); return this.gridContext.rowSelector.contains(indexes); } } diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts index eb8abc28a7..c9ba49675d 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-action.component.ts @@ -23,7 +23,7 @@ export class EgGridToolbarActionComponent implements OnInit { return; } - let action = new EgGridToolbarAction(); + const action = new EgGridToolbarAction(); action.label = this.label; action.action = this.action; diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-button.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-button.component.ts index 1f5f9d1920..7c37d45d69 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-button.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar-button.component.ts @@ -23,7 +23,7 @@ export class EgGridToolbarButtonComponent implements OnInit { return; } - let btn = new EgGridToolbarButton(); + const btn = new EgGridToolbarButton(); btn.label = this.label; btn.action = this.action; diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts index 68cbd3b7a1..690c14cf0e 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid-toolbar.component.ts @@ -65,8 +65,8 @@ export class EgGridToolbarComponent implements OnInit { this.gridContext.gridToCsv().then(csv => { console.log(csv); - var blob = new Blob([csv], {type : 'text/plain'}); - let win: any = window; + const blob = new Blob([csv], {type : 'text/plain'}); + const win: any = window; // avoid TS errors this.csvExportUrl = this.sanitizer.bypassSecurityTrustUrl( (win.URL || win.webkitURL).createObjectURL(blob) ); diff --git a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts index 26fc21d9b5..29d5863703 100644 --- a/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts +++ b/Open-ILS/src/eg2/src/app/share/grid/grid.component.ts @@ -1,6 +1,6 @@ import {Component, Input, OnInit, AfterViewInit, EventEmitter, OnDestroy, HostListener, ViewEncapsulation} from '@angular/core'; -import {Subscription} from "rxjs/Subscription"; +import {Subscription} from 'rxjs/Subscription'; import {EgIdlService} from '@eg/core/idl.service'; import {EgOrgService} from '@eg/core/org.service'; import {EgStoreService} from '@eg/core/store.service'; @@ -45,7 +45,7 @@ export class EgGridComponent implements OnInit, AfterViewInit, OnDestroy { this.context.mainLabel = this.mainLabel; this.context.idlClass = this.idlClass; this.context.dataSource = this.dataSource; - this.context.persistKey = this.persistKey + this.context.persistKey = this.persistKey; this.context.isSortable = this.isSortable === true; this.context.isMultiSortable = this.isMultiSortable === true; this.context.disableMultiSelect = this.disableMultiSelect === true; @@ -62,7 +62,7 @@ export class EgGridComponent implements OnInit, AfterViewInit, OnDestroy { // Not using @HostListener because it only works globally. onGridKeyDown(evt: KeyboardEvent) { - switch(evt.key) { + switch (evt.key) { case 'ArrowUp': this.context.selectPreviousRow(); evt.stopPropagation(); @@ -98,13 +98,14 @@ export class EgGridComponent implements OnInit, AfterViewInit, OnDestroy { } onRowClick($event: any, row: any, idx: number) { - let index = this.context.getRowIndex(row); + const index = this.context.getRowIndex(row); if (this.context.disableMultiSelect) { this.context.selectOneRow(index); } else if ($event.ctrlKey || $event.metaKey /* mac command */) { - if (this.context.toggleSelectOneRow(index)) + if (this.context.toggleSelectOneRow(index)) { this.context.lastSelectedIndex = index; + } } else if ($event.shiftKey) { // TODO shift range click diff --git a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts index 76a8655669..81440238b0 100644 --- a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts @@ -10,12 +10,11 @@ import {EgAuthService} from '@eg/core/auth.service'; import {EgStoreService} from '@eg/core/store.service'; import {EgOrgService} from '@eg/core/org.service'; import {EgIdlObject} from '@eg/core/idl.service'; -import {NgbTypeahead, NgbTypeaheadSelectItemEvent} - from '@ng-bootstrap/ng-bootstrap'; +import {NgbTypeahead, NgbTypeaheadSelectItemEvent} from '@ng-bootstrap/ng-bootstrap'; // Use a unicode char for spacing instead of ASCII=32 so the browser // won't collapse the nested display entries down to a single space. -const PAD_SPACE: string = ' '; // U+2007 +const PAD_SPACE = ' '; // U+2007 interface OrgDisplay { id: number; @@ -38,49 +37,53 @@ export class EgOrgSelectComponent implements OnInit { @ViewChild('instance') instance: NgbTypeahead; // Placeholder text for selector input - @Input() placeholder: string = ''; + @Input() placeholder = ''; @Input() stickySetting: string; // Org unit field displayed in the selector - @Input() displayField: string = 'shortname'; + @Input() displayField = 'shortname'; // Apply a default org unit value when none is set. // First tries workstation org unit, then user home org unit. // An onChange event WILL be generated when a default is applied. - @Input() applyDefault: boolean = false; + @Input() applyDefault = false; // List of org unit IDs to exclude from the selector @Input() set hideOrgs(ids: number[]) { - if (ids) this.hidden = ids; + if (ids) { this.hidden = ids; } } // List of org unit IDs to disable in the selector @Input() set disableOrgs(ids: number[]) { - if (ids) this.disabled = ids; + if (ids) { this.disabled = ids; } } // Apply an org unit value at load time. // This will NOT result in an onChange event. @Input() set initialOrg(org: EgIdlObject) { - if (org) this.startOrg = org; + if (org) { this.startOrg = org; } } // Apply an org unit value by ID at load time. // This will NOT result in an onChange event. @Input() set initialOrgId(id: number) { - if (id) this.startOrg = this.org.get(id); + if (id) { this.startOrg = this.org.get(id); } } // Modify the selected org unit via data binding. // This WILL result in an onChange event firing. @Input() set applyOrg(org: EgIdlObject) { - if (org) this.selected = this.formatForDisplay(org); + if (org) { + this.selected = this.formatForDisplay(org); + } } // Modify the selected org unit by ID via data binding. // This WILL result in an onChange event firing. @Input() set applyOrgId(id: number) { - if (id) this.selected = this.formatForDisplay(this.org.get(id)); + if (id) { + this.selected = this.formatForDisplay(this.org.get(id)); + } } // Emitted when the org unit value is changed via the selector. @@ -145,13 +148,12 @@ export class EgOrgSelectComponent implements OnInit { // Find orgs matching the search term return org[this.displayField]() - .toLowerCase().indexOf(term.toLowerCase()) > -1 + .toLowerCase().indexOf(term.toLowerCase()) > -1; }).filter(org => { // Exclude hidden orgs - return this.hidden.filter( - id => {return org.id() == id}).length == 0; + return this.hidden.filter(id => org.id() === id).length === 0; - }).map(org => {return this.formatForDisplay(org)}) + }).map(org => this.formatForDisplay(org)); }) ); } diff --git a/Open-ILS/src/eg2/src/app/share/string/string.component.ts b/Open-ILS/src/eg2/src/app/share/string/string.component.ts index ef34f162fa..b4cfe5a5e8 100644 --- a/Open-ILS/src/eg2/src/app/share/string/string.component.ts +++ b/Open-ILS/src/eg2/src/app/share/string/string.component.ts @@ -36,7 +36,7 @@ export class EgStringComponent implements OnInit { if (this.key) { this.strings.register({ key: this.key, - resolver: (ctx:any) => this.current(ctx) + resolver: (ctx: any) => this.current(ctx) }); } } @@ -48,7 +48,7 @@ export class EgStringComponent implements OnInit { // hopefully we can retire the EgString* code entirely once // in-code translations are supported (Ang6?) current(ctx?: any): Promise { - if (ctx) this.ctx = ctx; + if (ctx) { this.ctx = ctx; } return new Promise(resolve => { setTimeout(() => resolve(this.elm.nativeElement.textContent)); }); diff --git a/Open-ILS/src/eg2/src/app/share/string/string.service.ts b/Open-ILS/src/eg2/src/app/share/string/string.service.ts index 3d9eed5fb2..5c120e84ac 100644 --- a/Open-ILS/src/eg2/src/app/share/string/string.service.ts +++ b/Open-ILS/src/eg2/src/app/share/string/string.service.ts @@ -1,14 +1,14 @@ import {Injectable} from '@angular/core'; interface EgStringAssignment { - key: string, // keyboard command - resolver: (ctx:any) => Promise -}; + key: string; // keyboard command + resolver: (ctx: any) => Promise; +} @Injectable() export class EgStringService { - strings: {[key:string] : EgStringAssignment} = {}; + strings: {[key: string]: EgStringAssignment} = {}; constructor() {} @@ -17,8 +17,9 @@ export class EgStringService { } interpolate(key: string, ctx?: any): Promise { - if (!this.strings[key]) + if (!this.strings[key]) { return Promise.reject('No Such String'); + } return this.strings[key].resolver(ctx); } diff --git a/Open-ILS/src/eg2/src/app/share/toast/toast.component.ts b/Open-ILS/src/eg2/src/app/share/toast/toast.component.ts index bb9cab716d..8744c0ccea 100644 --- a/Open-ILS/src/eg2/src/app/share/toast/toast.component.ts +++ b/Open-ILS/src/eg2/src/app/share/toast/toast.component.ts @@ -15,7 +15,7 @@ export class EgToastComponent implements OnInit { // track the most recent timeout event timeout: any; - constructor(private toast: EgToastService) { + constructor(private toast: EgToastService) { } ngOnInit() { diff --git a/Open-ILS/src/eg2/src/app/share/toast/toast.service.ts b/Open-ILS/src/eg2/src/app/share/toast/toast.service.ts index 6c2f9e3989..92a1725714 100644 --- a/Open-ILS/src/eg2/src/app/share/toast/toast.service.ts +++ b/Open-ILS/src/eg2/src/app/share/toast/toast.service.ts @@ -1,9 +1,9 @@ import {Injectable, EventEmitter} from '@angular/core'; export interface EgToastMessage { - text: string, - style: string -}; + text: string; + style: string; +} @Injectable() export class EgToastService { diff --git a/Open-ILS/src/eg2/src/app/staff/common.module.ts b/Open-ILS/src/eg2/src/app/staff/common.module.ts index 86c61ae75a..09c26bcdd3 100644 --- a/Open-ILS/src/eg2/src/app/staff/common.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/common.module.ts @@ -16,8 +16,7 @@ import {EgStringComponent} from '@eg/share/string/string.component'; import {EgStringService} from '@eg/share/string/string.service'; import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; import {EgDateSelectComponent} from '@eg/share/date-select/date-select.component'; -import {EgLinkTableComponent, EgLinkTableLinkComponent} - from '@eg/staff/share/link-table/link-table.component'; +import {EgLinkTableComponent, EgLinkTableLinkComponent} from '@eg/staff/share/link-table/link-table.component'; /** * Imports the EG common modules and adds modules common to all staff UI's. diff --git a/Open-ILS/src/eg2/src/app/staff/login.component.ts b/Open-ILS/src/eg2/src/app/staff/login.component.ts index 86df59f941..733ac8f033 100644 --- a/Open-ILS/src/eg2/src/app/staff/login.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/login.component.ts @@ -41,14 +41,14 @@ export class EgStaffLoginComponent implements OnInit { .then(list => this.workstations = list || []) .then(list => this.store.getItem('eg.workstation.default')) .then(defWs => this.args.workstation = defWs) - .then(noOp => this.applyWorkstation()) + .then(noOp => this.applyWorkstation()); } applyWorkstation() { - let wanted = this.route.snapshot.queryParamMap.get('workstation'); - if (!wanted) return; // use the default + const wanted = this.route.snapshot.queryParamMap.get('workstation'); + if (!wanted) { return; } // use the default - let exists = this.workstations.filter(w => w.name == wanted)[0]; + const exists = this.workstations.filter(w => w.name === wanted)[0]; if (exists) { this.args.workstation = wanted; } else { @@ -59,14 +59,14 @@ export class EgStaffLoginComponent implements OnInit { handleSubmit() { // post-login URL - let url: string = this.auth.redirectUrl || '/staff/splash'; - let workstation: string = this.args.workstation; + const url: string = this.auth.redirectUrl || '/staff/splash'; + const workstation: string = this.args.workstation; this.auth.login(this.args).then( ok => { this.auth.redirectUrl = null; - if (this.auth.workstationState == EgAuthWsState.NOT_FOUND_SERVER) { + if (this.auth.workstationState === EgAuthWsState.NOT_FOUND_SERVER) { // User attempted to login with a workstation that is // unknown to the server. Redirect to the WS admin page. this.router.navigate( diff --git a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts index 8598de5401..a80a6cc3e2 100644 --- a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts @@ -49,10 +49,12 @@ export class EgStaffResolver implements Resolve> { // ^-- = this.ngLocation.prepareExternalUrl('/staff'); // Not sure how to get the path without params... using this for now. - let path = state.url.split('?')[0] - if (path == '/staff/login') return Observable.of(true); + const path = state.url.split('?')[0]; + if (path === '/staff/login') { + return Observable.of(true); + } - let observable: Observable + const observable: Observable = Observable.create(o => this.observer = o); this.auth.testAuthToken().then( @@ -63,7 +65,7 @@ export class EgStaffResolver implements Resolve> { this.auth.verifyWorkstation().then( wsOk => { this.loadStartupData() - .then(ok => this.observer.complete()) + .then(ok => this.observer.complete()); }, wsNotOk => this.handleInvalidWorkstation(path) ); diff --git a/Open-ILS/src/eg2/src/app/staff/share/link-table/link-table.component.ts b/Open-ILS/src/eg2/src/app/staff/share/link-table/link-table.component.ts index e290786b97..dfa5cc2c49 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/link-table/link-table.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/link-table/link-table.component.ts @@ -1,9 +1,9 @@ import {Component, Input, OnInit, AfterViewInit, Host} from '@angular/core'; interface LinkTableLink { - label: string, - url?: string, - routerLink?: string + label: string; + url?: string; + routerLink?: string; } @Component({ @@ -26,11 +26,12 @@ export class EgLinkTableComponent implements AfterViewInit { ngAfterViewInit() { // table-ize the links - let rowCount = Math.ceil(this.links.length / this.columnCount); + const rowCount = Math.ceil(this.links.length / this.columnCount); this.colWidth = Math.floor(12 / this.columnCount); // Bootstrap 12-grid - for (let col = 0; col < this.columnCount; col++) + for (let col = 0; col < this.columnCount; col++) { this.colList.push(col); + } // Modifying values in AfterViewInit without other activity // happening can result in the modified values not getting diff --git a/Open-ILS/src/eg2/src/app/staff/share/op-change/op-change.component.ts b/Open-ILS/src/eg2/src/app/staff/share/op-change/op-change.component.ts index c4fccb7b77..abb1559bd0 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/op-change/op-change.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/op-change/op-change.component.ts @@ -14,12 +14,12 @@ export class EgOpChangeComponent @Input() username: string; @Input() password: string; - @Input() loginType: string = 'temp'; + @Input() loginType = 'temp'; @Input() successMessage: string; @Input() failMessage: string; - constructor( + constructor( private modal: NgbModal, // required for passing to parent private renderer: Renderer2, private toast: EgToastService, @@ -36,8 +36,9 @@ export class EgOpChangeComponent } login(): Promise { - if (!(this.username && this.password)) + if (!(this.username && this.password)) { return Promise.reject('Missing Params'); + } return this.auth.login( { username : this.username, @@ -52,7 +53,7 @@ export class EgOpChangeComponent // Fetch the user object this.auth.testAuthToken().then( - ok => { + ok2 => { this.close(); this.toast.success(this.successMessage); } diff --git a/Open-ILS/src/eg2/src/app/staff/splash.component.ts b/Open-ILS/src/eg2/src/app/staff/splash.component.ts index 0fdb4e7fc2..4f9bffc56d 100644 --- a/Open-ILS/src/eg2/src/app/staff/splash.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/splash.component.ts @@ -21,7 +21,7 @@ export class EgStaffSplashComponent implements OnInit { } searchCatalog(): void { - if (!this.catSearchQuery) return; + if (!this.catSearchQuery) { return; } this.router.navigate( ['/staff/catalog/search'], diff --git a/Open-ILS/src/eg2/src/app/staff/staff.component.ts b/Open-ILS/src/eg2/src/app/staff/staff.component.ts index da270e5e3f..4b201309bd 100644 --- a/Open-ILS/src/eg2/src/app/staff/staff.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/staff.component.ts @@ -3,8 +3,7 @@ import {Router, ActivatedRoute, NavigationEnd} from '@angular/router'; import {EgAuthService, EgAuthWsState} from '@eg/core/auth.service'; import {EgNetService} from '@eg/core/net.service'; import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service'; -import {EgAccessKeyInfoComponent} - from '@eg/share/accesskey/accesskey-info.component'; +import {EgAccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.component'; const LOGIN_PATH = '/staff/login'; const WS_BASE_PATH = '/staff/admin/workstation/workstations/'; @@ -33,7 +32,7 @@ export class EgStaffComponent implements OnInit { // Fires on all in-app router navigation, but not initial page load. this.router.events.subscribe(routeEvent => { if (routeEvent instanceof NavigationEnd) { - //console.debug(`EgStaffComponent routing to ${routeEvent.url}`); + // console.debug(`EgStaffComponent routing to ${routeEvent.url}`); this.preventForbiddenNavigation(routeEvent.url); } }); @@ -43,7 +42,9 @@ export class EgStaffComponent implements OnInit { // If the expired authtoken was identified locally (i.e. // in this browser tab) notify all tabs of imminent logout. - if (!expireEvent.viaExternal) this.auth.broadcastLogout(); + if (!expireEvent.viaExternal) { + this.auth.broadcastLogout(); + } console.debug('Auth session has expired. Redirecting to login'); this.auth.redirectUrl = this.router.url; @@ -59,7 +60,7 @@ export class EgStaffComponent implements OnInit { }); }); - this.route.data.subscribe((data: {staffResolver : any}) => { + this.route.data.subscribe((data: {staffResolver: any}) => { // Data fetched via EgStaffResolver is available here. }); @@ -81,17 +82,23 @@ export class EgStaffComponent implements OnInit { preventForbiddenNavigation(url: string): void { // No auth checks needed for login page. - if (url.startsWith(LOGIN_PATH)) return; + if (url.startsWith(LOGIN_PATH)) { + return; + } // We lost our authtoken, go back to the login page. - if (!this.auth.token()) + if (!this.auth.token()) { this.router.navigate([LOGIN_PATH]); + } // No workstation checks needed for workstation admin page. - if (url.startsWith(WS_BASE_PATH)) return; + if (url.startsWith(WS_BASE_PATH)) { + return; + } - if (this.auth.workstationState != EgAuthWsState.VALID) + if (this.auth.workstationState !== EgAuthWsState.VALID) { this.router.navigate([WS_MANAGE_PATH]); + } } /** -- 2.11.0