1- import { Injectable , Inject , PLATFORM_ID , Optional } from " @angular/core" ;
2- import { HttpClient } from " @angular/common/http" ;
3- import { isPlatformServer } from " @angular/common" ;
4- import { REQUEST } from " @nguniversal/express-engine/tokens" ;
1+ import { Injectable , Inject , PLATFORM_ID , Optional } from ' @angular/core' ;
2+ import { HttpClient } from ' @angular/common/http' ;
3+ import { isPlatformServer } from ' @angular/common' ;
4+ import { REQUEST } from ' @nguniversal/express-engine/tokens' ;
55import {
66 TransferState ,
77 makeStateKey ,
88 StateKey ,
9- } from " @angular/platform-browser" ;
10- import { ISettings } from " ../../typings/settings" ;
11- import { TranslateService } from " @ngx-translate/core" ;
12- import { Request } from " express" ;
13- import * as fs from "fs" ;
14- import { join } from " path" ;
15- import { stringify } from " querystring" ;
9+ } from ' @angular/platform-browser' ;
10+ import { ISettings } from ' ../../typings/settings' ;
11+ import { TranslateService } from ' @ngx-translate/core' ;
12+ import { Request } from ' express' ;
13+ import * as fs from 'fs' ;
14+ import { join } from ' path' ;
15+ import { stringify } from ' querystring' ;
1616
17- const APP_CONFIG_URL : any = " ./app.json" ;
18- const LANGUAGE_KEY : any = makeStateKey < string > ( " language" ) ;
17+ const APP_CONFIG_URL : any = ' ./app.json' ;
18+ const LANGUAGE_KEY : any = makeStateKey < string > ( ' language' ) ;
1919
2020@Injectable ( )
2121export class SettingsService {
@@ -30,24 +30,24 @@ export class SettingsService {
3030 @Inject ( PLATFORM_ID ) platformId : string ,
3131 @Optional ( ) @Inject ( REQUEST ) protected request : Request ,
3232 private transferState : TransferState ,
33- private translate : TranslateService
33+ private translate : TranslateService ,
3434 ) {
3535 SettingsService . isServer = isPlatformServer ( platformId ) ;
3636 }
3737
3838 public async load ( ) : Promise < void > {
3939 let data : any | ISettings ;
40- const configKey : StateKey < number > = makeStateKey < number > ( " app-config" ) ;
40+ const configKey : StateKey < number > = makeStateKey < number > ( ' app-config' ) ;
4141 if ( SettingsService . isServer ) {
4242 const assetsFolder : string = join (
4343 process . cwd ( ) ,
44- " dist" ,
45- " career-portal" ,
46- " browser"
44+ ' dist' ,
45+ ' career-portal' ,
46+ ' browser' ,
4747 ) ;
4848
4949 data = JSON . parse (
50- fs . readFileSync ( join ( assetsFolder , " app.json" ) , " utf8" )
50+ fs . readFileSync ( join ( assetsFolder , ' app.json' ) , ' utf8' ) ,
5151 ) ;
5252 this . transferState . set ( configKey , data ) ;
5353 } else {
@@ -65,11 +65,11 @@ export class SettingsService {
6565 SettingsService . settings = data ;
6666
6767 const objectConfigOptions : string [ ] = [
68- " service" ,
69- " additionalJobCriteria" ,
70- " integrations" ,
71- " eeoc" ,
72- " privacyConsent" ,
68+ ' service' ,
69+ ' additionalJobCriteria' ,
70+ ' integrations' ,
71+ ' eeoc' ,
72+ ' privacyConsent' ,
7373 ] ;
7474
7575 objectConfigOptions . forEach ( ( option : string ) => {
@@ -82,28 +82,28 @@ export class SettingsService {
8282 SettingsService . settings . service . fields . length === 0
8383 ) {
8484 SettingsService . settings . service . fields = [
85- "id" ,
86- " title" ,
87- " publishedCategory(id,name)" ,
88- " address(city,state,countryName)" ,
89- " employmentType" ,
90- " dateLastPublished" ,
91- " publicDescription" ,
92- " isOpen" ,
93- " isPublic" ,
94- " isDeleted" ,
95- " publishedZip" ,
96- " salary" ,
97- " salaryUnit" ,
85+ 'id' ,
86+ ' title' ,
87+ ' publishedCategory(id,name)' ,
88+ ' address(city,state,countryName)' ,
89+ ' employmentType' ,
90+ ' dateLastPublished' ,
91+ ' publicDescription' ,
92+ ' isOpen' ,
93+ ' isPublic' ,
94+ ' isDeleted' ,
95+ ' publishedZip' ,
96+ ' salary' ,
97+ ' salaryUnit' ,
9898 ] ;
9999 }
100100
101101 if ( ! SettingsService . settings . service . jobInfoChips ) {
102102 SettingsService . settings . service . jobInfoChips = [
103- " employmentType" ,
103+ ' employmentType' ,
104104 {
105- type : " mediumDate" ,
106- field : " dateLastPublished" ,
105+ type : ' mediumDate' ,
106+ field : ' dateLastPublished' ,
107107 } ,
108108 ] ;
109109 }
@@ -113,20 +113,20 @@ export class SettingsService {
113113 SettingsService . settings . service . keywordSearchFields . length === 0
114114 ) {
115115 SettingsService . settings . service . keywordSearchFields = [
116- " publicDescription" ,
117- " title" ,
116+ ' publicDescription' ,
117+ ' title' ,
118118 ] ;
119119 }
120120 const validTokenRegex : RegExp = / [ ^ A - Z a - z 0 - 9 ] / ;
121121 if (
122122 ! SettingsService . settings . service . corpToken ||
123123 validTokenRegex . test ( SettingsService . settings . service . corpToken )
124124 ) {
125- throw new Error ( " Invalid Corp Token" ) ;
125+ throw new Error ( ' Invalid Corp Token' ) ;
126126 }
127127
128128 if ( ! SettingsService . settings . service . swimlane ) {
129- throw new Error ( " Invalid Swimlane" ) ;
129+ throw new Error ( ' Invalid Swimlane' ) ;
130130 }
131131 await this . translate . use ( this . getPreferredLanguage ( ) ) . toPromise ( ) ;
132132
@@ -137,25 +137,22 @@ export class SettingsService {
137137 }
138138
139139 private getPreferredLanguage ( ) : string {
140- let supportedLanguages : string [ ] =
141- SettingsService . settings . supportedLocales ;
140+ let supportedLanguages : string [ ] = SettingsService . settings . supportedLocales || [ ] ;
142141 let language : string = SettingsService . settings . defaultLocale ;
143142 if ( SettingsService . isServer ) {
144- language = < string > this . request [ " acceptsLanguages" ] ( supportedLanguages ) ;
143+ language = < string > this . request [ ' acceptsLanguages' ] ( supportedLanguages ) ;
145144 if ( ! language ) {
146145 language = SettingsService . settings . defaultLocale ;
147146 }
148147 this . transferState . set ( LANGUAGE_KEY , language ) ;
149148 } else {
150- language =
151- localStorage . getItem ( "preferredLanguage" ) ||
152- this . transferState . get ( LANGUAGE_KEY , undefined ) ;
149+ language = localStorage . getItem ( 'preferredLanguage' ) || this . transferState . get ( LANGUAGE_KEY , undefined ) ;
153150
154151 if ( ! language ) {
155152 language = SettingsService . settings . supportedLocales . filter (
156153 ( locale : string ) => {
157154 return navigator . language === locale ;
158- }
155+ } ,
159156 ) [ 0 ] ;
160157 }
161158 if ( ! language ) {
0 commit comments