From 5874ff93fac2a81a5a6fd1663ba04153fd0a771b Mon Sep 17 00:00:00 2001 From: Charles Barnes Date: Fri, 18 Mar 2022 09:20:46 -0500 Subject: [PATCH] fix lint --- src/app/app.component.ts | 28 +++--- src/app/app.module.ts | 60 +++++------ src/app/services/settings/settings.service.ts | 99 +++++++++---------- src/app/sidebar/sidebar.component.ts | 54 +++++----- 4 files changed, 119 insertions(+), 122 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d0aa96a..256269a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,13 +1,13 @@ -import { Component, ViewContainerRef, OnInit } from "@angular/core"; -import { Router, NavigationEnd } from "@angular/router"; -import { SettingsService } from "./services/settings/settings.service"; -import { Meta } from "@angular/platform-browser"; -import { NovoToastService, NovoModalService } from "novo-elements"; +import { Component, ViewContainerRef, OnInit } from '@angular/core'; +import { Router, NavigationEnd } from '@angular/router'; +import { SettingsService } from './services/settings/settings.service'; +import { Meta } from '@angular/platform-browser'; +import { NovoToastService, NovoModalService } from 'novo-elements'; @Component({ - selector: "app-root", - templateUrl: "./app.component.html", - styleUrls: ["./app.component.scss"], + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.scss'], }) export class AppComponent implements OnInit { public title: string = SettingsService.settings.companyName; @@ -17,17 +17,17 @@ export class AppComponent implements OnInit { private meta: Meta, private ref: ViewContainerRef, private toastService: NovoToastService, - private modalService: NovoModalService + private modalService: NovoModalService, ) { if (SettingsService.settings.integrations.googleSiteVerification) { this.meta.updateTag({ - name: "google-site-verification", + name: 'google-site-verification', content: SettingsService.settings.integrations.googleSiteVerification .verificationCode, }); } - let trackingId: string = ""; + let trackingId: string = ''; if (SettingsService.settings.integrations.googleAnalytics) { trackingId = SettingsService.settings.integrations.googleAnalytics.trackingId; @@ -35,9 +35,9 @@ export class AppComponent implements OnInit { if (trackingId && !SettingsService.isServer) { this.router.events.subscribe((event: any) => { if (event instanceof NavigationEnd) { - (window).ga("create", trackingId, "auto"); - (window).ga("set", "page", event.urlAfterRedirects); - (window).ga("send", "pageview"); + (window).ga('create', trackingId, 'auto'); + (window).ga('set', 'page', event.urlAfterRedirects); + (window).ga('send', 'pageview'); } }); } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index bf6b2cf..49d9fa9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,17 +1,17 @@ -import { BrowserModule } from "@angular/platform-browser"; -import { NgModule, APP_INITIALIZER } from "@angular/core"; -import { AppComponent } from "./app.component"; -import { JobListComponent } from "./job-list/job-list.component"; -import { SettingsService } from "./services/settings/settings.service"; -import { AnalyticsService } from "./services/analytics/analytics.service"; -import { HttpClientModule } from "@angular/common/http"; -import { FormsModule } from "@angular/forms"; -import { SearchService } from "./services/search/search.service"; -import { ShareService } from "./services/share/share.service"; -import { ApplyService } from "./services/apply/apply.service"; -import { SidebarComponent } from "./sidebar/sidebar.component"; -import { SidebarFilterComponent } from "./sidebar/sidebar-filter/sidebar-filter.component"; -import { BrowserTransferStateModule } from "@angular/platform-browser"; +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule, APP_INITIALIZER } from '@angular/core'; +import { AppComponent } from './app.component'; +import { JobListComponent } from './job-list/job-list.component'; +import { SettingsService } from './services/settings/settings.service'; +import { AnalyticsService } from './services/analytics/analytics.service'; +import { HttpClientModule } from '@angular/common/http'; +import { FormsModule } from '@angular/forms'; +import { SearchService } from './services/search/search.service'; +import { ShareService } from './services/share/share.service'; +import { ApplyService } from './services/apply/apply.service'; +import { SidebarComponent } from './sidebar/sidebar.component'; +import { SidebarFilterComponent } from './sidebar/sidebar-filter/sidebar-filter.component'; +import { BrowserTransferStateModule } from '@angular/platform-browser'; import { NovoListModule, NovoElementsModule, @@ -22,21 +22,21 @@ import { NovoToastService, NovoDropdownModule, NovoButtonModule, -} from "novo-elements"; -import { MainPageComponent } from "./main-page/main-page.component"; -import { JobDetailsComponent } from "./job-details/job-details.component"; -import { ApplyModalComponent } from "./apply-modal/apply-modal.component"; -import { ErrorModalComponent } from "./error-modal/error-modal.component"; -import { StripHtmlPipe } from "./utils/stripHtml.pipe"; -import { StructuredSeoComponent } from "./structured-seo/structured-seo.component"; -import { DatePipe } from "@angular/common"; -import { JobResolver } from "./job.resolver"; -import { ServerResponseService } from "./services/server-response/server-response.service"; -import { PrivacyPolicyComponent } from "./privacy-policy/privacy-policy.component"; -import { TranslateLoader, TranslateModule } from "@ngx-translate/core"; -import { TranslationLoader } from "./services/localization/loader"; -import { AppRoutingModule } from "./app-routing.module"; -import { InfoChipsComponent } from "./components/info-chips/info-chips.component"; +} from 'novo-elements'; +import { MainPageComponent } from './main-page/main-page.component'; +import { JobDetailsComponent } from './job-details/job-details.component'; +import { ApplyModalComponent } from './apply-modal/apply-modal.component'; +import { ErrorModalComponent } from './error-modal/error-modal.component'; +import { StripHtmlPipe } from './utils/stripHtml.pipe'; +import { StructuredSeoComponent } from './structured-seo/structured-seo.component'; +import { DatePipe } from '@angular/common'; +import { JobResolver } from './job.resolver'; +import { ServerResponseService } from './services/server-response/server-response.service'; +import { PrivacyPolicyComponent } from './privacy-policy/privacy-policy.component'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { TranslationLoader } from './services/localization/loader'; +import { AppRoutingModule } from './app-routing.module'; +import { InfoChipsComponent } from './components/info-chips/info-chips.component'; export function initSettings(settings: SettingsService): () => Promise { return () => settings.load(); @@ -59,7 +59,7 @@ export function initSettings(settings: SettingsService): () => Promise { ], entryComponents: [ApplyModalComponent, ErrorModalComponent], imports: [ - BrowserModule.withServerTransition({ appId: "serverApp" }), + BrowserModule.withServerTransition({ appId: 'serverApp' }), AppRoutingModule, HttpClientModule, NovoElementsModule, diff --git a/src/app/services/settings/settings.service.ts b/src/app/services/settings/settings.service.ts index f0ef256..2c70228 100644 --- a/src/app/services/settings/settings.service.ts +++ b/src/app/services/settings/settings.service.ts @@ -1,21 +1,21 @@ -import { Injectable, Inject, PLATFORM_ID, Optional } from "@angular/core"; -import { HttpClient } from "@angular/common/http"; -import { isPlatformServer } from "@angular/common"; -import { REQUEST } from "@nguniversal/express-engine/tokens"; +import { Injectable, Inject, PLATFORM_ID, Optional } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { isPlatformServer } from '@angular/common'; +import { REQUEST } from '@nguniversal/express-engine/tokens'; import { TransferState, makeStateKey, StateKey, -} from "@angular/platform-browser"; -import { ISettings } from "../../typings/settings"; -import { TranslateService } from "@ngx-translate/core"; -import { Request } from "express"; -import * as fs from "fs"; -import { join } from "path"; -import { stringify } from "querystring"; +} from '@angular/platform-browser'; +import { ISettings } from '../../typings/settings'; +import { TranslateService } from '@ngx-translate/core'; +import { Request } from 'express'; +import * as fs from 'fs'; +import { join } from 'path'; +import { stringify } from 'querystring'; -const APP_CONFIG_URL: any = "./app.json"; -const LANGUAGE_KEY: any = makeStateKey("language"); +const APP_CONFIG_URL: any = './app.json'; +const LANGUAGE_KEY: any = makeStateKey('language'); @Injectable() export class SettingsService { @@ -30,24 +30,24 @@ export class SettingsService { @Inject(PLATFORM_ID) platformId: string, @Optional() @Inject(REQUEST) protected request: Request, private transferState: TransferState, - private translate: TranslateService + private translate: TranslateService, ) { SettingsService.isServer = isPlatformServer(platformId); } public async load(): Promise { let data: any | ISettings; - const configKey: StateKey = makeStateKey("app-config"); + const configKey: StateKey = makeStateKey('app-config'); if (SettingsService.isServer) { const assetsFolder: string = join( process.cwd(), - "dist", - "career-portal", - "browser" + 'dist', + 'career-portal', + 'browser', ); data = JSON.parse( - fs.readFileSync(join(assetsFolder, "app.json"), "utf8") + fs.readFileSync(join(assetsFolder, 'app.json'), 'utf8'), ); this.transferState.set(configKey, data); } else { @@ -65,11 +65,11 @@ export class SettingsService { SettingsService.settings = data; const objectConfigOptions: string[] = [ - "service", - "additionalJobCriteria", - "integrations", - "eeoc", - "privacyConsent", + 'service', + 'additionalJobCriteria', + 'integrations', + 'eeoc', + 'privacyConsent', ]; objectConfigOptions.forEach((option: string) => { @@ -82,28 +82,28 @@ export class SettingsService { SettingsService.settings.service.fields.length === 0 ) { SettingsService.settings.service.fields = [ - "id", - "title", - "publishedCategory(id,name)", - "address(city,state,countryName)", - "employmentType", - "dateLastPublished", - "publicDescription", - "isOpen", - "isPublic", - "isDeleted", - "publishedZip", - "salary", - "salaryUnit", + 'id', + 'title', + 'publishedCategory(id,name)', + 'address(city,state,countryName)', + 'employmentType', + 'dateLastPublished', + 'publicDescription', + 'isOpen', + 'isPublic', + 'isDeleted', + 'publishedZip', + 'salary', + 'salaryUnit', ]; } if (!SettingsService.settings.service.jobInfoChips) { SettingsService.settings.service.jobInfoChips = [ - "employmentType", + 'employmentType', { - type: "mediumDate", - field: "dateLastPublished", + type: 'mediumDate', + field: 'dateLastPublished', }, ]; } @@ -113,8 +113,8 @@ export class SettingsService { SettingsService.settings.service.keywordSearchFields.length === 0 ) { SettingsService.settings.service.keywordSearchFields = [ - "publicDescription", - "title", + 'publicDescription', + 'title', ]; } const validTokenRegex: RegExp = /[^A-Za-z0-9]/; @@ -122,11 +122,11 @@ export class SettingsService { !SettingsService.settings.service.corpToken || validTokenRegex.test(SettingsService.settings.service.corpToken) ) { - throw new Error("Invalid Corp Token"); + throw new Error('Invalid Corp Token'); } if (!SettingsService.settings.service.swimlane) { - throw new Error("Invalid Swimlane"); + throw new Error('Invalid Swimlane'); } await this.translate.use(this.getPreferredLanguage()).toPromise(); @@ -137,25 +137,22 @@ export class SettingsService { } private getPreferredLanguage(): string { - let supportedLanguages: string[] = - SettingsService.settings.supportedLocales; + let supportedLanguages: string[] = SettingsService.settings.supportedLocales || []; let language: string = SettingsService.settings.defaultLocale; if (SettingsService.isServer) { - language = this.request["acceptsLanguages"](supportedLanguages); + language = this.request['acceptsLanguages'](supportedLanguages); if (!language) { language = SettingsService.settings.defaultLocale; } this.transferState.set(LANGUAGE_KEY, language); } else { - language = - localStorage.getItem("preferredLanguage") || - this.transferState.get(LANGUAGE_KEY, undefined); + language = localStorage.getItem('preferredLanguage') || this.transferState.get(LANGUAGE_KEY, undefined); if (!language) { language = SettingsService.settings.supportedLocales.filter( (locale: string) => { return navigator.language === locale; - } + }, )[0]; } if (!language) { diff --git a/src/app/sidebar/sidebar.component.ts b/src/app/sidebar/sidebar.component.ts index c06d49a..85f8d46 100644 --- a/src/app/sidebar/sidebar.component.ts +++ b/src/app/sidebar/sidebar.component.ts @@ -4,39 +4,39 @@ import { EventEmitter, HostBinding, Input, -} from "@angular/core"; -import { SettingsService } from "../services/settings/settings.service"; -import { NovoFormGroup } from "novo-elements"; -import { SearchService } from "../services/search/search.service"; -import { Router } from "@angular/router"; -import { IAdditionalLanguageOption } from "../typings/settings"; +} from '@angular/core'; +import { SettingsService } from '../services/settings/settings.service'; +import { NovoFormGroup } from 'novo-elements'; +import { SearchService } from '../services/search/search.service'; +import { Router } from '@angular/router'; +import { IAdditionalLanguageOption } from '../typings/settings'; @Component({ - selector: "app-sidebar", - templateUrl: "./sidebar.component.html", - styleUrls: ["./sidebar.component.scss"], + selector: 'app-sidebar', + templateUrl: './sidebar.component.html', + styleUrls: ['./sidebar.component.scss'], }) export class SidebarComponent { @Output() public newFilter: EventEmitter = new EventEmitter(); @Output() public toggleSidebar: EventEmitter = new EventEmitter(); - @HostBinding("class.active") @Input() public display: boolean = false; + @HostBinding('class.active') @Input() public display: boolean = false; public filterUrl: any; public controls: any[] = []; public updateFilterOptions: Function; public sidebarForm: NovoFormGroup; - public keyword: string = ""; + public keyword: string = ''; public timeout: any; public loading: boolean = false; public filter: object = {}; public showPrivacyPolicy: boolean = SettingsService.settings.privacyConsent.sidebarLink; public languageDropdownEnabled = - SettingsService.settings.languageDropdownOptions.enabled && + SettingsService.settings.languageDropdownOptions?.enabled && !SettingsService.isServer; public availableLocales: IAdditionalLanguageOption[] = - SettingsService.settings.languageDropdownOptions.choices; + SettingsService.settings?.languageDropdownOptions?.choices || []; constructor(private searchService: SearchService, private router: Router) {} public searchOnDelay(): void { @@ -47,22 +47,22 @@ export class SidebarComponent { } this.timeout = setTimeout(() => { - let searchString: string = ""; + let searchString: string = ''; if (this.keyword.trim()) { keywordSearchFields.forEach((field: string, index: number) => { if (index > 0) { - searchString += " OR "; + searchString += ' OR '; } searchString += `${field}{?^^equals}${ - this.keyword.trim() ? this.keyword.trim() + "*" : "" + this.keyword.trim() ? this.keyword.trim() + '*' : '' }`; }); } - delete this.filter["ids"]; + delete this.filter['ids']; if (searchString) { - this.filter["keyword"] = searchString; + this.filter['keyword'] = searchString; } else { - delete this.filter["keyword"]; + delete this.filter['keyword']; } this.searchService .getCurrentJobIds(this.filter, []) @@ -72,9 +72,9 @@ export class SidebarComponent { public updateFilter( field: string, - httpFormatedFilter: string | string[] + httpFormatedFilter: string | string[], ): void { - delete this.filter["keyword"]; + delete this.filter['keyword']; this.filter[field] = httpFormatedFilter; let filter: object = {}; Object.assign(filter, this.filter); @@ -89,12 +89,16 @@ export class SidebarComponent { public viewPrivacyPolicy(): void { const url: string = SettingsService.settings.privacyConsent.privacyPolicyUrl; - if (url === "/privacy") { + if (url === '/privacy') { this.router.navigate([url]); } else { window.open(url); } } + public setPreferredLanguage(language: string): void { + localStorage.setItem('preferredLanguage', language); + location.reload(); + } private handleJobIdsOnSuccess(res: any): void { let resultIds: string[] = res.data.map((result: any) => { @@ -103,10 +107,6 @@ export class SidebarComponent { if (resultIds.length === 0) { resultIds.push(`id{?^^equals}${0}`); } - this.updateFilter("ids", resultIds); - } - public setPreferredLanguage(language: string): void { - localStorage.setItem("preferredLanguage", language); - location.reload(); + this.updateFilter('ids', resultIds); } }