From 40cd22be3c5ca949975c4ce6265d00737859dd58 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 18 May 2018 10:35:48 -0400 Subject: [PATCH] LP#1775466 ng-lint updates Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/angular.json | 6 ++-- Open-ILS/src/eg2/src/app/app.module.ts | 2 +- Open-ILS/src/eg2/src/app/common.module.ts | 2 +- Open-ILS/src/eg2/src/app/core/org.service.ts | 40 +++++++++++----------- Open-ILS/src/eg2/src/app/core/perm.service.ts | 11 +++--- Open-ILS/src/eg2/src/app/resolver.service.ts | 8 ++--- Open-ILS/src/eg2/src/app/routing.module.ts | 8 ++--- .../src/eg2/src/app/share/print/print.component.ts | 4 +-- .../src/eg2/src/app/share/print/print.service.ts | 6 ++-- .../src/eg2/src/app/share/util/audio.service.ts | 24 ++++++------- .../src/eg2/src/app/share/util/format.service.ts | 26 +++++++------- Open-ILS/src/eg2/src/app/welcome.component.ts | 1 - Open-ILS/src/eg2/tslint.json | 4 +-- 13 files changed, 72 insertions(+), 70 deletions(-) diff --git a/Open-ILS/src/eg2/angular.json b/Open-ILS/src/eg2/angular.json index ad2ee9d8dc..d3cc725f1d 100644 --- a/Open-ILS/src/eg2/angular.json +++ b/Open-ILS/src/eg2/angular.json @@ -122,11 +122,11 @@ "defaultProject": "eg", "schematics": { "@schematics/angular:component": { - "prefix": "app", + "prefix": "eg", "styleext": "css" }, "@schematics/angular:directive": { - "prefix": "app" + "prefix": "eg" } } -} \ No newline at end of file +} diff --git a/Open-ILS/src/eg2/src/app/app.module.ts b/Open-ILS/src/eg2/src/app/app.module.ts index 8998b01d73..b45230589a 100644 --- a/Open-ILS/src/eg2/src/app/app.module.ts +++ b/Open-ILS/src/eg2/src/app/app.module.ts @@ -31,4 +31,4 @@ import {WelcomeComponent} from './welcome.component'; }) export class EgBaseModule {} - + diff --git a/Open-ILS/src/eg2/src/app/common.module.ts b/Open-ILS/src/eg2/src/app/common.module.ts index 3844c07296..c999a22d4c 100644 --- a/Open-ILS/src/eg2/src/app/common.module.ts +++ b/Open-ILS/src/eg2/src/app/common.module.ts @@ -1,6 +1,6 @@ /** * Modules, services, and components used by all apps. - */ + */ import {CommonModule, DatePipe, CurrencyPipe} from '@angular/common'; import {NgModule, ModuleWithProviders} from '@angular/core'; import {RouterModule} from '@angular/router'; diff --git a/Open-ILS/src/eg2/src/app/core/org.service.ts b/Open-ILS/src/eg2/src/app/core/org.service.ts index 3a16708eca..958d8214bf 100644 --- a/Open-ILS/src/eg2/src/app/core/org.service.ts +++ b/Open-ILS/src/eg2/src/app/core/org.service.ts @@ -24,7 +24,7 @@ export class EgOrgService { private orgList: EgIdlObject[] = []; private orgTree: EgIdlObject; // root node + children - private orgMap: {[id:number] : EgIdlObject} = {}; + private orgMap: {[id: number]: EgIdlObject} = {}; private settingsCache: OrgSettingsBatch = {}; constructor( @@ -50,26 +50,26 @@ export class EgOrgService { * Unset filter options are ignored. */ filterList(filter: OrgFilter, asId?: boolean): any[] { - let list = []; + const list = []; this.list().forEach(org => { - let chu = filter.canHaveUsers; + const chu = filter.canHaveUsers; if (chu && !this.canHaveUsers(org)) { return; } if (chu === false && this.canHaveUsers(org)) { return; } - let chv = filter.canHaveVolumes; + const chv = filter.canHaveVolumes; if (chv && !this.canHaveVolumes(org)) { return; } if (chv === false && this.canHaveVolumes(org)) { return; } - let ov = filter.opacVisible; + const ov = filter.opacVisible; if (ov && !this.opacVisible(org)) { return; } if (ov === false && this.opacVisible(org)) { return; } - if (filter.inList && filter.inList.indexOf(org.id()) == -1) { + if (filter.inList && !filter.inList.includes(org.id())) { return; } - if (filter.notInList && filter.notInList.indexOf(org.id()) > -1) { + if (filter.notInList && filter.notInList.includes(org.id())) { return; } @@ -93,8 +93,8 @@ export class EgOrgService { ancestors(nodeOrId: EgOrgNodeOrId, asId?: boolean): any[] { let node = this.get(nodeOrId); if (!node) { return []; } - let nodes = [node]; - while( (node = this.get(node.parent_ou()))) { + const nodes = [node]; + while ( (node = this.get(node.parent_ou())) ) { nodes.push(node); } if (asId) { @@ -122,13 +122,13 @@ export class EgOrgService { // list of org_unit objects or IDs for me + descendants descendants(nodeOrId: EgOrgNodeOrId, asId?: boolean): any[] { - let node = this.get(nodeOrId); + const node = this.get(nodeOrId); if (!node) { return []; } - let nodes = []; + const nodes = []; const descend = (n) => { nodes.push(n); n.children().forEach(descend); - } + }; descend(node); if (asId) { return nodes.map(n => n.id()); @@ -138,7 +138,7 @@ export class EgOrgService { // list of org_unit objects or IDs for ancestors + me + descendants fullPath(nodeOrId: EgOrgNodeOrId, asId?: boolean): any[] { - let list = this.ancestors(nodeOrId, false).concat( + const list = this.ancestors(nodeOrId, false).concat( this.descendants(nodeOrId, false).slice(1)); if (asId) { return list.map(n => n.id()); @@ -151,7 +151,7 @@ export class EgOrgService { if (!node) { node = this.orgTree; } node.children( node.children.sort((a, b) => { - return a[sortField]() < b[sortField]() ? -1 : 1 + return a[sortField]() < b[sortField]() ? -1 : 1; }) ); node.children.forEach(n => this.sortTree(n)); @@ -188,10 +188,10 @@ export class EgOrgService { * Return the list of settings /not/ pulled from cache. */ private settingsFromCache(names: string[], target: any) { - let cacheKeys = Object.keys(this.settingsCache); + const cacheKeys = Object.keys(this.settingsCache); cacheKeys.forEach(key => { - let matchIdx = names.indexOf(key); + const matchIdx = names.indexOf(key); if (matchIdx > -1) { target[key] = this.settingsCache[key]; names.splice(matchIdx, 1); @@ -208,7 +208,7 @@ export class EgOrgService { private settingsFromNet(orgId: number, names: string[], auth?: string): Promise { - let settings = {}; + const settings = {}; return new Promise((resolve, reject) => { this.net.request( 'open-ils.actor', @@ -217,7 +217,7 @@ export class EgOrgService { ).subscribe( blob => { Object.keys(blob).forEach(key => { - let val = blob[key]; // null or hash + const val = blob[key]; // null or hash settings[key] = val ? val.value : null; }); resolve(settings); @@ -234,13 +234,13 @@ export class EgOrgService { settings(names: string[], orgId?: number, anonymous?: boolean): Promise { - let settings = {}; + const settings = {}; let auth: string = null; let useCache = false; if (this.auth.user()) { if (orgId) { - useCache = Number(orgId) == Number(this.auth.user().ws_ou()); + useCache = Number(orgId) === Number(this.auth.user().ws_ou()); } else { orgId = this.auth.user().ws_ou(); useCache = true; diff --git a/Open-ILS/src/eg2/src/app/core/perm.service.ts b/Open-ILS/src/eg2/src/app/core/perm.service.ts index 2e535d14e9..8ecba5afa4 100644 --- a/Open-ILS/src/eg2/src/app/core/perm.service.ts +++ b/Open-ILS/src/eg2/src/app/core/perm.service.ts @@ -27,9 +27,9 @@ export class EgPermService { 'open-ils.actor.user.has_work_perm_at.batch', this.auth.token(), permNames ).toPromise().then(resp => { - var answer: HasPermAtResult = {}; + const answer: HasPermAtResult = {}; permNames.forEach(perm => { - var orgs = []; + const orgs = []; resp[perm].forEach(oneOrg => { orgs = orgs.concat(this.org.descendants(oneOrg, asId)); }); @@ -42,13 +42,14 @@ export class EgPermService { // workstation required hasWorkPermHere(permNames: string[]): Promise { - let wsId: number = +this.auth.user().wsid(); + const wsId: number = +this.auth.user().wsid(); - if (!wsId) + if (!wsId) { return Promise.reject('hasWorkPermHere requires a workstation'); + } return this.hasWorkPermAt(permNames, true).then(resp => { - let answer: HasPermHereResult = {}; + const answer: HasPermHereResult = {}; Object.keys(resp).forEach(perm => { answer[perm] = resp[perm].indexOf(wsId) > -1; }); diff --git a/Open-ILS/src/eg2/src/app/resolver.service.ts b/Open-ILS/src/eg2/src/app/resolver.service.ts index 0049c40452..5fad4e47a1 100644 --- a/Open-ILS/src/eg2/src/app/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/resolver.service.ts @@ -3,23 +3,23 @@ import {Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot} from '@angular/router'; import {EgIdlService} from '@eg/core/idl.service'; import {EgOrgService} from '@eg/core/org.service'; - + @Injectable() export class EgBaseResolver implements Resolve> { constructor( - private router: Router, + private router: Router, private idl: EgIdlService, private org: EgOrgService, ) {} /** * Loads pre-auth data common to all applications. - * No auth token is available at this level. When needed, auth is + * No auth token is available at this level. When needed, auth is * enforced by application/group-specific resolvers at lower levels. */ resolve( - route: ActivatedRouteSnapshot, + route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { console.debug('EgBaseResolver:resolve()'); diff --git a/Open-ILS/src/eg2/src/app/routing.module.ts b/Open-ILS/src/eg2/src/app/routing.module.ts index 594521303f..c60df919e4 100644 --- a/Open-ILS/src/eg2/src/app/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/routing.module.ts @@ -1,7 +1,7 @@ -import {NgModule} from '@angular/core'; +import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {EgBaseResolver} from './resolver.service'; -import {WelcomeComponent} from './welcome.component'; +import {EgBaseResolver} from './resolver.service'; +import {WelcomeComponent} from './welcome.component'; /** * Avoid loading all application JS up front by lazy-loading sub-modules. @@ -14,7 +14,7 @@ const routes: Routes = [ { path: '', component: WelcomeComponent }, { - path: 'staff', + path: 'staff', resolve : {startup : EgBaseResolver}, loadChildren: './staff/staff.module#EgStaffModule' } diff --git a/Open-ILS/src/eg2/src/app/share/print/print.component.ts b/Open-ILS/src/eg2/src/app/share/print/print.component.ts index 1144f3d7d4..ff36bd9abf 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.component.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.component.ts @@ -15,7 +15,7 @@ export class EgPrintComponent implements OnInit { private elm: ElementRef, private printer: EgPrintService ) {} - + ngOnInit() { this.printer.onPrintRequest$.subscribe( printReq => this.handlePrintRequest(printReq)); @@ -36,7 +36,7 @@ export class EgPrintComponent implements OnInit { } else { */ window.print(); - //} + // } } /* diff --git a/Open-ILS/src/eg2/src/app/share/print/print.service.ts b/Open-ILS/src/eg2/src/app/share/print/print.service.ts index a983c72e30..3b18692f76 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.service.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.service.ts @@ -1,9 +1,9 @@ import {Injectable, EventEmitter, TemplateRef} from '@angular/core'; export interface EgPrintRequest { - template: TemplateRef, - contextData: any, - printContext: string + template: TemplateRef; + contextData: any; + printContext: string; } @Injectable() diff --git a/Open-ILS/src/eg2/src/app/share/util/audio.service.ts b/Open-ILS/src/eg2/src/app/share/util/audio.service.ts index 971fe7e932..85dae6945e 100644 --- a/Open-ILS/src/eg2/src/app/share/util/audio.service.ts +++ b/Open-ILS/src/eg2/src/app/share/util/audio.service.ts @@ -1,6 +1,6 @@ /** - * Plays audio files (alerts, generally) by key name. Each sound uses a - * dot-path to indicate the sound. + * Plays audio files (alerts, generally) by key name. Each sound uses a + * dot-path to indicate the sound. * * For example: * @@ -13,7 +13,7 @@ * /audio/notifications/warning/checkout.wav * /audio/notifications/warning.wav * - * Files are only played when sounds are configured to play via + * Files are only played when sounds are configured to play via * workstation settings. */ import {Injectable, EventEmitter} from '@angular/core'; @@ -24,7 +24,7 @@ const AUDIO_BASE_URL = '/audio/notifications/'; export class EgAudioService { // map of requested audio path to resolved path - private urlCache: {[path:string] : string} = {}; + private urlCache: {[path: string]: string} = {}; constructor(private store: EgStoreService) {} @@ -35,15 +35,15 @@ export class EgAudioService { } playUrl(path: string, origPath: string): void { - //console.debug(`audio: playUrl(${path}, ${origPath})`); + // console.debug(`audio: playUrl(${path}, ${origPath})`); this.store.getItem('eg.audio.disable').then(audioDisabled => { - if (audioDisabled) return; - - let url = this.urlCache[path] || + if (audioDisabled) { return; } + + const url = this.urlCache[path] || AUDIO_BASE_URL + path.replace(/\./g, '/') + '.wav'; - let player = new Audio(url); + const player = new Audio(url); player.onloadeddata = () => { this.urlCache[origPath] = url; @@ -58,19 +58,19 @@ export class EgAudioService { player.onerror = () => { // Unable to play path at the requested URL. - + if (!path.match(/\./)) { // all fall-through options have been exhausted. // No path to play. console.warn( - "No suitable URL found for path '" + origPath + "'"); + `No suitable URL found for path "${origPath}"`); return; } // Fall through to the next (more generic) option path = path.replace(/\.[^\.]+$/, ''); this.playUrl(path, origPath); - } + }; }); } } diff --git a/Open-ILS/src/eg2/src/app/share/util/format.service.ts b/Open-ILS/src/eg2/src/app/share/util/format.service.ts index f1c2b0a260..b3d9215283 100644 --- a/Open-ILS/src/eg2/src/app/share/util/format.service.ts +++ b/Open-ILS/src/eg2/src/app/share/util/format.service.ts @@ -17,8 +17,8 @@ export interface EgFormatParams { @Injectable() export class EgFormatService { - dateFormat: string = 'shortDate'; - dateTimeFormat: string = 'short'; + dateFormat = 'shortDate'; + dateTimeFormat = 'short'; wsOrgTimezone: string = OpenSRF.tz; constructor( @@ -32,12 +32,14 @@ export class EgFormatService { * Create a human-friendly display version of any field type. */ transform(params: EgFormatParams): string { - let value = params.value; + const value = params.value; - if ( value === undefined - || value === null - || value === '' - || Number.isNaN(value)) return ''; + if ( value === undefined + || value === null + || value === '' + || Number.isNaN(value)) { + return ''; + } let datatype = params.datatype; @@ -51,16 +53,16 @@ export class EgFormatService { } } - switch(datatype) { + switch (datatype) { case 'org_unit': - let orgField = params.orgField || 'shortname'; - let org = this.org.get(value); + const orgField = params.orgField || 'shortname'; + const org = this.org.get(value); return org ? org[orgField]() : ''; case 'timestamp': - let date = new Date(value); - let fmt = this.dateFormat || 'shortDate'; + const date = new Date(value); + const fmt = this.dateFormat || 'shortDate'; if (params.datePlusTime) { fmt = this.dateTimeFormat || 'short'; } diff --git a/Open-ILS/src/eg2/src/app/welcome.component.ts b/Open-ILS/src/eg2/src/app/welcome.component.ts index 398d12776b..a5886614b0 100644 --- a/Open-ILS/src/eg2/src/app/welcome.component.ts +++ b/Open-ILS/src/eg2/src/app/welcome.component.ts @@ -5,7 +5,6 @@ import { Component, OnInit } from '@angular/core'; }) export class WelcomeComponent implements OnInit { - ngOnInit() { } } diff --git a/Open-ILS/src/eg2/tslint.json b/Open-ILS/src/eg2/tslint.json index 450a2a7f1b..127e171080 100644 --- a/Open-ILS/src/eg2/tslint.json +++ b/Open-ILS/src/eg2/tslint.json @@ -115,13 +115,13 @@ "directive-selector": [ true, "attribute", - "app", + "eg", "camelCase" ], "component-selector": [ true, "element", - "app", + "eg", "kebab-case" ], "use-input-property-decorator": true, -- 2.11.0