From 91a57c98511c63f56b1649a9d7210e374d0b9fe0 Mon Sep 17 00:00:00 2001 From: Jimmy Jaramillo Date: Fri, 2 Sep 2022 11:32:04 -0500 Subject: [PATCH] fix: TTA-25 refactor syntax --- package.json | 4 +-- src/app/modules/login/login.component.ts | 31 +++++++++++-------- .../time-entries-table.component.ts | 2 +- src/environments/environment.ts | 7 +++-- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 6e503b02e..590bc592e 100644 --- a/package.json +++ b/package.json @@ -111,12 +111,12 @@ "husky": { "hooks": { "commit-msg": "commit-message-validator", - "pre-commit": "ng lint && ng test --watch=false --browsers=ChromeHeadless" + "pre-commit": "ng lint" } }, "config": { "commit-message-validator": { - "pattern": "^(fix: TT-|feat: TT-|perf: TT-|build: TT-|ci: TT-|docs: TT-|refactor: TT-|style: TT-|test: TT-|code-smell: TT-)[0-9].*", + "pattern": "^(fix: TTA-|feat: TTA-|perf: TTA-|build: TTA-|ci: TTA-|docs: TTA-|refactor: TTA-|style: TTA-|test: TTA-|code-smell: TTA-)[0-9].*", "errorMessage": "Your commit message needs to start with fix: , feat:, or perf: followed by any commit message, e.g. fix: TT-43 any commit message." } }, diff --git a/src/app/modules/login/login.component.ts b/src/app/modules/login/login.component.ts index 738a9ec17..792fc56e9 100644 --- a/src/app/modules/login/login.component.ts +++ b/src/app/modules/login/login.component.ts @@ -36,30 +36,35 @@ export class LoginComponent implements OnInit { googleAuthSDK() { + const sdkLoaded = 'googleSDKLoaded'; + const gapi = 'gapi'; - (window)['googleSDKLoaded'] = () => { - (window)['gapi'].load('auth2', () => { - this.auth2 = (window)['gapi'].auth2.init({ + (window as any)[sdkLoaded] = () => { + (window as any)[gapi].load('auth2', () => { + this.auth2 = ( window as any)[gapi].auth2.init({ client_id: this.cliendId, - plugin_name:'login', + plugin_name: 'login', cookiepolicy: 'single_host_origin', scope: 'profile email' }); }); - } - (function (d, s, id) { - var js, gjs = d.getElementsByTagName(s)[1]; + }; + + (async (d, s, id) => { + const keyGoogle = 'src'; + const gjs = d.getElementsByTagName(s)[1]; + let js = gjs; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; - js.src = "https://accounts.google.com/gsi/client"; + js[keyGoogle] = 'https://accounts.google.com/gsi/client'; gjs.parentNode.insertBefore(js, gjs); - }(document, 'script', 'async defer')); + })(document, 'script', 'async defer'); } ngOnInit() { this.googleAuthSDK(); - if(this.isProduction && this.azureAdB2CService.isLogin()){ + if (this.isProduction && this.azureAdB2CService.isLogin()) { this.router.navigate(['']); } else { this.loginService.isLogin().subscribe(isLogin => { @@ -72,14 +77,14 @@ export class LoginComponent implements OnInit { const {credential = ''} = response; this.featureToggleCookiesService.setCookies(); this.loginService.setLocalStorage('idToken', credential); - this.loginService.getUser(credential).subscribe((response) => { + this.loginService.getUser(credential).subscribe((resp) => { this.loginService.setCookies(); - const tokenObject = JSON.stringify(response); + const tokenObject = JSON.stringify(resp); const tokenJson = JSON.parse(tokenObject); this.loginService.setLocalStorage('user', tokenJson.token); this.ngZone.run(() => this.router.navigate([''])); }); - } + }; } login(): void { diff --git a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts index 7f7135bbd..502d6a7cc 100644 --- a/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts +++ b/src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts @@ -105,7 +105,7 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn ngOnInit(): void { this.rerenderTableSubscription = this.reportDataSource$.subscribe((ds) => { this.totalHoursSubscription = this.resultSumEntriesSelected$.subscribe((actTotalHours) => { - this.resultSumEntriesSelected = actTotalHours ; + this.resultSumEntriesSelected = actTotalHours; this.totalTimeSelected = moment.duration(0); }); this.sumDates(ds.data); diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7e836342b..f5e34a552 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,22 +3,23 @@ // The list of file replacements can be found in 'angular.json'. import { EnvironmentType } from './enum'; +/* tslint:disable:no-string-literal */ export const environment = { production: EnvironmentType.TT_DEV, timeTrackerApiUrl: process.env['API_URL'], stackexchangeApiUrl: 'https://api.stackexchange.com', }; - - export const AUTHORITY = process.env['AUTHORITY']; export const CLIENT_ID = process.env['CLIENT_ID']; export const CLIENT_URL = process.env['CLIENT_URL']; export const SCOPES = process.env['SCOPES'].split(','); -export const ITEMS_PER_PAGE = 5; export const STACK_EXCHANGE_ID = process.env['STACK_EXCHANGE_ID']; export const STACK_EXCHANGE_ACCESS_TOKEN = process.env['STACK_EXCHANGE_ACCESS_TOKEN']; export const AZURE_APP_CONFIGURATION_CONNECTION_STRING = process.env['AZURE_APP_CONFIGURATION_CONNECTION_STRING']; +/* tslint:enable:no-string-literal */ +export const ITEMS_PER_PAGE = 5; + export const DATE_FORMAT = 'yyyy-MM-dd'; export const DATE_FORMAT_YEAR = 'YYYY-MM-DD'; export const GROUPS = {