Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesabarnes committed Mar 18, 2022
1 parent ac31590 commit 5874ff9
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 122 deletions.
28 changes: 14 additions & 14 deletions 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;
Expand All @@ -17,27 +17,27 @@ 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;
}
if (trackingId && !SettingsService.isServer) {
this.router.events.subscribe((event: any) => {
if (event instanceof NavigationEnd) {
(<any>window).ga("create", trackingId, "auto");
(<any>window).ga("set", "page", event.urlAfterRedirects);
(<any>window).ga("send", "pageview");
(<any>window).ga('create', trackingId, 'auto');
(<any>window).ga('set', 'page', event.urlAfterRedirects);
(<any>window).ga('send', 'pageview');
}
});
}
Expand Down
60 changes: 30 additions & 30 deletions 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,
Expand All @@ -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<void> {
return () => settings.load();
Expand All @@ -59,7 +59,7 @@ export function initSettings(settings: SettingsService): () => Promise<void> {
],
entryComponents: [ApplyModalComponent, ErrorModalComponent],
imports: [
BrowserModule.withServerTransition({ appId: "serverApp" }),
BrowserModule.withServerTransition({ appId: 'serverApp' }),
AppRoutingModule,
HttpClientModule,
NovoElementsModule,
Expand Down
99 changes: 48 additions & 51 deletions 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<string>("language");
const APP_CONFIG_URL: any = './app.json';
const LANGUAGE_KEY: any = makeStateKey<string>('language');

@Injectable()
export class SettingsService {
Expand All @@ -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<void> {
let data: any | ISettings;
const configKey: StateKey<number> = makeStateKey<number>("app-config");
const configKey: StateKey<number> = makeStateKey<number>('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 {
Expand All @@ -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) => {
Expand All @@ -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',
},
];
}
Expand All @@ -113,20 +113,20 @@ export class SettingsService {
SettingsService.settings.service.keywordSearchFields.length === 0
) {
SettingsService.settings.service.keywordSearchFields = [
"publicDescription",
"title",
'publicDescription',
'title',
];
}
const validTokenRegex: RegExp = /[^A-Za-z0-9]/;
if (
!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();

Expand All @@ -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 = <string>this.request["acceptsLanguages"](supportedLanguages);
language = <string>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) {
Expand Down

0 comments on commit 5874ff9

Please sign in to comment.