From 8a08f2e634637a01b1b8598ba8edfb42fcc9e695 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Fri, 3 Jan 2025 19:01:34 -0600 Subject: [PATCH 1/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- .gitignore | 1 + angular.json | 52 +----------- documentation.json | 34 ++++---- package.json | 13 ++- scripts/postbuild.ts | 15 ++-- .../runtime-environment-setter.dev-runtime.ts | 24 ++++++ .../runtime-environment-setter.postbuild.ts | 22 ++++++ scripts/utils.ts | 79 ++++++++++++++++--- ...s-duplicated-merged-confirmed.component.ts | 2 +- .../dialog-actions-duplicated.component.ts | 2 +- .../settings-defaults-language.component.ts | 2 +- .../settings-sharing-html-code.component.ts | 2 +- ...ialog-add-trusted-individuals.component.ts | 2 +- ...og-revoke-trusted-individuals.component.ts | 2 +- ...gs-trusted-individuals-search.component.ts | 2 +- .../settings-trusted-individuals.component.ts | 2 +- ...ettings-users-that-thrust-you.component.ts | 2 +- src/app/app.module.ts | 43 +--------- .../cdk/platform-info/browserlist.regexp.ts | 3 +- src/app/cdk/recaptcha/recaptcha.directive.ts | 2 +- src/app/cdk/snackbar/snackbar.service.ts | 2 +- src/app/constants.ts | 2 +- .../account-actions-deactivate.service.ts | 2 +- .../account-actions-download.service.ts | 2 +- .../account-actions-duplicated.service.ts | 4 +- ...count-default-email-frequencies.service.ts | 10 +-- .../account-default-visibility.service.ts | 2 +- ...ount-security-alternate-sign-in.service.ts | 4 +- .../account-security-password.service.ts | 2 +- .../account-trusted-individuals.service.ts | 16 ++-- .../account-trusted-organizations.service.ts | 4 +- src/app/core/announcer/announcer.service.ts | 2 +- .../canonocal-url/canonocal-url.service.ts | 4 +- .../developer-tools.service.ts | 12 +-- src/app/core/disco/disco.service.ts | 5 +- .../google-tag-manager.service.ts | 9 +-- src/app/core/help-hero/help-hero.service.ts | 2 +- src/app/core/inbox/inbox.service.ts | 10 +-- src/app/core/language/language.service.ts | 6 +- src/app/core/news/news.service.ts | 2 +- src/app/core/oauth/oauth.service.ts | 12 +-- .../observability-events.service.ts | 4 +- src/app/core/open-graph/open-graph.service.ts | 4 +- .../organizations/organizations.service.ts | 4 +- .../password-recovery.service.ts | 8 +- .../core/reactivation/reactivation.service.ts | 4 +- .../record-affiliations.service.ts | 20 ++--- .../record-biography.service.ts | 6 +- .../record-countries.service.ts | 4 +- .../record-emails/record-emails.service.ts | 12 +-- .../record-fundings.service.ts | 22 +++--- .../record-keyword/record-keyword.service.ts | 6 +- .../core/record-names/record-names.service.ts | 6 +- .../record-other-names.service.ts | 6 +- .../record-peer-review.service.ts | 20 ++--- .../record-person/record-person.service.ts | 2 +- .../record-person-identifier.service.ts | 4 +- .../record-public-side-bar.service.ts | 2 +- .../record-research-resource.service.ts | 14 ++-- .../record-websites.service.ts | 6 +- .../record-works/record-works.service.spec.ts | 8 +- .../core/record-works/record-works.service.ts | 38 ++++----- src/app/core/record/record.service.ts | 14 ++-- .../register/register.backend-validators.ts | 6 +- src/app/core/register/register.service.ts | 6 +- .../register2/register2.backend-validators.ts | 6 +- src/app/core/register2/register2.service.ts | 8 +- .../robots-meta-tags.service.ts | 4 +- src/app/core/search/search.service.ts | 2 +- src/app/core/sign-in/sign-in.service.ts | 10 +-- src/app/core/togglz/togglz.service.ts | 2 +- .../trusted-individuals.service.ts | 2 +- .../trusted-summary.service.ts | 2 +- .../two-factor-authentication.service.ts | 18 ++--- src/app/core/user-info/user-info.service.ts | 2 +- src/app/core/user/user.service.ts | 14 ++-- .../core/wordpress/wordpress.service.spec.ts | 28 +++---- src/app/core/wordpress/wordpress.service.ts | 12 +-- .../environment-banner.component.ts | 4 +- src/app/guards/language.guard.ts | 2 +- .../home/components/news/news.component.ts | 2 +- src/app/home/pages/home/home.component.ts | 2 +- .../institutional/institutional.component.ts | 6 +- src/app/layout/footer/footer.component.ts | 4 +- src/app/layout/header/header.component.ts | 6 +- src/app/layout/language/language.component.ts | 4 +- .../layout/user-menu/user-menu.component.ts | 4 +- .../modal-peer-reviews.component.ts | 2 +- .../record-header/record-header.component.ts | 4 +- .../record-info/record-info.component.ts | 2 +- .../search-link-wizard.component.ts | 2 +- .../top-bar-actions.component.ts | 2 +- .../top-bar-record-issues.component.ts | 2 +- .../work-contributors.component.ts | 4 +- .../components/step-a/step-a.component.ts | 2 +- .../form-password/form-password.component.ts | 2 +- .../form-personal/form-personal.component.ts | 2 +- .../components/step-a/step-a.component.ts | 2 +- .../logged-in/logged-in.component.ts | 2 +- .../components/social/social.component.ts | 2 +- src/assets/local-dev-environment.js | 62 +++++++++++++++ src/environments/environment.int.ts | 4 +- .../environment.local-with-proxy.ts | 5 +- src/environments/environment.local.tomcat.ts | 43 ---------- src/environments/environment.local.ts | 5 +- src/environments/environment.production.ts | 7 +- src/environments/environment.qa.ts | 4 +- src/environments/environment.sandbox.ts | 4 +- src/environments/global-environment.d.ts | 30 +++++++ src/index.html | 6 +- src/main.ts | 2 +- src/test.ts | 2 +- 112 files changed, 531 insertions(+), 463 deletions(-) create mode 100644 scripts/runtime-environment-setter.dev-runtime.ts create mode 100644 scripts/runtime-environment-setter.postbuild.ts create mode 100644 src/assets/local-dev-environment.js delete mode 100644 src/environments/environment.local.tomcat.ts create mode 100644 src/environments/global-environment.d.ts diff --git a/.gitignore b/.gitignore index 8ac008313a..c06dcbee5b 100644 --- a/.gitignore +++ b/.gitignore @@ -77,4 +77,5 @@ cypress/plugins/token.json # Packages ignore package-lock to depend only on yarn package-lock.json +src/assets/dev-runtime-environment-setter.js diff --git a/angular.json b/angular.json index de733f46e4..edbf79beee 100644 --- a/angular.json +++ b/angular.json @@ -243,48 +243,6 @@ } ] }, - "qa": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.qa.ts" - } - ] - }, - "sandbox": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.sandbox.ts" - } - ] - }, - "int": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.int.ts" - } - ] - }, "en": { "localize": ["en"] }, @@ -370,23 +328,17 @@ }, "local-sandbox": { "browserTarget": "ng-orcid:build:local-with-proxy", - "proxyConfig": "src/proxy.conf.sandbox..mjs" + "proxyConfig": "src/proxy.conf.sandbox.mjs" }, "local": { "browserTarget": "ng-orcid:build:local" }, "local-tomcat": { - "browserTarget": "ng-orcid:build:local-tomcat" }, "production": { "browserTarget": "ng-orcid:build:production" }, - "sandbox": { - "browserTarget": "ng-orcid:build:sandbox" - }, - "qa": { - "browserTarget": "ng-orcid:build:qa" - }, + "en": { "browserTarget": "ng-orcid:build:en" }, diff --git a/documentation.json b/documentation.json index 812d0f11a8..0a17b539ad 100644 --- a/documentation.json +++ b/documentation.json @@ -17236,7 +17236,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { HttpClient } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { Observable, ReplaySubject } from 'rxjs'\nimport { catchError, first, map, retry, take, tap } from 'rxjs/operators'\n\nimport { environment } from '../../../environments/environment'\nimport { Institutional } from '../../types/institutional.endpoint'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { ERROR_REPORT } from 'src/app/errors'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DiscoService {\n discoFeedSubject: ReplaySubject\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n getInstitutionsNames(institutions, filterInput?: string): string[] {\n const allInstitutionNames = this.getDiscoFeedInstitutionsNames(institutions)\n let institutionNames: string[]\n if (filterInput && filterInput.length > 0) {\n institutionNames = allInstitutionNames.filter((institutionName) => {\n institutionName = institutionName.toLowerCase()\n filterInput = filterInput.toLocaleLowerCase()\n return institutionName.indexOf(filterInput.toLowerCase()) !== -1\n })\n institutionNames = institutionNames.slice(\n 0,\n environment.INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT\n )\n } else {\n institutionNames = allInstitutionNames\n }\n\n return institutionNames\n }\n\n getInstitutionBaseOnName(\n institutionName: string,\n allInstitutions: Institutional[]\n ): Institutional {\n institutionName = institutionName.toLowerCase()\n return allInstitutions.find((institution) =>\n institution?.DisplayNames?.find(\n (name) =>\n name.lang === 'en' &&\n name.value.toLocaleLowerCase() === institutionName\n )\n )\n }\n\n getInstitutionBaseOnID(entityId: string): Observable {\n return this.getDiscoFeed().pipe(\n first(),\n map((value) => this.getInstitutionBaseOnIDFromObject(value, entityId))\n )\n }\n getInstitutionBaseOnIDFromObject(\n institutions: Institutional[],\n entityId: string\n ): Institutional | undefined {\n return institutions.find(\n (institution) => institution?.entityID === entityId\n )\n }\n\n getInstitutionNameBaseOnId(entityId): Observable {\n return this.getInstitutionBaseOnID(entityId).pipe(\n map((value) => this.getInstitutionNameBaseOnIdFromObject(value))\n )\n }\n\n getInstitutionNameBaseOnIdFromObject(\n institution: Institutional | undefined\n ): string | undefined {\n return institution?.DisplayNames?.filter(\n (subElement) => subElement.lang === 'en'\n ).map((en) => {\n return en.value\n })?.[0]\n }\n\n public getDiscoFeed(): Observable {\n if (!this.discoFeedSubject) {\n this.discoFeedSubject = new ReplaySubject(1)\n return this._http\n .get(environment.BASE_URL + 'Shibboleth.sso/DiscoFeed')\n .pipe(\n tap((feed) => {\n this.discoFeedSubject.next(feed)\n }),\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n {\n return this.discoFeedSubject.pipe(take(1))\n }\n }\n\n private getDiscoFeedInstitutionsNames(allInstitutions): string[] {\n return this.discoFeedToInstitutionNames(allInstitutions)\n }\n\n private discoFeedToInstitutionNames(institutions: Institutional[]): string[] {\n const names = []\n institutions.map((inst) =>\n inst.DisplayNames.filter((name) => name.lang === 'en').map((en) =>\n names.push(en.value)\n )\n )\n return names\n }\n}\n", + "sourceCode": "import { HttpClient } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { Observable, ReplaySubject } from 'rxjs'\nimport { catchError, first, map, retry, take, tap } from 'rxjs/operators'\n\n\nimport { Institutional } from '../../types/institutional.endpoint'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { ERROR_REPORT } from 'src/app/errors'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DiscoService {\n discoFeedSubject: ReplaySubject\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n getInstitutionsNames(institutions, filterInput?: string): string[] {\n const allInstitutionNames = this.getDiscoFeedInstitutionsNames(institutions)\n let institutionNames: string[]\n if (filterInput && filterInput.length > 0) {\n institutionNames = allInstitutionNames.filter((institutionName) => {\n institutionName = institutionName.toLowerCase()\n filterInput = filterInput.toLocaleLowerCase()\n return institutionName.indexOf(filterInput.toLowerCase()) !== -1\n })\n institutionNames = institutionNames.slice(\n 0,\n environment.INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT\n )\n } else {\n institutionNames = allInstitutionNames\n }\n\n return institutionNames\n }\n\n getInstitutionBaseOnName(\n institutionName: string,\n allInstitutions: Institutional[]\n ): Institutional {\n institutionName = institutionName.toLowerCase()\n return allInstitutions.find((institution) =>\n institution?.DisplayNames?.find(\n (name) =>\n name.lang === 'en' &&\n name.value.toLocaleLowerCase() === institutionName\n )\n )\n }\n\n getInstitutionBaseOnID(entityId: string): Observable {\n return this.getDiscoFeed().pipe(\n first(),\n map((value) => this.getInstitutionBaseOnIDFromObject(value, entityId))\n )\n }\n getInstitutionBaseOnIDFromObject(\n institutions: Institutional[],\n entityId: string\n ): Institutional | undefined {\n return institutions.find(\n (institution) => institution?.entityID === entityId\n )\n }\n\n getInstitutionNameBaseOnId(entityId): Observable {\n return this.getInstitutionBaseOnID(entityId).pipe(\n map((value) => this.getInstitutionNameBaseOnIdFromObject(value))\n )\n }\n\n getInstitutionNameBaseOnIdFromObject(\n institution: Institutional | undefined\n ): string | undefined {\n return institution?.DisplayNames?.filter(\n (subElement) => subElement.lang === 'en'\n ).map((en) => {\n return en.value\n })?.[0]\n }\n\n public getDiscoFeed(): Observable {\n if (!this.discoFeedSubject) {\n this.discoFeedSubject = new ReplaySubject(1)\n return this._http\n .get(environment.BASE_URL + 'Shibboleth.sso/DiscoFeed')\n .pipe(\n tap((feed) => {\n this.discoFeedSubject.next(feed)\n }),\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n {\n return this.discoFeedSubject.pipe(take(1))\n }\n }\n\n private getDiscoFeedInstitutionsNames(allInstitutions): string[] {\n return this.discoFeedToInstitutionNames(allInstitutions)\n }\n\n private discoFeedToInstitutionNames(institutions: Institutional[]): string[] {\n const names = []\n institutions.map((inst) =>\n inst.DisplayNames.filter((name) => name.lang === 'en').map((en) =>\n names.push(en.value)\n )\n )\n return names\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -17669,7 +17669,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Inject, Injectable } from '@angular/core'\nimport { environment } from '../../../environments/environment'\nimport { RequestInfoForm } from '../../types'\nimport { BehaviorSubject, Observable } from 'rxjs'\nimport {\n browserGlobals,\n buildClientString,\n pushOnDataLayer,\n removeUrlParameters,\n} from '../../analytics-utils'\nimport { catchError } from 'rxjs/operators'\nimport { ItemGTM } from '../../types/item_gtm'\nimport { ERROR_REPORT } from '../../errors'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { WINDOW } from 'src/app/cdk/window'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GoogleTagManagerService {\n private _loading = new BehaviorSubject(false)\n public readonly loading$ = this._loading.asObservable()\n\n private isLoaded = false\n\n constructor(\n private _errorHandler: ErrorHandlerService,\n @Inject(WINDOW) private _window: Window\n ) {}\n\n public pushTag(item: ItemGTM): Observable {\n return new Observable((subscriber) => {\n if (!this.isLoaded) {\n this.addGtmToDom()\n .pipe(\n catchError((err) =>\n this._errorHandler.handleError(\n err,\n ERROR_REPORT.STANDARD_NO_VERBOSE_NO_GA\n )\n )\n )\n .subscribe(\n (response) => {\n if (response) {\n pushOnDataLayer(item)\n if (!this.isGtmRunning()) {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Gtm is not adding uniqueEventId attributes',\n })\n } else {\n subscriber.next()\n subscriber.complete()\n }\n }\n },\n () => {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Unable to add GTM',\n })\n }\n )\n } else {\n pushOnDataLayer(item)\n if (!this.isGtmRunning()) {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Gtm is not adding uniqueEventId attributes',\n })\n } else {\n subscriber.next()\n subscriber.complete()\n }\n }\n })\n }\n\n public isGtmRunning(): boolean {\n // When GTM is blocked by add blockers like Ublock\n // the `gtm.uniqueEventId` will not be added to the dataLayer objects\n const gtmData = (this._window as any).dataLayer || []\n return gtmData.some((event: any) => event['gtm.uniqueEventId'])\n }\n\n public addGtmToDom(): Observable {\n return new Observable((subscriber) => {\n if (this.isLoaded) {\n subscriber.next(true)\n subscriber.complete()\n }\n const doc = browserGlobals.documentRef()\n pushOnDataLayer({\n 'gtm.start': new Date().getTime(),\n event: 'gtm.js',\n })\n\n const gtmScript = doc.createElement('script')\n gtmScript.id = 'GTM'\n gtmScript.async = true\n gtmScript.src =\n 'https://www.googletagmanager.com/gtm.js?id=' +\n environment.GOOGLE_TAG_MANAGER\n gtmScript.setAttributeNode(doc.createAttribute('data-ot-ignore'))\n gtmScript.addEventListener('load', () => {\n this.isLoaded = true\n subscriber.next(true)\n subscriber.complete()\n })\n gtmScript.addEventListener('error', () => {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Unable to add GTM',\n })\n })\n doc.head.insertBefore(gtmScript, doc.head.firstChild)\n })\n }\n\n reportPageView(url: string) {\n if (environment.debugger) {\n console.debug(`GTM Navigation ${url}`)\n }\n const gtmTag: ItemGTM = {\n event: 'page',\n pageName: url,\n }\n this.pushTag(gtmTag).subscribe()\n }\n\n public reportEvent(\n event: string,\n label: RequestInfoForm | string\n ): Observable {\n let clientId\n let redirectUrl\n if (typeof label !== 'string') {\n clientId = (label as unknown as RequestInfoForm).clientId\n redirectUrl = (label as unknown as RequestInfoForm).redirectUrl\n label = 'OAuth ' + buildClientString(label)\n }\n if (environment.debugger) {\n console.debug(`GTM - Event /${event}/${label}/`)\n }\n\n let tagItem = {\n event,\n label,\n } as ItemGTM\n if (clientId) {\n tagItem.clientId = clientId\n }\n\n if (event === 'Reauthorize') {\n tagItem.redirectUrl = redirectUrl\n }\n\n return this.pushTag(tagItem)\n }\n\n reportNavigationEnd(url: string, duration: number | void): Observable {\n if (duration) {\n if (environment.debugger) {\n console.debug(`GTM - Took ${duration} to load ${url}`)\n }\n\n return this.pushTag({\n event: 'timing_complete',\n orcid: removeUrlParameters(url),\n duration: Math.round(duration),\n pageName: url,\n })\n }\n }\n}\n", + "sourceCode": "import { Inject, Injectable } from '@angular/core'\n\nimport { RequestInfoForm } from '../../types'\nimport { BehaviorSubject, Observable } from 'rxjs'\nimport {\n browserGlobals,\n buildClientString,\n pushOnDataLayer,\n removeUrlParameters,\n} from '../../analytics-utils'\nimport { catchError } from 'rxjs/operators'\nimport { ItemGTM } from '../../types/item_gtm'\nimport { ERROR_REPORT } from '../../errors'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { WINDOW } from 'src/app/cdk/window'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class GoogleTagManagerService {\n private _loading = new BehaviorSubject(false)\n public readonly loading$ = this._loading.asObservable()\n\n private isLoaded = false\n\n constructor(\n private _errorHandler: ErrorHandlerService,\n @Inject(WINDOW) private _window: Window\n ) {}\n\n public pushTag(item: ItemGTM): Observable {\n return new Observable((subscriber) => {\n if (!this.isLoaded) {\n this.addGtmToDom()\n .pipe(\n catchError((err) =>\n this._errorHandler.handleError(\n err,\n ERROR_REPORT.STANDARD_NO_VERBOSE_NO_GA\n )\n )\n )\n .subscribe(\n (response) => {\n if (response) {\n pushOnDataLayer(item)\n if (!this.isGtmRunning()) {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Gtm is not adding uniqueEventId attributes',\n })\n } else {\n subscriber.next()\n subscriber.complete()\n }\n }\n },\n () => {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Unable to add GTM',\n })\n }\n )\n } else {\n pushOnDataLayer(item)\n if (!this.isGtmRunning()) {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Gtm is not adding uniqueEventId attributes',\n })\n } else {\n subscriber.next()\n subscriber.complete()\n }\n }\n })\n }\n\n public isGtmRunning(): boolean {\n // When GTM is blocked by add blockers like Ublock\n // the `gtm.uniqueEventId` will not be added to the dataLayer objects\n const gtmData = (this._window as any).dataLayer || []\n return gtmData.some((event: any) => event['gtm.uniqueEventId'])\n }\n\n public addGtmToDom(): Observable {\n return new Observable((subscriber) => {\n if (this.isLoaded) {\n subscriber.next(true)\n subscriber.complete()\n }\n const doc = browserGlobals.documentRef()\n pushOnDataLayer({\n 'gtm.start': new Date().getTime(),\n event: 'gtm.js',\n })\n\n const gtmScript = doc.createElement('script')\n gtmScript.id = 'GTM'\n gtmScript.async = true\n gtmScript.src =\n 'https://www.googletagmanager.com/gtm.js?id=' +\n environment.GOOGLE_TAG_MANAGER\n gtmScript.setAttributeNode(doc.createAttribute('data-ot-ignore'))\n gtmScript.addEventListener('load', () => {\n this.isLoaded = true\n subscriber.next(true)\n subscriber.complete()\n })\n gtmScript.addEventListener('error', () => {\n subscriber.error({\n name: 'GTM - Error',\n message: 'Unable to add GTM',\n })\n })\n doc.head.insertBefore(gtmScript, doc.head.firstChild)\n })\n }\n\n reportPageView(url: string) {\n if (environment.debugger) {\n console.debug(`GTM Navigation ${url}`)\n }\n const gtmTag: ItemGTM = {\n event: 'page',\n pageName: url,\n }\n this.pushTag(gtmTag).subscribe()\n }\n\n public reportEvent(\n event: string,\n label: RequestInfoForm | string\n ): Observable {\n let clientId\n let redirectUrl\n if (typeof label !== 'string') {\n clientId = (label as unknown as RequestInfoForm).clientId\n redirectUrl = (label as unknown as RequestInfoForm).redirectUrl\n label = 'OAuth ' + buildClientString(label)\n }\n if (environment.debugger) {\n console.debug(`GTM - Event /${event}/${label}/`)\n }\n\n let tagItem = {\n event,\n label,\n } as ItemGTM\n if (clientId) {\n tagItem.clientId = clientId\n }\n\n if (event === 'Reauthorize') {\n tagItem.redirectUrl = redirectUrl\n }\n\n return this.pushTag(tagItem)\n }\n\n reportNavigationEnd(url: string, duration: number | void): Observable {\n if (duration) {\n if (environment.debugger) {\n console.debug(`GTM - Took ${duration} to load ${url}`)\n }\n\n return this.pushTag({\n event: 'timing_complete',\n orcid: removeUrlParameters(url),\n duration: Math.round(duration),\n pageName: url,\n })\n }\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -18789,7 +18789,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Inject, Injectable } from '@angular/core'\nimport { Router } from '@angular/router'\nimport { NEVER, Observable, of, ReplaySubject } from 'rxjs'\nimport {\n catchError,\n last,\n map,\n retry,\n shareReplay,\n switchMap,\n tap,\n} from 'rxjs/operators'\nimport { WINDOW } from 'src/app/cdk/window'\nimport { ApplicationRoutes } from 'src/app/constants'\nimport { ERROR_REPORT } from 'src/app/errors'\nimport { OauthParameters, RequestInfoForm } from 'src/app/types'\nimport { OauthAuthorize } from 'src/app/types/authorize.endpoint'\nimport { UserSessionUpdateParameters } from 'src/app/types/session.local'\n\nimport { environment } from '../../../environments/environment'\nimport { SignInData } from '../../types/sign-in-data.endpoint'\nimport { TwoFactor } from '../../types/two-factor.endpoint'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { objectToUrlParameters } from '../../constants'\n\nconst OAUTH_SESSION_ERROR_CODES_HANDLE_BY_CLIENT_APP = [\n 'login_required',\n 'interaction_required',\n 'invalid_scope',\n 'unsupported_response_type',\n]\n\n@Injectable({\n providedIn: 'root',\n})\nexport class OauthService {\n private headers: HttpHeaders\n private requestInfoSubject = new ReplaySubject(1)\n private declareOauthSession$\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _router: Router,\n @Inject(WINDOW) private window: Window\n ) {\n this.headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n }\n\n /**\n * @deprecated in favor of only getting the oauth session data through the user service\n */\n loadRequestInfoFormFromMemory(): Observable {\n return this.requestInfoSubject\n }\n /**\n * @deprecated in favor of only getting the oauth session data through the user service\n */\n updateRequestInfoFormInMemory(requestInfoForm: RequestInfoForm) {\n this.requestInfoSubject.next(requestInfoForm)\n }\n\n /**\n * @deprecated Oauth session are not require to be persistent since https://github.com/ORCID/orcid-angular/pull/609\n */\n loadRequestInfoForm(): Observable {\n return this._http\n .get(\n environment.BASE_URL + 'oauth/custom/requestInfoForm.json',\n { headers: this.headers }\n )\n .pipe(\n // Return null if the requestInfo is empty\n map((requestInfo) => (requestInfo.clientId ? requestInfo : undefined)),\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n switchMap((session) => this.handleSessionErrors(session))\n )\n }\n\n authorize(approved: boolean): Observable {\n const value: OauthAuthorize = {\n // tslint:disable-next-line: max-line-length\n // TODO @angel please confirm that persistentTokenEnabled is always true https://github.com/ORCID/ORCID-Source/blob/master/orcid-web/src/main/webapp/static/javascript/ng1Orcid/app/modules/oauthAuthorization/oauthAuthorization.component.ts#L161\n // TODO @angel by looking into analytics, I can see we have never reported a persistentTokenDisabled\n persistentTokenEnabled: true,\n // tslint:disable-next-line: max-line-length\n // TODO @angel please confirm that email access is always allowed know and at some point it was optional https://github.com/ORCID/ORCID-Source/blob/master/orcid-web/src/main/resources/freemarker/includes/oauth/scopes_ng2.ftl#L42\n emailAccessAllowed: true,\n approved,\n }\n return this._http\n .post(\n environment.BASE_URL + 'oauth/custom/authorize.json',\n value,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n ),\n tap((requestInfo) => {\n this.requestInfoSubject.next(requestInfo)\n })\n )\n }\n\n /**\n * @param queryParameters Orcid supported OAuth parameters\n *\n * Important: Avoid calling this method directly, since getting the oauth RequestInfo from the UserService.getSession is preferred\n *\n * After the first call to this method it will keep returning the same observable, ignoring new or different queryParameters\n * this is not an issue since the Oauth session will only be refresh if the app is reloaded with a new Oauth URL\n *\n */\n declareOauthSession(\n queryParameters: OauthParameters,\n updateParameters?: UserSessionUpdateParameters\n ): Observable {\n if (\n !this.declareOauthSession$ ||\n updateParameters.checkTrigger.timerUpdate === undefined\n ) {\n this.declareOauthSession$ = this._http\n .post(\n environment.BASE_URL +\n `oauth/custom/init.json?${objectToUrlParameters(queryParameters)}`,\n queryParameters,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n ),\n switchMap((session) =>\n this.handleSessionErrors(session, queryParameters)\n ),\n shareReplay(1)\n )\n return this.declareOauthSession$.pipe(last())\n } else {\n return this.declareOauthSession$.pipe(last())\n }\n }\n\n handleSessionErrors(\n session: RequestInfoForm,\n queryParameters?: OauthParameters\n ): Observable {\n if (!session) {\n return of(null)\n }\n if (\n session.error &&\n OAUTH_SESSION_ERROR_CODES_HANDLE_BY_CLIENT_APP.find(\n (x) => x === session.error\n )\n ) {\n // Redirect error that is handle by the client application\n ;(this.window as any).outOfRouterNavigation(\n `${session.redirectUrl}#error=${session.error}`\n )\n return NEVER\n } else if (session.error || (session.errors && session.errors.length)) {\n // Send the user to the oauth page to see the error\n this._router\n .navigate([ApplicationRoutes.authorize], {\n queryParams: queryParameters,\n })\n .then((navigated: boolean) => {\n if (navigated) {\n this._errorHandler\n .handleError(\n new Error(\n `${session.error || session.errors}.${\n session.errorDescription\n }`\n ),\n ERROR_REPORT.OAUTH_PARAMETERS\n )\n .subscribe()\n }\n })\n }\n return of(session)\n }\n\n loadShibbolethSignInData(): Observable {\n return this._http\n .get(environment.BASE_URL + 'shibboleth/signinData.json', {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n\n loadSocialSigninData(): Observable {\n return this._http\n .get(environment.BASE_URL + 'social/signinData.json', {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n}\n", + "sourceCode": "import { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Inject, Injectable } from '@angular/core'\nimport { Router } from '@angular/router'\nimport { NEVER, Observable, of, ReplaySubject } from 'rxjs'\nimport {\n catchError,\n last,\n map,\n retry,\n shareReplay,\n switchMap,\n tap,\n} from 'rxjs/operators'\nimport { WINDOW } from 'src/app/cdk/window'\nimport { ApplicationRoutes } from 'src/app/constants'\nimport { ERROR_REPORT } from 'src/app/errors'\nimport { OauthParameters, RequestInfoForm } from 'src/app/types'\nimport { OauthAuthorize } from 'src/app/types/authorize.endpoint'\nimport { UserSessionUpdateParameters } from 'src/app/types/session.local'\n\n\nimport { SignInData } from '../../types/sign-in-data.endpoint'\nimport { TwoFactor } from '../../types/two-factor.endpoint'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { objectToUrlParameters } from '../../constants'\n\nconst OAUTH_SESSION_ERROR_CODES_HANDLE_BY_CLIENT_APP = [\n 'login_required',\n 'interaction_required',\n 'invalid_scope',\n 'unsupported_response_type',\n]\n\n@Injectable({\n providedIn: 'root',\n})\nexport class OauthService {\n private headers: HttpHeaders\n private requestInfoSubject = new ReplaySubject(1)\n private declareOauthSession$\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _router: Router,\n @Inject(WINDOW) private window: Window\n ) {\n this.headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n }\n\n /**\n * @deprecated in favor of only getting the oauth session data through the user service\n */\n loadRequestInfoFormFromMemory(): Observable {\n return this.requestInfoSubject\n }\n /**\n * @deprecated in favor of only getting the oauth session data through the user service\n */\n updateRequestInfoFormInMemory(requestInfoForm: RequestInfoForm) {\n this.requestInfoSubject.next(requestInfoForm)\n }\n\n /**\n * @deprecated Oauth session are not require to be persistent since https://github.com/ORCID/orcid-angular/pull/609\n */\n loadRequestInfoForm(): Observable {\n return this._http\n .get(\n environment.BASE_URL + 'oauth/custom/requestInfoForm.json',\n { headers: this.headers }\n )\n .pipe(\n // Return null if the requestInfo is empty\n map((requestInfo) => (requestInfo.clientId ? requestInfo : undefined)),\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n switchMap((session) => this.handleSessionErrors(session))\n )\n }\n\n authorize(approved: boolean): Observable {\n const value: OauthAuthorize = {\n // tslint:disable-next-line: max-line-length\n // TODO @angel please confirm that persistentTokenEnabled is always true https://github.com/ORCID/ORCID-Source/blob/master/orcid-web/src/main/webapp/static/javascript/ng1Orcid/app/modules/oauthAuthorization/oauthAuthorization.component.ts#L161\n // TODO @angel by looking into analytics, I can see we have never reported a persistentTokenDisabled\n persistentTokenEnabled: true,\n // tslint:disable-next-line: max-line-length\n // TODO @angel please confirm that email access is always allowed know and at some point it was optional https://github.com/ORCID/ORCID-Source/blob/master/orcid-web/src/main/resources/freemarker/includes/oauth/scopes_ng2.ftl#L42\n emailAccessAllowed: true,\n approved,\n }\n return this._http\n .post(\n environment.BASE_URL + 'oauth/custom/authorize.json',\n value,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n ),\n tap((requestInfo) => {\n this.requestInfoSubject.next(requestInfo)\n })\n )\n }\n\n /**\n * @param queryParameters Orcid supported OAuth parameters\n *\n * Important: Avoid calling this method directly, since getting the oauth RequestInfo from the UserService.getSession is preferred\n *\n * After the first call to this method it will keep returning the same observable, ignoring new or different queryParameters\n * this is not an issue since the Oauth session will only be refresh if the app is reloaded with a new Oauth URL\n *\n */\n declareOauthSession(\n queryParameters: OauthParameters,\n updateParameters?: UserSessionUpdateParameters\n ): Observable {\n if (\n !this.declareOauthSession$ ||\n updateParameters.checkTrigger.timerUpdate === undefined\n ) {\n this.declareOauthSession$ = this._http\n .post(\n environment.BASE_URL +\n `oauth/custom/init.json?${objectToUrlParameters(queryParameters)}`,\n queryParameters,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n ),\n switchMap((session) =>\n this.handleSessionErrors(session, queryParameters)\n ),\n shareReplay(1)\n )\n return this.declareOauthSession$.pipe(last())\n } else {\n return this.declareOauthSession$.pipe(last())\n }\n }\n\n handleSessionErrors(\n session: RequestInfoForm,\n queryParameters?: OauthParameters\n ): Observable {\n if (!session) {\n return of(null)\n }\n if (\n session.error &&\n OAUTH_SESSION_ERROR_CODES_HANDLE_BY_CLIENT_APP.find(\n (x) => x === session.error\n )\n ) {\n // Redirect error that is handle by the client application\n ;(this.window as any).outOfRouterNavigation(\n `${session.redirectUrl}#error=${session.error}`\n )\n return NEVER\n } else if (session.error || (session.errors && session.errors.length)) {\n // Send the user to the oauth page to see the error\n this._router\n .navigate([ApplicationRoutes.authorize], {\n queryParams: queryParameters,\n })\n .then((navigated: boolean) => {\n if (navigated) {\n this._errorHandler\n .handleError(\n new Error(\n `${session.error || session.errors}.${\n session.errorDescription\n }`\n ),\n ERROR_REPORT.OAUTH_PARAMETERS\n )\n .subscribe()\n }\n })\n }\n return of(session)\n }\n\n loadShibbolethSignInData(): Observable {\n return this._http\n .get(environment.BASE_URL + 'shibboleth/signinData.json', {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n\n loadSocialSigninData(): Observable {\n return this._http\n .get(environment.BASE_URL + 'social/signinData.json', {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -19181,7 +19181,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { HttpClient } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { Observable, of } from 'rxjs'\nimport { catchError, retry } from 'rxjs/operators'\nimport { WHITE_SPACE_REGEXP } from 'src/app/constants'\nimport { OrgDisambiguated } from 'src/app/types'\n\nimport { environment } from '../../../environments/environment'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class OrganizationsService {\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n getOrgDisambiguated(type, value): Observable {\n if (type && value) {\n return this._http\n .get(\n environment.API_WEB +\n `orgs/disambiguated/${type}?value=${encodeURIComponent(value)}`\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error))\n )\n } else {\n return of(null)\n }\n }\n}\n", + "sourceCode": "import { HttpClient } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { Observable, of } from 'rxjs'\nimport { catchError, retry } from 'rxjs/operators'\nimport { WHITE_SPACE_REGEXP } from 'src/app/constants'\nimport { OrgDisambiguated } from 'src/app/types'\n\n\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class OrganizationsService {\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n getOrgDisambiguated(type, value): Observable {\n if (type && value) {\n return this._http\n .get(\n environment.API_WEB +\n `orgs/disambiguated/${type}?value=${encodeURIComponent(value)}`\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error))\n )\n } else {\n return of(null)\n }\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -19763,7 +19763,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient } from '@angular/common/http'\nimport { Observable } from 'rxjs/internal/Observable'\nimport { environment } from '../../../environments/environment'\nimport { Reactivation } from '../../types/reactivation.endpoint'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ReactivationService {\n constructor(private _http: HttpClient) {}\n\n getReactivationData(resetParams): Observable {\n return this._http.get(\n `${environment.API_WEB}reactivationData.json?params=${resetParams}`\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient } from '@angular/common/http'\nimport { Observable } from 'rxjs/internal/Observable'\n\nimport { Reactivation } from '../../types/reactivation.endpoint'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ReactivationService {\n constructor(private _http: HttpClient) {}\n\n getReactivationData(resetParams): Observable {\n return this._http.get(\n `${environment.API_WEB}reactivationData.json?params=${resetParams}`\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -20511,7 +20511,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { environment } from '../../../environments/environment'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { BiographyEndPoint } from '../../types/record-biography.endpoint'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordBiographyService {\n $biography: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getBiography(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.biography))\n }\n\n if (!this.$biography) {\n this.$biography = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$biography\n }\n if (options.cleanCacheIfExist && this.$biography) {\n this.$biography.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `account/biographyForm.json`,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({} as BiographyEndPoint)),\n tap((value) => {\n this.$biography.next(value)\n })\n )\n .subscribe()\n return this.$biography\n }\n\n postBiography(biography: BiographyEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `account/biographyForm.json`,\n biography,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getBiography({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\n\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { BiographyEndPoint } from '../../types/record-biography.endpoint'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordBiographyService {\n $biography: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getBiography(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.biography))\n }\n\n if (!this.$biography) {\n this.$biography = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$biography\n }\n if (options.cleanCacheIfExist && this.$biography) {\n this.$biography.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `account/biographyForm.json`,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({} as BiographyEndPoint)),\n tap((value) => {\n this.$biography.next(value)\n })\n )\n .subscribe()\n return this.$biography\n }\n\n postBiography(biography: BiographyEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `account/biographyForm.json`,\n biography,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getBiography({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -21747,7 +21747,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { KeywordEndPoint } from '../../types/record-keyword.endpoint'\nimport { environment } from '../../../environments/environment'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordKeywordService {\n $keywords: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getKeywords(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.keyword))\n }\n\n if (!this.$keywords) {\n this.$keywords = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$keywords\n }\n if (options.cleanCacheIfExist && this.$keywords) {\n this.$keywords.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `my-orcid/keywordsForms.json`,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ keywords: [] } as KeywordEndPoint)),\n tap((value) => {\n this.$keywords.next(value)\n })\n )\n .subscribe()\n\n return this.$keywords\n }\n\n postKeywords(keywords: KeywordEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `my-orcid/keywordsForms.json`,\n keywords,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getKeywords({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { KeywordEndPoint } from '../../types/record-keyword.endpoint'\n\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordKeywordService {\n $keywords: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getKeywords(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.keyword))\n }\n\n if (!this.$keywords) {\n this.$keywords = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$keywords\n }\n if (options.cleanCacheIfExist && this.$keywords) {\n this.$keywords.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `my-orcid/keywordsForms.json`,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ keywords: [] } as KeywordEndPoint)),\n tap((value) => {\n this.$keywords.next(value)\n })\n )\n .subscribe()\n\n return this.$keywords\n }\n\n postKeywords(keywords: KeywordEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `my-orcid/keywordsForms.json`,\n keywords,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getKeywords({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -21895,7 +21895,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { NamesEndPoint } from '../../types/record-name.endpoint'\nimport { environment } from '../../../environments/environment'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordNamesService {\n $names: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getNames(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.names))\n }\n if (!this.$names) {\n this.$names = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$names\n }\n if (options.cleanCacheIfExist && this.$names) {\n this.$names.next(undefined)\n }\n\n this._http\n .get(environment.API_WEB + `account/nameForm.json`, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({} as NamesEndPoint)),\n tap((value) => {\n this.$names.next(value)\n })\n )\n .subscribe()\n\n return this.$names\n }\n\n postNames(names: NamesEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `account/nameForm.json`,\n names,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getNames({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { NamesEndPoint } from '../../types/record-name.endpoint'\n\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordNamesService {\n $names: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getNames(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.names))\n }\n if (!this.$names) {\n this.$names = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$names\n }\n if (options.cleanCacheIfExist && this.$names) {\n this.$names.next(undefined)\n }\n\n this._http\n .get(environment.API_WEB + `account/nameForm.json`, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({} as NamesEndPoint)),\n tap((value) => {\n this.$names.next(value)\n })\n )\n .subscribe()\n\n return this.$names\n }\n\n postNames(names: NamesEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `account/nameForm.json`,\n names,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getNames({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -22043,7 +22043,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { OtherNamesEndPoint } from '../../types/record-other-names.endpoint'\nimport { environment } from '../../../environments/environment'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\nimport { flatMap, groupBy } from 'lodash'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordOtherNamesService {\n $otherNames: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getOtherNames(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar.getPublicRecordSideBar(options).pipe(\n map((value) => value?.otherNames),\n map((value) => {\n if (value?.otherNames) {\n value.otherNames = flatMap(\n groupBy(value?.otherNames, (item) =>\n item?.content.toLowerCase().trim()\n )\n )\n }\n return value\n })\n )\n }\n if (!this.$otherNames) {\n this.$otherNames = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$otherNames\n } else if (options.cleanCacheIfExist && this.$otherNames) {\n this.$otherNames.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `my-orcid/otherNamesForms.json`,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ otherNames: [] } as OtherNamesEndPoint)),\n tap((value) => {\n this.$otherNames.next(value)\n })\n )\n .subscribe()\n\n return this.$otherNames\n }\n\n postOtherNames(\n otherNames: OtherNamesEndPoint\n ): Observable {\n return this._http\n .post(\n environment.API_WEB + `my-orcid/otherNamesForms.json`,\n otherNames,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getOtherNames({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { OtherNamesEndPoint } from '../../types/record-other-names.endpoint'\n\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\nimport { flatMap, groupBy } from 'lodash'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordOtherNamesService {\n $otherNames: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getOtherNames(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar.getPublicRecordSideBar(options).pipe(\n map((value) => value?.otherNames),\n map((value) => {\n if (value?.otherNames) {\n value.otherNames = flatMap(\n groupBy(value?.otherNames, (item) =>\n item?.content.toLowerCase().trim()\n )\n )\n }\n return value\n })\n )\n }\n if (!this.$otherNames) {\n this.$otherNames = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$otherNames\n } else if (options.cleanCacheIfExist && this.$otherNames) {\n this.$otherNames.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `my-orcid/otherNamesForms.json`,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ otherNames: [] } as OtherNamesEndPoint)),\n tap((value) => {\n this.$otherNames.next(value)\n })\n )\n .subscribe()\n\n return this.$otherNames\n }\n\n postOtherNames(\n otherNames: OtherNamesEndPoint\n ): Observable {\n return this._http\n .post(\n environment.API_WEB + `my-orcid/otherNamesForms.json`,\n otherNames,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getOtherNames({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -22439,7 +22439,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { environment } from '../../../environments/environment'\nimport { PeerReview } from '../../types/record-peer-review.endpoint'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordImportWizard } from '../../types/record-peer-review-import.endpoint'\nimport { catchError, first, map, retry, switchMap, tap } from 'rxjs/operators'\nimport { VisibilityStrings } from '../../types/common.endpoint'\nimport { TogglzService } from '../togglz/togglz.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordPeerReviewService {\n $peer: ReplaySubject = new ReplaySubject()\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n lastEmittedValue: PeerReview[]\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _togglz: TogglzService\n ) {}\n\n getPeerReviewGroups(options: UserRecordOptions): Observable {\n if (options?.cleanCacheIfExist && this.$peer) {\n this.$peer.next(undefined)\n }\n\n let url: string\n if (options.publicRecordId) {\n url = options.publicRecordId + '/peer-reviews-minimized.json?sortAsc='\n } else {\n url = 'peer-reviews/peer-reviews-minimized.json?sortAsc='\n }\n\n this._http\n .get(\n environment.API_WEB +\n url +\n (options.sortAsc != null ? options.sortAsc : true)\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of([])),\n tap((data) => {\n this.lastEmittedValue = data\n this.$peer.next(data)\n })\n )\n .subscribe()\n\n return this.$peer.asObservable()\n }\n\n getPeerReviewsByGroupId(\n options: UserRecordOptions,\n groupId\n ): Observable {\n if (options?.publicRecordId) {\n return this._http\n .get(\n environment.API_WEB +\n options.publicRecordId +\n '/peer-reviews-by-group-id.json?sortAsc=' +\n (options.sortAsc != null ? options.sortAsc : true) +\n '&groupId=' +\n encodeURIComponent(groupId)\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of([]))\n )\n } else {\n return this._http\n .get(\n environment.API_WEB +\n 'peer-reviews/peer-reviews-by-group-id.json?sortAsc=' +\n (options.sortAsc != null ? options.sortAsc : true) +\n '&groupId=' +\n encodeURIComponent(groupId)\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of([]))\n )\n }\n }\n\n changeUserRecordContext(userRecordContext: UserRecordOptions) {\n this.getPeerReviewGroups(userRecordContext).subscribe()\n }\n\n getPeerReviewById(putCode: number): Observable {\n return this._http.get(\n environment.API_WEB + 'peer-reviews/peer-review.json?putCode=' + putCode\n )\n }\n\n getPeerReviewImportWizardList(): Observable {\n return this._http.get(\n environment.API_WEB + 'workspace/retrieve-peer-review-import-wizards.json'\n )\n }\n\n getPublicPeerReviewById(orcid: string, putCode: number): Observable {\n return this._http.get(\n environment.API_WEB + orcid + '/peer-review.json?putCode=' + putCode\n )\n }\n\n updateVisibility(\n putCode: any,\n visibility: VisibilityStrings,\n groupId?: any\n ): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'peer-reviews/' +\n putCode +\n '/visibility/' +\n visibility\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => {\n if (groupId) {\n this.getPeerReviewsByGroupId({ forceReload: true }, groupId)\n } else {\n this.getPeerReviewGroups({ forceReload: true })\n }\n })\n )\n }\n\n delete(putCode: string): Observable {\n return this._http\n .delete(environment.API_WEB + 'peer-reviews/' + putCode, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getPeerReviewGroups({ forceReload: true }))\n )\n }\n\n updatePreferredSource(putCode: string): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'peer-reviews/updateToMaxDisplay.json?putCode=' +\n putCode\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getPeerReviewGroups({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\n\nimport { PeerReview } from '../../types/record-peer-review.endpoint'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordImportWizard } from '../../types/record-peer-review-import.endpoint'\nimport { catchError, first, map, retry, switchMap, tap } from 'rxjs/operators'\nimport { VisibilityStrings } from '../../types/common.endpoint'\nimport { TogglzService } from '../togglz/togglz.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordPeerReviewService {\n $peer: ReplaySubject = new ReplaySubject()\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n lastEmittedValue: PeerReview[]\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _togglz: TogglzService\n ) {}\n\n getPeerReviewGroups(options: UserRecordOptions): Observable {\n if (options?.cleanCacheIfExist && this.$peer) {\n this.$peer.next(undefined)\n }\n\n let url: string\n if (options.publicRecordId) {\n url = options.publicRecordId + '/peer-reviews-minimized.json?sortAsc='\n } else {\n url = 'peer-reviews/peer-reviews-minimized.json?sortAsc='\n }\n\n this._http\n .get(\n environment.API_WEB +\n url +\n (options.sortAsc != null ? options.sortAsc : true)\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of([])),\n tap((data) => {\n this.lastEmittedValue = data\n this.$peer.next(data)\n })\n )\n .subscribe()\n\n return this.$peer.asObservable()\n }\n\n getPeerReviewsByGroupId(\n options: UserRecordOptions,\n groupId\n ): Observable {\n if (options?.publicRecordId) {\n return this._http\n .get(\n environment.API_WEB +\n options.publicRecordId +\n '/peer-reviews-by-group-id.json?sortAsc=' +\n (options.sortAsc != null ? options.sortAsc : true) +\n '&groupId=' +\n encodeURIComponent(groupId)\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of([]))\n )\n } else {\n return this._http\n .get(\n environment.API_WEB +\n 'peer-reviews/peer-reviews-by-group-id.json?sortAsc=' +\n (options.sortAsc != null ? options.sortAsc : true) +\n '&groupId=' +\n encodeURIComponent(groupId)\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of([]))\n )\n }\n }\n\n changeUserRecordContext(userRecordContext: UserRecordOptions) {\n this.getPeerReviewGroups(userRecordContext).subscribe()\n }\n\n getPeerReviewById(putCode: number): Observable {\n return this._http.get(\n environment.API_WEB + 'peer-reviews/peer-review.json?putCode=' + putCode\n )\n }\n\n getPeerReviewImportWizardList(): Observable {\n return this._http.get(\n environment.API_WEB + 'workspace/retrieve-peer-review-import-wizards.json'\n )\n }\n\n getPublicPeerReviewById(orcid: string, putCode: number): Observable {\n return this._http.get(\n environment.API_WEB + orcid + '/peer-review.json?putCode=' + putCode\n )\n }\n\n updateVisibility(\n putCode: any,\n visibility: VisibilityStrings,\n groupId?: any\n ): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'peer-reviews/' +\n putCode +\n '/visibility/' +\n visibility\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => {\n if (groupId) {\n this.getPeerReviewsByGroupId({ forceReload: true }, groupId)\n } else {\n this.getPeerReviewGroups({ forceReload: true })\n }\n })\n )\n }\n\n delete(putCode: string): Observable {\n return this._http\n .delete(environment.API_WEB + 'peer-reviews/' + putCode, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getPeerReviewGroups({ forceReload: true }))\n )\n }\n\n updatePreferredSource(putCode: string): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'peer-reviews/updateToMaxDisplay.json?putCode=' +\n putCode\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getPeerReviewGroups({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -23305,7 +23305,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { UserRecordOptions } from 'src/app/types/record.local'\n\nimport { environment } from '../../../environments/environment'\nimport {\n ResearchResource,\n ResearchResourcesEndpoint,\n} from '../../types/record-research-resources.endpoint'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { VisibilityStrings } from '../../types/common.endpoint'\nimport { DEFAULT_PAGE_SIZE } from 'src/app/constants'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordResearchResourceService {\n $researchResourcesSubject: ReplaySubject =\n new ReplaySubject()\n\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n getResearchResourcePage(\n options: UserRecordOptions\n ): Observable {\n if (!options) {\n options = {}\n }\n options.pageSize = options?.pageSize || DEFAULT_PAGE_SIZE\n options.offset = options?.offset || 0\n\n let url\n if (options?.publicRecordId) {\n url = options.publicRecordId + '/researchResourcePage.json'\n } else {\n url = 'research-resources/researchResourcePage.json'\n }\n\n if (options?.cleanCacheIfExist && this.$researchResourcesSubject) {\n this.$researchResourcesSubject.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB +\n url +\n '?offset=' +\n options.offset +\n '&sort=' +\n (options.sort != null ? options.sort : 'date') +\n '&sortAsc=' +\n (options.sortAsc != null ? options.sortAsc : false) +\n '&pageSize=' +\n options.pageSize\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ groups: [] } as ResearchResourcesEndpoint)),\n map((data) => {\n data.pageSize = options.pageSize\n data.pageIndex = options.offset\n ? Math.floor(options.offset / options.pageSize)\n : 0\n return data\n }),\n tap((data) => {\n this.$researchResourcesSubject.next(data)\n })\n )\n .subscribe()\n return this.$researchResourcesSubject.asObservable()\n }\n\n changeUserRecordContext(\n event: UserRecordOptions\n ): Observable {\n return this.getResearchResourcePage(event)\n }\n\n getResearchResourceById(putCode: string): Observable {\n return this._http.get(\n environment.API_WEB +\n 'research-resources/researchResource.json?id=' +\n putCode\n )\n }\n\n getPublicResearchResourceById(orcid, putCode): Observable {\n return this._http.get(\n environment.API_WEB + orcid + '/researchResource.json?id=' + putCode\n )\n }\n\n updateVisibility(\n putCode: string,\n visibility: VisibilityStrings\n ): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'research-resources/' +\n putCode +\n '/visibility/' +\n visibility\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getResearchResourcePage({ forceReload: true }))\n )\n }\n\n delete(putCode: string): Observable {\n return this._http\n .delete(environment.API_WEB + 'research-resources/' + putCode, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getResearchResourcePage({ forceReload: true }))\n )\n }\n\n updatePreferredSource(putCode: string): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'research-resources/updateToMaxDisplay.json?putCode=' +\n putCode\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getResearchResourcePage({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { UserRecordOptions } from 'src/app/types/record.local'\n\n\nimport {\n ResearchResource,\n ResearchResourcesEndpoint,\n} from '../../types/record-research-resources.endpoint'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { VisibilityStrings } from '../../types/common.endpoint'\nimport { DEFAULT_PAGE_SIZE } from 'src/app/constants'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordResearchResourceService {\n $researchResourcesSubject: ReplaySubject =\n new ReplaySubject()\n\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n getResearchResourcePage(\n options: UserRecordOptions\n ): Observable {\n if (!options) {\n options = {}\n }\n options.pageSize = options?.pageSize || DEFAULT_PAGE_SIZE\n options.offset = options?.offset || 0\n\n let url\n if (options?.publicRecordId) {\n url = options.publicRecordId + '/researchResourcePage.json'\n } else {\n url = 'research-resources/researchResourcePage.json'\n }\n\n if (options?.cleanCacheIfExist && this.$researchResourcesSubject) {\n this.$researchResourcesSubject.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB +\n url +\n '?offset=' +\n options.offset +\n '&sort=' +\n (options.sort != null ? options.sort : 'date') +\n '&sortAsc=' +\n (options.sortAsc != null ? options.sortAsc : false) +\n '&pageSize=' +\n options.pageSize\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ groups: [] } as ResearchResourcesEndpoint)),\n map((data) => {\n data.pageSize = options.pageSize\n data.pageIndex = options.offset\n ? Math.floor(options.offset / options.pageSize)\n : 0\n return data\n }),\n tap((data) => {\n this.$researchResourcesSubject.next(data)\n })\n )\n .subscribe()\n return this.$researchResourcesSubject.asObservable()\n }\n\n changeUserRecordContext(\n event: UserRecordOptions\n ): Observable {\n return this.getResearchResourcePage(event)\n }\n\n getResearchResourceById(putCode: string): Observable {\n return this._http.get(\n environment.API_WEB +\n 'research-resources/researchResource.json?id=' +\n putCode\n )\n }\n\n getPublicResearchResourceById(orcid, putCode): Observable {\n return this._http.get(\n environment.API_WEB + orcid + '/researchResource.json?id=' + putCode\n )\n }\n\n updateVisibility(\n putCode: string,\n visibility: VisibilityStrings\n ): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'research-resources/' +\n putCode +\n '/visibility/' +\n visibility\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getResearchResourcePage({ forceReload: true }))\n )\n }\n\n delete(putCode: string): Observable {\n return this._http\n .delete(environment.API_WEB + 'research-resources/' + putCode, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getResearchResourcePage({ forceReload: true }))\n )\n }\n\n updatePreferredSource(putCode: string): Observable {\n return this._http\n .get(\n environment.API_WEB +\n 'research-resources/updateToMaxDisplay.json?putCode=' +\n putCode\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getResearchResourcePage({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -24007,7 +24007,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { WebsitesEndPoint } from '../../types/record-websites.endpoint'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { environment } from '../../../environments/environment'\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordWebsitesService {\n $websites: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getWebsites(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.website))\n }\n if (!this.$websites) {\n this.$websites = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$websites\n }\n\n if (options.cleanCacheIfExist && this.$websites) {\n this.$websites.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `my-orcid/websitesForms.json`,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ websites: [] } as WebsitesEndPoint)),\n tap((value) => {\n this.$websites.next(value)\n })\n )\n .subscribe()\n return this.$websites\n }\n\n postWebsites(website: WebsitesEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `my-orcid/websitesForms.json`,\n website,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getWebsites({ forceReload: true }))\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { Observable, of, ReplaySubject } from 'rxjs'\nimport { WebsitesEndPoint } from '../../types/record-websites.endpoint'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\n\nimport { catchError, map, retry, tap } from 'rxjs/operators'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { UserRecordOptions } from 'src/app/types/record.local'\nimport { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class RecordWebsitesService {\n $websites: ReplaySubject\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService,\n private _recordPublicSidebar: RecordPublicSideBarService\n ) {}\n\n getWebsites(\n options: UserRecordOptions = {\n forceReload: false,\n }\n ): Observable {\n if (options.publicRecordId) {\n return this._recordPublicSidebar\n .getPublicRecordSideBar(options)\n .pipe(map((value) => value.website))\n }\n if (!this.$websites) {\n this.$websites = new ReplaySubject(1)\n } else if (!options.forceReload) {\n return this.$websites\n }\n\n if (options.cleanCacheIfExist && this.$websites) {\n this.$websites.next(undefined)\n }\n\n this._http\n .get(\n environment.API_WEB + `my-orcid/websitesForms.json`,\n {\n headers: this.headers,\n }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n catchError(() => of({ websites: [] } as WebsitesEndPoint)),\n tap((value) => {\n this.$websites.next(value)\n })\n )\n .subscribe()\n return this.$websites\n }\n\n postWebsites(website: WebsitesEndPoint): Observable {\n return this._http\n .post(\n environment.API_WEB + `my-orcid/websitesForms.json`,\n website,\n { headers: this.headers }\n )\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n tap(() => this.getWebsites({ forceReload: true }))\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -26167,7 +26167,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { catchError, map, retry, switchMap, first } from 'rxjs/operators'\n\nimport { environment } from '../../../environments/environment'\nimport { getOrcidNumber } from '../../constants'\nimport { Reactivation } from '../../types/reactivation.endpoint'\nimport { SignIn } from '../../types/sign-in.endpoint'\nimport { SignInLocal, TypeSignIn } from '../../types/sign-in.local'\nimport { CustomEncoder } from '../custom-encoder/custom.encoder'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { UserService } from '../user/user.service'\nimport { ERROR_REPORT } from 'src/app/errors'\nimport { Title } from '@angular/platform-browser'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SignInService {\n private headers: HttpHeaders\n\n constructor(\n private _http: HttpClient,\n private _titleService: Title,\n private _errorHandler: ErrorHandlerService,\n private _userService: UserService\n ) {\n this.headers = new HttpHeaders().set(\n 'Content-Type',\n 'application/x-www-form-urlencoded;charset=utf-8'\n )\n }\n /**\n * @param SignInLocal sign in information\n * @param updateUserSession default true, set to true if after successfully signing Orcid Angular will still be open\n * @param forceSessionUpdate default false, set to true if the user session should be updated even when the user status does not change\n */\n signIn(\n signInLocal: SignInLocal,\n updateUserSession = true,\n forceSessionUpdate = false\n ) {\n let loginUrl = 'signin/auth.json'\n\n if (signInLocal.type && signInLocal.type === TypeSignIn.institutional) {\n loginUrl = 'shibboleth/signin/auth.json'\n }\n\n if (signInLocal.type && signInLocal.type === TypeSignIn.social) {\n loginUrl = 'social/signin/auth.json'\n }\n\n let body = new HttpParams({ encoder: new CustomEncoder() })\n .set('userId', getOrcidNumber(signInLocal.data.username))\n .set('password', signInLocal.data.password)\n if (signInLocal.data.verificationCode) {\n body = body.set('verificationCode', signInLocal.data.verificationCode)\n }\n if (signInLocal.data.recoveryCode) {\n body = body.set('recoveryCode', signInLocal.data.recoveryCode)\n }\n body = body.set('oauthRequest', signInLocal.isOauth ? 'true' : 'false')\n return this._http\n .post(environment.API_WEB + loginUrl, body, {\n headers: this.headers,\n withCredentials: true,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n switchMap((response) => {\n // call refreshUserSession with force session update to handle register actions from sessions with a logged in user\n return this._userService\n .refreshUserSession(forceSessionUpdate, true)\n .pipe(\n first(),\n map(() => response)\n )\n })\n )\n }\n\n reactivation(email: string) {\n let body = new HttpParams({ encoder: new CustomEncoder() })\n body = body.set('email', email)\n return this._http\n .post(environment.API_WEB + `sendReactivation.json`, body, {\n headers: this.headers,\n withCredentials: true,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(\n error,\n ERROR_REPORT.REGISTER_REACTIVATED_EMAIL\n )\n )\n )\n }\n\n singOut() {\n this._titleService.setTitle('ORCID')\n return this._http\n .get(environment.API_WEB + 'userStatus.json?logUserOut=true', {\n headers: this.headers,\n withCredentials: true,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n switchMap(() => this._userService.refreshUserSession())\n )\n }\n}\n", + "sourceCode": "import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'\nimport { Injectable } from '@angular/core'\nimport { catchError, map, retry, switchMap, first } from 'rxjs/operators'\n\n\nimport { getOrcidNumber } from '../../constants'\nimport { Reactivation } from '../../types/reactivation.endpoint'\nimport { SignIn } from '../../types/sign-in.endpoint'\nimport { SignInLocal, TypeSignIn } from '../../types/sign-in.local'\nimport { CustomEncoder } from '../custom-encoder/custom.encoder'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\nimport { UserService } from '../user/user.service'\nimport { ERROR_REPORT } from 'src/app/errors'\nimport { Title } from '@angular/platform-browser'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SignInService {\n private headers: HttpHeaders\n\n constructor(\n private _http: HttpClient,\n private _titleService: Title,\n private _errorHandler: ErrorHandlerService,\n private _userService: UserService\n ) {\n this.headers = new HttpHeaders().set(\n 'Content-Type',\n 'application/x-www-form-urlencoded;charset=utf-8'\n )\n }\n /**\n * @param SignInLocal sign in information\n * @param updateUserSession default true, set to true if after successfully signing Orcid Angular will still be open\n * @param forceSessionUpdate default false, set to true if the user session should be updated even when the user status does not change\n */\n signIn(\n signInLocal: SignInLocal,\n updateUserSession = true,\n forceSessionUpdate = false\n ) {\n let loginUrl = 'signin/auth.json'\n\n if (signInLocal.type && signInLocal.type === TypeSignIn.institutional) {\n loginUrl = 'shibboleth/signin/auth.json'\n }\n\n if (signInLocal.type && signInLocal.type === TypeSignIn.social) {\n loginUrl = 'social/signin/auth.json'\n }\n\n let body = new HttpParams({ encoder: new CustomEncoder() })\n .set('userId', getOrcidNumber(signInLocal.data.username))\n .set('password', signInLocal.data.password)\n if (signInLocal.data.verificationCode) {\n body = body.set('verificationCode', signInLocal.data.verificationCode)\n }\n if (signInLocal.data.recoveryCode) {\n body = body.set('recoveryCode', signInLocal.data.recoveryCode)\n }\n body = body.set('oauthRequest', signInLocal.isOauth ? 'true' : 'false')\n return this._http\n .post(environment.API_WEB + loginUrl, body, {\n headers: this.headers,\n withCredentials: true,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n switchMap((response) => {\n // call refreshUserSession with force session update to handle register actions from sessions with a logged in user\n return this._userService\n .refreshUserSession(forceSessionUpdate, true)\n .pipe(\n first(),\n map(() => response)\n )\n })\n )\n }\n\n reactivation(email: string) {\n let body = new HttpParams({ encoder: new CustomEncoder() })\n body = body.set('email', email)\n return this._http\n .post(environment.API_WEB + `sendReactivation.json`, body, {\n headers: this.headers,\n withCredentials: true,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(\n error,\n ERROR_REPORT.REGISTER_REACTIVATED_EMAIL\n )\n )\n )\n }\n\n singOut() {\n this._titleService.setTitle('ORCID')\n return this._http\n .get(environment.API_WEB + 'userStatus.json?logUserOut=true', {\n headers: this.headers,\n withCredentials: true,\n })\n .pipe(\n retry(3),\n catchError((error) => this._errorHandler.handleError(error)),\n switchMap(() => this._userService.refreshUserSession())\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -27085,7 +27085,7 @@ "deprecationMessage": "", "description": "", "rawdescription": "\n", - "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Observable } from 'rxjs/internal/Observable'\nimport { environment } from '../../../environments/environment'\nimport {\n QrCode,\n Status,\n TwoFactor,\n TwoFactorSetup,\n} from '../../types/two-factor.endpoint'\nimport { catchError, retry } from 'rxjs/operators'\nimport { ERROR_REPORT } from '../../errors'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TwoFactorAuthenticationService {\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n checkState(): Observable {\n return this._http.get(environment.BASE_URL + '2FA/status.json')\n }\n\n disable(): Observable {\n return this._http.post(\n environment.BASE_URL + '2FA/disable.json',\n {},\n { headers: this.headers }\n )\n }\n\n getTextCode(): Observable<{ secret: string }> {\n return this._http.get<{ secret: string }>(\n environment.BASE_URL + '2FA/secret.json'\n )\n }\n\n startSetup(): Observable {\n return this._http.get(environment.BASE_URL + '2FA/QRCode.json')\n }\n\n register(obj): Observable {\n return this._http.post(\n environment.BASE_URL + '2FA/register.json',\n JSON.stringify(obj),\n { headers: this.headers }\n )\n }\n\n sendVerificationCode(obj): Observable {\n return this._http.post(\n environment.BASE_URL + '2FA/QRCode.json',\n JSON.stringify(obj),\n { headers: this.headers }\n )\n }\n\n submitCode(twoFactor: TwoFactor, social?) {\n let url = 'shibboleth/2FA/submitCode.json'\n if (social) {\n url = 'social/2FA/submitCode.json'\n }\n return this._http\n .post(environment.BASE_URL + url, twoFactor, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n\n submitCodeForAnotherAccount(code: TwoFactor) {\n return this._http\n .post(environment.BASE_URL + `2FA/submitCode.json`, code, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n}\n", + "sourceCode": "import { Injectable } from '@angular/core'\nimport { HttpClient, HttpHeaders } from '@angular/common/http'\nimport { Observable } from 'rxjs/internal/Observable'\n\nimport {\n QrCode,\n Status,\n TwoFactor,\n TwoFactorSetup,\n} from '../../types/two-factor.endpoint'\nimport { catchError, retry } from 'rxjs/operators'\nimport { ERROR_REPORT } from '../../errors'\nimport { ErrorHandlerService } from '../error-handler/error-handler.service'\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TwoFactorAuthenticationService {\n headers = new HttpHeaders({\n 'Access-Control-Allow-Origin': '*',\n 'Content-Type': 'application/json',\n })\n\n constructor(\n private _http: HttpClient,\n private _errorHandler: ErrorHandlerService\n ) {}\n\n checkState(): Observable {\n return this._http.get(environment.BASE_URL + '2FA/status.json')\n }\n\n disable(): Observable {\n return this._http.post(\n environment.BASE_URL + '2FA/disable.json',\n {},\n { headers: this.headers }\n )\n }\n\n getTextCode(): Observable<{ secret: string }> {\n return this._http.get<{ secret: string }>(\n environment.BASE_URL + '2FA/secret.json'\n )\n }\n\n startSetup(): Observable {\n return this._http.get(environment.BASE_URL + '2FA/QRCode.json')\n }\n\n register(obj): Observable {\n return this._http.post(\n environment.BASE_URL + '2FA/register.json',\n JSON.stringify(obj),\n { headers: this.headers }\n )\n }\n\n sendVerificationCode(obj): Observable {\n return this._http.post(\n environment.BASE_URL + '2FA/QRCode.json',\n JSON.stringify(obj),\n { headers: this.headers }\n )\n }\n\n submitCode(twoFactor: TwoFactor, social?) {\n let url = 'shibboleth/2FA/submitCode.json'\n if (social) {\n url = 'social/2FA/submitCode.json'\n }\n return this._http\n .post(environment.BASE_URL + url, twoFactor, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n\n submitCodeForAnotherAccount(code: TwoFactor) {\n return this._http\n .post(environment.BASE_URL + `2FA/submitCode.json`, code, {\n headers: this.headers,\n })\n .pipe(\n retry(3),\n catchError((error) =>\n this._errorHandler.handleError(error, ERROR_REPORT.STANDARD_VERBOSE)\n )\n )\n }\n}\n", "constructorObj": { "name": "constructor", "description": "", @@ -38894,7 +38894,7 @@ "description": "", "rawdescription": "\n", "type": "component", - "sourceCode": "import { Component, OnInit, Inject, HostBinding } from '@angular/core'\nimport { CookieService } from 'ngx-cookie-service'\nimport { WINDOW } from 'src/app/cdk/window'\nimport { environment } from '../../../environments/environment'\n\n@Component({\n selector: 'app-environment-banner',\n templateUrl: './environment-banner.component.html',\n styleUrls: ['./environment-banner.component.scss'],\n preserveWhitespaces: true,\n})\nexport class EnvironmentBannerComponent implements OnInit {\n hostUrl\n canDismiss = environment['CAN_DISABLE_TEST_WARNING_BANNER']\n @HostBinding('style.display') display = 'none'\n labelWarning = $localize`:@@environmentBanner.ariaLabelWarning:Warning, testing website`\n constructor(\n @Inject(WINDOW) private window: Window,\n private _cookieService: CookieService\n ) {\n this.hostUrl = window.location.host\n if (!this._cookieService.get('testWarningCookie') || !this.canDismiss) {\n this.display = 'auto'\n }\n }\n\n onDismiss() {\n this.display = 'none'\n this._cookieService.set('testWarningCookie', 'dont show message', 365)\n }\n\n ngOnInit() {}\n}\n", + "sourceCode": "import { Component, OnInit, Inject, HostBinding } from '@angular/core'\nimport { CookieService } from 'ngx-cookie-service'\nimport { WINDOW } from 'src/app/cdk/window'\n\n\n@Component({\n selector: 'app-environment-banner',\n templateUrl: './environment-banner.component.html',\n styleUrls: ['./environment-banner.component.scss'],\n preserveWhitespaces: true,\n})\nexport class EnvironmentBannerComponent implements OnInit {\n hostUrl\n canDismiss = environment['CAN_DISABLE_TEST_WARNING_BANNER']\n @HostBinding('style.display') display = 'none'\n labelWarning = $localize`:@@environmentBanner.ariaLabelWarning:Warning, testing website`\n constructor(\n @Inject(WINDOW) private window: Window,\n private _cookieService: CookieService\n ) {\n this.hostUrl = window.location.host\n if (!this._cookieService.get('testWarningCookie') || !this.canDismiss) {\n this.display = 'auto'\n }\n }\n\n onDismiss() {\n this.display = 'none'\n this._cookieService.set('testWarningCookie', 'dont show message', 365)\n }\n\n ngOnInit() {}\n}\n", "assetsDirs": [], "styleUrlsData": [ { @@ -39048,7 +39048,7 @@ "description": "", "rawdescription": "\n", "type": "component", - "sourceCode": "import { Component, OnInit, Inject } from '@angular/core'\nimport { PlatformInfoService } from 'src/app/cdk/platform-info'\nimport { WINDOW } from 'src/app/cdk/window'\nimport { environment } from '../../../environments/environment'\n\n@Component({\n selector: 'app-footer',\n templateUrl: './footer.component.html',\n styleUrls: ['./footer.component.scss-theme.scss', './footer.component.scss'],\n preserveWhitespaces: true,\n})\nexport class FooterComponent implements OnInit {\n platform\n labelFooter = $localize`:@@layout.ariaLabelFooter:footer`\n infoSiteBaseUrl = environment.INFO_SITE\n\n constructor(\n _platformInfo: PlatformInfoService,\n @Inject(WINDOW) private window: Window\n ) {\n _platformInfo.get().subscribe((platformInfo) => {\n this.platform = platformInfo\n })\n }\n\n ngOnInit() {\n setTimeout(() => {\n const otBtn = this.window.document.getElementById('ot-sdk-btn')\n if (otBtn) {\n otBtn.innerText = $localize`:@@footer.cookieSettings:Cookie Settings`\n }\n }, 200)\n }\n\n goTo(url) {\n this.window.location.href = url\n }\n}\n", + "sourceCode": "import { Component, OnInit, Inject } from '@angular/core'\nimport { PlatformInfoService } from 'src/app/cdk/platform-info'\nimport { WINDOW } from 'src/app/cdk/window'\n\n\n@Component({\n selector: 'app-footer',\n templateUrl: './footer.component.html',\n styleUrls: ['./footer.component.scss-theme.scss', './footer.component.scss'],\n preserveWhitespaces: true,\n})\nexport class FooterComponent implements OnInit {\n platform\n labelFooter = $localize`:@@layout.ariaLabelFooter:footer`\n infoSiteBaseUrl = environment.INFO_SITE\n\n constructor(\n _platformInfo: PlatformInfoService,\n @Inject(WINDOW) private window: Window\n ) {\n _platformInfo.get().subscribe((platformInfo) => {\n this.platform = platformInfo\n })\n }\n\n ngOnInit() {\n setTimeout(() => {\n const otBtn = this.window.document.getElementById('ot-sdk-btn')\n if (otBtn) {\n otBtn.innerText = $localize`:@@footer.cookieSettings:Cookie Settings`\n }\n }, 200)\n }\n\n goTo(url) {\n this.window.location.href = url\n }\n}\n", "assetsDirs": [], "styleUrlsData": [ { @@ -44718,7 +44718,7 @@ "description": "", "rawdescription": "\n", "type": "component", - "sourceCode": "import { Location } from '@angular/common'\nimport { Component, Inject, Input, OnInit } from '@angular/core'\nimport { NavigationStart, Router } from '@angular/router'\nimport { filter } from 'rxjs/operators'\nimport { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'\nimport { WINDOW } from 'src/app/cdk/window'\nimport { UserService } from 'src/app/core'\nimport { SignInService } from 'src/app/core/sign-in/sign-in.service'\nimport { TogglzService } from 'src/app/core/togglz/togglz.service'\nimport { ApplicationMenuItem, UserInfo } from 'src/app/types'\nimport {\n ApplicationMenuItemBasic,\n MenuItemRequirement,\n} from 'src/app/types/menu.local'\nimport { Config } from 'src/app/types/togglz.endpoint'\n\nimport { environment } from '../../../environments/environment'\nimport { ApplicationRoutes, ORCID_REGEXP } from '../../constants'\nimport { menu } from './menu'\n\n@Component({\n selector: 'app-header',\n templateUrl: './header.component.html',\n styleUrls: ['./header.component.scss-theme.scss', './header.component.scss'],\n})\nexport class HeaderComponent implements OnInit {\n hideMainMenu = false\n _currentRoute: string\n @Input() set currentRoute(value) {\n this._currentRoute = value\n this.setChildOfCurrentRouteAsSecondaryMenu()\n }\n get currentRoute() {\n return this._currentRoute\n }\n platform: PlatformInfo\n mobileMenuState = false\n menu: ApplicationMenuItem[] = this.createMenuList(menu)\n user: UserInfo\n togglz: Config\n signinRegisterButton = true\n labelLogo = $localize`:@@layout.ariaLabelLogo:orcid mini logo`\n labelMenu = $localize`:@@layout.ariaLabelMenu:main menu`\n\n constructor(\n private _router: Router,\n _platform: PlatformInfoService,\n @Inject(WINDOW) private window: Window,\n _userInfo: UserService,\n _togglz: TogglzService,\n location: Location,\n private _user: UserService\n ) {\n _router.events\n .pipe(filter((event: any) => event instanceof NavigationStart))\n .subscribe((val: NavigationStart) => {\n this.currentRoute = _router.url\n this.setChildOfCurrentRouteAsSecondaryMenu()\n })\n\n _platform.get().subscribe((data) => {\n this.platform = data\n })\n _userInfo.getUserSession().subscribe((data) => {\n this.user = data.userInfo\n })\n _togglz.getTogglz().subscribe((data) => {\n this.togglz = data\n })\n _router.events.subscribe(() => {\n const path = location.path()\n this.signinRegisterButton = path !== `/${ApplicationRoutes.signin}`\n this.hideMainMenu =\n ORCID_REGEXP.test(path) ||\n path === `/${ApplicationRoutes.myOrcid}` ||\n path === `/${ApplicationRoutes.account}` ||\n path === `/${ApplicationRoutes.trustedParties}` ||\n path === `/${ApplicationRoutes.selfService}` ||\n path === `/${ApplicationRoutes.inbox}` ||\n path === `/${ApplicationRoutes.developerTools}`\n })\n }\n\n ngOnInit() {}\n\n mouseLeave() {\n if (this.platform.columns12) {\n this.setChildOfCurrentRouteAsSecondaryMenu()\n }\n }\n\n setChildOfCurrentRouteAsSecondaryMenu() {\n // Check all first level menu items\n this.menu.forEach((button) => {\n // If the activeRoute of the button is equal to the current route show it as hover\n // Excepts if the current route is the home page\n if (button.activeRoute != null && this.currentRoute !== '/') {\n button.hover = '/' + button.activeRoute === this.currentRoute\n } else {\n button.hover = '/' + button.route === this.currentRoute\n }\n })\n }\n\n click(treeLocation: string[], button: ApplicationMenuItem) {\n if (!this.platform.columns12) {\n if (\n button.route !== undefined &&\n (!button.buttons || !button.buttons.length)\n ) {\n this.goto(button.route)\n } else {\n this.updateMenu(this.menu, treeLocation, true)\n }\n } else if (button.route !== undefined) {\n this.goto(button.route)\n }\n }\n\n mouseEnter(treeLocation: string[]) {\n if (this.platform.columns12) {\n this.updateMenu(this.menu, treeLocation)\n }\n }\n\n updateMenu(\n menuToUpdate: ApplicationMenuItem[],\n treeLocation: string[],\n switchState?: boolean\n ) {\n if (treeLocation.length) {\n const current = treeLocation.shift()\n if (menuToUpdate != null) {\n menuToUpdate.forEach((button) => {\n if (button.id === current) {\n if (treeLocation.length > 0) {\n button.hover = true\n this.updateMenu(button.buttons, treeLocation, switchState)\n } else {\n button.hover = switchState ? !button.hover : true\n }\n } else {\n button.hover = false\n }\n })\n }\n }\n }\n createMenuList(\n menuDefinition: ApplicationMenuItemBasic[]\n ): ApplicationMenuItem[] {\n const list: ApplicationMenuItem[] = []\n if (!menuDefinition || !menuDefinition.length) {\n return []\n }\n menuDefinition.forEach((item) => {\n const newItem: ApplicationMenuItem = {\n ...item,\n hover: false,\n active: false,\n buttons: this.createMenuList(item.buttons),\n }\n\n list.push(newItem)\n })\n\n return list\n }\n\n checkMenuItemRequirements(requirements: MenuItemRequirement) {\n if (!requirements) {\n return true\n } else if (\n typeof requirements.desktop !== 'undefined' &&\n requirements.desktop &&\n !this.platform.columns12\n ) {\n return false\n } else if (\n typeof requirements.desktop !== 'undefined' &&\n !requirements.desktop &&\n this.platform.columns12\n ) {\n return false\n } else if (\n typeof requirements.logging !== 'undefined' &&\n requirements.logging &&\n !this.user\n ) {\n return false\n } else if (\n typeof requirements.logging !== 'undefined' &&\n !requirements.logging &&\n this.user\n ) {\n return false\n } else if (requirements.requiresAll) {\n for (const accessKey of requirements.requiresAll) {\n const key = Object.keys(accessKey)[0]\n const value = accessKey[key]\n if (\n !this.user ||\n !(\n this.user[key] === value ||\n (typeof this.user[key] === 'undefined' && value === 'false')\n )\n ) {\n return false\n }\n }\n } else if (requirements.requiresAny) {\n for (const accessKey of requirements.requiresAny) {\n const key = Object.keys(accessKey)[0]\n const value = accessKey[key]\n if (\n this.user &&\n (this.user[key] === value ||\n (typeof this.user[key] === 'undefined' && value === 'false'))\n ) {\n return true\n }\n }\n return false\n } else if (typeof requirements.togglz !== 'undefined') {\n if (!this.togglz || !this.togglz.messages) {\n return false\n }\n let foundAnUnmeetTogglz = false\n Object.keys(requirements.togglz).forEach((key) => {\n if (Object.keys(this.togglz.messages).indexOf(key)) {\n if (this.togglz.messages[key] !== requirements.togglz[key]) {\n foundAnUnmeetTogglz = true\n }\n } else {\n foundAnUnmeetTogglz = true\n }\n })\n if (foundAnUnmeetTogglz) {\n return false\n }\n }\n return true\n }\n\n isDesktopThirdLevelMenu(parents: any[]) {\n return parents.length > 1 && this.platform.columns12\n }\n isDesktopSecondLevelMenu(parents: any[]) {\n return parents.length === 1 && this.platform.columns12\n }\n isMobileThirdLevelMenu(parents: any[]) {\n return parents.length > 1 && !this.platform.columns12\n }\n menuButtonColor(parents) {\n return this.isDesktopSecondLevelMenu(parents) ||\n this.isMobileThirdLevelMenu(parents)\n ? 'primary'\n : null\n }\n\n goto(route: string) {\n if (route === 'signin') {\n this._router.navigate([ApplicationRoutes.signin])\n this.mobileMenuState = false\n } else if (route === 'signout' && environment.proxyMode) {\n this._user.noRedirectLogout().subscribe()\n } else {\n ;(this.window as any).outOfRouterNavigation(environment.INFO_SITE + route)\n }\n }\n}\n", + "sourceCode": "import { Location } from '@angular/common'\nimport { Component, Inject, Input, OnInit } from '@angular/core'\nimport { NavigationStart, Router } from '@angular/router'\nimport { filter } from 'rxjs/operators'\nimport { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info'\nimport { WINDOW } from 'src/app/cdk/window'\nimport { UserService } from 'src/app/core'\nimport { SignInService } from 'src/app/core/sign-in/sign-in.service'\nimport { TogglzService } from 'src/app/core/togglz/togglz.service'\nimport { ApplicationMenuItem, UserInfo } from 'src/app/types'\nimport {\n ApplicationMenuItemBasic,\n MenuItemRequirement,\n} from 'src/app/types/menu.local'\nimport { Config } from 'src/app/types/togglz.endpoint'\n\n\nimport { ApplicationRoutes, ORCID_REGEXP } from '../../constants'\nimport { menu } from './menu'\n\n@Component({\n selector: 'app-header',\n templateUrl: './header.component.html',\n styleUrls: ['./header.component.scss-theme.scss', './header.component.scss'],\n})\nexport class HeaderComponent implements OnInit {\n hideMainMenu = false\n _currentRoute: string\n @Input() set currentRoute(value) {\n this._currentRoute = value\n this.setChildOfCurrentRouteAsSecondaryMenu()\n }\n get currentRoute() {\n return this._currentRoute\n }\n platform: PlatformInfo\n mobileMenuState = false\n menu: ApplicationMenuItem[] = this.createMenuList(menu)\n user: UserInfo\n togglz: Config\n signinRegisterButton = true\n labelLogo = $localize`:@@layout.ariaLabelLogo:orcid mini logo`\n labelMenu = $localize`:@@layout.ariaLabelMenu:main menu`\n\n constructor(\n private _router: Router,\n _platform: PlatformInfoService,\n @Inject(WINDOW) private window: Window,\n _userInfo: UserService,\n _togglz: TogglzService,\n location: Location,\n private _user: UserService\n ) {\n _router.events\n .pipe(filter((event: any) => event instanceof NavigationStart))\n .subscribe((val: NavigationStart) => {\n this.currentRoute = _router.url\n this.setChildOfCurrentRouteAsSecondaryMenu()\n })\n\n _platform.get().subscribe((data) => {\n this.platform = data\n })\n _userInfo.getUserSession().subscribe((data) => {\n this.user = data.userInfo\n })\n _togglz.getTogglz().subscribe((data) => {\n this.togglz = data\n })\n _router.events.subscribe(() => {\n const path = location.path()\n this.signinRegisterButton = path !== `/${ApplicationRoutes.signin}`\n this.hideMainMenu =\n ORCID_REGEXP.test(path) ||\n path === `/${ApplicationRoutes.myOrcid}` ||\n path === `/${ApplicationRoutes.account}` ||\n path === `/${ApplicationRoutes.trustedParties}` ||\n path === `/${ApplicationRoutes.selfService}` ||\n path === `/${ApplicationRoutes.inbox}` ||\n path === `/${ApplicationRoutes.developerTools}`\n })\n }\n\n ngOnInit() {}\n\n mouseLeave() {\n if (this.platform.columns12) {\n this.setChildOfCurrentRouteAsSecondaryMenu()\n }\n }\n\n setChildOfCurrentRouteAsSecondaryMenu() {\n // Check all first level menu items\n this.menu.forEach((button) => {\n // If the activeRoute of the button is equal to the current route show it as hover\n // Excepts if the current route is the home page\n if (button.activeRoute != null && this.currentRoute !== '/') {\n button.hover = '/' + button.activeRoute === this.currentRoute\n } else {\n button.hover = '/' + button.route === this.currentRoute\n }\n })\n }\n\n click(treeLocation: string[], button: ApplicationMenuItem) {\n if (!this.platform.columns12) {\n if (\n button.route !== undefined &&\n (!button.buttons || !button.buttons.length)\n ) {\n this.goto(button.route)\n } else {\n this.updateMenu(this.menu, treeLocation, true)\n }\n } else if (button.route !== undefined) {\n this.goto(button.route)\n }\n }\n\n mouseEnter(treeLocation: string[]) {\n if (this.platform.columns12) {\n this.updateMenu(this.menu, treeLocation)\n }\n }\n\n updateMenu(\n menuToUpdate: ApplicationMenuItem[],\n treeLocation: string[],\n switchState?: boolean\n ) {\n if (treeLocation.length) {\n const current = treeLocation.shift()\n if (menuToUpdate != null) {\n menuToUpdate.forEach((button) => {\n if (button.id === current) {\n if (treeLocation.length > 0) {\n button.hover = true\n this.updateMenu(button.buttons, treeLocation, switchState)\n } else {\n button.hover = switchState ? !button.hover : true\n }\n } else {\n button.hover = false\n }\n })\n }\n }\n }\n createMenuList(\n menuDefinition: ApplicationMenuItemBasic[]\n ): ApplicationMenuItem[] {\n const list: ApplicationMenuItem[] = []\n if (!menuDefinition || !menuDefinition.length) {\n return []\n }\n menuDefinition.forEach((item) => {\n const newItem: ApplicationMenuItem = {\n ...item,\n hover: false,\n active: false,\n buttons: this.createMenuList(item.buttons),\n }\n\n list.push(newItem)\n })\n\n return list\n }\n\n checkMenuItemRequirements(requirements: MenuItemRequirement) {\n if (!requirements) {\n return true\n } else if (\n typeof requirements.desktop !== 'undefined' &&\n requirements.desktop &&\n !this.platform.columns12\n ) {\n return false\n } else if (\n typeof requirements.desktop !== 'undefined' &&\n !requirements.desktop &&\n this.platform.columns12\n ) {\n return false\n } else if (\n typeof requirements.logging !== 'undefined' &&\n requirements.logging &&\n !this.user\n ) {\n return false\n } else if (\n typeof requirements.logging !== 'undefined' &&\n !requirements.logging &&\n this.user\n ) {\n return false\n } else if (requirements.requiresAll) {\n for (const accessKey of requirements.requiresAll) {\n const key = Object.keys(accessKey)[0]\n const value = accessKey[key]\n if (\n !this.user ||\n !(\n this.user[key] === value ||\n (typeof this.user[key] === 'undefined' && value === 'false')\n )\n ) {\n return false\n }\n }\n } else if (requirements.requiresAny) {\n for (const accessKey of requirements.requiresAny) {\n const key = Object.keys(accessKey)[0]\n const value = accessKey[key]\n if (\n this.user &&\n (this.user[key] === value ||\n (typeof this.user[key] === 'undefined' && value === 'false'))\n ) {\n return true\n }\n }\n return false\n } else if (typeof requirements.togglz !== 'undefined') {\n if (!this.togglz || !this.togglz.messages) {\n return false\n }\n let foundAnUnmeetTogglz = false\n Object.keys(requirements.togglz).forEach((key) => {\n if (Object.keys(this.togglz.messages).indexOf(key)) {\n if (this.togglz.messages[key] !== requirements.togglz[key]) {\n foundAnUnmeetTogglz = true\n }\n } else {\n foundAnUnmeetTogglz = true\n }\n })\n if (foundAnUnmeetTogglz) {\n return false\n }\n }\n return true\n }\n\n isDesktopThirdLevelMenu(parents: any[]) {\n return parents.length > 1 && this.platform.columns12\n }\n isDesktopSecondLevelMenu(parents: any[]) {\n return parents.length === 1 && this.platform.columns12\n }\n isMobileThirdLevelMenu(parents: any[]) {\n return parents.length > 1 && !this.platform.columns12\n }\n menuButtonColor(parents) {\n return this.isDesktopSecondLevelMenu(parents) ||\n this.isMobileThirdLevelMenu(parents)\n ? 'primary'\n : null\n }\n\n goto(route: string) {\n if (route === 'signin') {\n this._router.navigate([ApplicationRoutes.signin])\n this.mobileMenuState = false\n } else if (route === 'signout' && environment.proxyMode) {\n this._user.noRedirectLogout().subscribe()\n } else {\n ;(this.window as any).outOfRouterNavigation(environment.INFO_SITE + route)\n }\n }\n}\n", "assetsDirs": [], "styleUrlsData": [ { diff --git a/package.json b/package.json index 9320e30ff8..074e7cdc14 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "ng-orcid", "version": "0.0.0", "scripts": { - "start-local": "ng serve --disable-host-check --host 0.0.0.0", - "start": "ng serve --configuration=local-qa --host 0.0.0.0", + "start-local": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts && ng serve --disable-host-check --host 0.0.0.0", + "start": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts && ng serve --configuration=local-qa --host 0.0.0.0", "start-sandbox": "ng serve --configuration=local-sandbox --host 0.0.0.0", "start:en": "ng serve --configuration=local-qa-en --disable-host-check", "start:ar": "ng serve --configuration=local-qa-ar --disable-host-check", @@ -15,17 +15,16 @@ "e2e": "ng e2e", "prebuild": "rimraf dist && yarn build:i18n && yarn build:browserslist", "build": "ng build --configuration production --localize", - "postbuild": "ts-node -P scripts/tsconfig.json scripts/postbuild.ts --env production", + "postbuild": "ts-node -P scripts/tsconfig.json scripts/postbuild.ts", "build:i18n:clone": "ts-node -P scripts/tsconfig.json scripts/properties-clone.postbuild.ts", "build:i18n:generate-testing": "ts-node -P scripts/tsconfig.json scripts/properties-test-generator.postbuild.ts", "build:i18n:extract": "ng extract-i18n --format=xlf2 --output-path src/locale", "build:i18n:generate": "ts-node -P scripts/tsconfig.json scripts/translate-file-generator.prebuild.ts", "build:i18n": "yarn build:i18n:extract && yarn build:i18n:generate", "build:prod": "yarn build", - "build:sandbox": "yarn prebuild && ng build --configuration=sandbox --localize && yarn postbuild --env sandbox", - "build:qa": "yarn prebuild && ng build --configuration=qa --localize && yarn postbuild --env qa", - "build:int": "yarn prebuild && ng build --configuration=int --localize && yarn postbuild --env int", - "build:local-tomcat": "yarn prebuild && ng build --configuration=local-tomcat --localize && ng run ng-orcid:build:local-tomcat-source", + "build:sandbox": "yarn build", + "build:qa": "yarn build", + "build:int": "yarn build", "build:local": "yarn run prebuild && ng build --localize", "format": "npm run lint && prettier --write .", "build:report": "webpack-bundle-analyzer dist/en/stats.json", diff --git a/scripts/postbuild.ts b/scripts/postbuild.ts index 980b49bbe0..97fefc6744 100644 --- a/scripts/postbuild.ts +++ b/scripts/postbuild.ts @@ -1,6 +1,5 @@ // This file contains some updates made right after Angular Cli -import { uniqueLength } from './unique-length.postbuild' import { buildInfo } from './build-info.postbuild' import { addLanguageCodeToHashesOnToHTMLFiles, @@ -8,10 +7,9 @@ import { } from './uniqueLanguageFilesNames' import { getOptionsObjet, save } from './utils' import { renameSync, readFileSync } from 'fs' -import { zendeskPlugin } from './zend-desk.postbuild' import { createShareAssetsFolder } from './moveToShareFolder.postbuild' -import { robotsMetadata } from './robots-metada.postbuild' -import { newRelic } from './new-relic.postbuild' +import { replaceEnvPlaceholder } from './runtime-environment-setter.postbuild' + const glob = require('glob') // Run updates on index.html files across languages glob @@ -19,13 +17,14 @@ glob .forEach((file) => { const options = getOptionsObjet(file) let data = readFileSync(file, 'utf8') - data = uniqueLength(data, options) + data = replaceEnvPlaceholder(data) + // data = uniqueLength(data, options) DISABLED unique leght for now, as migth not be required anymore data = buildInfo(data, options) - data = newRelic(data, options) - data = zendeskPlugin(data, options) + // data = newRelic(data, options) TEMPORALLY DISABLE NEW RELIC + // Replace all the `*.js` references to match updated JS file names with the language code. data = addLanguageCodeToHashesOnToHTMLFiles(data, options) - data = robotsMetadata(data, options) + // data = robotsMetadata(data, options) DISABLE robots headers, as those will be handle via nginx save(data, options) }) diff --git a/scripts/runtime-environment-setter.dev-runtime.ts b/scripts/runtime-environment-setter.dev-runtime.ts new file mode 100644 index 0000000000..57a0d78b0e --- /dev/null +++ b/scripts/runtime-environment-setter.dev-runtime.ts @@ -0,0 +1,24 @@ +import * as fs from 'fs' +import * as path from 'path' +import { runtimeEnvironmentScript } from './utils' + +function main() { + // Create the script content + const scriptContent = `//DO NOT MODIFY THIS environment file directly, to updat this file. +//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" +${runtimeEnvironmentScript()}` + + // Write the file. For example, dist/local-dev-environment.js + const outputPath = path.resolve( + __dirname, + '../src/assets/local-dev-environment.js' + ) + + fs.writeFileSync(outputPath, scriptContent, { encoding: 'utf8' }) + + console.log(`Generated: ${outputPath}`) +} +console.log('runtime-environment-setter.dev-runtime.ts') +if (require.main === module) { + main() +} diff --git a/scripts/runtime-environment-setter.postbuild.ts b/scripts/runtime-environment-setter.postbuild.ts new file mode 100644 index 0000000000..c7f559d34a --- /dev/null +++ b/scripts/runtime-environment-setter.postbuild.ts @@ -0,0 +1,22 @@ +import { runtimeEnvironmentScript } from "./utils"; + +/** + * Receives an HTML string, replaces the [ENVIRONMENT_VARAIBLES_PLACEHOLDER] + * with a `; + + // 3. Replace the placeholder in the HTML + const placeholderBlockRegex = /([\s\S]*?)/; + + const updatedHtml = htmlContent.replace(placeholderBlockRegex, scriptTag); + + // 4. Return the updated HTML + return updatedHtml; +} \ No newline at end of file diff --git a/scripts/utils.ts b/scripts/utils.ts index 2cb3b60525..e94bdae45d 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,7 +1,9 @@ +import { writeFileSync } from 'fs' import * as environmentProduction from '../src/environments/environment.production' import * as environmentQa from '../src/environments/environment.qa' import * as environmentSandbox from '../src/environments/environment.sandbox' -import { writeFileSync } from 'fs' +import * as environment4200 from '../src/environments/environment.local-with-proxy' +import * as environmentDev from '../src/environments/environment.local' export function save(data, options) { writeFileSync(options.file, data, 'utf8') @@ -11,23 +13,11 @@ export function getOptionsObjet(file) { const environment = getEnvironmentVar() const languageCode = getLanguageCode(file) const folder = getFolderName(file) - let environmentVariables - - if (environment === 'production') { - environmentVariables = environmentProduction.environment - } else if (environment === 'qa') { - environmentVariables = environmentQa.environment - } else if (environment === 'sandbox') { - environmentVariables = environmentSandbox.environment - } else { - console.warn('the environment variable is invalid') - } return { languageCode, environment, file, - environmentVariables, folder, } } @@ -51,3 +41,66 @@ function getFolderName(file) { folderPathSegments.pop() return folderPathSegments.join('/') } + +export function runtimeEnvironmentScript() { + return ` + (function() { + // The raw environment objects + var environmentProduction = ${JSON.stringify(environmentProduction.environment)}; + var environmentQa = ${JSON.stringify(environmentQa.environment)}; + var environmentSandbox = ${JSON.stringify(environmentSandbox.environment)}; + var environment4200 = ${JSON.stringify(environment4200.environment)}; + var environmentDev = ${JSON.stringify(environmentDev.environment)}; + + function getCurrentLeanDomain() { + var port = window.location.port ? ':' + window.location.port : ''; + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(-2) -> ["myorg", "com"] + return window.location.hostname.split('.').slice(-2).join('.') + port; + } + + function getSubDomain() { + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(0, -2) -> ["qa"] + var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); + return subdomain ? subdomain + '.' : ''; + } + + function replaceEnvironmentVars(env) { + if (!env) return; + if (env.API_WEB) { + env.API_WEB = env.API_WEB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.BASE_URL) { + env.BASE_URL = env.BASE_URL + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.API_PUB) { + env.API_PUB = env.API_PUB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + } + + var domain = window.location.hostname + window.location.pathname; + var chosenEnv = environmentProduction; // default to production + + if (domain.includes('qa.orcid.org')) { + chosenEnv = environmentQa; + } else if (domain.includes('sandbox.orcid.org')) { + chosenEnv = environmentSandbox; + } else if (domain.includes('localhost:4200')) { + chosenEnv = environment4200; + } else if (domain.includes('dev.orcid.org')) { + chosenEnv = environmentDev; + } + + replaceEnvironmentVars(chosenEnv); + + window.runtimeEnvironment = chosenEnv; + })(); + `; +} \ No newline at end of file diff --git a/src/app/account-settings/components/dialog-actions-duplicated-merged-confirmed/dialog-actions-duplicated-merged-confirmed.component.ts b/src/app/account-settings/components/dialog-actions-duplicated-merged-confirmed/dialog-actions-duplicated-merged-confirmed.component.ts index 646f81021b..a24e42632a 100644 --- a/src/app/account-settings/components/dialog-actions-duplicated-merged-confirmed/dialog-actions-duplicated-merged-confirmed.component.ts +++ b/src/app/account-settings/components/dialog-actions-duplicated-merged-confirmed/dialog-actions-duplicated-merged-confirmed.component.ts @@ -13,7 +13,7 @@ import { environment } from 'src/environments/environment' preserveWhitespaces: true, }) export class DialogActionsDuplicatedMergedConfirmedComponent implements OnInit { - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor( private matRef: MatDialogRef, diff --git a/src/app/account-settings/components/dialog-actions-duplicated/dialog-actions-duplicated.component.ts b/src/app/account-settings/components/dialog-actions-duplicated/dialog-actions-duplicated.component.ts index d98c260617..509fdcdbe0 100644 --- a/src/app/account-settings/components/dialog-actions-duplicated/dialog-actions-duplicated.component.ts +++ b/src/app/account-settings/components/dialog-actions-duplicated/dialog-actions-duplicated.component.ts @@ -17,7 +17,7 @@ import { environment } from 'src/environments/environment' }) export class DialogActionsDuplicatedComponent implements OnInit { isMobile: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor( private matRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: DuplicateRemoveEndpoint, diff --git a/src/app/account-settings/components/settings-defaults-language/settings-defaults-language.component.ts b/src/app/account-settings/components/settings-defaults-language/settings-defaults-language.component.ts index b0b9caa05f..a67a6b3af5 100644 --- a/src/app/account-settings/components/settings-defaults-language/settings-defaults-language.component.ts +++ b/src/app/account-settings/components/settings-defaults-language/settings-defaults-language.component.ts @@ -31,7 +31,7 @@ export class SettingsDefaultsLanguageComponent implements OnInit, OnDestroy { private _language: LanguageService, private _fb: UntypedFormBuilder ) { - this.languageMenuOptions = environment.LANGUAGE_MENU_OPTIONS + this.languageMenuOptions = runtimeEnvironment.LANGUAGE_MENU_OPTIONS } ngOnInit() { diff --git a/src/app/account-settings/components/settings-sharing-html-code/settings-sharing-html-code.component.ts b/src/app/account-settings/components/settings-sharing-html-code/settings-sharing-html-code.component.ts index cd2315cdea..01f544433f 100644 --- a/src/app/account-settings/components/settings-sharing-html-code/settings-sharing-html-code.component.ts +++ b/src/app/account-settings/components/settings-sharing-html-code/settings-sharing-html-code.component.ts @@ -12,7 +12,7 @@ import { environment } from 'src/environments/environment' export class SettingsSharingHtmlCodeComponent implements OnInit { @Output() loading = new EventEmitter() userSession: UserSession - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor(private _user: UserService) {} diff --git a/src/app/account-trusted-parties/components/dialog-add-trusted-individuals/dialog-add-trusted-individuals.component.ts b/src/app/account-trusted-parties/components/dialog-add-trusted-individuals/dialog-add-trusted-individuals.component.ts index 6ddfd04dfa..85efcdae24 100644 --- a/src/app/account-trusted-parties/components/dialog-add-trusted-individuals/dialog-add-trusted-individuals.component.ts +++ b/src/app/account-trusted-parties/components/dialog-add-trusted-individuals/dialog-add-trusted-individuals.component.ts @@ -14,7 +14,7 @@ import { environment } from 'src/environments/environment' }) export class DialogAddTrustedIndividualsComponent implements OnInit { isMobile: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL addByEmailOrOrcid: string constructor( private matRef: MatDialogRef, diff --git a/src/app/account-trusted-parties/components/dialog-revoke-trusted-individuals/dialog-revoke-trusted-individuals.component.ts b/src/app/account-trusted-parties/components/dialog-revoke-trusted-individuals/dialog-revoke-trusted-individuals.component.ts index 8aaecbdd02..e82a8ea66c 100644 --- a/src/app/account-trusted-parties/components/dialog-revoke-trusted-individuals/dialog-revoke-trusted-individuals.component.ts +++ b/src/app/account-trusted-parties/components/dialog-revoke-trusted-individuals/dialog-revoke-trusted-individuals.component.ts @@ -16,7 +16,7 @@ import { environment } from 'src/environments/environment' }) export class DialogRevokeTrustedIndividualsComponent implements OnInit { isMobile: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor( private matRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: AccountTrustedIndividual, diff --git a/src/app/account-trusted-parties/components/settings-trusted-individuals-search/settings-trusted-individuals-search.component.ts b/src/app/account-trusted-parties/components/settings-trusted-individuals-search/settings-trusted-individuals-search.component.ts index 2e4f423363..caf60a2a7f 100644 --- a/src/app/account-trusted-parties/components/settings-trusted-individuals-search/settings-trusted-individuals-search.component.ts +++ b/src/app/account-trusted-parties/components/settings-trusted-individuals-search/settings-trusted-individuals-search.component.ts @@ -52,7 +52,7 @@ export class SettingsTrustedIndividualsSearchComponent pageSize: number ariaLabelPaginator = $localize`:@@search.paginator:paginator` loading: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL userSession: UserSession searchPlaceHolder = $localize`:@@account.searchIndividualsPlaceHolder:ORCID iD, email address, or names` trustedIndividuals: AccountTrustedIndividual[] diff --git a/src/app/account-trusted-parties/components/settings-trusted-individuals/settings-trusted-individuals.component.ts b/src/app/account-trusted-parties/components/settings-trusted-individuals/settings-trusted-individuals.component.ts index 865f51faaa..569ff4f2a4 100644 --- a/src/app/account-trusted-parties/components/settings-trusted-individuals/settings-trusted-individuals.component.ts +++ b/src/app/account-trusted-parties/components/settings-trusted-individuals/settings-trusted-individuals.component.ts @@ -22,7 +22,7 @@ export class SettingsTrustedIndividualsComponent implements OnInit, OnDestroy { displayedColumns = ['trustedIndividuals', 'orcid', 'granted', 'actions'] platformSubs = new Subject() isMobile: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL trustedPartiesUrl = '/trusted-parties' constructor( private _trustedIndividualsService: AccountTrustedIndividualsService, diff --git a/src/app/account-trusted-parties/components/settings-users-that-thrust-you/settings-users-that-thrust-you.component.ts b/src/app/account-trusted-parties/components/settings-users-that-thrust-you/settings-users-that-thrust-you.component.ts index b96f389ace..ebb9210f0a 100644 --- a/src/app/account-trusted-parties/components/settings-users-that-thrust-you/settings-users-that-thrust-you.component.ts +++ b/src/app/account-trusted-parties/components/settings-users-that-thrust-you/settings-users-that-thrust-you.component.ts @@ -20,7 +20,7 @@ export class SettingsUsersThatThrustYouComponent implements OnInit { displayedColumns = ['trustedIndividuals', 'orcid', 'granted'] platformSubs = new Subject() isMobile: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor( private _trustedIndividualsService: TrustedIndividualsService, private dialog: MatDialog, diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 6aeb0993f0..25b5173caa 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -37,45 +37,4 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http' ], bootstrap: [AppComponent], }) -export class AppModule { - constructor() { - this.initializeApp() - } - - private initializeApp() { - environment.API_WEB = environment.API_WEB.replace( - '', - this.getSubDomain() - ) - environment.BASE_URL = environment.BASE_URL.replace( - '', - this.getSubDomain() - ) - environment.API_PUB = environment.API_PUB.replace( - '', - this.getSubDomain() - ) - environment.API_WEB = environment.API_WEB.replace( - '', - this.getCurrentLeanDomain() - ) - environment.BASE_URL = environment.BASE_URL.replace( - '', - this.getCurrentLeanDomain() - ) - environment.API_PUB = environment.API_PUB.replace( - '', - this.getCurrentLeanDomain() - ) - } - - getCurrentLeanDomain() { - const port = window.location.port ? ':' + window.location.port : '' - return window.location.hostname.split('.').slice(-2).join('.') + port - } - - getSubDomain() { - const subdomain = window.location.hostname.split('.').slice(0, -2).join('.') - return subdomain ? subdomain + '.' : '' - } -} +export class AppModule {} diff --git a/src/app/cdk/platform-info/browserlist.regexp.ts b/src/app/cdk/platform-info/browserlist.regexp.ts index 545a90290e..bf8c4aa5cf 100644 --- a/src/app/cdk/platform-info/browserlist.regexp.ts +++ b/src/app/cdk/platform-info/browserlist.regexp.ts @@ -1,3 +1,2 @@ // tslint:disable-next-line: max-line-length -export const BROWSERLIST_REGEXP = - /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ +export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ diff --git a/src/app/cdk/recaptcha/recaptcha.directive.ts b/src/app/cdk/recaptcha/recaptcha.directive.ts index 4398090406..36188cd0d1 100644 --- a/src/app/cdk/recaptcha/recaptcha.directive.ts +++ b/src/app/cdk/recaptcha/recaptcha.directive.ts @@ -65,7 +65,7 @@ export class RecaptchaDirective implements OnInit, ControlValueAccessor { registerReCaptchaCallback() { this.window.orcidReCaptchaOnLoad = () => { const config = { - sitekey: environment.GOOGLE_RECAPTCHA, + sitekey: runtimeEnvironment.GOOGLE_RECAPTCHA, callback: (response: string) => { this.ngZone.run(() => this.onSuccess(response)) }, diff --git a/src/app/cdk/snackbar/snackbar.service.ts b/src/app/cdk/snackbar/snackbar.service.ts index ce46ab5efe..3194378398 100644 --- a/src/app/cdk/snackbar/snackbar.service.ts +++ b/src/app/cdk/snackbar/snackbar.service.ts @@ -38,7 +38,7 @@ export class SnackbarService { if ( errorReport?.display && (!errorReport.display.displayOnlyOnVerboseEnvironment || - environment.VERBOSE_SNACKBAR_ERRORS_REPORTS) + runtimeEnvironment.VERBOSE_SNACKBAR_ERRORS_REPORTS) ) { mappedDisplay = { ...errorReport.display, diff --git a/src/app/constants.ts b/src/app/constants.ts index 9ff0663d32..78f0856c38 100644 --- a/src/app/constants.ts +++ b/src/app/constants.ts @@ -400,7 +400,7 @@ export function getAriaLabel( } export function navigateTo(val, windowRef) { - if (val === '/signout' && environment.proxyMode) { + if (val === '/signout' && runtimeEnvironment.proxyMode) { this._user.noRedirectLogout().subscribe() } else { windowRef.location.href = val diff --git a/src/app/core/account-actions-deactivate/account-actions-deactivate.service.ts b/src/app/core/account-actions-deactivate/account-actions-deactivate.service.ts index 9d3c4c48dd..6ba7097c6d 100644 --- a/src/app/core/account-actions-deactivate/account-actions-deactivate.service.ts +++ b/src/app/core/account-actions-deactivate/account-actions-deactivate.service.ts @@ -29,7 +29,7 @@ export class AccountActionsDeactivateService { deactivateAccount(): Observable { return this._http .post( - environment.API_WEB + `account/send-deactivate-account.json`, + runtimeEnvironment.API_WEB + `account/send-deactivate-account.json`, this.options ) .pipe( diff --git a/src/app/core/account-actions-download/account-actions-download.service.ts b/src/app/core/account-actions-download/account-actions-download.service.ts index 8e85932d4c..c9ea608f24 100644 --- a/src/app/core/account-actions-download/account-actions-download.service.ts +++ b/src/app/core/account-actions-download/account-actions-download.service.ts @@ -17,7 +17,7 @@ export class AccountActionsDownloadService { downloadUserData() { return this.downloadBlogFile({ - url: environment.API_WEB + 'get-my-data', + url: runtimeEnvironment.API_WEB + 'get-my-data', dataType: 'application/octet-stream', }) } diff --git a/src/app/core/account-actions-duplicated/account-actions-duplicated.service.ts b/src/app/core/account-actions-duplicated/account-actions-duplicated.service.ts index 6c3a15db94..177f00ca8e 100644 --- a/src/app/core/account-actions-duplicated/account-actions-duplicated.service.ts +++ b/src/app/core/account-actions-duplicated/account-actions-duplicated.service.ts @@ -25,7 +25,7 @@ export class AccountActionsDuplicatedService { ): Observable { return this._http .post( - environment.API_WEB + `account/confirm-deprecate-profile.json`, + runtimeEnvironment.API_WEB + `account/confirm-deprecate-profile.json`, account, { headers: this.headers } ) @@ -42,7 +42,7 @@ export class AccountActionsDuplicatedService { ): Observable { return this._http .post( - environment.API_WEB + `account/validate-deprecate-profile.json`, + runtimeEnvironment.API_WEB + `account/validate-deprecate-profile.json`, account, { headers: this.headers } ) diff --git a/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts b/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts index 0cb9b33637..691dbbe774 100644 --- a/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts +++ b/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts @@ -22,7 +22,7 @@ export class AccountDefaultEmailFrequenciesService { get(): Observable { return this._http .get( - environment.API_WEB + `notifications/frequencies/view`, + runtimeEnvironment.API_WEB + `notifications/frequencies/view`, { headers: this.headers } ) .pipe( @@ -34,7 +34,7 @@ export class AccountDefaultEmailFrequenciesService { updateAmendNotifications(frequency: number): Observable { return this._http .post( - environment.API_WEB + `notifications/frequencies/update/amendUpdates`, + runtimeEnvironment.API_WEB + `notifications/frequencies/update/amendUpdates`, frequency, { headers: this.headers } ) @@ -46,7 +46,7 @@ export class AccountDefaultEmailFrequenciesService { updateAdminNotifications(frequency: string): Observable { return this._http .post( - environment.API_WEB + `notifications/frequencies/update/adminUpdates`, + runtimeEnvironment.API_WEB + `notifications/frequencies/update/adminUpdates`, frequency, { headers: this.headers } ) @@ -58,7 +58,7 @@ export class AccountDefaultEmailFrequenciesService { updateMemberNotifications(frequency: string): Observable { return this._http .post( - environment.API_WEB + `notifications/frequencies/update/memberUpdates`, + runtimeEnvironment.API_WEB + `notifications/frequencies/update/memberUpdates`, frequency, { headers: this.headers } ) @@ -71,7 +71,7 @@ export class AccountDefaultEmailFrequenciesService { updateMemberTipsUpdates(tips: boolean): Observable { return this._http .post( - environment.API_WEB + `notifications/frequencies/update/tipsUpdates`, + runtimeEnvironment.API_WEB + `notifications/frequencies/update/tipsUpdates`, tips, { headers: this.headers } ) diff --git a/src/app/core/account-default-visibility/account-default-visibility.service.ts b/src/app/core/account-default-visibility/account-default-visibility.service.ts index c7289d82ee..e1e9411034 100644 --- a/src/app/core/account-default-visibility/account-default-visibility.service.ts +++ b/src/app/core/account-default-visibility/account-default-visibility.service.ts @@ -22,7 +22,7 @@ export class AccountDefaultVisibilityService { update(frequency: VisibilityStrings): Observable { return this._http .post( - environment.API_WEB + `account/default_visibility.json`, + runtimeEnvironment.API_WEB + `account/default_visibility.json`, frequency, { headers: this.headers } ) diff --git a/src/app/core/account-security-alternate-sign-in/account-security-alternate-sign-in.service.ts b/src/app/core/account-security-alternate-sign-in/account-security-alternate-sign-in.service.ts index c817c84fa7..ff0097c907 100644 --- a/src/app/core/account-security-alternate-sign-in/account-security-alternate-sign-in.service.ts +++ b/src/app/core/account-security-alternate-sign-in/account-security-alternate-sign-in.service.ts @@ -30,7 +30,7 @@ export class AccountSecurityAlternateSignInService { get(): Observable { return this._http .get( - environment.API_WEB + `account/socialAccounts.json`, + runtimeEnvironment.API_WEB + `account/socialAccounts.json`, { headers: this.headers, } @@ -69,7 +69,7 @@ export class AccountSecurityAlternateSignInService { delete(idToManage: SocialAccountId): Observable { return this._http .post( - environment.API_WEB + `account/revokeSocialAccount.json`, + runtimeEnvironment.API_WEB + `account/revokeSocialAccount.json`, { idToManage }, { headers: this.headers, diff --git a/src/app/core/account-security-password/account-security-password.service.ts b/src/app/core/account-security-password/account-security-password.service.ts index fe82310a29..6af59a6ccc 100644 --- a/src/app/core/account-security-password/account-security-password.service.ts +++ b/src/app/core/account-security-password/account-security-password.service.ts @@ -25,7 +25,7 @@ export class AccountSecurityPasswordService { ): Observable { return this._http .post( - environment.API_WEB + `account/change-password.json`, + runtimeEnvironment.API_WEB + `account/change-password.json`, accountPassword, { headers: this.headers } ) diff --git a/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts b/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts index 94a6a3c4e3..0aa8f412a6 100644 --- a/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts +++ b/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts @@ -31,7 +31,7 @@ export class AccountTrustedIndividualsService { get(): Observable { return this._http .get( - environment.API_WEB + `account/delegates.json`, + runtimeEnvironment.API_WEB + `account/delegates.json`, { headers: this.headers } ) .pipe( @@ -51,7 +51,7 @@ export class AccountTrustedIndividualsService { delete(account: AccountTrustedIndividual): Observable { return this._http .post( - environment.API_WEB + `account/revokeDelegate.json`, + runtimeEnvironment.API_WEB + `account/revokeDelegate.json`, { delegateToManage: account.receiverOrcid.path }, { headers: this.headers } ) @@ -64,7 +64,7 @@ export class AccountTrustedIndividualsService { getPersonDetails(orcid: string) { return this._http - .get(environment.API_PUB + `${orcid}/personal-details`, { + .get(runtimeEnvironment.API_PUB + `${orcid}/personal-details`, { headers: this.headers, }) .pipe( @@ -75,7 +75,7 @@ export class AccountTrustedIndividualsService { add(value: ExpandedSearchResultsContent) { return this._http .post( - environment.API_WEB + `account/addDelegate.json`, + runtimeEnvironment.API_WEB + `account/addDelegate.json`, { delegateToManage: value['orcid-id'] }, { headers: this.headers } ) @@ -88,7 +88,7 @@ export class AccountTrustedIndividualsService { searchByEmail(email: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `account/search-for-delegate-by-email/${encodeURIComponent(email)}/`, { headers: this.headers } ) @@ -100,7 +100,7 @@ export class AccountTrustedIndividualsService { addByEmail(delegateEmail: string) { return this._http .post( - environment.API_WEB + `account/addDelegateByEmail.json/`, + runtimeEnvironment.API_WEB + `account/addDelegateByEmail.json/`, { delegateEmail }, { headers: this.headers } ) @@ -114,7 +114,7 @@ export class AccountTrustedIndividualsService { searchByOrcid(email: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `account/search-for-delegate-by-orcid/${encodeURIComponent(email)}/`, { headers: this.headers } ) @@ -126,7 +126,7 @@ export class AccountTrustedIndividualsService { addByOrcid(delegateToManage: string) { return this._http .post( - environment.API_WEB + `account/addDelegateByOrcid.json`, + runtimeEnvironment.API_WEB + `account/addDelegateByOrcid.json`, { delegateToManage }, { headers: this.headers } ) diff --git a/src/app/core/account-trusted-organizations/account-trusted-organizations.service.ts b/src/app/core/account-trusted-organizations/account-trusted-organizations.service.ts index 2f15fd2b92..cacba5050f 100644 --- a/src/app/core/account-trusted-organizations/account-trusted-organizations.service.ts +++ b/src/app/core/account-trusted-organizations/account-trusted-organizations.service.ts @@ -22,7 +22,7 @@ export class AccountTrustedOrganizationsService { get(): Observable { return this._http .get( - environment.API_WEB + `account/get-trusted-orgs.json`, + runtimeEnvironment.API_WEB + `account/get-trusted-orgs.json`, { headers: this.headers } ) .pipe( @@ -36,7 +36,7 @@ export class AccountTrustedOrganizationsService { ): Observable { return this._http .post( - environment.API_WEB + + runtimeEnvironment.API_WEB + `account/revoke-application.json?clientId=` + account.clientId, undefined, diff --git a/src/app/core/announcer/announcer.service.ts b/src/app/core/announcer/announcer.service.ts index 85039159e0..36c55f2544 100644 --- a/src/app/core/announcer/announcer.service.ts +++ b/src/app/core/announcer/announcer.service.ts @@ -54,7 +54,7 @@ export class AnnouncerService { } private announce(announcement: string) { - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug('📢' + announcement) } this._liveAnnouncer.announce(announcement, 'assertive') diff --git a/src/app/core/canonocal-url/canonocal-url.service.ts b/src/app/core/canonocal-url/canonocal-url.service.ts index ea3cc7102e..5a0062dbc0 100644 --- a/src/app/core/canonocal-url/canonocal-url.service.ts +++ b/src/app/core/canonocal-url/canonocal-url.service.ts @@ -35,8 +35,8 @@ export class CanonocalUrlService { this.removeCanonicalUrl() let canonicalUrl = 'https:' + - environment.BASE_URL + - (environment.BASE_URL.endsWith('/') ? publicOrcid : '/' + publicOrcid) + runtimeEnvironment.BASE_URL + + (runtimeEnvironment.BASE_URL.endsWith('/') ? publicOrcid : '/' + publicOrcid) let link: HTMLLinkElement = this.doc.createElement('link') link.setAttribute('rel', 'canonical') diff --git a/src/app/core/developer-tools/developer-tools.service.ts b/src/app/core/developer-tools/developer-tools.service.ts index dc185e0508..38336a9d97 100644 --- a/src/app/core/developer-tools/developer-tools.service.ts +++ b/src/app/core/developer-tools/developer-tools.service.ts @@ -18,7 +18,7 @@ export class DeveloperToolsService { getDeveloperToolsClient(): Observable { return this._http - .get(environment.BASE_URL + 'developer-tools/get-client.json') + .get(runtimeEnvironment.BASE_URL + 'developer-tools/get-client.json') .pipe( retry(3), catchError((error) => @@ -30,7 +30,7 @@ export class DeveloperToolsService { postDeveloperToolsClient(client: Client): Observable { return this._http .post( - environment.BASE_URL + 'developer-tools/create-client.json', + runtimeEnvironment.BASE_URL + 'developer-tools/create-client.json', client ) .pipe( @@ -44,7 +44,7 @@ export class DeveloperToolsService { updateDeveloperToolsClient(client: Client): Observable { return this._http .post( - environment.BASE_URL + 'developer-tools/update-client.json', + runtimeEnvironment.BASE_URL + 'developer-tools/update-client.json', client ) .pipe( @@ -58,7 +58,7 @@ export class DeveloperToolsService { postResetClientSecret(client: Client): Observable { return this._http .post( - environment.BASE_URL + 'developer-tools/reset-client-secret.json', + runtimeEnvironment.BASE_URL + 'developer-tools/reset-client-secret.json', client ) .pipe( @@ -72,7 +72,7 @@ export class DeveloperToolsService { enableDeveloperTools() { return this._http .post( - environment.BASE_URL + 'developer-tools/enable-developer-tools.json', + runtimeEnvironment.BASE_URL + 'developer-tools/enable-developer-tools.json', {} ) .pipe( @@ -86,7 +86,7 @@ export class DeveloperToolsService { resetClientSecret(client: Client): Observable { return this._http .post( - environment.BASE_URL + 'developer-tools/reset-client-secret.json', + runtimeEnvironment.BASE_URL + 'developer-tools/reset-client-secret.json', client ) .pipe( diff --git a/src/app/core/disco/disco.service.ts b/src/app/core/disco/disco.service.ts index edb17ad4a9..853de357a0 100644 --- a/src/app/core/disco/disco.service.ts +++ b/src/app/core/disco/disco.service.ts @@ -3,7 +3,6 @@ import { Injectable } from '@angular/core' import { Observable, ReplaySubject } from 'rxjs' import { catchError, first, map, retry, take, tap } from 'rxjs/operators' -import { environment } from '../../../environments/environment' import { Institutional } from '../../types/institutional.endpoint' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { ERROR_REPORT } from 'src/app/errors' @@ -29,7 +28,7 @@ export class DiscoService { }) institutionNames = institutionNames.slice( 0, - environment.INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT + runtimeEnvironment.INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT ) } else { institutionNames = allInstitutionNames @@ -87,7 +86,7 @@ export class DiscoService { if (!this.discoFeedSubject) { this.discoFeedSubject = new ReplaySubject(1) return this._http - .get(environment.BASE_URL + 'Shibboleth.sso/DiscoFeed') + .get(runtimeEnvironment.BASE_URL + 'Shibboleth.sso/DiscoFeed') .pipe( tap((feed) => { this.discoFeedSubject.next(feed) diff --git a/src/app/core/google-tag-manager/google-tag-manager.service.ts b/src/app/core/google-tag-manager/google-tag-manager.service.ts index 5e6472af80..9446e67eb8 100644 --- a/src/app/core/google-tag-manager/google-tag-manager.service.ts +++ b/src/app/core/google-tag-manager/google-tag-manager.service.ts @@ -1,5 +1,4 @@ import { Inject, Injectable } from '@angular/core' -import { environment } from '../../../environments/environment' import { RequestInfoForm } from '../../types' import { BehaviorSubject, Observable } from 'rxjs' import { @@ -101,7 +100,7 @@ export class GoogleTagManagerService { gtmScript.async = true gtmScript.src = 'https://www.googletagmanager.com/gtm.js?id=' + - environment.GOOGLE_TAG_MANAGER + runtimeEnvironment.GOOGLE_TAG_MANAGER gtmScript.setAttributeNode(doc.createAttribute('data-ot-ignore')) gtmScript.addEventListener('load', () => { this.isLoaded = true @@ -119,7 +118,7 @@ export class GoogleTagManagerService { } reportPageView(url: string) { - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug(`GTM Navigation ${url}`) } const gtmTag: ItemGTM = { @@ -140,7 +139,7 @@ export class GoogleTagManagerService { redirectUrl = (label as unknown as RequestInfoForm).redirectUrl label = 'OAuth ' + buildClientString(label) } - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug(`GTM - Event /${event}/${label}/`) } @@ -161,7 +160,7 @@ export class GoogleTagManagerService { reportNavigationEnd(url: string, duration: number | void): Observable { if (duration) { - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug(`GTM - Took ${duration} to load ${url}`) } diff --git a/src/app/core/help-hero/help-hero.service.ts b/src/app/core/help-hero/help-hero.service.ts index ccd75b466b..c6dd11a8ad 100644 --- a/src/app/core/help-hero/help-hero.service.ts +++ b/src/app/core/help-hero/help-hero.service.ts @@ -41,7 +41,7 @@ export class HelpHeroService { !(this.window as any).Cypress ) { this.modifyHelpHeroScriptOnCreate() - this.hlp = initHelpHero(environment.HELP_HERO_ID) + this.hlp = initHelpHero(runtimeEnvironment.HELP_HERO_ID) const helpHeroIdentifyObject = { numberOfValidatedEmails: this.getNumberOfValidatedEmails( userRecord?.emails?.emails diff --git a/src/app/core/inbox/inbox.service.ts b/src/app/core/inbox/inbox.service.ts index 709000c071..2d5c675c6e 100644 --- a/src/app/core/inbox/inbox.service.ts +++ b/src/app/core/inbox/inbox.service.ts @@ -118,7 +118,7 @@ export class InboxService { >( !this.nextLoadRequireAFullBackendSyncronization ? // if a complete refresh is not required only load the the new notifications - environment.BASE_URL + + runtimeEnvironment.BASE_URL + `inbox/notifications.json?firstResult=${ AMOUNT_OF_RETRIEVE_NOTIFICATIONS_PER_CALL * depthLevel }&maxResults=${AMOUNT_OF_RETRIEVE_NOTIFICATIONS_PER_CALL}&includeArchived=${includeArchived}` @@ -154,7 +154,7 @@ export class InboxService { | InboxNotificationHtml | InboxNotificationInstitutional | InboxNotificationPermission - >(environment.BASE_URL + `inbox/${code}/archive.json`, code, { + >(runtimeEnvironment.BASE_URL + `inbox/${code}/archive.json`, code, { headers: this.headers, }) .pipe( @@ -202,7 +202,7 @@ export class InboxService { | InboxNotificationHtml | InboxNotificationInstitutional | InboxNotificationPermission - >(environment.BASE_URL + `inbox/${code}/read.json`, code, { + >(runtimeEnvironment.BASE_URL + `inbox/${code}/read.json`, code, { headers: this.headers, }) .pipe( @@ -220,13 +220,13 @@ export class InboxService { } retrieveUnreadCount(): any { - return this._http.get(environment.BASE_URL + 'inbox/unreadCount.json') + return this._http.get(runtimeEnvironment.BASE_URL + 'inbox/unreadCount.json') } totalNumber() { return this._http .get( - environment.BASE_URL + `inbox/totalCount.json`, + runtimeEnvironment.BASE_URL + `inbox/totalCount.json`, { headers: this.headers, } diff --git a/src/app/core/language/language.service.ts b/src/app/core/language/language.service.ts index 237893529a..f8e072cae3 100644 --- a/src/app/core/language/language.service.ts +++ b/src/app/core/language/language.service.ts @@ -21,13 +21,13 @@ export class LanguageService { return of({}).pipe( // If the language is not listed on the current frontend environment it wont attempt to change it tap(() => { - if (!environment.production) { + if (!runtimeEnvironment.production) { { throw new Error(`change-language-require-production-mode`) } } if ( - !Object.keys(environment.LANGUAGE_MENU_OPTIONS).find( + !Object.keys(runtimeEnvironment.LANGUAGE_MENU_OPTIONS).find( (x) => x.toLocaleLowerCase().replace('-', '_') === languageCode ) ) { @@ -36,7 +36,7 @@ export class LanguageService { }), switchMap(() => this._http - .get(environment.API_WEB + 'lang.json?lang=' + languageCode) + .get(runtimeEnvironment.API_WEB + 'lang.json?lang=' + languageCode) .pipe(retry(3)) ), catchError((error) => diff --git a/src/app/core/news/news.service.ts b/src/app/core/news/news.service.ts index af7e4e0c69..95f5fd916c 100644 --- a/src/app/core/news/news.service.ts +++ b/src/app/core/news/news.service.ts @@ -19,7 +19,7 @@ export class NewsService { ) {} getNews() { - const url = environment.API_NEWS + const url = runtimeEnvironment.API_NEWS // Get the news! return this._http.get(url, { responseType: 'text' }).pipe( retry(3), diff --git a/src/app/core/oauth/oauth.service.ts b/src/app/core/oauth/oauth.service.ts index d374d904e5..12aba899a7 100644 --- a/src/app/core/oauth/oauth.service.ts +++ b/src/app/core/oauth/oauth.service.ts @@ -18,7 +18,7 @@ import { OauthParameters, RequestInfoForm } from 'src/app/types' import { OauthAuthorize } from 'src/app/types/authorize.endpoint' import { UserSessionUpdateParameters } from 'src/app/types/session.local' -import { environment } from '../../../environments/environment' + import { SignInData } from '../../types/sign-in-data.endpoint' import { TwoFactor } from '../../types/two-factor.endpoint' import { ErrorHandlerService } from '../error-handler/error-handler.service' @@ -69,7 +69,7 @@ export class OauthService { loadRequestInfoForm(): Observable { return this._http .get( - environment.BASE_URL + 'oauth/custom/requestInfoForm.json', + runtimeEnvironment.BASE_URL + 'oauth/custom/requestInfoForm.json', { headers: this.headers } ) .pipe( @@ -94,7 +94,7 @@ export class OauthService { } return this._http .post( - environment.BASE_URL + 'oauth/custom/authorize.json', + runtimeEnvironment.BASE_URL + 'oauth/custom/authorize.json', value, { headers: this.headers, withCredentials: true } ) @@ -128,7 +128,7 @@ export class OauthService { ) { this.declareOauthSession$ = this._http .post( - environment.BASE_URL + + runtimeEnvironment.BASE_URL + `oauth/custom/init.json?${objectToUrlParameters(queryParameters)}`, queryParameters, { headers: this.headers } @@ -193,7 +193,7 @@ export class OauthService { loadShibbolethSignInData(): Observable { return this._http - .get(environment.BASE_URL + 'shibboleth/signinData.json', { + .get(runtimeEnvironment.BASE_URL + 'shibboleth/signinData.json', { headers: this.headers, }) .pipe( @@ -206,7 +206,7 @@ export class OauthService { loadSocialSigninData(): Observable { return this._http - .get(environment.BASE_URL + 'social/signinData.json', { + .get(runtimeEnvironment.BASE_URL + 'social/signinData.json', { headers: this.headers, }) .pipe( diff --git a/src/app/core/observability-events/observability-events.service.ts b/src/app/core/observability-events/observability-events.service.ts index 958da77e46..be0768e345 100644 --- a/src/app/core/observability-events/observability-events.service.ts +++ b/src/app/core/observability-events/observability-events.service.ts @@ -25,7 +25,7 @@ export class CustomEventService { attributes, } - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug( `-> Journey "${journeyType}" started at ${this.journeys[journeyType].startTime}`, attributes @@ -64,7 +64,7 @@ export class CustomEventService { } // Send the custom event to New Relic - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug( `-> Event "${eventName}" recorded for journey "${journeyType}" with elapsed time ${elapsedTime}ms`, eventAttributes diff --git a/src/app/core/open-graph/open-graph.service.ts b/src/app/core/open-graph/open-graph.service.ts index 0508417bda..84d0283afd 100644 --- a/src/app/core/open-graph/open-graph.service.ts +++ b/src/app/core/open-graph/open-graph.service.ts @@ -63,7 +63,7 @@ export class OpenGraphService { property: this.urlMeta, content: 'https:' + - environment.BASE_URL + + runtimeEnvironment.BASE_URL + record.userInfo.EFFECTIVE_USER_ORCID, }, { @@ -82,7 +82,7 @@ export class OpenGraphService { { property: this.imageMeta, content: - 'https:' + environment.BASE_URL + 'assets/img/orcid-og-image.png', + 'https:' + runtimeEnvironment.BASE_URL + 'assets/img/orcid-og-image.png', }, ]) } catch (e) { diff --git a/src/app/core/organizations/organizations.service.ts b/src/app/core/organizations/organizations.service.ts index e4a41c7921..82e94fe43e 100644 --- a/src/app/core/organizations/organizations.service.ts +++ b/src/app/core/organizations/organizations.service.ts @@ -5,7 +5,7 @@ import { catchError, retry } from 'rxjs/operators' import { WHITE_SPACE_REGEXP } from 'src/app/constants' import { OrgDisambiguated } from 'src/app/types' -import { environment } from '../../../environments/environment' + import { ErrorHandlerService } from '../error-handler/error-handler.service' @Injectable({ @@ -21,7 +21,7 @@ export class OrganizationsService { if (type && value) { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `orgs/disambiguated/${type}?value=${encodeURIComponent(value)}` ) .pipe( diff --git a/src/app/core/password-recovery/password-recovery.service.ts b/src/app/core/password-recovery/password-recovery.service.ts index ceecff6914..d1ba0dfa24 100644 --- a/src/app/core/password-recovery/password-recovery.service.ts +++ b/src/app/core/password-recovery/password-recovery.service.ts @@ -25,7 +25,7 @@ export class PasswordRecoveryService { resetPassword(data) { return this._http .post( - environment.API_WEB + `reset-password.json`, + runtimeEnvironment.API_WEB + `reset-password.json`, data, { withCredentials: true } ) @@ -42,7 +42,7 @@ export class PasswordRecoveryService { remindOrcidId(data) { return this._http - .post(environment.API_WEB + `forgot-id.json`, data, { + .post(runtimeEnvironment.API_WEB + `forgot-id.json`, data, { withCredentials: true, }) .pipe( @@ -60,7 +60,7 @@ export class PasswordRecoveryService { let encodedData = JSON.stringify(resetPassword) return this._http .post( - environment.API_WEB + `reset-password-email-v2.json`, + runtimeEnvironment.API_WEB + `reset-password-email-v2.json`, encodedData, { headers: this.headers, @@ -78,7 +78,7 @@ export class PasswordRecoveryService { let encodedData = JSON.stringify(resetPassword) return this._http .post( - environment.API_WEB + `reset-password-email-validate-token.json`, + runtimeEnvironment.API_WEB + `reset-password-email-validate-token.json`, encodedData, { headers: this.headers, diff --git a/src/app/core/reactivation/reactivation.service.ts b/src/app/core/reactivation/reactivation.service.ts index 53bd6e00f4..92e84ab602 100644 --- a/src/app/core/reactivation/reactivation.service.ts +++ b/src/app/core/reactivation/reactivation.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { HttpClient } from '@angular/common/http' import { Observable } from 'rxjs/internal/Observable' -import { environment } from '../../../environments/environment' + import { Reactivation } from '../../types/reactivation.endpoint' @Injectable({ @@ -12,7 +12,7 @@ export class ReactivationService { getReactivationData(resetParams): Observable { return this._http.get( - `${environment.API_WEB}reactivationData.json?params=${resetParams}` + `${runtimeEnvironment.API_WEB}reactivationData.json?params=${resetParams}` ) } } diff --git a/src/app/core/record-affiliations/record-affiliations.service.ts b/src/app/core/record-affiliations/record-affiliations.service.ts index ac5d15abd7..84401d05b8 100644 --- a/src/app/core/record-affiliations/record-affiliations.service.ts +++ b/src/app/core/record-affiliations/record-affiliations.service.ts @@ -112,7 +112,7 @@ export class RecordAffiliationService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `${ options?.publicRecordId ? options?.publicRecordId + '/' @@ -131,7 +131,7 @@ export class RecordAffiliationService { if (options.publicRecordId) { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `${options.publicRecordId}/affiliationGroups.json` ) .pipe( @@ -143,7 +143,7 @@ export class RecordAffiliationService { } else { return this._http .get( - environment.API_WEB + `affiliations/affiliationGroups.json` + runtimeEnvironment.API_WEB + `affiliations/affiliationGroups.json` ) .pipe( retry(3), @@ -188,7 +188,7 @@ export class RecordAffiliationService { postAffiliation(affiliation): Observable { return this._http .post( - environment.API_WEB + 'affiliations/affiliation.json', + runtimeEnvironment.API_WEB + 'affiliations/affiliation.json', affiliation, { headers: this.headers, @@ -205,7 +205,7 @@ export class RecordAffiliationService { if (org.length > 2) { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'affiliations/disambiguated/name/' + org + '?limit=100', @@ -227,7 +227,7 @@ export class RecordAffiliationService { ): Observable { return this._http .get( - environment.API_WEB + 'affiliations/disambiguated/id/' + id, + runtimeEnvironment.API_WEB + 'affiliations/disambiguated/id/' + id, { headers: this.headers, } @@ -244,7 +244,7 @@ export class RecordAffiliationService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'affiliations/' + putCode + '/visibility/' + @@ -260,7 +260,7 @@ export class RecordAffiliationService { delete(putCode: string): Observable { return this._http .delete( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'affiliations/affiliation.json' + '?id=' + encodeURIComponent(putCode) @@ -275,7 +275,7 @@ export class RecordAffiliationService { updatePreferredSource(putCode: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'affiliations/updateToMaxDisplay.json?putCode=' + putCode ) @@ -289,7 +289,7 @@ export class RecordAffiliationService { getEmployments(): Observable { return this._http .get( - environment.API_WEB + 'affiliations/employments.json', + runtimeEnvironment.API_WEB + 'affiliations/employments.json', { headers: this.headers, } diff --git a/src/app/core/record-biography/record-biography.service.ts b/src/app/core/record-biography/record-biography.service.ts index 752c51a1db..fa147f9bea 100644 --- a/src/app/core/record-biography/record-biography.service.ts +++ b/src/app/core/record-biography/record-biography.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { Observable, of, ReplaySubject } from 'rxjs' import { catchError, map, retry, tap } from 'rxjs/operators' import { HttpClient, HttpHeaders } from '@angular/common/http' -import { environment } from '../../../environments/environment' + import { ErrorHandlerService } from '../error-handler/error-handler.service' import { BiographyEndPoint } from '../../types/record-biography.endpoint' import { UserRecordOptions } from 'src/app/types/record.local' @@ -45,7 +45,7 @@ export class RecordBiographyService { this._http .get( - environment.API_WEB + `account/biographyForm.json`, + runtimeEnvironment.API_WEB + `account/biographyForm.json`, { headers: this.headers } ) .pipe( @@ -63,7 +63,7 @@ export class RecordBiographyService { postBiography(biography: BiographyEndPoint): Observable { return this._http .post( - environment.API_WEB + `account/biographyForm.json`, + runtimeEnvironment.API_WEB + `account/biographyForm.json`, biography, { headers: this.headers } ) diff --git a/src/app/core/record-countries/record-countries.service.ts b/src/app/core/record-countries/record-countries.service.ts index 34df04e2ef..989fbeef2a 100644 --- a/src/app/core/record-countries/record-countries.service.ts +++ b/src/app/core/record-countries/record-countries.service.ts @@ -329,7 +329,7 @@ export class RecordCountriesService { forkJoin([ this._http .get( - environment.API_WEB + `account/countryForm.json`, + runtimeEnvironment.API_WEB + `account/countryForm.json`, { headers: this.headers, } @@ -366,7 +366,7 @@ export class RecordCountriesService { postAddresses(countries: CountriesEndpoint): Observable { return this._http .post( - environment.API_WEB + `account/countryForm.json`, + runtimeEnvironment.API_WEB + `account/countryForm.json`, countries, { headers: this.headers } ) diff --git a/src/app/core/record-emails/record-emails.service.ts b/src/app/core/record-emails/record-emails.service.ts index f289746c5f..3801a64e62 100644 --- a/src/app/core/record-emails/record-emails.service.ts +++ b/src/app/core/record-emails/record-emails.service.ts @@ -54,7 +54,7 @@ export class RecordEmailsService { } this._http - .get(environment.API_WEB + `account/emails.json`, { + .get(runtimeEnvironment.API_WEB + `account/emails.json`, { headers: this.headers, }) .pipe( @@ -77,7 +77,7 @@ export class RecordEmailsService { postEmails(emails: EmailsEndpoint): Observable { return this._http .post( - environment.API_WEB + `account/emails.json`, + runtimeEnvironment.API_WEB + `account/emails.json`, emails, { headers: this.headers, @@ -93,7 +93,7 @@ export class RecordEmailsService { editEmail(original: string, edited: string): Observable { return this._http .post( - environment.API_WEB + `account/email/edit.json`, + runtimeEnvironment.API_WEB + `account/email/edit.json`, { original, edited }, { headers: this.headers, @@ -109,7 +109,7 @@ export class RecordEmailsService { verifyEmail(email: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `account/verifyEmail.json?email=${encodeURIComponent(email)}`, { headers: this.headers, @@ -126,7 +126,7 @@ export class RecordEmailsService { const encoded_data = JSON.stringify(email) return this._http - .post(environment.API_WEB + `account/email/visibility`, encoded_data, { + .post(runtimeEnvironment.API_WEB + `account/email/visibility`, encoded_data, { headers: this.headers, }) .pipe( @@ -141,7 +141,7 @@ export class RecordEmailsService { ): Observable { return this._http .post( - environment.API_WEB + `account/validateEmail.json`, + runtimeEnvironment.API_WEB + `account/validateEmail.json`, value ) .pipe( diff --git a/src/app/core/record-fundings/record-fundings.service.ts b/src/app/core/record-fundings/record-fundings.service.ts index 148b328bfd..230895fc3c 100644 --- a/src/app/core/record-fundings/record-fundings.service.ts +++ b/src/app/core/record-fundings/record-fundings.service.ts @@ -35,7 +35,7 @@ export class RecordFundingsService { if (options?.publicRecordId) { this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + options.publicRecordId + '/fundingGroups.json?' + '&sort=' + @@ -75,7 +75,7 @@ export class RecordFundingsService { getFundingDetails(putCode): Observable { return this._http .get( - environment.API_WEB + `fundings/fundingDetails.json?id=${putCode}` + runtimeEnvironment.API_WEB + `fundings/fundingDetails.json?id=${putCode}` ) .pipe( retry(3), @@ -87,7 +87,7 @@ export class RecordFundingsService { getPublicFundingDetails(orcid, putCode): Observable { return this._http .get( - environment.API_WEB + orcid + `/fundingDetails.json?id=${putCode}` + runtimeEnvironment.API_WEB + orcid + `/fundingDetails.json?id=${putCode}` ) .pipe( retry(3), @@ -104,7 +104,7 @@ export class RecordFundingsService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `fundings/fundingGroups.json?` + '&sort=' + (options?.sort != null ? options.sort : 'date') + @@ -127,7 +127,7 @@ export class RecordFundingsService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'fundings/' + putCode + '/visibility/' + @@ -143,7 +143,7 @@ export class RecordFundingsService { delete(putCode: string): Observable { return this._http .delete( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'fundings/funding.json?id=' + encodeURIComponent(putCode) ) @@ -156,7 +156,7 @@ export class RecordFundingsService { getFunding(): Observable { return this._http - .get(environment.API_WEB + `fundings/funding.json`) + .get(runtimeEnvironment.API_WEB + `fundings/funding.json`) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) @@ -165,7 +165,7 @@ export class RecordFundingsService { save(funding: Funding) { return this._http - .post(environment.API_WEB + `fundings/funding.json`, funding) + .post(runtimeEnvironment.API_WEB + `fundings/funding.json`, funding) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), @@ -177,7 +177,7 @@ export class RecordFundingsService { if (org.length > 2) { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'fundings/disambiguated/name/' + org + '?limit=100&funders-only=true', @@ -196,14 +196,14 @@ export class RecordFundingsService { loadFundingImportWizardList(): Observable { return this._http.get( - environment.API_WEB + 'workspace/retrieve-funding-import-wizards.json' + runtimeEnvironment.API_WEB + 'workspace/retrieve-funding-import-wizards.json' ) } updatePreferredSource(putCode: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'fundings/updateToMaxDisplay.json?putCode=' + putCode ) diff --git a/src/app/core/record-keyword/record-keyword.service.ts b/src/app/core/record-keyword/record-keyword.service.ts index 888fe0e011..e4ce61c672 100644 --- a/src/app/core/record-keyword/record-keyword.service.ts +++ b/src/app/core/record-keyword/record-keyword.service.ts @@ -4,7 +4,7 @@ import { Observable, of, ReplaySubject } from 'rxjs' import { catchError, map, retry, tap } from 'rxjs/operators' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { KeywordEndPoint } from '../../types/record-keyword.endpoint' -import { environment } from '../../../environments/environment' + import { UserRecordOptions } from 'src/app/types/record.local' import { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service' @@ -45,7 +45,7 @@ export class RecordKeywordService { this._http .get( - environment.API_WEB + `my-orcid/keywordsForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/keywordsForms.json`, { headers: this.headers, } @@ -66,7 +66,7 @@ export class RecordKeywordService { postKeywords(keywords: KeywordEndPoint): Observable { return this._http .post( - environment.API_WEB + `my-orcid/keywordsForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/keywordsForms.json`, keywords, { headers: this.headers } ) diff --git a/src/app/core/record-names/record-names.service.ts b/src/app/core/record-names/record-names.service.ts index 43cc5e14ca..cf1ede7875 100644 --- a/src/app/core/record-names/record-names.service.ts +++ b/src/app/core/record-names/record-names.service.ts @@ -4,7 +4,7 @@ import { catchError, map, retry, tap } from 'rxjs/operators' import { HttpClient, HttpHeaders } from '@angular/common/http' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { NamesEndPoint } from '../../types/record-name.endpoint' -import { environment } from '../../../environments/environment' + import { UserRecordOptions } from 'src/app/types/record.local' import { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service' @@ -43,7 +43,7 @@ export class RecordNamesService { } this._http - .get(environment.API_WEB + `account/nameForm.json`, { + .get(runtimeEnvironment.API_WEB + `account/nameForm.json`, { headers: this.headers, }) .pipe( @@ -62,7 +62,7 @@ export class RecordNamesService { postNames(names: NamesEndPoint): Observable { return this._http .post( - environment.API_WEB + `account/nameForm.json`, + runtimeEnvironment.API_WEB + `account/nameForm.json`, names, { headers: this.headers, diff --git a/src/app/core/record-other-names/record-other-names.service.ts b/src/app/core/record-other-names/record-other-names.service.ts index 256c27be8a..f0e6044cdb 100644 --- a/src/app/core/record-other-names/record-other-names.service.ts +++ b/src/app/core/record-other-names/record-other-names.service.ts @@ -4,7 +4,7 @@ import { Observable, of, ReplaySubject } from 'rxjs' import { catchError, map, retry, tap } from 'rxjs/operators' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { OtherNamesEndPoint } from '../../types/record-other-names.endpoint' -import { environment } from '../../../environments/environment' + import { UserRecordOptions } from 'src/app/types/record.local' import { RecordPublicSideBarService } from '../record-public-side-bar/record-public-side-bar.service' import { flatMap, groupBy } from 'lodash' @@ -54,7 +54,7 @@ export class RecordOtherNamesService { this._http .get( - environment.API_WEB + `my-orcid/otherNamesForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/otherNamesForms.json`, { headers: this.headers, } @@ -77,7 +77,7 @@ export class RecordOtherNamesService { ): Observable { return this._http .post( - environment.API_WEB + `my-orcid/otherNamesForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/otherNamesForms.json`, otherNames, { headers: this.headers } ) diff --git a/src/app/core/record-peer-review/record-peer-review.service.ts b/src/app/core/record-peer-review/record-peer-review.service.ts index 58c52b1a9f..102c47674c 100644 --- a/src/app/core/record-peer-review/record-peer-review.service.ts +++ b/src/app/core/record-peer-review/record-peer-review.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { Observable, of, ReplaySubject } from 'rxjs' import { HttpClient, HttpHeaders } from '@angular/common/http' import { ErrorHandlerService } from '../error-handler/error-handler.service' -import { environment } from '../../../environments/environment' + import { PeerReview } from '../../types/record-peer-review.endpoint' import { UserRecordOptions } from 'src/app/types/record.local' import { RecordImportWizard } from '../../types/record-peer-review-import.endpoint' @@ -40,7 +40,7 @@ export class RecordPeerReviewService { this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + url + (options.sortAsc != null ? options.sortAsc : true) ) @@ -65,7 +65,7 @@ export class RecordPeerReviewService { if (options?.publicRecordId) { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + options.publicRecordId + '/peer-reviews-by-group-id.json?sortAsc=' + (options.sortAsc != null ? options.sortAsc : true) + @@ -80,7 +80,7 @@ export class RecordPeerReviewService { } else { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'peer-reviews/peer-reviews-by-group-id.json?sortAsc=' + (options.sortAsc != null ? options.sortAsc : true) + '&groupId=' + @@ -100,19 +100,19 @@ export class RecordPeerReviewService { getPeerReviewById(putCode: number): Observable { return this._http.get( - environment.API_WEB + 'peer-reviews/peer-review.json?putCode=' + putCode + runtimeEnvironment.API_WEB + 'peer-reviews/peer-review.json?putCode=' + putCode ) } getPeerReviewImportWizardList(): Observable { return this._http.get( - environment.API_WEB + 'workspace/retrieve-peer-review-import-wizards.json' + runtimeEnvironment.API_WEB + 'workspace/retrieve-peer-review-import-wizards.json' ) } getPublicPeerReviewById(orcid: string, putCode: number): Observable { return this._http.get( - environment.API_WEB + orcid + '/peer-review.json?putCode=' + putCode + runtimeEnvironment.API_WEB + orcid + '/peer-review.json?putCode=' + putCode ) } @@ -123,7 +123,7 @@ export class RecordPeerReviewService { ): Observable { return this._http .post( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'peer-reviews/' + putCode + '/visibility/' + @@ -145,7 +145,7 @@ export class RecordPeerReviewService { delete(putCode: string): Observable { return this._http - .delete(environment.API_WEB + 'peer-reviews/' + putCode, { + .delete(runtimeEnvironment.API_WEB + 'peer-reviews/' + putCode, { headers: this.headers, }) .pipe( @@ -158,7 +158,7 @@ export class RecordPeerReviewService { updatePreferredSource(putCode: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'peer-reviews/updateToMaxDisplay.json?putCode=' + putCode ) diff --git a/src/app/core/record-person/record-person.service.ts b/src/app/core/record-person/record-person.service.ts index 97cb3f539f..8ddc444535 100644 --- a/src/app/core/record-person/record-person.service.ts +++ b/src/app/core/record-person/record-person.service.ts @@ -80,7 +80,7 @@ export class RecordPersonService { private getPersonHttpCall(orcid: string): Observable { return this._http - .get(environment.API_WEB + `${orcid}/person.json`) + .get(runtimeEnvironment.API_WEB + `${orcid}/person.json`) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/record-personal-identifiers/record-person-identifier.service.ts b/src/app/core/record-personal-identifiers/record-person-identifier.service.ts index dd3c7c1f4a..c9114dc77d 100644 --- a/src/app/core/record-personal-identifiers/record-person-identifier.service.ts +++ b/src/app/core/record-personal-identifiers/record-person-identifier.service.ts @@ -55,7 +55,7 @@ export class RecordPersonIdentifierService { this._http .get( - environment.API_WEB + `my-orcid/externalIdentifiers.json`, + runtimeEnvironment.API_WEB + `my-orcid/externalIdentifiers.json`, { headers: this.headers, } @@ -81,7 +81,7 @@ export class RecordPersonIdentifierService { postPersonalIdentifiers(otherNames: PersonIdentifierEndpoint) { return this._http .post( - environment.API_WEB + `my-orcid/externalIdentifiers.json`, + runtimeEnvironment.API_WEB + `my-orcid/externalIdentifiers.json`, otherNames, { headers: this.headers, diff --git a/src/app/core/record-public-side-bar/record-public-side-bar.service.ts b/src/app/core/record-public-side-bar/record-public-side-bar.service.ts index 34215ba1ed..64079a6c66 100644 --- a/src/app/core/record-public-side-bar/record-public-side-bar.service.ts +++ b/src/app/core/record-public-side-bar/record-public-side-bar.service.ts @@ -47,7 +47,7 @@ export class RecordPublicSideBarService { return this._http .get( - environment.API_WEB + options.publicRecordId + `/public-record.json`, + runtimeEnvironment.API_WEB + options.publicRecordId + `/public-record.json`, { headers: this.headers, } diff --git a/src/app/core/record-research-resource/record-research-resource.service.ts b/src/app/core/record-research-resource/record-research-resource.service.ts index 887a3d5d56..703748ec0c 100644 --- a/src/app/core/record-research-resource/record-research-resource.service.ts +++ b/src/app/core/record-research-resource/record-research-resource.service.ts @@ -4,7 +4,7 @@ import { Observable, of, ReplaySubject } from 'rxjs' import { catchError, map, retry, tap } from 'rxjs/operators' import { UserRecordOptions } from 'src/app/types/record.local' -import { environment } from '../../../environments/environment' + import { ResearchResource, ResearchResourcesEndpoint, @@ -51,7 +51,7 @@ export class RecordResearchResourceService { this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + url + '?offset=' + options.offset + @@ -89,7 +89,7 @@ export class RecordResearchResourceService { getResearchResourceById(putCode: string): Observable { return this._http.get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'research-resources/researchResource.json?id=' + putCode ) @@ -97,7 +97,7 @@ export class RecordResearchResourceService { getPublicResearchResourceById(orcid, putCode): Observable { return this._http.get( - environment.API_WEB + orcid + '/researchResource.json?id=' + putCode + runtimeEnvironment.API_WEB + orcid + '/researchResource.json?id=' + putCode ) } @@ -107,7 +107,7 @@ export class RecordResearchResourceService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'research-resources/' + putCode + '/visibility/' + @@ -122,7 +122,7 @@ export class RecordResearchResourceService { delete(putCode: string): Observable { return this._http - .delete(environment.API_WEB + 'research-resources/' + putCode, { + .delete(runtimeEnvironment.API_WEB + 'research-resources/' + putCode, { headers: this.headers, }) .pipe( @@ -135,7 +135,7 @@ export class RecordResearchResourceService { updatePreferredSource(putCode: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'research-resources/updateToMaxDisplay.json?putCode=' + putCode ) diff --git a/src/app/core/record-websites/record-websites.service.ts b/src/app/core/record-websites/record-websites.service.ts index d6db5a7a70..5bfbb5d14f 100644 --- a/src/app/core/record-websites/record-websites.service.ts +++ b/src/app/core/record-websites/record-websites.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { Observable, of, ReplaySubject } from 'rxjs' import { WebsitesEndPoint } from '../../types/record-websites.endpoint' import { HttpClient, HttpHeaders } from '@angular/common/http' -import { environment } from '../../../environments/environment' + import { catchError, map, retry, tap } from 'rxjs/operators' import { ErrorHandlerService } from '../error-handler/error-handler.service' import { UserRecordOptions } from 'src/app/types/record.local' @@ -45,7 +45,7 @@ export class RecordWebsitesService { this._http .get( - environment.API_WEB + `my-orcid/websitesForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/websitesForms.json`, { headers: this.headers, } @@ -65,7 +65,7 @@ export class RecordWebsitesService { postWebsites(website: WebsitesEndPoint): Observable { return this._http .post( - environment.API_WEB + `my-orcid/websitesForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/websitesForms.json`, website, { headers: this.headers } ) diff --git a/src/app/core/record-works/record-works.service.spec.ts b/src/app/core/record-works/record-works.service.spec.ts index f7db945c01..657fa4bf29 100644 --- a/src/app/core/record-works/record-works.service.spec.ts +++ b/src/app/core/record-works/record-works.service.spec.ts @@ -18,7 +18,7 @@ import { WorkGroup, WorksEndpoint, } from '../../types/record-works.endpoint' -import { environment } from '../../../environments/environment.local' +import { environment } from '../../../environments/runtimeEnvironment.local' import { TogglzService } from '../togglz/togglz.service' import { of, ReplaySubject } from 'rxjs' import { UserService } from '..' @@ -73,7 +73,7 @@ describe('RecordWorksService', () => { .subscribe((workSaved) => { expect(workSaved).toBeTruthy() requestGetWorks = httpTestingController.match( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'works/worksExtendedPage.json?offset=0&sort=date&sortAsc=false&pageSize=50' ) @@ -83,7 +83,7 @@ describe('RecordWorksService', () => { requestGetWorks.forEach((getWorks) => { getWorks.flush({}) const requestGroupingSuggestions = httpTestingController.match( - environment.API_WEB + 'works/groupingSuggestions.json' + runtimeEnvironment.API_WEB + 'works/groupingSuggestions.json' ) expect(requestGroupingSuggestions.length).toEqual(1) requestGroupingSuggestions.forEach((grouping) => { @@ -95,7 +95,7 @@ describe('RecordWorksService', () => { }) const requestsSaveWorks = httpTestingController.match( - environment.API_WEB + 'works/work.json' + runtimeEnvironment.API_WEB + 'works/work.json' ) expect(requestsSaveWorks.length).toEqual(5) diff --git a/src/app/core/record-works/record-works.service.ts b/src/app/core/record-works/record-works.service.ts index 18df72ffda..68aeac1b15 100644 --- a/src/app/core/record-works/record-works.service.ts +++ b/src/app/core/record-works/record-works.service.ts @@ -113,7 +113,7 @@ export class RecordWorksService { this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + url + '?offset=' + options.offset + @@ -204,7 +204,7 @@ export class RecordWorksService { getWorkInfo(putCode: string, orcidId?: string): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `${ orcidId ? orcidId + '/' : 'works/' }getWorkInfo.json?workId=${putCode}` @@ -218,7 +218,7 @@ export class RecordWorksService { getWorksInfo(putCodes: string[], orcidId?: string): Observable { return this._http .get( - environment.API_WEB + `works/worksInfo/${putCodes.join(',')}` + runtimeEnvironment.API_WEB + `works/worksInfo/${putCodes.join(',')}` ) .pipe( retry(3), @@ -234,7 +234,7 @@ export class RecordWorksService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + `${ orcidId ? orcidId + '/' : 'works/' }worksPage.json?offset=${offset}&sort=${sort}&sortAsc=${sortAsc}&pageSize=50` @@ -251,7 +251,7 @@ export class RecordWorksService { isLastWorkElement = false ): Observable { return this._http - .post(environment.API_WEB + `works/work.json`, work) + .post(runtimeEnvironment.API_WEB + `works/work.json`, work) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), @@ -264,7 +264,7 @@ export class RecordWorksService { } getWork(): Observable { - return this._http.get(environment.API_WEB + `works/work.json`).pipe( + return this._http.get(runtimeEnvironment.API_WEB + `works/work.json`).pipe( retry(3), map((x) => { x.workExternalIdentifiers = [] @@ -291,7 +291,7 @@ export class RecordWorksService { return this._http .get( - environment.API_WEB + 'works/' + putCode + '/visibility/' + visibility + runtimeEnvironment.API_WEB + 'works/' + putCode + '/visibility/' + visibility ) .pipe( retry(3), @@ -303,7 +303,7 @@ export class RecordWorksService { updatePreferredSource(putCode: string): Observable { return this._http .get( - environment.API_WEB + 'works/updateToMaxDisplay.json?putCode=' + putCode + runtimeEnvironment.API_WEB + 'works/updateToMaxDisplay.json?putCode=' + putCode ) .pipe( retry(3), @@ -316,7 +316,7 @@ export class RecordWorksService { public loadWorkIdTypes(): Observable { return this._http - .get(`${environment.API_WEB}works/idTypes.json?query=`) + .get(`${runtimeEnvironment.API_WEB}works/idTypes.json?query=`) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) @@ -329,7 +329,7 @@ export class RecordWorksService { ): Observable { return this._http .get( - `${environment.API_WEB}works/id/${idType}?value=${workId}` + `${runtimeEnvironment.API_WEB}works/id/${idType}?value=${workId}` ) .pipe( retry(3), @@ -340,7 +340,7 @@ export class RecordWorksService { delete(putCode: any): Observable { return this._http .delete( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'works/' + (Array.isArray(putCode) ? putCode.join(',') : putCode) ) @@ -358,7 +358,7 @@ export class RecordWorksService { combinePutCodes(putCodes: string): Observable { return this._http .post( - environment.API_WEB + 'works/group/' + putCodes, + runtimeEnvironment.API_WEB + 'works/group/' + putCodes, {} ) .pipe( @@ -374,7 +374,7 @@ export class RecordWorksService { ): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'works/' + putCodes.join(',') + '/visibility/' + @@ -388,14 +388,14 @@ export class RecordWorksService { } export(): Observable { - return this._http.get(environment.API_WEB + 'works/works.bib', { + return this._http.get(runtimeEnvironment.API_WEB + 'works/works.bib', { responseType: 'text', }) } exportSelected(putCodes: string[]): Observable { return this._http.get( - environment.API_WEB + + runtimeEnvironment.API_WEB + 'works/export/bibtex?workIdsStr=' + putCodes.join(','), { @@ -406,7 +406,7 @@ export class RecordWorksService { loadWorkImportWizardList(): Observable { return this._http.get( - environment.API_WEB + 'workspace/retrieve-work-import-wizards.json' + runtimeEnvironment.API_WEB + 'workspace/retrieve-work-import-wizards.json' ) } @@ -421,12 +421,12 @@ export class RecordWorksService { url = result ? 'works/resolve/pmc/?value=' : 'works/resolve/pmid?value=' } - return this._http.get(environment.API_WEB + url + externalId) + return this._http.get(runtimeEnvironment.API_WEB + url + externalId) } worksValidate(obj): Observable { return this._http.post( - environment.API_WEB + 'works/worksValidate.json', + runtimeEnvironment.API_WEB + 'works/worksValidate.json', JSON.stringify(obj), { headers: { @@ -443,7 +443,7 @@ export class RecordWorksService { this.groupingSuggestionsSubjectInitialized = true this._http .get( - environment.API_WEB + 'works/groupingSuggestions.json', + runtimeEnvironment.API_WEB + 'works/groupingSuggestions.json', { headers: { 'Access-Control-Allow-Origin': '*', diff --git a/src/app/core/record/record.service.ts b/src/app/core/record/record.service.ts index 2086c5ba69..a8027b8a54 100644 --- a/src/app/core/record/record.service.ts +++ b/src/app/core/record/record.service.ts @@ -205,7 +205,7 @@ export class RecordService { return this.recordSubject$.asObservable() } attachDebugger() { - if (environment.debugger) { + if (runtimeEnvironment.debugger) { this.recordSubject$.subscribe((value) => { console.debug(value) }) @@ -215,7 +215,7 @@ export class RecordService { getExternalIdentifier(): Observable { return this._http .get( - environment.API_WEB + `my-orcid/externalIdentifiers.json`, + runtimeEnvironment.API_WEB + `my-orcid/externalIdentifiers.json`, { headers: this.headers } ) .pipe( @@ -226,7 +226,7 @@ export class RecordService { getKeywords(): Observable { return this._http - .get(environment.API_WEB + `my-orcid/keywordsForms.json`, { + .get(runtimeEnvironment.API_WEB + `my-orcid/keywordsForms.json`, { headers: this.headers, }) .pipe( @@ -241,7 +241,7 @@ export class RecordService { ): Observable { return this._http .post( - environment.API_WEB + `my-orcid/externalIdentifiers.json`, + runtimeEnvironment.API_WEB + `my-orcid/externalIdentifiers.json`, website, { headers: this.headers } ) @@ -254,7 +254,7 @@ export class RecordService { postKeywords(keywords: Keywords): Observable { return this._http .post( - environment.API_WEB + `my-orcid/keywordsForms.json`, + runtimeEnvironment.API_WEB + `my-orcid/keywordsForms.json`, keywords, { headers: this.headers } ) @@ -276,7 +276,7 @@ export class RecordService { return this._http .get( - environment.API_WEB + `account/preferences.json`, + runtimeEnvironment.API_WEB + `account/preferences.json`, { headers: this.headers } ) @@ -290,7 +290,7 @@ export class RecordService { postPreferences(names: Preferences): Observable { return this._http .post( - environment.API_WEB + `account/preferences.json`, + runtimeEnvironment.API_WEB + `account/preferences.json`, names, { headers: this.headers } ) diff --git a/src/app/core/register/register.backend-validators.ts b/src/app/core/register/register.backend-validators.ts index f3597f7535..e2c49cc0c7 100644 --- a/src/app/core/register/register.backend-validators.ts +++ b/src/app/core/register/register.backend-validators.ts @@ -61,7 +61,7 @@ export function RegisterBackendValidatorMixin< ): Observable { return this._http .post( - environment.API_WEB + + runtimeEnvironment.API_WEB + `oauth/custom/register/${this.formInputs[controlName].validationEndpoint}.json`, value ) @@ -76,7 +76,7 @@ export function RegisterBackendValidatorMixin< ): Observable { return this._http .post( - `${environment.API_WEB}reactivateAdditionalEmailsValidate.json`, + `${runtimeEnvironment.API_WEB}reactivateAdditionalEmailsValidate.json`, value ) .pipe( @@ -168,7 +168,7 @@ export function RegisterBackendValidatorMixin< StepC ) return this._http - .post(`${environment.API_WEB}register.json`, registerForm) + .post(`${runtimeEnvironment.API_WEB}register.json`, registerForm) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/register/register.service.ts b/src/app/core/register/register.service.ts index 98e7fa6758..3e7c6070a6 100644 --- a/src/app/core/register/register.service.ts +++ b/src/app/core/register/register.service.ts @@ -52,7 +52,7 @@ export class RegisterService extends _RegisterServiceMixingBase { givenNames: string }) { return this._http - .get(environment.API_WEB + `dupicateResearcher.json`, { + .get(runtimeEnvironment.API_WEB + `dupicateResearcher.json`, { params: names, withCredentials: true, }) @@ -64,7 +64,7 @@ export class RegisterService extends _RegisterServiceMixingBase { getRegisterForm(): Observable { return this._http - .get(`${environment.API_WEB}register.json`, { + .get(`${runtimeEnvironment.API_WEB}register.json`, { withCredentials: true, }) .pipe( @@ -93,7 +93,7 @@ export class RegisterService extends _RegisterServiceMixingBase { return this._platform.get().pipe( first(), switchMap((platform) => { - let url = `${environment.API_WEB}` + let url = `${runtimeEnvironment.API_WEB}` if ( platform.institutional || platform.queryParameters.linkType === 'shibboleth' diff --git a/src/app/core/register2/register2.backend-validators.ts b/src/app/core/register2/register2.backend-validators.ts index 5d730df0ad..66dddf5cfd 100644 --- a/src/app/core/register2/register2.backend-validators.ts +++ b/src/app/core/register2/register2.backend-validators.ts @@ -63,7 +63,7 @@ export function Register2BackendValidatorMixin< ): Observable { return this._http .post( - environment.API_WEB + + runtimeEnvironment.API_WEB + `oauth/custom/register/${this.formInputs[controlName].validationEndpoint}.json`, value ) @@ -78,7 +78,7 @@ export function Register2BackendValidatorMixin< ): Observable { return this._http .post( - `${environment.API_WEB}reactivateAdditionalEmailsValidate.json`, + `${runtimeEnvironment.API_WEB}reactivateAdditionalEmailsValidate.json`, value ) .pipe( @@ -175,7 +175,7 @@ export function Register2BackendValidatorMixin< StepD ) return this._http - .post(`${environment.API_WEB}register.json`, registerForm) + .post(`${runtimeEnvironment.API_WEB}register.json`, registerForm) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/register2/register2.service.ts b/src/app/core/register2/register2.service.ts index 627e8ed9bb..3859631cf2 100644 --- a/src/app/core/register2/register2.service.ts +++ b/src/app/core/register2/register2.service.ts @@ -53,7 +53,7 @@ export class Register2Service extends _RegisterServiceMixingBase { givenNames: string }) { return this._http - .get(environment.API_WEB + `dupicateResearcher.json`, { + .get(runtimeEnvironment.API_WEB + `dupicateResearcher.json`, { params: names, withCredentials: true, }) @@ -65,7 +65,7 @@ export class Register2Service extends _RegisterServiceMixingBase { getRegisterForm(): Observable { return this._http - .get(`${environment.API_WEB}register.json`, { + .get(`${runtimeEnvironment.API_WEB}register.json`, { withCredentials: true, }) .pipe( @@ -77,7 +77,7 @@ export class Register2Service extends _RegisterServiceMixingBase { getEmailCategory(email: string): Observable { return this._http.get( - `${environment.API_WEB}email-domain/find-category?domain=${email}` + `${runtimeEnvironment.API_WEB}email-domain/find-category?domain=${email}` ) } @@ -104,7 +104,7 @@ export class Register2Service extends _RegisterServiceMixingBase { return this._platform.get().pipe( first(), switchMap((platform) => { - let url = `${environment.API_WEB}` + let url = `${runtimeEnvironment.API_WEB}` if ( platform.institutional || platform.queryParameters.linkType === 'shibboleth' diff --git a/src/app/core/robots-meta-tags/robots-meta-tags.service.ts b/src/app/core/robots-meta-tags/robots-meta-tags.service.ts index cce8e24ce3..67a74d8a55 100644 --- a/src/app/core/robots-meta-tags/robots-meta-tags.service.ts +++ b/src/app/core/robots-meta-tags/robots-meta-tags.service.ts @@ -19,8 +19,8 @@ export class RobotsMetaTagsService { }) } restoreEnvironmentRobotsConfig() { - if (environment.ROBOTS) { - this.meta.updateTag({ name: this.robots, content: environment.ROBOTS }) + if (runtimeEnvironment.ROBOTS) { + this.meta.updateTag({ name: this.robots, content: runtimeEnvironment.ROBOTS }) } else { // If not defined by the environment do not allow robots this.meta.updateTag({ diff --git a/src/app/core/search/search.service.ts b/src/app/core/search/search.service.ts index a484e67545..940590a898 100644 --- a/src/app/core/search/search.service.ts +++ b/src/app/core/search/search.service.ts @@ -27,7 +27,7 @@ export class SearchService { search(querryParam: SearchParameters): Observable { return this._http .get( - `${environment.API_PUB}/expanded-search/${this.buildSearchUrl( + `${runtimeEnvironment.API_PUB}/expanded-search/${this.buildSearchUrl( querryParam )}`, { diff --git a/src/app/core/sign-in/sign-in.service.ts b/src/app/core/sign-in/sign-in.service.ts index 81e7402b9e..00b8e13c0c 100644 --- a/src/app/core/sign-in/sign-in.service.ts +++ b/src/app/core/sign-in/sign-in.service.ts @@ -2,7 +2,7 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { catchError, map, retry, switchMap, first } from 'rxjs/operators' -import { environment } from '../../../environments/environment' + import { getOrcidNumber, isValidOrcidFormat } from '../../constants' import { Claim } from '../../types/claim.endpoint' import { Reactivation } from '../../types/reactivation.endpoint' @@ -55,7 +55,7 @@ export class SignInService { } body = body.set('oauthRequest', signInLocal.isOauth ? 'true' : 'false') return this._http - .post(environment.API_WEB + loginUrl, body, { + .post(runtimeEnvironment.API_WEB + loginUrl, body, { withCredentials: true, }) .pipe( @@ -77,7 +77,7 @@ export class SignInService { let body = new HttpParams({ encoder: new CustomEncoder() }) body = body.set(isValidOrcidFormat(username) ? 'orcid' : 'email', username) return this._http - .post(environment.API_WEB + `sendReactivation.json`, body, { + .post(runtimeEnvironment.API_WEB + `sendReactivation.json`, body, { withCredentials: true, }) .pipe( @@ -100,7 +100,7 @@ export class SignInService { let body = JSON.stringify(claim) return this._http - .post(environment.API_WEB + `resend-claim.json`, body, { + .post(runtimeEnvironment.API_WEB + `resend-claim.json`, body, { headers: new HttpHeaders({ 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json', @@ -121,7 +121,7 @@ export class SignInService { singOut() { this._titleService.setTitle('ORCID') return this._http - .get(environment.API_WEB + 'userStatus.json?logUserOut=true', { + .get(runtimeEnvironment.API_WEB + 'userStatus.json?logUserOut=true', { withCredentials: true, }) .pipe( diff --git a/src/app/core/togglz/togglz.service.ts b/src/app/core/togglz/togglz.service.ts index 24e2817895..6acb41336b 100644 --- a/src/app/core/togglz/togglz.service.ts +++ b/src/app/core/togglz/togglz.service.ts @@ -16,7 +16,7 @@ export class TogglzService { constructor(private _http: HttpClient, private userService: UserService) {} private getConfig() { - return this._http.get(environment.API_WEB + 'config.json', { + return this._http.get(runtimeEnvironment.API_WEB + 'config.json', { withCredentials: true, }) } diff --git a/src/app/core/trusted-individuals/trusted-individuals.service.ts b/src/app/core/trusted-individuals/trusted-individuals.service.ts index 5dd23cb6d5..8104e9a1ac 100644 --- a/src/app/core/trusted-individuals/trusted-individuals.service.ts +++ b/src/app/core/trusted-individuals/trusted-individuals.service.ts @@ -14,7 +14,7 @@ export class TrustedIndividualsService { getTrustedIndividuals(): Observable { return this._http .get( - `${environment.API_WEB}delegators/delegators-and-me.json`, + `${runtimeEnvironment.API_WEB}delegators/delegators-and-me.json`, { withCredentials: true, } diff --git a/src/app/core/trusted-summary/trusted-summary.service.ts b/src/app/core/trusted-summary/trusted-summary.service.ts index b30169e3a6..d80d0d4dd3 100644 --- a/src/app/core/trusted-summary/trusted-summary.service.ts +++ b/src/app/core/trusted-summary/trusted-summary.service.ts @@ -23,7 +23,7 @@ export class TrustedSummaryService { getSummary(orcid): Observable { let url = orcid + '/summary.json' return this._http - .get(environment.BASE_URL + url, { + .get(runtimeEnvironment.BASE_URL + url, { headers: this.headers, }) .pipe( diff --git a/src/app/core/two-factor-authentication/two-factor-authentication.service.ts b/src/app/core/two-factor-authentication/two-factor-authentication.service.ts index d8dad0fcdb..363c394618 100644 --- a/src/app/core/two-factor-authentication/two-factor-authentication.service.ts +++ b/src/app/core/two-factor-authentication/two-factor-authentication.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { HttpClient, HttpHeaders } from '@angular/common/http' import { Observable } from 'rxjs/internal/Observable' -import { environment } from '../../../environments/environment' + import { QrCode, Status, @@ -26,12 +26,12 @@ export class TwoFactorAuthenticationService { ) {} checkState(): Observable { - return this._http.get(environment.BASE_URL + '2FA/status.json') + return this._http.get(runtimeEnvironment.BASE_URL + '2FA/status.json') } disable(): Observable { return this._http.post( - environment.BASE_URL + '2FA/disable.json', + runtimeEnvironment.BASE_URL + '2FA/disable.json', {}, { headers: this.headers } ) @@ -39,17 +39,17 @@ export class TwoFactorAuthenticationService { getTextCode(): Observable<{ secret: string }> { return this._http.get<{ secret: string }>( - environment.BASE_URL + '2FA/secret.json' + runtimeEnvironment.BASE_URL + '2FA/secret.json' ) } startSetup(): Observable { - return this._http.get(environment.BASE_URL + '2FA/QRCode.json') + return this._http.get(runtimeEnvironment.BASE_URL + '2FA/QRCode.json') } register(obj): Observable { return this._http.post( - environment.BASE_URL + '2FA/register.json', + runtimeEnvironment.BASE_URL + '2FA/register.json', JSON.stringify(obj), { headers: this.headers } ) @@ -57,7 +57,7 @@ export class TwoFactorAuthenticationService { sendVerificationCode(obj): Observable { return this._http.post( - environment.BASE_URL + '2FA/QRCode.json', + runtimeEnvironment.BASE_URL + '2FA/QRCode.json', JSON.stringify(obj), { headers: this.headers } ) @@ -69,7 +69,7 @@ export class TwoFactorAuthenticationService { url = 'social/2FA/submitCode.json' } return this._http - .post(environment.BASE_URL + url, twoFactor, { + .post(runtimeEnvironment.BASE_URL + url, twoFactor, { headers: this.headers, }) .pipe( @@ -82,7 +82,7 @@ export class TwoFactorAuthenticationService { submitCodeForAnotherAccount(code: TwoFactor) { return this._http - .post(environment.BASE_URL + `2FA/submitCode.json`, code, { + .post(runtimeEnvironment.BASE_URL + `2FA/submitCode.json`, code, { headers: this.headers, }) .pipe( diff --git a/src/app/core/user-info/user-info.service.ts b/src/app/core/user-info/user-info.service.ts index 5e012843be..b23616bead 100644 --- a/src/app/core/user-info/user-info.service.ts +++ b/src/app/core/user-info/user-info.service.ts @@ -26,7 +26,7 @@ export class UserInfoService { public getUserInfo(options?: UserRecordOptions): Observable { return this._http .get( - environment.API_WEB + + runtimeEnvironment.API_WEB + (options?.publicRecordId ? options.publicRecordId + '/' : '') + 'userInfo.json', { diff --git a/src/app/core/user/user.service.ts b/src/app/core/user/user.service.ts index 265d1f69de..a781014cfa 100644 --- a/src/app/core/user/user.service.ts +++ b/src/app/core/user/user.service.ts @@ -95,7 +95,7 @@ export class UserService { public getUserStatus(): Observable { return this._http - .get(environment.API_WEB + 'userStatus.json', { + .get(runtimeEnvironment.API_WEB + 'userStatus.json', { withCredentials: true, }) .pipe(map((response) => !!response.loggedIn)) @@ -109,7 +109,7 @@ export class UserService { private getNameForm(): Observable { return this._http.get( - environment.API_WEB + 'account/nameForm.json', + runtimeEnvironment.API_WEB + 'account/nameForm.json', { withCredentials: true, } @@ -196,7 +196,7 @@ export class UserService { map((data) => this.computesUpdatedUserData(data)), // Debugger for the user session on development time tap((session) => - environment.debugger ? console.debug(session) : null + runtimeEnvironment.debugger ? console.debug(session) : null ), tap((session) => { this.$userSessionSubject.next(session) @@ -260,7 +260,7 @@ export class UserService { ? data.userInfo.EFFECTIVE_USER_ORCID : data.userInfo.REAL_USER_ORCID if (orcidId) { - return 'https:' + environment.BASE_URL + orcidId + return 'https:' + runtimeEnvironment.BASE_URL + orcidId } } return undefined @@ -322,7 +322,7 @@ export class UserService { return this._oauth.declareOauthSession(params, updateParameters).pipe( tap((session) => (this.keepRefreshingUserSession = !session.error)), tap(() => - environment.debugger + runtimeEnvironment.debugger ? console.debug('Oauth session declare') : null ) @@ -457,7 +457,7 @@ export class UserService { delegator.giverOrcid.path ) return this._http - .post(`${environment.API_WEB}switch-user`, '', { + .post(`${runtimeEnvironment.API_WEB}switch-user`, '', { headers: this.headers, params: params, }) @@ -498,7 +498,7 @@ export class UserService { noRedirectLogout() { return this._http - .get(`${environment.API_WEB}signout`, { + .get(`${runtimeEnvironment.API_WEB}signout`, { headers: this.headers, observe: 'response', responseType: 'text', diff --git a/src/app/core/wordpress/wordpress.service.spec.ts b/src/app/core/wordpress/wordpress.service.spec.ts index d2010ebdad..b65a373659 100644 --- a/src/app/core/wordpress/wordpress.service.spec.ts +++ b/src/app/core/wordpress/wordpress.service.spec.ts @@ -43,7 +43,7 @@ describe('WordpressService', () => { expect(html).toContain(mockHtml) }) - const req = httpMock.expectOne(`${environment.WORDPRESS_S3}/index.html`) + const req = httpMock.expectOne(`${runtimeEnvironment.WORDPRESS_S3}/index.html`) expect(req.request.method).toBe('GET') req.flush(mockHtml) }) @@ -55,12 +55,12 @@ describe('WordpressService', () => { }) const primaryReq = httpMock.expectOne( - `${environment.WORDPRESS_S3}/index.html` + `${runtimeEnvironment.WORDPRESS_S3}/index.html` ) primaryReq.flush(null, { status: 500, statusText: 'Server Error' }) const fallbackReq = httpMock.expectOne( - `${environment.WORDPRESS_S3_FALLBACK}/index.html` + `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/index.html` ) expect(fallbackReq.request.method).toBe('GET') fallbackReq.flush(mockHtml) @@ -73,7 +73,7 @@ describe('WordpressService', () => { }) const req = httpMock.expectOne( - `${environment.WORDPRESS_S3}/wordpress-homepage.css` + `${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.css` ) expect(req.request.method).toBe('GET') req.flush(mockCss) @@ -86,12 +86,12 @@ describe('WordpressService', () => { }) const primaryReq = httpMock.expectOne( - `${environment.WORDPRESS_S3}/wordpress-homepage.css` + `${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.css` ) primaryReq.flush(null, { status: 500, statusText: 'Server Error' }) const fallbackReq = httpMock.expectOne( - `${environment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.css` + `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.css` ) expect(fallbackReq.request.method).toBe('GET') fallbackReq.flush(mockCss) @@ -104,7 +104,7 @@ describe('WordpressService', () => { }) const req = httpMock.expectOne( - `${environment.WORDPRESS_S3}/wordpress-homepage.js` + `${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.js` ) expect(req.request.method).toBe('GET') req.flush(mockJs) @@ -117,12 +117,12 @@ describe('WordpressService', () => { }) const primaryReq = httpMock.expectOne( - `${environment.WORDPRESS_S3}/wordpress-homepage.js` + `${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.js` ) primaryReq.flush(null, { status: 500, statusText: 'Server Error' }) const fallbackReq = httpMock.expectOne( - `${environment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.js` + `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.js` ) expect(fallbackReq.request.method).toBe('GET') fallbackReq.flush(mockJs) @@ -131,13 +131,13 @@ describe('WordpressService', () => { it('should fetch home page post from primary URL and update asset paths', () => { const mockHtml = '' - const expectedHtml = `` + const expectedHtml = `` service.getHomePagePost().subscribe((html) => { expect(html).toBe(expectedHtml) }) - const req = httpMock.expectOne(`${environment.WORDPRESS_S3}/index.html`) + const req = httpMock.expectOne(`${runtimeEnvironment.WORDPRESS_S3}/index.html`) expect(req.request.method).toBe('GET') req.flush(mockHtml) }) @@ -145,19 +145,19 @@ describe('WordpressService', () => { it('should fetch home page post from fallback URL and update asset paths when primary fails', () => { const mockHtml = '' - const expectedHtml = `` + const expectedHtml = `` service.getHomePagePost().subscribe((html) => { expect(html).toBe(expectedHtml) }) const primaryReq = httpMock.expectOne( - `${environment.WORDPRESS_S3}/index.html` + `${runtimeEnvironment.WORDPRESS_S3}/index.html` ) primaryReq.flush(null, { status: 500, statusText: 'Server Error' }) const fallbackReq = httpMock.expectOne( - `${environment.WORDPRESS_S3_FALLBACK}/index.html` + `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/index.html` ) expect(fallbackReq.request.method).toBe('GET') fallbackReq.flush(mockHtml) diff --git a/src/app/core/wordpress/wordpress.service.ts b/src/app/core/wordpress/wordpress.service.ts index 5af43363ed..8573b906d1 100644 --- a/src/app/core/wordpress/wordpress.service.ts +++ b/src/app/core/wordpress/wordpress.service.ts @@ -15,10 +15,10 @@ export class WordpressService { getHomePagePost(): Observable { const primaryUrl = `${ - environment.WORDPRESS_S3 + runtimeEnvironment.WORDPRESS_S3 }/index${this.getWordpressLocalizationCode()}.html` const fallbackUrl = `${ - environment.WORDPRESS_S3_FALLBACK + runtimeEnvironment.WORDPRESS_S3_FALLBACK }/index${this.getWordpressLocalizationCode()}.html` return this.fetchWithFallback(primaryUrl, fallbackUrl).pipe( map((data: { html: string; url: string }) => { @@ -34,8 +34,8 @@ export class WordpressService { } getHomePageCSS(): Observable { - const primaryUrl = `${environment.WORDPRESS_S3}/wordpress-homepage.css` - const fallbackUrl = `${environment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.css` + const primaryUrl = `${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.css` + const fallbackUrl = `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.css` return this.fetchWithFallback(primaryUrl, fallbackUrl).pipe( map((data: { html: string; url: string }) => { const find = 'assets/' @@ -50,8 +50,8 @@ export class WordpressService { } getHomePageJS(): Observable { - const primaryUrl = `${environment.WORDPRESS_S3}/wordpress-homepage.js` - const fallbackUrl = `${environment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.js` + const primaryUrl = `${runtimeEnvironment.WORDPRESS_S3}/wordpress-homepage.js` + const fallbackUrl = `${runtimeEnvironment.WORDPRESS_S3_FALLBACK}/wordpress-homepage.js` return this.fetchWithFallback(primaryUrl, fallbackUrl).pipe( map((data: { html: string; url: string }) => { const find = './assets/' diff --git a/src/app/environment-banner/environment-banner/environment-banner.component.ts b/src/app/environment-banner/environment-banner/environment-banner.component.ts index 282df0394f..f737a821c7 100644 --- a/src/app/environment-banner/environment-banner/environment-banner.component.ts +++ b/src/app/environment-banner/environment-banner/environment-banner.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, Inject, HostBinding } from '@angular/core' import { CookieService } from 'ngx-cookie-service' import { WINDOW } from 'src/app/cdk/window' -import { environment } from '../../../environments/environment' + @Component({ selector: 'app-environment-banner', @@ -11,7 +11,7 @@ import { environment } from '../../../environments/environment' }) export class EnvironmentBannerComponent implements OnInit { hostUrl - canDismiss = environment['CAN_DISABLE_TEST_WARNING_BANNER'] + canDismiss = runtimeEnvironment['CAN_DISABLE_TEST_WARNING_BANNER'] @HostBinding('style.display') display = 'none' labelWarning = $localize`:@@environmentBanner.ariaLabelWarning:Warning, testing website` notInsideIframe: boolean diff --git a/src/app/guards/language.guard.ts b/src/app/guards/language.guard.ts index a02abe324c..ba0502d30f 100644 --- a/src/app/guards/language.guard.ts +++ b/src/app/guards/language.guard.ts @@ -35,7 +35,7 @@ export class LanguageGuard { // get language context langContext = this.getLanguageContext(next.queryParams) - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug('language context', langContext) } }), diff --git a/src/app/home/components/news/news.component.ts b/src/app/home/components/news/news.component.ts index ecc896f03a..e343f9f848 100644 --- a/src/app/home/components/news/news.component.ts +++ b/src/app/home/components/news/news.component.ts @@ -36,6 +36,6 @@ export class NewsComponent implements OnInit { } moreNews() { - this.window.location.href = environment.INFO_SITE + this.window.location.href = runtimeEnvironment.INFO_SITE } } diff --git a/src/app/home/pages/home/home.component.ts b/src/app/home/pages/home/home.component.ts index a02e61b5b4..ecb82aa63a 100644 --- a/src/app/home/pages/home/home.component.ts +++ b/src/app/home/pages/home/home.component.ts @@ -88,7 +88,7 @@ export class HomeComponent implements OnInit { } goto(url) { - this.window.location.href = environment.BASE_URL + url + this.window.location.href = runtimeEnvironment.BASE_URL + url } ngOnInit() {} diff --git a/src/app/institutional/pages/institutional/institutional.component.ts b/src/app/institutional/pages/institutional/institutional.component.ts index 18929cb089..b69f7fa16b 100644 --- a/src/app/institutional/pages/institutional/institutional.component.ts +++ b/src/app/institutional/pages/institutional/institutional.component.ts @@ -91,7 +91,7 @@ export class InstitutionalComponent implements OnInit { filterInput ) return institutionsFiltered.length > - environment.INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT + runtimeEnvironment.INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT ? [] : institutionsFiltered }) @@ -123,10 +123,10 @@ export class InstitutionalComponent implements OnInit { this.addUserSelectedIdPs() const defaultReturn = 'https:' + - environment.BASE_URL + + runtimeEnvironment.BASE_URL + 'Shibboleth.sso/Login?SAMLDS=1&target=' + encodeURIComponent( - 'https:' + environment.BASE_URL + 'shibboleth/signin' + 'https:' + runtimeEnvironment.BASE_URL + 'shibboleth/signin' ) this.navigateTo( diff --git a/src/app/layout/footer/footer.component.ts b/src/app/layout/footer/footer.component.ts index 28d8067cc4..a7c9c756fb 100644 --- a/src/app/layout/footer/footer.component.ts +++ b/src/app/layout/footer/footer.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, Inject } from '@angular/core' import { PlatformInfoService } from 'src/app/cdk/platform-info' import { WINDOW } from 'src/app/cdk/window' -import { environment } from '../../../environments/environment' + import { RecordUtil } from 'src/app/shared/utils/record.util' @Component({ @@ -13,7 +13,7 @@ import { RecordUtil } from 'src/app/shared/utils/record.util' export class FooterComponent implements OnInit { platform labelFooter = $localize`:@@layout.ariaLabelFooter:footer` - infoSiteBaseUrl = environment.INFO_SITE + infoSiteBaseUrl = runtimeEnvironment.INFO_SITE isDesktop = false isTablet = false isMobile = false diff --git a/src/app/layout/header/header.component.ts b/src/app/layout/header/header.component.ts index 21a74ecf69..1298117b47 100644 --- a/src/app/layout/header/header.component.ts +++ b/src/app/layout/header/header.component.ts @@ -13,7 +13,7 @@ import { } from 'src/app/types/menu.local' import { Config } from 'src/app/types/togglz.endpoint' -import { environment } from '../../../environments/environment' + import { ApplicationRoutes, ORCID_REGEXP } from '../../constants' import { menu } from './menu' @@ -267,12 +267,12 @@ export class HeaderComponent implements OnInit { this._router.navigate([ApplicationRoutes.signin]) this.mobileMenuState = false } else if (route === 'signout') { - if (environment.proxyMode) { + if (runtimeEnvironment.proxyMode) { this._user.noRedirectLogout().subscribe() } this.window.location.href = route } else { - ;(this.window as any).outOfRouterNavigation(environment.INFO_SITE + route) + ;(this.window as any).outOfRouterNavigation(runtimeEnvironment.INFO_SITE + route) } } } diff --git a/src/app/layout/language/language.component.ts b/src/app/layout/language/language.component.ts index 0a8cf74d5f..9532da686f 100644 --- a/src/app/layout/language/language.component.ts +++ b/src/app/layout/language/language.component.ts @@ -17,10 +17,10 @@ export class LanguageComponent implements OnInit { @Inject(WINDOW) private window: Window, private _language: LanguageService ) { - this.languageMenuOptions = environment.LANGUAGE_MENU_OPTIONS + this.languageMenuOptions = runtimeEnvironment.LANGUAGE_MENU_OPTIONS // LOCAL DEV GET'S `en-US` from locale but `en` is required this.locale = this.locale === 'en-US' ? 'en' : this.locale - this.labelLanguage += ` ${environment.LANGUAGE_MENU_OPTIONS[this.locale]}` + this.labelLanguage += ` ${runtimeEnvironment.LANGUAGE_MENU_OPTIONS[this.locale]}` } changeLanguage(languageKey: string) { diff --git a/src/app/layout/user-menu/user-menu.component.ts b/src/app/layout/user-menu/user-menu.component.ts index 20affc0d8c..72842d0d3a 100644 --- a/src/app/layout/user-menu/user-menu.component.ts +++ b/src/app/layout/user-menu/user-menu.component.ts @@ -75,12 +75,12 @@ export class UserMenuComponent implements OnInit { } else if (url === 'developer-tools') { this._router.navigate([ApplicationRoutes.developerTools]) } else { - this.window.location.href = environment.BASE_URL + url + this.window.location.href = runtimeEnvironment.BASE_URL + url } } navigateTo(val) { - if (val === '/signout' && environment.proxyMode) { + if (val === '/signout' && runtimeEnvironment.proxyMode) { this._userInfo.noRedirectLogout().subscribe() } else { this.window.location.href = val diff --git a/src/app/record/components/peer-review-stacks-groups/modals/modal-peer-reviews/modal-peer-reviews.component.ts b/src/app/record/components/peer-review-stacks-groups/modals/modal-peer-reviews/modal-peer-reviews.component.ts index a2266f1d9a..25ebc364c1 100644 --- a/src/app/record/components/peer-review-stacks-groups/modals/modal-peer-reviews/modal-peer-reviews.component.ts +++ b/src/app/record/components/peer-review-stacks-groups/modals/modal-peer-reviews/modal-peer-reviews.component.ts @@ -40,7 +40,7 @@ export class ModalPeerReviewsComponent implements OnInit, OnDestroy { return client.clientWebsite } else { return ( - environment.BASE_URL + + runtimeEnvironment.BASE_URL + 'oauth/authorize' + '?client_id=' + client.id + diff --git a/src/app/record/components/record-header/record-header.component.ts b/src/app/record/components/record-header/record-header.component.ts index ce3ff051d8..87d6c0c4e6 100644 --- a/src/app/record/components/record-header/record-header.component.ts +++ b/src/app/record/components/record-header/record-header.component.ts @@ -78,7 +78,7 @@ export class RecordHeaderComponent implements OnInit { ) {} ngOnInit(): void { - this.orcidId = 'https:' + environment.BASE_URL + this.isPublicRecord + this.orcidId = 'https:' + runtimeEnvironment.BASE_URL + this.isPublicRecord this._platform .get() @@ -144,7 +144,7 @@ export class RecordHeaderComponent implements OnInit { printRecord() { this.window.open( - environment.BASE_URL + + runtimeEnvironment.BASE_URL + this.userRecord?.userInfo?.EFFECTIVE_USER_ORCID + '/print' ) diff --git a/src/app/record/components/record-info/record-info.component.ts b/src/app/record/components/record-info/record-info.component.ts index 1725fd68be..9c00e47abb 100644 --- a/src/app/record/components/record-info/record-info.component.ts +++ b/src/app/record/components/record-info/record-info.component.ts @@ -21,7 +21,7 @@ export class RecordInfoComponent implements OnInit { userInfo: UserInfo isNamePublic: boolean - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor(private _record: RecordService) {} diff --git a/src/app/record/components/search-link-wizard/search-link-wizard.component.ts b/src/app/record/components/search-link-wizard/search-link-wizard.component.ts index e7a1602443..b4dbb822d3 100644 --- a/src/app/record/components/search-link-wizard/search-link-wizard.component.ts +++ b/src/app/record/components/search-link-wizard/search-link-wizard.component.ts @@ -19,7 +19,7 @@ export class SearchLinkWizardComponent implements OnInit { return client.clientWebsite } else { return ( - environment.BASE_URL + + runtimeEnvironment.BASE_URL + 'oauth/authorize' + '?client_id=' + client.id + diff --git a/src/app/record/components/top-bar-actions/top-bar-actions.component.ts b/src/app/record/components/top-bar-actions/top-bar-actions.component.ts index d2e73d4a59..2be5ead8ed 100644 --- a/src/app/record/components/top-bar-actions/top-bar-actions.component.ts +++ b/src/app/record/components/top-bar-actions/top-bar-actions.component.ts @@ -46,7 +46,7 @@ export class TopBarActionsComponent implements OnInit, OnDestroy { printRecord() { this.window.open( - environment.BASE_URL + + runtimeEnvironment.BASE_URL + this.userRecord?.userInfo?.EFFECTIVE_USER_ORCID + '/print' ) diff --git a/src/app/record/components/top-bar-record-issues/top-bar-record-issues.component.ts b/src/app/record/components/top-bar-record-issues/top-bar-record-issues.component.ts index b0512ca025..768bd26f4d 100644 --- a/src/app/record/components/top-bar-record-issues/top-bar-record-issues.component.ts +++ b/src/app/record/components/top-bar-record-issues/top-bar-record-issues.component.ts @@ -15,7 +15,7 @@ export class TopBarRecordIssuesComponent implements OnInit, OnDestroy { @Input() isPublicRecord: string $destroy: Subject = new Subject() userInfo: UserInfo - baseUrl = environment.BASE_URL + baseUrl = runtimeEnvironment.BASE_URL constructor(private _record: RecordService) {} diff --git a/src/app/record/components/work-contributors/work-contributors.component.ts b/src/app/record/components/work-contributors/work-contributors.component.ts index c70bd32096..ee161173dc 100644 --- a/src/app/record/components/work-contributors/work-contributors.component.ts +++ b/src/app/record/components/work-contributors/work-contributors.component.ts @@ -274,7 +274,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy { contributorOrcid: this.formBuilder.group({ path: [orcid ? orcid : null], uri: [ - uri ? uri : orcid ? `https:${environment.BASE_URL}${orcid}` : null, + uri ? uri : orcid ? `https:${runtimeEnvironment.BASE_URL}${orcid}` : null, ], }), roles: new UntypedFormArray([]), @@ -394,7 +394,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy { : this.getCreditNameFromUserRecord() const uri = this.recordHolderContribution?.contributorOrcid?.uri ? this.recordHolderContribution?.contributorOrcid?.uri - : `https:${environment.BASE_URL}${orcid}` + : `https:${runtimeEnvironment.BASE_URL}${orcid}` // todo validate if its necessary if (!this.recordHolderContribution) { this.recordHolderContribution = { diff --git a/src/app/register/components/step-a/step-a.component.ts b/src/app/register/components/step-a/step-a.component.ts index cc3c652e92..e4836a4878 100644 --- a/src/app/register/components/step-a/step-a.component.ts +++ b/src/app/register/components/step-a/step-a.component.ts @@ -20,7 +20,7 @@ export class StepAComponent extends BaseStepDirective { constructor(private _platform: PlatformInfoService, private _router: Router) { super() } - infoSiteBaseUrl = environment.INFO_SITE + infoSiteBaseUrl = runtimeEnvironment.INFO_SITE goForward() { this.formGroup.markAllAsTouched() diff --git a/src/app/register2/components/form-password/form-password.component.ts b/src/app/register2/components/form-password/form-password.component.ts index 2485228992..50ebbbd4c1 100644 --- a/src/app/register2/components/form-password/form-password.component.ts +++ b/src/app/register2/components/form-password/form-password.component.ts @@ -311,7 +311,7 @@ export class FormPasswordComponent } private announce(announcement: string) { - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug('📢' + announcement) } this._liveAnnouncer.announce(announcement, 'assertive') diff --git a/src/app/register2/components/form-personal/form-personal.component.ts b/src/app/register2/components/form-personal/form-personal.component.ts index 043b19e13b..2a35b0850d 100644 --- a/src/app/register2/components/form-personal/form-personal.component.ts +++ b/src/app/register2/components/form-personal/form-personal.component.ts @@ -357,7 +357,7 @@ export class FormPersonalComponent } private announce(announcement: string) { - if (environment.debugger) { + if (runtimeEnvironment.debugger) { console.debug('📢' + announcement) } this._liveAnnouncer.announce(announcement, 'assertive') diff --git a/src/app/register2/components/step-a/step-a.component.ts b/src/app/register2/components/step-a/step-a.component.ts index 664f9a5ffd..c63a042ddc 100644 --- a/src/app/register2/components/step-a/step-a.component.ts +++ b/src/app/register2/components/step-a/step-a.component.ts @@ -46,7 +46,7 @@ export class StepAComponent } ngOnInit(): void {} - infoSiteBaseUrl = environment.INFO_SITE + infoSiteBaseUrl = runtimeEnvironment.INFO_SITE goBack() { this._registerStateService.registerStepperButtonClicked('a', 'back') diff --git a/src/app/sign-in/components/logged-in/logged-in.component.ts b/src/app/sign-in/components/logged-in/logged-in.component.ts index 949b39ab90..74d51327c5 100644 --- a/src/app/sign-in/components/logged-in/logged-in.component.ts +++ b/src/app/sign-in/components/logged-in/logged-in.component.ts @@ -20,7 +20,7 @@ export class LoggedInComponent implements OnInit { ngOnInit() {} navigateTo(val) { - if (val === '/signout' && environment.proxyMode) { + if (val === '/signout' && runtimeEnvironment.proxyMode) { this.user.noRedirectLogout().subscribe() } else { this.window.location.href = val diff --git a/src/app/sign-in/components/social/social.component.ts b/src/app/sign-in/components/social/social.component.ts index 95b668d525..90942237ff 100644 --- a/src/app/sign-in/components/social/social.component.ts +++ b/src/app/sign-in/components/social/social.component.ts @@ -32,7 +32,7 @@ export class SocialComponent implements OnInit { _platform.get().subscribe((data) => { this.platform = data }) - this.baseUri = environment.API_WEB + this.baseUri = runtimeEnvironment.API_WEB this.csrf = this._cookie.get('XSRF-TOKEN') } diff --git a/src/assets/local-dev-environment.js b/src/assets/local-dev-environment.js new file mode 100644 index 0000000000..95397e981b --- /dev/null +++ b/src/assets/local-dev-environment.js @@ -0,0 +1,62 @@ +//DO NOT MODIFY THIS environment file directly, to updat this file. +//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" + + (function() { + // The raw environment objects + var environmentProduction = {"production":true,"debugger":false,"ROBOTS":"all","API_NEWS":"https://info.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","SHOW_TEST_WARNING_BANNER":false,"GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-WDKLQXL","GOOGLE_RECAPTCHA":"6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335825","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":null,"CAN_DISABLE_TEST_WARNING_BANNER":null}; + var environmentQa = {"production":true,"debugger":true,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-TRLHLRZ","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; + var environmentSandbox = {"production":true,"debugger":false,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-M9Z7DHS","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":false,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335828","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":false}; + var environment4200 = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"///v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":true}; + var environmentDev = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; + + function getCurrentLeanDomain() { + var port = window.location.port ? ':' + window.location.port : ''; + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(-2) -> ["myorg", "com"] + return window.location.hostname.split('.').slice(-2).join('.') + port; + } + + function getSubDomain() { + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(0, -2) -> ["qa"] + var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); + return subdomain ? subdomain + '.' : ''; + } + + function replaceEnvironmentVars(env) { + if (!env) return; + if (env.API_WEB) { + env.API_WEB = env.API_WEB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.BASE_URL) { + env.BASE_URL = env.BASE_URL + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.API_PUB) { + env.API_PUB = env.API_PUB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + } + + var domain = window.location.hostname + window.location.pathname; + var chosenEnv = environmentProduction; // default to production + + if (domain.includes('qa.orcid.org')) { + chosenEnv = environmentQa; + } else if (domain.includes('sandbox.orcid.org')) { + chosenEnv = environmentSandbox; + } else if (domain.includes('localhost:4200')) { + chosenEnv = environment4200; + } else if (domain.includes('dev.orcid.org')) { + chosenEnv = environmentDev; + } + + replaceEnvironmentVars(chosenEnv); + + window.runtimeEnvironment = chosenEnv; + })(); + \ No newline at end of file diff --git a/src/environments/environment.int.ts b/src/environments/environment.int.ts index 35eb40b725..b0a1e9db8d 100644 --- a/src/environments/environment.int.ts +++ b/src/environments/environment.int.ts @@ -1,4 +1,5 @@ -export const environment = { +import { EnvironmentInterface } from './global-environment' +export const environment: EnvironmentInterface = { production: true, debugger: true, ROBOTS: 'noindex, nofollow', @@ -42,4 +43,5 @@ export const environment = { ca: '** Catalan', }, proxyMode: false, + NEW_RELIC_APP: '772335828', } diff --git a/src/environments/environment.local-with-proxy.ts b/src/environments/environment.local-with-proxy.ts index f78e9f60bd..ca8818aefb 100644 --- a/src/environments/environment.local-with-proxy.ts +++ b/src/environments/environment.local-with-proxy.ts @@ -1,5 +1,6 @@ -export const environment = { - production: false, +import { EnvironmentInterface } from './global-environment' + +export const environment: EnvironmentInterface = { production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', diff --git a/src/environments/environment.local.tomcat.ts b/src/environments/environment.local.tomcat.ts deleted file mode 100644 index b34ec9f37b..0000000000 --- a/src/environments/environment.local.tomcat.ts +++ /dev/null @@ -1,43 +0,0 @@ -export const environment = { - production: true, - debugger: true, - API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: '//pub.localhost/v3.0', - API_WEB: '//localhost/', - BASE_URL: '', - BLOG_NEWS: 'https://localhost/about/news', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-0000000', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: false, -} diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index 975d5c70fd..189827e7df 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -1,5 +1,6 @@ -export const environment = { - production: false, +import { EnvironmentInterface } from './global-environment' + +export const environment: EnvironmentInterface = { production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', diff --git a/src/environments/environment.production.ts b/src/environments/environment.production.ts index 3ed290aae8..a0840fb8b6 100644 --- a/src/environments/environment.production.ts +++ b/src/environments/environment.production.ts @@ -1,4 +1,6 @@ -export const environment = { +import { EnvironmentInterface } from './global-environment' + +export const environment: EnvironmentInterface = { production: true, debugger: false, ROBOTS: 'all', @@ -35,5 +37,6 @@ export const environment = { 'zh-CN': '简体中文', 'zh-TW': '繁體中文', }, - proxyMode: false, + proxyMode: null, + CAN_DISABLE_TEST_WARNING_BANNER: null, } diff --git a/src/environments/environment.qa.ts b/src/environments/environment.qa.ts index ee232719a1..1d5d2d9044 100644 --- a/src/environments/environment.qa.ts +++ b/src/environments/environment.qa.ts @@ -1,4 +1,6 @@ -export const environment = { +import { EnvironmentInterface } from './global-environment' + +export const environment: EnvironmentInterface = { production: true, debugger: true, ROBOTS: 'noindex, nofollow', diff --git a/src/environments/environment.sandbox.ts b/src/environments/environment.sandbox.ts index cea92e6dcc..9e5c1fecce 100644 --- a/src/environments/environment.sandbox.ts +++ b/src/environments/environment.sandbox.ts @@ -1,4 +1,6 @@ -export const environment = { +import { EnvironmentInterface } from './global-environment' + +export const environment: EnvironmentInterface = { production: true, debugger: false, ROBOTS: 'noindex, nofollow', diff --git a/src/environments/global-environment.d.ts b/src/environments/global-environment.d.ts new file mode 100644 index 0000000000..49c883eee5 --- /dev/null +++ b/src/environments/global-environment.d.ts @@ -0,0 +1,30 @@ +export interface EnvironmentInterface { + production: boolean + debugger: boolean + ROBOTS: string + API_NEWS: string + API_PUB: string + API_WEB: string + BASE_URL: string + INFO_SITE: string + GOOGLE_ANALYTICS_TESTING_MODE: boolean + GOOGLE_TAG_MANAGER: string + GOOGLE_RECAPTCHA: string + HELP_HERO_ID: string + ZENDESK: string | null + SHOW_TEST_WARNING_BANNER: boolean + CAN_DISABLE_TEST_WARNING_BANNER: boolean + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: number + VERBOSE_SNACKBAR_ERRORS_REPORTS: boolean + WORDPRESS_S3: string + WORDPRESS_S3_FALLBACK: string + NEW_RELIC_APP: string + LANGUAGE_MENU_OPTIONS: { + [key: string]: string + } + proxyMode: boolean +} + +declare global { + const runtimeEnvironment: EnvironmentInterface +} diff --git a/src/index.html b/src/index.html index 75d6f26a56..6264df998c 100644 --- a/src/index.html +++ b/src/index.html @@ -4,12 +4,14 @@ ORCID - - + + + + Date: Fri, 3 Jan 2025 19:04:22 -0600 Subject: [PATCH 2/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- angular.json | 5 +- .../runtime-environment-setter.postbuild.ts | 14 +- scripts/utils.ts | 12 +- .../cdk/platform-info/browserlist.regexp.ts | 3 +- ...count-default-email-frequencies.service.ts | 12 +- .../account-trusted-individuals.service.ts | 9 +- .../canonocal-url/canonocal-url.service.ts | 4 +- .../developer-tools.service.ts | 13 +- src/app/core/disco/disco.service.ts | 4 +- src/app/core/inbox/inbox.service.ts | 4 +- src/app/core/oauth/oauth.service.ts | 10 +- src/app/core/open-graph/open-graph.service.ts | 4 +- .../organizations/organizations.service.ts | 1 - .../password-recovery.service.ts | 10 +- .../record-emails/record-emails.service.ts | 10 +- .../record-fundings.service.ts | 15 +- .../core/record-names/record-names.service.ts | 9 +- .../record-peer-review.service.ts | 12 +- .../record-public-side-bar.service.ts | 4 +- .../record-research-resource.service.ts | 6 +- .../core/record-works/record-works.service.ts | 32 +- src/app/core/record/record.service.ts | 9 +- .../register/register.backend-validators.ts | 5 +- src/app/core/register/register.service.ts | 11 +- .../register2/register2.backend-validators.ts | 5 +- src/app/core/register2/register2.service.ts | 11 +- .../robots-meta-tags.service.ts | 5 +- src/app/core/sign-in/sign-in.service.ts | 20 +- .../two-factor-authentication.service.ts | 18 +- .../core/wordpress/wordpress.service.spec.ts | 8 +- .../environment-banner.component.ts | 1 - src/app/layout/header/header.component.ts | 5 +- src/app/layout/language/language.component.ts | 4 +- .../work-contributors.component.ts | 6 +- src/assets/local-dev-environment.js | 339 ++++++++++++++---- .../environment.local-with-proxy.ts | 3 +- src/environments/environment.local.ts | 3 +- 37 files changed, 484 insertions(+), 162 deletions(-) diff --git a/angular.json b/angular.json index edbf79beee..16e03f4530 100644 --- a/angular.json +++ b/angular.json @@ -333,12 +333,11 @@ "local": { "browserTarget": "ng-orcid:build:local" }, - "local-tomcat": { - }, + "local-tomcat": {}, "production": { "browserTarget": "ng-orcid:build:production" }, - + "en": { "browserTarget": "ng-orcid:build:en" }, diff --git a/scripts/runtime-environment-setter.postbuild.ts b/scripts/runtime-environment-setter.postbuild.ts index c7f559d34a..4934cb588a 100644 --- a/scripts/runtime-environment-setter.postbuild.ts +++ b/scripts/runtime-environment-setter.postbuild.ts @@ -1,4 +1,4 @@ -import { runtimeEnvironmentScript } from "./utils"; +import { runtimeEnvironmentScript } from './utils' /** * Receives an HTML string, replaces the [ENVIRONMENT_VARAIBLES_PLACEHOLDER] @@ -8,15 +8,15 @@ import { runtimeEnvironmentScript } from "./utils"; export function replaceEnvPlaceholder(htmlContent: string): string { // 1. Build the script that runs in the browser - // 2. Wrap the content in a `; + const scriptTag = `` // 3. Replace the placeholder in the HTML - const placeholderBlockRegex = /([\s\S]*?)/; + const placeholderBlockRegex = + /([\s\S]*?)/ - const updatedHtml = htmlContent.replace(placeholderBlockRegex, scriptTag); + const updatedHtml = htmlContent.replace(placeholderBlockRegex, scriptTag) // 4. Return the updated HTML - return updatedHtml; -} \ No newline at end of file + return updatedHtml +} diff --git a/scripts/utils.ts b/scripts/utils.ts index e94bdae45d..f3f8d02e64 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -46,9 +46,13 @@ export function runtimeEnvironmentScript() { return ` (function() { // The raw environment objects - var environmentProduction = ${JSON.stringify(environmentProduction.environment)}; + var environmentProduction = ${JSON.stringify( + environmentProduction.environment + )}; var environmentQa = ${JSON.stringify(environmentQa.environment)}; - var environmentSandbox = ${JSON.stringify(environmentSandbox.environment)}; + var environmentSandbox = ${JSON.stringify( + environmentSandbox.environment + )}; var environment4200 = ${JSON.stringify(environment4200.environment)}; var environmentDev = ${JSON.stringify(environmentDev.environment)}; @@ -102,5 +106,5 @@ export function runtimeEnvironmentScript() { window.runtimeEnvironment = chosenEnv; })(); - `; -} \ No newline at end of file + ` +} diff --git a/src/app/cdk/platform-info/browserlist.regexp.ts b/src/app/cdk/platform-info/browserlist.regexp.ts index bf8c4aa5cf..545a90290e 100644 --- a/src/app/cdk/platform-info/browserlist.regexp.ts +++ b/src/app/cdk/platform-info/browserlist.regexp.ts @@ -1,2 +1,3 @@ // tslint:disable-next-line: max-line-length -export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ +export const BROWSERLIST_REGEXP = + /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ diff --git a/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts b/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts index 691dbbe774..0f9ee9e0ca 100644 --- a/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts +++ b/src/app/core/account-default-email-frequencies/account-default-email-frequencies.service.ts @@ -34,7 +34,8 @@ export class AccountDefaultEmailFrequenciesService { updateAmendNotifications(frequency: number): Observable { return this._http .post( - runtimeEnvironment.API_WEB + `notifications/frequencies/update/amendUpdates`, + runtimeEnvironment.API_WEB + + `notifications/frequencies/update/amendUpdates`, frequency, { headers: this.headers } ) @@ -46,7 +47,8 @@ export class AccountDefaultEmailFrequenciesService { updateAdminNotifications(frequency: string): Observable { return this._http .post( - runtimeEnvironment.API_WEB + `notifications/frequencies/update/adminUpdates`, + runtimeEnvironment.API_WEB + + `notifications/frequencies/update/adminUpdates`, frequency, { headers: this.headers } ) @@ -58,7 +60,8 @@ export class AccountDefaultEmailFrequenciesService { updateMemberNotifications(frequency: string): Observable { return this._http .post( - runtimeEnvironment.API_WEB + `notifications/frequencies/update/memberUpdates`, + runtimeEnvironment.API_WEB + + `notifications/frequencies/update/memberUpdates`, frequency, { headers: this.headers } ) @@ -71,7 +74,8 @@ export class AccountDefaultEmailFrequenciesService { updateMemberTipsUpdates(tips: boolean): Observable { return this._http .post( - runtimeEnvironment.API_WEB + `notifications/frequencies/update/tipsUpdates`, + runtimeEnvironment.API_WEB + + `notifications/frequencies/update/tipsUpdates`, tips, { headers: this.headers } ) diff --git a/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts b/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts index 0aa8f412a6..ab31fac758 100644 --- a/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts +++ b/src/app/core/account-trusted-individuals/account-trusted-individuals.service.ts @@ -64,9 +64,12 @@ export class AccountTrustedIndividualsService { getPersonDetails(orcid: string) { return this._http - .get(runtimeEnvironment.API_PUB + `${orcid}/personal-details`, { - headers: this.headers, - }) + .get( + runtimeEnvironment.API_PUB + `${orcid}/personal-details`, + { + headers: this.headers, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/canonocal-url/canonocal-url.service.ts b/src/app/core/canonocal-url/canonocal-url.service.ts index 5a0062dbc0..3d6a75a11a 100644 --- a/src/app/core/canonocal-url/canonocal-url.service.ts +++ b/src/app/core/canonocal-url/canonocal-url.service.ts @@ -36,7 +36,9 @@ export class CanonocalUrlService { let canonicalUrl = 'https:' + runtimeEnvironment.BASE_URL + - (runtimeEnvironment.BASE_URL.endsWith('/') ? publicOrcid : '/' + publicOrcid) + (runtimeEnvironment.BASE_URL.endsWith('/') + ? publicOrcid + : '/' + publicOrcid) let link: HTMLLinkElement = this.doc.createElement('link') link.setAttribute('rel', 'canonical') diff --git a/src/app/core/developer-tools/developer-tools.service.ts b/src/app/core/developer-tools/developer-tools.service.ts index 38336a9d97..fa69d92f7e 100644 --- a/src/app/core/developer-tools/developer-tools.service.ts +++ b/src/app/core/developer-tools/developer-tools.service.ts @@ -18,7 +18,9 @@ export class DeveloperToolsService { getDeveloperToolsClient(): Observable { return this._http - .get(runtimeEnvironment.BASE_URL + 'developer-tools/get-client.json') + .get( + runtimeEnvironment.BASE_URL + 'developer-tools/get-client.json' + ) .pipe( retry(3), catchError((error) => @@ -58,7 +60,8 @@ export class DeveloperToolsService { postResetClientSecret(client: Client): Observable { return this._http .post( - runtimeEnvironment.BASE_URL + 'developer-tools/reset-client-secret.json', + runtimeEnvironment.BASE_URL + + 'developer-tools/reset-client-secret.json', client ) .pipe( @@ -72,7 +75,8 @@ export class DeveloperToolsService { enableDeveloperTools() { return this._http .post( - runtimeEnvironment.BASE_URL + 'developer-tools/enable-developer-tools.json', + runtimeEnvironment.BASE_URL + + 'developer-tools/enable-developer-tools.json', {} ) .pipe( @@ -86,7 +90,8 @@ export class DeveloperToolsService { resetClientSecret(client: Client): Observable { return this._http .post( - runtimeEnvironment.BASE_URL + 'developer-tools/reset-client-secret.json', + runtimeEnvironment.BASE_URL + + 'developer-tools/reset-client-secret.json', client ) .pipe( diff --git a/src/app/core/disco/disco.service.ts b/src/app/core/disco/disco.service.ts index 853de357a0..3f020d4466 100644 --- a/src/app/core/disco/disco.service.ts +++ b/src/app/core/disco/disco.service.ts @@ -86,7 +86,9 @@ export class DiscoService { if (!this.discoFeedSubject) { this.discoFeedSubject = new ReplaySubject(1) return this._http - .get(runtimeEnvironment.BASE_URL + 'Shibboleth.sso/DiscoFeed') + .get( + runtimeEnvironment.BASE_URL + 'Shibboleth.sso/DiscoFeed' + ) .pipe( tap((feed) => { this.discoFeedSubject.next(feed) diff --git a/src/app/core/inbox/inbox.service.ts b/src/app/core/inbox/inbox.service.ts index 2d5c675c6e..0156ebcf75 100644 --- a/src/app/core/inbox/inbox.service.ts +++ b/src/app/core/inbox/inbox.service.ts @@ -220,7 +220,9 @@ export class InboxService { } retrieveUnreadCount(): any { - return this._http.get(runtimeEnvironment.BASE_URL + 'inbox/unreadCount.json') + return this._http.get( + runtimeEnvironment.BASE_URL + 'inbox/unreadCount.json' + ) } totalNumber() { diff --git a/src/app/core/oauth/oauth.service.ts b/src/app/core/oauth/oauth.service.ts index 12aba899a7..fe10796ad1 100644 --- a/src/app/core/oauth/oauth.service.ts +++ b/src/app/core/oauth/oauth.service.ts @@ -18,7 +18,6 @@ import { OauthParameters, RequestInfoForm } from 'src/app/types' import { OauthAuthorize } from 'src/app/types/authorize.endpoint' import { UserSessionUpdateParameters } from 'src/app/types/session.local' - import { SignInData } from '../../types/sign-in-data.endpoint' import { TwoFactor } from '../../types/two-factor.endpoint' import { ErrorHandlerService } from '../error-handler/error-handler.service' @@ -193,9 +192,12 @@ export class OauthService { loadShibbolethSignInData(): Observable { return this._http - .get(runtimeEnvironment.BASE_URL + 'shibboleth/signinData.json', { - headers: this.headers, - }) + .get( + runtimeEnvironment.BASE_URL + 'shibboleth/signinData.json', + { + headers: this.headers, + } + ) .pipe( retry(3), catchError((error) => diff --git a/src/app/core/open-graph/open-graph.service.ts b/src/app/core/open-graph/open-graph.service.ts index 84d0283afd..7a6e9f9669 100644 --- a/src/app/core/open-graph/open-graph.service.ts +++ b/src/app/core/open-graph/open-graph.service.ts @@ -82,7 +82,9 @@ export class OpenGraphService { { property: this.imageMeta, content: - 'https:' + runtimeEnvironment.BASE_URL + 'assets/img/orcid-og-image.png', + 'https:' + + runtimeEnvironment.BASE_URL + + 'assets/img/orcid-og-image.png', }, ]) } catch (e) { diff --git a/src/app/core/organizations/organizations.service.ts b/src/app/core/organizations/organizations.service.ts index 82e94fe43e..76e82e88e5 100644 --- a/src/app/core/organizations/organizations.service.ts +++ b/src/app/core/organizations/organizations.service.ts @@ -5,7 +5,6 @@ import { catchError, retry } from 'rxjs/operators' import { WHITE_SPACE_REGEXP } from 'src/app/constants' import { OrgDisambiguated } from 'src/app/types' - import { ErrorHandlerService } from '../error-handler/error-handler.service' @Injectable({ diff --git a/src/app/core/password-recovery/password-recovery.service.ts b/src/app/core/password-recovery/password-recovery.service.ts index d1ba0dfa24..b72138c15f 100644 --- a/src/app/core/password-recovery/password-recovery.service.ts +++ b/src/app/core/password-recovery/password-recovery.service.ts @@ -42,9 +42,13 @@ export class PasswordRecoveryService { remindOrcidId(data) { return this._http - .post(runtimeEnvironment.API_WEB + `forgot-id.json`, data, { - withCredentials: true, - }) + .post( + runtimeEnvironment.API_WEB + `forgot-id.json`, + data, + { + withCredentials: true, + } + ) .pipe( retry(3), catchError((error) => diff --git a/src/app/core/record-emails/record-emails.service.ts b/src/app/core/record-emails/record-emails.service.ts index 3801a64e62..4e3639e3c3 100644 --- a/src/app/core/record-emails/record-emails.service.ts +++ b/src/app/core/record-emails/record-emails.service.ts @@ -126,9 +126,13 @@ export class RecordEmailsService { const encoded_data = JSON.stringify(email) return this._http - .post(runtimeEnvironment.API_WEB + `account/email/visibility`, encoded_data, { - headers: this.headers, - }) + .post( + runtimeEnvironment.API_WEB + `account/email/visibility`, + encoded_data, + { + headers: this.headers, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), diff --git a/src/app/core/record-fundings/record-fundings.service.ts b/src/app/core/record-fundings/record-fundings.service.ts index 230895fc3c..5a3d1cca88 100644 --- a/src/app/core/record-fundings/record-fundings.service.ts +++ b/src/app/core/record-fundings/record-fundings.service.ts @@ -75,7 +75,8 @@ export class RecordFundingsService { getFundingDetails(putCode): Observable { return this._http .get( - runtimeEnvironment.API_WEB + `fundings/fundingDetails.json?id=${putCode}` + runtimeEnvironment.API_WEB + + `fundings/fundingDetails.json?id=${putCode}` ) .pipe( retry(3), @@ -87,7 +88,9 @@ export class RecordFundingsService { getPublicFundingDetails(orcid, putCode): Observable { return this._http .get( - runtimeEnvironment.API_WEB + orcid + `/fundingDetails.json?id=${putCode}` + runtimeEnvironment.API_WEB + + orcid + + `/fundingDetails.json?id=${putCode}` ) .pipe( retry(3), @@ -165,7 +168,10 @@ export class RecordFundingsService { save(funding: Funding) { return this._http - .post(runtimeEnvironment.API_WEB + `fundings/funding.json`, funding) + .post( + runtimeEnvironment.API_WEB + `fundings/funding.json`, + funding + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), @@ -196,7 +202,8 @@ export class RecordFundingsService { loadFundingImportWizardList(): Observable { return this._http.get( - runtimeEnvironment.API_WEB + 'workspace/retrieve-funding-import-wizards.json' + runtimeEnvironment.API_WEB + + 'workspace/retrieve-funding-import-wizards.json' ) } diff --git a/src/app/core/record-names/record-names.service.ts b/src/app/core/record-names/record-names.service.ts index cf1ede7875..201392dca8 100644 --- a/src/app/core/record-names/record-names.service.ts +++ b/src/app/core/record-names/record-names.service.ts @@ -43,9 +43,12 @@ export class RecordNamesService { } this._http - .get(runtimeEnvironment.API_WEB + `account/nameForm.json`, { - headers: this.headers, - }) + .get( + runtimeEnvironment.API_WEB + `account/nameForm.json`, + { + headers: this.headers, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), diff --git a/src/app/core/record-peer-review/record-peer-review.service.ts b/src/app/core/record-peer-review/record-peer-review.service.ts index 102c47674c..99461265c7 100644 --- a/src/app/core/record-peer-review/record-peer-review.service.ts +++ b/src/app/core/record-peer-review/record-peer-review.service.ts @@ -100,19 +100,25 @@ export class RecordPeerReviewService { getPeerReviewById(putCode: number): Observable { return this._http.get( - runtimeEnvironment.API_WEB + 'peer-reviews/peer-review.json?putCode=' + putCode + runtimeEnvironment.API_WEB + + 'peer-reviews/peer-review.json?putCode=' + + putCode ) } getPeerReviewImportWizardList(): Observable { return this._http.get( - runtimeEnvironment.API_WEB + 'workspace/retrieve-peer-review-import-wizards.json' + runtimeEnvironment.API_WEB + + 'workspace/retrieve-peer-review-import-wizards.json' ) } getPublicPeerReviewById(orcid: string, putCode: number): Observable { return this._http.get( - runtimeEnvironment.API_WEB + orcid + '/peer-review.json?putCode=' + putCode + runtimeEnvironment.API_WEB + + orcid + + '/peer-review.json?putCode=' + + putCode ) } diff --git a/src/app/core/record-public-side-bar/record-public-side-bar.service.ts b/src/app/core/record-public-side-bar/record-public-side-bar.service.ts index 64079a6c66..b2bec18451 100644 --- a/src/app/core/record-public-side-bar/record-public-side-bar.service.ts +++ b/src/app/core/record-public-side-bar/record-public-side-bar.service.ts @@ -47,7 +47,9 @@ export class RecordPublicSideBarService { return this._http .get( - runtimeEnvironment.API_WEB + options.publicRecordId + `/public-record.json`, + runtimeEnvironment.API_WEB + + options.publicRecordId + + `/public-record.json`, { headers: this.headers, } diff --git a/src/app/core/record-research-resource/record-research-resource.service.ts b/src/app/core/record-research-resource/record-research-resource.service.ts index 703748ec0c..45a7e76e7d 100644 --- a/src/app/core/record-research-resource/record-research-resource.service.ts +++ b/src/app/core/record-research-resource/record-research-resource.service.ts @@ -4,7 +4,6 @@ import { Observable, of, ReplaySubject } from 'rxjs' import { catchError, map, retry, tap } from 'rxjs/operators' import { UserRecordOptions } from 'src/app/types/record.local' - import { ResearchResource, ResearchResourcesEndpoint, @@ -97,7 +96,10 @@ export class RecordResearchResourceService { getPublicResearchResourceById(orcid, putCode): Observable { return this._http.get( - runtimeEnvironment.API_WEB + orcid + '/researchResource.json?id=' + putCode + runtimeEnvironment.API_WEB + + orcid + + '/researchResource.json?id=' + + putCode ) } diff --git a/src/app/core/record-works/record-works.service.ts b/src/app/core/record-works/record-works.service.ts index 68aeac1b15..fa092350ee 100644 --- a/src/app/core/record-works/record-works.service.ts +++ b/src/app/core/record-works/record-works.service.ts @@ -264,14 +264,16 @@ export class RecordWorksService { } getWork(): Observable { - return this._http.get(runtimeEnvironment.API_WEB + `works/work.json`).pipe( - retry(3), - map((x) => { - x.workExternalIdentifiers = [] - return x - }), - catchError((error) => this._errorHandler.handleError(error)) - ) + return this._http + .get(runtimeEnvironment.API_WEB + `works/work.json`) + .pipe( + retry(3), + map((x) => { + x.workExternalIdentifiers = [] + return x + }), + catchError((error) => this._errorHandler.handleError(error)) + ) } set(value: any): Observable { @@ -291,7 +293,11 @@ export class RecordWorksService { return this._http .get( - runtimeEnvironment.API_WEB + 'works/' + putCode + '/visibility/' + visibility + runtimeEnvironment.API_WEB + + 'works/' + + putCode + + '/visibility/' + + visibility ) .pipe( retry(3), @@ -303,7 +309,9 @@ export class RecordWorksService { updatePreferredSource(putCode: string): Observable { return this._http .get( - runtimeEnvironment.API_WEB + 'works/updateToMaxDisplay.json?putCode=' + putCode + runtimeEnvironment.API_WEB + + 'works/updateToMaxDisplay.json?putCode=' + + putCode ) .pipe( retry(3), @@ -316,7 +324,9 @@ export class RecordWorksService { public loadWorkIdTypes(): Observable { return this._http - .get(`${runtimeEnvironment.API_WEB}works/idTypes.json?query=`) + .get( + `${runtimeEnvironment.API_WEB}works/idTypes.json?query=` + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/record/record.service.ts b/src/app/core/record/record.service.ts index a8027b8a54..68a2afc487 100644 --- a/src/app/core/record/record.service.ts +++ b/src/app/core/record/record.service.ts @@ -226,9 +226,12 @@ export class RecordService { getKeywords(): Observable { return this._http - .get(runtimeEnvironment.API_WEB + `my-orcid/keywordsForms.json`, { - headers: this.headers, - }) + .get( + runtimeEnvironment.API_WEB + `my-orcid/keywordsForms.json`, + { + headers: this.headers, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/register/register.backend-validators.ts b/src/app/core/register/register.backend-validators.ts index e2c49cc0c7..01f069db66 100644 --- a/src/app/core/register/register.backend-validators.ts +++ b/src/app/core/register/register.backend-validators.ts @@ -168,7 +168,10 @@ export function RegisterBackendValidatorMixin< StepC ) return this._http - .post(`${runtimeEnvironment.API_WEB}register.json`, registerForm) + .post( + `${runtimeEnvironment.API_WEB}register.json`, + registerForm + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/register/register.service.ts b/src/app/core/register/register.service.ts index 3e7c6070a6..de53608344 100644 --- a/src/app/core/register/register.service.ts +++ b/src/app/core/register/register.service.ts @@ -52,10 +52,13 @@ export class RegisterService extends _RegisterServiceMixingBase { givenNames: string }) { return this._http - .get(runtimeEnvironment.API_WEB + `dupicateResearcher.json`, { - params: names, - withCredentials: true, - }) + .get( + runtimeEnvironment.API_WEB + `dupicateResearcher.json`, + { + params: names, + withCredentials: true, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/register2/register2.backend-validators.ts b/src/app/core/register2/register2.backend-validators.ts index 66dddf5cfd..d30431978c 100644 --- a/src/app/core/register2/register2.backend-validators.ts +++ b/src/app/core/register2/register2.backend-validators.ts @@ -175,7 +175,10 @@ export function Register2BackendValidatorMixin< StepD ) return this._http - .post(`${runtimeEnvironment.API_WEB}register.json`, registerForm) + .post( + `${runtimeEnvironment.API_WEB}register.json`, + registerForm + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/register2/register2.service.ts b/src/app/core/register2/register2.service.ts index 3859631cf2..77be8682e9 100644 --- a/src/app/core/register2/register2.service.ts +++ b/src/app/core/register2/register2.service.ts @@ -53,10 +53,13 @@ export class Register2Service extends _RegisterServiceMixingBase { givenNames: string }) { return this._http - .get(runtimeEnvironment.API_WEB + `dupicateResearcher.json`, { - params: names, - withCredentials: true, - }) + .get( + runtimeEnvironment.API_WEB + `dupicateResearcher.json`, + { + params: names, + withCredentials: true, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)) diff --git a/src/app/core/robots-meta-tags/robots-meta-tags.service.ts b/src/app/core/robots-meta-tags/robots-meta-tags.service.ts index 67a74d8a55..9e962645db 100644 --- a/src/app/core/robots-meta-tags/robots-meta-tags.service.ts +++ b/src/app/core/robots-meta-tags/robots-meta-tags.service.ts @@ -20,7 +20,10 @@ export class RobotsMetaTagsService { } restoreEnvironmentRobotsConfig() { if (runtimeEnvironment.ROBOTS) { - this.meta.updateTag({ name: this.robots, content: runtimeEnvironment.ROBOTS }) + this.meta.updateTag({ + name: this.robots, + content: runtimeEnvironment.ROBOTS, + }) } else { // If not defined by the environment do not allow robots this.meta.updateTag({ diff --git a/src/app/core/sign-in/sign-in.service.ts b/src/app/core/sign-in/sign-in.service.ts index 00b8e13c0c..15d014fead 100644 --- a/src/app/core/sign-in/sign-in.service.ts +++ b/src/app/core/sign-in/sign-in.service.ts @@ -2,7 +2,6 @@ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { catchError, map, retry, switchMap, first } from 'rxjs/operators' - import { getOrcidNumber, isValidOrcidFormat } from '../../constants' import { Claim } from '../../types/claim.endpoint' import { Reactivation } from '../../types/reactivation.endpoint' @@ -77,9 +76,13 @@ export class SignInService { let body = new HttpParams({ encoder: new CustomEncoder() }) body = body.set(isValidOrcidFormat(username) ? 'orcid' : 'email', username) return this._http - .post(runtimeEnvironment.API_WEB + `sendReactivation.json`, body, { - withCredentials: true, - }) + .post( + runtimeEnvironment.API_WEB + `sendReactivation.json`, + body, + { + withCredentials: true, + } + ) .pipe( retry(3), catchError((error) => @@ -121,9 +124,12 @@ export class SignInService { singOut() { this._titleService.setTitle('ORCID') return this._http - .get(runtimeEnvironment.API_WEB + 'userStatus.json?logUserOut=true', { - withCredentials: true, - }) + .get( + runtimeEnvironment.API_WEB + 'userStatus.json?logUserOut=true', + { + withCredentials: true, + } + ) .pipe( retry(3), catchError((error) => this._errorHandler.handleError(error)), diff --git a/src/app/core/two-factor-authentication/two-factor-authentication.service.ts b/src/app/core/two-factor-authentication/two-factor-authentication.service.ts index 363c394618..6d110d664d 100644 --- a/src/app/core/two-factor-authentication/two-factor-authentication.service.ts +++ b/src/app/core/two-factor-authentication/two-factor-authentication.service.ts @@ -26,7 +26,9 @@ export class TwoFactorAuthenticationService { ) {} checkState(): Observable { - return this._http.get(runtimeEnvironment.BASE_URL + '2FA/status.json') + return this._http.get( + runtimeEnvironment.BASE_URL + '2FA/status.json' + ) } disable(): Observable { @@ -44,7 +46,9 @@ export class TwoFactorAuthenticationService { } startSetup(): Observable { - return this._http.get(runtimeEnvironment.BASE_URL + '2FA/QRCode.json') + return this._http.get( + runtimeEnvironment.BASE_URL + '2FA/QRCode.json' + ) } register(obj): Observable { @@ -82,9 +86,13 @@ export class TwoFactorAuthenticationService { submitCodeForAnotherAccount(code: TwoFactor) { return this._http - .post(runtimeEnvironment.BASE_URL + `2FA/submitCode.json`, code, { - headers: this.headers, - }) + .post( + runtimeEnvironment.BASE_URL + `2FA/submitCode.json`, + code, + { + headers: this.headers, + } + ) .pipe( retry(3), catchError((error) => diff --git a/src/app/core/wordpress/wordpress.service.spec.ts b/src/app/core/wordpress/wordpress.service.spec.ts index b65a373659..74893470db 100644 --- a/src/app/core/wordpress/wordpress.service.spec.ts +++ b/src/app/core/wordpress/wordpress.service.spec.ts @@ -43,7 +43,9 @@ describe('WordpressService', () => { expect(html).toContain(mockHtml) }) - const req = httpMock.expectOne(`${runtimeEnvironment.WORDPRESS_S3}/index.html`) + const req = httpMock.expectOne( + `${runtimeEnvironment.WORDPRESS_S3}/index.html` + ) expect(req.request.method).toBe('GET') req.flush(mockHtml) }) @@ -137,7 +139,9 @@ describe('WordpressService', () => { expect(html).toBe(expectedHtml) }) - const req = httpMock.expectOne(`${runtimeEnvironment.WORDPRESS_S3}/index.html`) + const req = httpMock.expectOne( + `${runtimeEnvironment.WORDPRESS_S3}/index.html` + ) expect(req.request.method).toBe('GET') req.flush(mockHtml) }) diff --git a/src/app/environment-banner/environment-banner/environment-banner.component.ts b/src/app/environment-banner/environment-banner/environment-banner.component.ts index f737a821c7..261819d1ee 100644 --- a/src/app/environment-banner/environment-banner/environment-banner.component.ts +++ b/src/app/environment-banner/environment-banner/environment-banner.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit, Inject, HostBinding } from '@angular/core' import { CookieService } from 'ngx-cookie-service' import { WINDOW } from 'src/app/cdk/window' - @Component({ selector: 'app-environment-banner', templateUrl: './environment-banner.component.html', diff --git a/src/app/layout/header/header.component.ts b/src/app/layout/header/header.component.ts index 1298117b47..0af0cf7892 100644 --- a/src/app/layout/header/header.component.ts +++ b/src/app/layout/header/header.component.ts @@ -13,7 +13,6 @@ import { } from 'src/app/types/menu.local' import { Config } from 'src/app/types/togglz.endpoint' - import { ApplicationRoutes, ORCID_REGEXP } from '../../constants' import { menu } from './menu' @@ -272,7 +271,9 @@ export class HeaderComponent implements OnInit { } this.window.location.href = route } else { - ;(this.window as any).outOfRouterNavigation(runtimeEnvironment.INFO_SITE + route) + ;(this.window as any).outOfRouterNavigation( + runtimeEnvironment.INFO_SITE + route + ) } } } diff --git a/src/app/layout/language/language.component.ts b/src/app/layout/language/language.component.ts index 9532da686f..0d66a2c41d 100644 --- a/src/app/layout/language/language.component.ts +++ b/src/app/layout/language/language.component.ts @@ -20,7 +20,9 @@ export class LanguageComponent implements OnInit { this.languageMenuOptions = runtimeEnvironment.LANGUAGE_MENU_OPTIONS // LOCAL DEV GET'S `en-US` from locale but `en` is required this.locale = this.locale === 'en-US' ? 'en' : this.locale - this.labelLanguage += ` ${runtimeEnvironment.LANGUAGE_MENU_OPTIONS[this.locale]}` + this.labelLanguage += ` ${ + runtimeEnvironment.LANGUAGE_MENU_OPTIONS[this.locale] + }` } changeLanguage(languageKey: string) { diff --git a/src/app/record/components/work-contributors/work-contributors.component.ts b/src/app/record/components/work-contributors/work-contributors.component.ts index ee161173dc..d500d47490 100644 --- a/src/app/record/components/work-contributors/work-contributors.component.ts +++ b/src/app/record/components/work-contributors/work-contributors.component.ts @@ -274,7 +274,11 @@ export class WorkContributorsComponent implements OnInit, OnDestroy { contributorOrcid: this.formBuilder.group({ path: [orcid ? orcid : null], uri: [ - uri ? uri : orcid ? `https:${runtimeEnvironment.BASE_URL}${orcid}` : null, + uri + ? uri + : orcid + ? `https:${runtimeEnvironment.BASE_URL}${orcid}` + : null, ], }), roles: new UntypedFormArray([]), diff --git a/src/assets/local-dev-environment.js b/src/assets/local-dev-environment.js index 95397e981b..4409ddbc86 100644 --- a/src/assets/local-dev-environment.js +++ b/src/assets/local-dev-environment.js @@ -1,62 +1,277 @@ -//DO NOT MODIFY THIS environment file directly, to updat this file. -//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" - - (function() { - // The raw environment objects - var environmentProduction = {"production":true,"debugger":false,"ROBOTS":"all","API_NEWS":"https://info.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","SHOW_TEST_WARNING_BANNER":false,"GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-WDKLQXL","GOOGLE_RECAPTCHA":"6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335825","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":null,"CAN_DISABLE_TEST_WARNING_BANNER":null}; - var environmentQa = {"production":true,"debugger":true,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-TRLHLRZ","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; - var environmentSandbox = {"production":true,"debugger":false,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-M9Z7DHS","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":false,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335828","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":false}; - var environment4200 = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"///v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":true}; - var environmentDev = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; - - function getCurrentLeanDomain() { - var port = window.location.port ? ':' + window.location.port : ''; - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(-2) -> ["myorg", "com"] - return window.location.hostname.split('.').slice(-2).join('.') + port; - } - - function getSubDomain() { - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(0, -2) -> ["qa"] - var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); - return subdomain ? subdomain + '.' : ''; - } - - function replaceEnvironmentVars(env) { - if (!env) return; - if (env.API_WEB) { - env.API_WEB = env.API_WEB - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - if (env.BASE_URL) { - env.BASE_URL = env.BASE_URL - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - if (env.API_PUB) { - env.API_PUB = env.API_PUB - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - } - - var domain = window.location.hostname + window.location.pathname; - var chosenEnv = environmentProduction; // default to production - - if (domain.includes('qa.orcid.org')) { - chosenEnv = environmentQa; - } else if (domain.includes('sandbox.orcid.org')) { - chosenEnv = environmentSandbox; - } else if (domain.includes('localhost:4200')) { - chosenEnv = environment4200; - } else if (domain.includes('dev.orcid.org')) { - chosenEnv = environmentDev; - } - - replaceEnvironmentVars(chosenEnv); - - window.runtimeEnvironment = chosenEnv; - })(); - \ No newline at end of file +//DO NOT MODIFY THIS environment file directly, to updat this file. +//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" + +;(function () { + // The raw environment objects + var environmentProduction = { + production: true, + debugger: false, + ROBOTS: 'all', + API_NEWS: 'https://info.orcid.org/feed/', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.orcid.org/', + SHOW_TEST_WARNING_BANNER: false, + GOOGLE_ANALYTICS_TESTING_MODE: false, + GOOGLE_TAG_MANAGER: 'GTM-WDKLQXL', + GOOGLE_RECAPTCHA: '6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj', + ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', + HELP_HERO_ID: 'oYFQMrzFHA', + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, + VERBOSE_SNACKBAR_ERRORS_REPORTS: false, + WORDPRESS_S3: 'https://homepage-prod.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335825', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + }, + proxyMode: null, + CAN_DISABLE_TEST_WARNING_BANNER: null, + } + var environmentQa = { + production: true, + debugger: true, + ROBOTS: 'noindex, nofollow', + API_NEWS: 'https://info.qa.orcid.org/feed/', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.qa.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: true, + GOOGLE_TAG_MANAGER: 'GTM-TRLHLRZ', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', + HELP_HERO_ID: 'oYFQMrzFHA', + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: true, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, + VERBOSE_SNACKBAR_ERRORS_REPORTS: true, + WORDPRESS_S3: 'https://homepage-qa.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335827', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + xx: '** xx', + src: '** source', + lr: '** lr', + rl: '** rl', + uk: '** Ukrainian', + ca: '** Catalan', + }, + proxyMode: false, + } + var environmentSandbox = { + production: true, + debugger: false, + ROBOTS: 'noindex, nofollow', + API_NEWS: 'https://info.qa.orcid.org/feed/', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.qa.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: false, + GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + HELP_HERO_ID: 'oYFQMrzFHA', + ZENDESK: null, + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: false, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, + VERBOSE_SNACKBAR_ERRORS_REPORTS: false, + WORDPRESS_S3: 'https://homepage-prod.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335828', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + }, + proxyMode: false, + } + var environment4200 = { + production: false, + debugger: true, + ROBOTS: 'all', + API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', + API_PUB: '///v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: true, + GOOGLE_TAG_MANAGER: 'GTM-0000000', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + HELP_HERO_ID: 'oYFQMrzFHA', + ZENDESK: null, + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: true, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, + VERBOSE_SNACKBAR_ERRORS_REPORTS: true, + WORDPRESS_S3: 'https://homepage-qa.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335827', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + xx: '** xx', + src: '** source', + lr: '** lr', + rl: '** rl', + uk: '** Ukrainian', + ca: '** Catalan', + }, + proxyMode: true, + } + var environmentDev = { + production: false, + debugger: true, + ROBOTS: 'all', + API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: true, + GOOGLE_TAG_MANAGER: 'GTM-0000000', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + HELP_HERO_ID: 'oYFQMrzFHA', + ZENDESK: null, + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: true, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, + VERBOSE_SNACKBAR_ERRORS_REPORTS: true, + WORDPRESS_S3: 'https://homepage-qa.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335827', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + xx: '** xx', + src: '** source', + lr: '** lr', + rl: '** rl', + uk: '** Ukrainian', + ca: '** Catalan', + }, + proxyMode: false, + } + + function getCurrentLeanDomain() { + var port = window.location.port ? ':' + window.location.port : '' + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(-2) -> ["myorg", "com"] + return window.location.hostname.split('.').slice(-2).join('.') + port + } + + function getSubDomain() { + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(0, -2) -> ["qa"] + var subdomain = window.location.hostname.split('.').slice(0, -2).join('.') + return subdomain ? subdomain + '.' : '' + } + + function replaceEnvironmentVars(env) { + if (!env) return + if (env.API_WEB) { + env.API_WEB = env.API_WEB.replace('', getSubDomain()).replace( + '', + getCurrentLeanDomain() + ) + } + if (env.BASE_URL) { + env.BASE_URL = env.BASE_URL.replace( + '', + getSubDomain() + ).replace('', getCurrentLeanDomain()) + } + if (env.API_PUB) { + env.API_PUB = env.API_PUB.replace('', getSubDomain()).replace( + '', + getCurrentLeanDomain() + ) + } + } + + var domain = window.location.hostname + window.location.pathname + var chosenEnv = environmentProduction // default to production + + if (domain.includes('qa.orcid.org')) { + chosenEnv = environmentQa + } else if (domain.includes('sandbox.orcid.org')) { + chosenEnv = environmentSandbox + } else if (domain.includes('localhost:4200')) { + chosenEnv = environment4200 + } else if (domain.includes('dev.orcid.org')) { + chosenEnv = environmentDev + } + + replaceEnvironmentVars(chosenEnv) + + window.runtimeEnvironment = chosenEnv +})() diff --git a/src/environments/environment.local-with-proxy.ts b/src/environments/environment.local-with-proxy.ts index ca8818aefb..698f2e931e 100644 --- a/src/environments/environment.local-with-proxy.ts +++ b/src/environments/environment.local-with-proxy.ts @@ -1,6 +1,7 @@ import { EnvironmentInterface } from './global-environment' -export const environment: EnvironmentInterface = { production: false, +export const environment: EnvironmentInterface = { + production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', diff --git a/src/environments/environment.local.ts b/src/environments/environment.local.ts index 189827e7df..60b6e05912 100644 --- a/src/environments/environment.local.ts +++ b/src/environments/environment.local.ts @@ -1,6 +1,7 @@ import { EnvironmentInterface } from './global-environment' -export const environment: EnvironmentInterface = { production: false, +export const environment: EnvironmentInterface = { + production: false, debugger: true, ROBOTS: 'all', API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', From 02e0749244effc7b56da286a391adca5283b5e13 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Wed, 8 Jan 2025 15:01:04 -0600 Subject: [PATCH 3/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- angular.json | 2 +- .../record-works/record-works.service.spec.ts | 1 - src/assets/local-dev-environment.js | 339 ++++-------------- 3 files changed, 63 insertions(+), 279 deletions(-) diff --git a/angular.json b/angular.json index 16e03f4530..dc3d689a6c 100644 --- a/angular.json +++ b/angular.json @@ -411,7 +411,7 @@ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", "src/styles.scss" ], - "scripts": [], + "scripts": ["src/assets/dev-runtime-environment-setter.js"], "assets": ["src/favicon.ico", "src/assets", "src/manifest.json"], "sourceMap": true } diff --git a/src/app/core/record-works/record-works.service.spec.ts b/src/app/core/record-works/record-works.service.spec.ts index 657fa4bf29..e925371a8a 100644 --- a/src/app/core/record-works/record-works.service.spec.ts +++ b/src/app/core/record-works/record-works.service.spec.ts @@ -18,7 +18,6 @@ import { WorkGroup, WorksEndpoint, } from '../../types/record-works.endpoint' -import { environment } from '../../../environments/runtimeEnvironment.local' import { TogglzService } from '../togglz/togglz.service' import { of, ReplaySubject } from 'rxjs' import { UserService } from '..' diff --git a/src/assets/local-dev-environment.js b/src/assets/local-dev-environment.js index 4409ddbc86..95397e981b 100644 --- a/src/assets/local-dev-environment.js +++ b/src/assets/local-dev-environment.js @@ -1,277 +1,62 @@ -//DO NOT MODIFY THIS environment file directly, to updat this file. -//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" - -;(function () { - // The raw environment objects - var environmentProduction = { - production: true, - debugger: false, - ROBOTS: 'all', - API_NEWS: 'https://info.orcid.org/feed/', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.orcid.org/', - SHOW_TEST_WARNING_BANNER: false, - GOOGLE_ANALYTICS_TESTING_MODE: false, - GOOGLE_TAG_MANAGER: 'GTM-WDKLQXL', - GOOGLE_RECAPTCHA: '6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj', - ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', - HELP_HERO_ID: 'oYFQMrzFHA', - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: false, - WORDPRESS_S3: 'https://homepage-prod.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335825', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - }, - proxyMode: null, - CAN_DISABLE_TEST_WARNING_BANNER: null, - } - var environmentQa = { - production: true, - debugger: true, - ROBOTS: 'noindex, nofollow', - API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.qa.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-TRLHLRZ', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', - HELP_HERO_ID: 'oYFQMrzFHA', - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335827', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: false, - } - var environmentSandbox = { - production: true, - debugger: false, - ROBOTS: 'noindex, nofollow', - API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.qa.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: false, - GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: false, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: false, - WORDPRESS_S3: 'https://homepage-prod.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335828', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - }, - proxyMode: false, - } - var environment4200 = { - production: false, - debugger: true, - ROBOTS: 'all', - API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: '///v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-0000000', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335827', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: true, - } - var environmentDev = { - production: false, - debugger: true, - ROBOTS: 'all', - API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-0000000', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335827', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: false, - } - - function getCurrentLeanDomain() { - var port = window.location.port ? ':' + window.location.port : '' - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(-2) -> ["myorg", "com"] - return window.location.hostname.split('.').slice(-2).join('.') + port - } - - function getSubDomain() { - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(0, -2) -> ["qa"] - var subdomain = window.location.hostname.split('.').slice(0, -2).join('.') - return subdomain ? subdomain + '.' : '' - } - - function replaceEnvironmentVars(env) { - if (!env) return - if (env.API_WEB) { - env.API_WEB = env.API_WEB.replace('', getSubDomain()).replace( - '', - getCurrentLeanDomain() - ) - } - if (env.BASE_URL) { - env.BASE_URL = env.BASE_URL.replace( - '', - getSubDomain() - ).replace('', getCurrentLeanDomain()) - } - if (env.API_PUB) { - env.API_PUB = env.API_PUB.replace('', getSubDomain()).replace( - '', - getCurrentLeanDomain() - ) - } - } - - var domain = window.location.hostname + window.location.pathname - var chosenEnv = environmentProduction // default to production - - if (domain.includes('qa.orcid.org')) { - chosenEnv = environmentQa - } else if (domain.includes('sandbox.orcid.org')) { - chosenEnv = environmentSandbox - } else if (domain.includes('localhost:4200')) { - chosenEnv = environment4200 - } else if (domain.includes('dev.orcid.org')) { - chosenEnv = environmentDev - } - - replaceEnvironmentVars(chosenEnv) - - window.runtimeEnvironment = chosenEnv -})() +//DO NOT MODIFY THIS environment file directly, to updat this file. +//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" + + (function() { + // The raw environment objects + var environmentProduction = {"production":true,"debugger":false,"ROBOTS":"all","API_NEWS":"https://info.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","SHOW_TEST_WARNING_BANNER":false,"GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-WDKLQXL","GOOGLE_RECAPTCHA":"6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335825","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":null,"CAN_DISABLE_TEST_WARNING_BANNER":null}; + var environmentQa = {"production":true,"debugger":true,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-TRLHLRZ","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; + var environmentSandbox = {"production":true,"debugger":false,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-M9Z7DHS","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":false,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335828","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":false}; + var environment4200 = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"///v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":true}; + var environmentDev = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; + + function getCurrentLeanDomain() { + var port = window.location.port ? ':' + window.location.port : ''; + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(-2) -> ["myorg", "com"] + return window.location.hostname.split('.').slice(-2).join('.') + port; + } + + function getSubDomain() { + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(0, -2) -> ["qa"] + var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); + return subdomain ? subdomain + '.' : ''; + } + + function replaceEnvironmentVars(env) { + if (!env) return; + if (env.API_WEB) { + env.API_WEB = env.API_WEB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.BASE_URL) { + env.BASE_URL = env.BASE_URL + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.API_PUB) { + env.API_PUB = env.API_PUB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + } + + var domain = window.location.hostname + window.location.pathname; + var chosenEnv = environmentProduction; // default to production + + if (domain.includes('qa.orcid.org')) { + chosenEnv = environmentQa; + } else if (domain.includes('sandbox.orcid.org')) { + chosenEnv = environmentSandbox; + } else if (domain.includes('localhost:4200')) { + chosenEnv = environment4200; + } else if (domain.includes('dev.orcid.org')) { + chosenEnv = environmentDev; + } + + replaceEnvironmentVars(chosenEnv); + + window.runtimeEnvironment = chosenEnv; + })(); + \ No newline at end of file From 4eef490270ca62320cc73d0b4a8c79fc9389b398 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Wed, 8 Jan 2025 15:05:26 -0600 Subject: [PATCH 4/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- src/assets/local-dev-environment.js | 339 +++++++++++++++++++++++----- 1 file changed, 277 insertions(+), 62 deletions(-) diff --git a/src/assets/local-dev-environment.js b/src/assets/local-dev-environment.js index 95397e981b..4409ddbc86 100644 --- a/src/assets/local-dev-environment.js +++ b/src/assets/local-dev-environment.js @@ -1,62 +1,277 @@ -//DO NOT MODIFY THIS environment file directly, to updat this file. -//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" - - (function() { - // The raw environment objects - var environmentProduction = {"production":true,"debugger":false,"ROBOTS":"all","API_NEWS":"https://info.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","SHOW_TEST_WARNING_BANNER":false,"GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-WDKLQXL","GOOGLE_RECAPTCHA":"6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335825","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":null,"CAN_DISABLE_TEST_WARNING_BANNER":null}; - var environmentQa = {"production":true,"debugger":true,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-TRLHLRZ","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; - var environmentSandbox = {"production":true,"debugger":false,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-M9Z7DHS","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":false,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335828","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":false}; - var environment4200 = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"///v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":true}; - var environmentDev = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; - - function getCurrentLeanDomain() { - var port = window.location.port ? ':' + window.location.port : ''; - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(-2) -> ["myorg", "com"] - return window.location.hostname.split('.').slice(-2).join('.') + port; - } - - function getSubDomain() { - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(0, -2) -> ["qa"] - var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); - return subdomain ? subdomain + '.' : ''; - } - - function replaceEnvironmentVars(env) { - if (!env) return; - if (env.API_WEB) { - env.API_WEB = env.API_WEB - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - if (env.BASE_URL) { - env.BASE_URL = env.BASE_URL - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - if (env.API_PUB) { - env.API_PUB = env.API_PUB - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - } - - var domain = window.location.hostname + window.location.pathname; - var chosenEnv = environmentProduction; // default to production - - if (domain.includes('qa.orcid.org')) { - chosenEnv = environmentQa; - } else if (domain.includes('sandbox.orcid.org')) { - chosenEnv = environmentSandbox; - } else if (domain.includes('localhost:4200')) { - chosenEnv = environment4200; - } else if (domain.includes('dev.orcid.org')) { - chosenEnv = environmentDev; - } - - replaceEnvironmentVars(chosenEnv); - - window.runtimeEnvironment = chosenEnv; - })(); - \ No newline at end of file +//DO NOT MODIFY THIS environment file directly, to updat this file. +//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" + +;(function () { + // The raw environment objects + var environmentProduction = { + production: true, + debugger: false, + ROBOTS: 'all', + API_NEWS: 'https://info.orcid.org/feed/', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.orcid.org/', + SHOW_TEST_WARNING_BANNER: false, + GOOGLE_ANALYTICS_TESTING_MODE: false, + GOOGLE_TAG_MANAGER: 'GTM-WDKLQXL', + GOOGLE_RECAPTCHA: '6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj', + ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', + HELP_HERO_ID: 'oYFQMrzFHA', + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, + VERBOSE_SNACKBAR_ERRORS_REPORTS: false, + WORDPRESS_S3: 'https://homepage-prod.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335825', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + }, + proxyMode: null, + CAN_DISABLE_TEST_WARNING_BANNER: null, + } + var environmentQa = { + production: true, + debugger: true, + ROBOTS: 'noindex, nofollow', + API_NEWS: 'https://info.qa.orcid.org/feed/', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.qa.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: true, + GOOGLE_TAG_MANAGER: 'GTM-TRLHLRZ', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', + HELP_HERO_ID: 'oYFQMrzFHA', + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: true, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, + VERBOSE_SNACKBAR_ERRORS_REPORTS: true, + WORDPRESS_S3: 'https://homepage-qa.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335827', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + xx: '** xx', + src: '** source', + lr: '** lr', + rl: '** rl', + uk: '** Ukrainian', + ca: '** Catalan', + }, + proxyMode: false, + } + var environmentSandbox = { + production: true, + debugger: false, + ROBOTS: 'noindex, nofollow', + API_NEWS: 'https://info.qa.orcid.org/feed/', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.qa.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: false, + GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + HELP_HERO_ID: 'oYFQMrzFHA', + ZENDESK: null, + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: false, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, + VERBOSE_SNACKBAR_ERRORS_REPORTS: false, + WORDPRESS_S3: 'https://homepage-prod.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335828', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + }, + proxyMode: false, + } + var environment4200 = { + production: false, + debugger: true, + ROBOTS: 'all', + API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', + API_PUB: '///v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: true, + GOOGLE_TAG_MANAGER: 'GTM-0000000', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + HELP_HERO_ID: 'oYFQMrzFHA', + ZENDESK: null, + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: true, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, + VERBOSE_SNACKBAR_ERRORS_REPORTS: true, + WORDPRESS_S3: 'https://homepage-qa.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335827', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + xx: '** xx', + src: '** source', + lr: '** lr', + rl: '** rl', + uk: '** Ukrainian', + ca: '** Catalan', + }, + proxyMode: true, + } + var environmentDev = { + production: false, + debugger: true, + ROBOTS: 'all', + API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', + API_PUB: '//pub./v3.0', + API_WEB: '///', + BASE_URL: '///', + INFO_SITE: 'https://info.orcid.org/', + GOOGLE_ANALYTICS_TESTING_MODE: true, + GOOGLE_TAG_MANAGER: 'GTM-0000000', + GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', + HELP_HERO_ID: 'oYFQMrzFHA', + ZENDESK: null, + SHOW_TEST_WARNING_BANNER: true, + CAN_DISABLE_TEST_WARNING_BANNER: true, + INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, + VERBOSE_SNACKBAR_ERRORS_REPORTS: true, + WORDPRESS_S3: 'https://homepage-qa.orcid.org', + WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', + NEW_RELIC_APP: '772335827', + LANGUAGE_MENU_OPTIONS: { + ar: 'العربية', + cs: 'Čeština', + de: 'Deutsch', + en: 'English', + es: 'Español', + fr: 'Français', + it: 'Italiano', + ja: '日本語', + ko: '한국어', + pl: 'Polski', + pt: 'Português', + ru: 'Русский', + tr: 'Türkçe', + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + xx: '** xx', + src: '** source', + lr: '** lr', + rl: '** rl', + uk: '** Ukrainian', + ca: '** Catalan', + }, + proxyMode: false, + } + + function getCurrentLeanDomain() { + var port = window.location.port ? ':' + window.location.port : '' + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(-2) -> ["myorg", "com"] + return window.location.hostname.split('.').slice(-2).join('.') + port + } + + function getSubDomain() { + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(0, -2) -> ["qa"] + var subdomain = window.location.hostname.split('.').slice(0, -2).join('.') + return subdomain ? subdomain + '.' : '' + } + + function replaceEnvironmentVars(env) { + if (!env) return + if (env.API_WEB) { + env.API_WEB = env.API_WEB.replace('', getSubDomain()).replace( + '', + getCurrentLeanDomain() + ) + } + if (env.BASE_URL) { + env.BASE_URL = env.BASE_URL.replace( + '', + getSubDomain() + ).replace('', getCurrentLeanDomain()) + } + if (env.API_PUB) { + env.API_PUB = env.API_PUB.replace('', getSubDomain()).replace( + '', + getCurrentLeanDomain() + ) + } + } + + var domain = window.location.hostname + window.location.pathname + var chosenEnv = environmentProduction // default to production + + if (domain.includes('qa.orcid.org')) { + chosenEnv = environmentQa + } else if (domain.includes('sandbox.orcid.org')) { + chosenEnv = environmentSandbox + } else if (domain.includes('localhost:4200')) { + chosenEnv = environment4200 + } else if (domain.includes('dev.orcid.org')) { + chosenEnv = environmentDev + } + + replaceEnvironmentVars(chosenEnv) + + window.runtimeEnvironment = chosenEnv +})() From bc4ccda73db96671ca2f80a488fa0c5c695bf017 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Wed, 8 Jan 2025 16:28:49 -0600 Subject: [PATCH 5/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- angular.json | 2 +- package.json | 9 +- src/assets/local-dev-environment.js | 339 +++++----------------------- 3 files changed, 68 insertions(+), 282 deletions(-) diff --git a/angular.json b/angular.json index dc3d689a6c..ed6e607c70 100644 --- a/angular.json +++ b/angular.json @@ -411,7 +411,7 @@ "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", "src/styles.scss" ], - "scripts": ["src/assets/dev-runtime-environment-setter.js"], + "scripts": ["src/assets/local-dev-environment.js"], "assets": ["src/favicon.ico", "src/assets", "src/manifest.json"], "sourceMap": true } diff --git a/package.json b/package.json index 074e7cdc14..0d019d25a1 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,16 @@ "name": "ng-orcid", "version": "0.0.0", "scripts": { - "start-local": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts && ng serve --disable-host-check --host 0.0.0.0", - "start": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts && ng serve --configuration=local-qa --host 0.0.0.0", + "start-local": "npm run build-runtime-env && ng serve --disable-host-check --host 0.0.0.0", + "start": "npm run build-runtime-env && ng serve --configuration=local-qa --host 0.0.0.0", "start-sandbox": "ng serve --configuration=local-sandbox --host 0.0.0.0", "start:en": "ng serve --configuration=local-qa-en --disable-host-check", "start:ar": "ng serve --configuration=local-qa-ar --disable-host-check", "start:fr": "ng serve --configuration=local-qa-fr --disable-host-check", "start:xx": "ng serve --configuration=local-qa-xx --disable-host-check", - "test": "ng test", - "test-headless": "ng test --watch=false --browsers=ChromeHeadless", + "test": "npm run build-runtime-env && ng test", + "test-headless": "npm run build-runtime-env && ng test --watch=false --browsers=ChromeHeadless", + "build-runtime-env": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts", "lint": "echo 'temporally disable Angular linter to until eslint update'", "e2e": "ng e2e", "prebuild": "rimraf dist && yarn build:i18n && yarn build:browserslist", diff --git a/src/assets/local-dev-environment.js b/src/assets/local-dev-environment.js index 4409ddbc86..95397e981b 100644 --- a/src/assets/local-dev-environment.js +++ b/src/assets/local-dev-environment.js @@ -1,277 +1,62 @@ -//DO NOT MODIFY THIS environment file directly, to updat this file. -//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" - -;(function () { - // The raw environment objects - var environmentProduction = { - production: true, - debugger: false, - ROBOTS: 'all', - API_NEWS: 'https://info.orcid.org/feed/', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.orcid.org/', - SHOW_TEST_WARNING_BANNER: false, - GOOGLE_ANALYTICS_TESTING_MODE: false, - GOOGLE_TAG_MANAGER: 'GTM-WDKLQXL', - GOOGLE_RECAPTCHA: '6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj', - ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', - HELP_HERO_ID: 'oYFQMrzFHA', - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: false, - WORDPRESS_S3: 'https://homepage-prod.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335825', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - }, - proxyMode: null, - CAN_DISABLE_TEST_WARNING_BANNER: null, - } - var environmentQa = { - production: true, - debugger: true, - ROBOTS: 'noindex, nofollow', - API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.qa.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-TRLHLRZ', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - ZENDESK: 'b8313acd-6439-4894-b431-8c5a2ae9e7cb', - HELP_HERO_ID: 'oYFQMrzFHA', - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335827', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: false, - } - var environmentSandbox = { - production: true, - debugger: false, - ROBOTS: 'noindex, nofollow', - API_NEWS: 'https://info.qa.orcid.org/feed/', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.qa.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: false, - GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: false, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 20, - VERBOSE_SNACKBAR_ERRORS_REPORTS: false, - WORDPRESS_S3: 'https://homepage-prod.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335828', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - }, - proxyMode: false, - } - var environment4200 = { - production: false, - debugger: true, - ROBOTS: 'all', - API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: '///v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-0000000', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335827', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: true, - } - var environmentDev = { - production: false, - debugger: true, - ROBOTS: 'all', - API_NEWS: 'https://www.mocky.io/v2/5dced45b3000007300931ce8', - API_PUB: '//pub./v3.0', - API_WEB: '///', - BASE_URL: '///', - INFO_SITE: 'https://info.orcid.org/', - GOOGLE_ANALYTICS_TESTING_MODE: true, - GOOGLE_TAG_MANAGER: 'GTM-0000000', - GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI', - HELP_HERO_ID: 'oYFQMrzFHA', - ZENDESK: null, - SHOW_TEST_WARNING_BANNER: true, - CAN_DISABLE_TEST_WARNING_BANNER: true, - INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT: 50, - VERBOSE_SNACKBAR_ERRORS_REPORTS: true, - WORDPRESS_S3: 'https://homepage-qa.orcid.org', - WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org', - NEW_RELIC_APP: '772335827', - LANGUAGE_MENU_OPTIONS: { - ar: 'العربية', - cs: 'Čeština', - de: 'Deutsch', - en: 'English', - es: 'Español', - fr: 'Français', - it: 'Italiano', - ja: '日本語', - ko: '한국어', - pl: 'Polski', - pt: 'Português', - ru: 'Русский', - tr: 'Türkçe', - 'zh-CN': '简体中文', - 'zh-TW': '繁體中文', - xx: '** xx', - src: '** source', - lr: '** lr', - rl: '** rl', - uk: '** Ukrainian', - ca: '** Catalan', - }, - proxyMode: false, - } - - function getCurrentLeanDomain() { - var port = window.location.port ? ':' + window.location.port : '' - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(-2) -> ["myorg", "com"] - return window.location.hostname.split('.').slice(-2).join('.') + port - } - - function getSubDomain() { - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(0, -2) -> ["qa"] - var subdomain = window.location.hostname.split('.').slice(0, -2).join('.') - return subdomain ? subdomain + '.' : '' - } - - function replaceEnvironmentVars(env) { - if (!env) return - if (env.API_WEB) { - env.API_WEB = env.API_WEB.replace('', getSubDomain()).replace( - '', - getCurrentLeanDomain() - ) - } - if (env.BASE_URL) { - env.BASE_URL = env.BASE_URL.replace( - '', - getSubDomain() - ).replace('', getCurrentLeanDomain()) - } - if (env.API_PUB) { - env.API_PUB = env.API_PUB.replace('', getSubDomain()).replace( - '', - getCurrentLeanDomain() - ) - } - } - - var domain = window.location.hostname + window.location.pathname - var chosenEnv = environmentProduction // default to production - - if (domain.includes('qa.orcid.org')) { - chosenEnv = environmentQa - } else if (domain.includes('sandbox.orcid.org')) { - chosenEnv = environmentSandbox - } else if (domain.includes('localhost:4200')) { - chosenEnv = environment4200 - } else if (domain.includes('dev.orcid.org')) { - chosenEnv = environmentDev - } - - replaceEnvironmentVars(chosenEnv) - - window.runtimeEnvironment = chosenEnv -})() +//DO NOT MODIFY THIS environment file directly, to updat this file. +//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" + + (function() { + // The raw environment objects + var environmentProduction = {"production":true,"debugger":false,"ROBOTS":"all","API_NEWS":"https://info.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","SHOW_TEST_WARNING_BANNER":false,"GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-WDKLQXL","GOOGLE_RECAPTCHA":"6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335825","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":null,"CAN_DISABLE_TEST_WARNING_BANNER":null}; + var environmentQa = {"production":true,"debugger":true,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-TRLHLRZ","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; + var environmentSandbox = {"production":true,"debugger":false,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-M9Z7DHS","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":false,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335828","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":false}; + var environment4200 = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"///v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":true}; + var environmentDev = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; + + function getCurrentLeanDomain() { + var port = window.location.port ? ':' + window.location.port : ''; + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(-2) -> ["myorg", "com"] + return window.location.hostname.split('.').slice(-2).join('.') + port; + } + + function getSubDomain() { + // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] + // .slice(0, -2) -> ["qa"] + var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); + return subdomain ? subdomain + '.' : ''; + } + + function replaceEnvironmentVars(env) { + if (!env) return; + if (env.API_WEB) { + env.API_WEB = env.API_WEB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.BASE_URL) { + env.BASE_URL = env.BASE_URL + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + if (env.API_PUB) { + env.API_PUB = env.API_PUB + .replace('', getSubDomain()) + .replace('', getCurrentLeanDomain()); + } + } + + var domain = window.location.hostname + window.location.pathname; + var chosenEnv = environmentProduction; // default to production + + if (domain.includes('qa.orcid.org')) { + chosenEnv = environmentQa; + } else if (domain.includes('sandbox.orcid.org')) { + chosenEnv = environmentSandbox; + } else if (domain.includes('localhost:4200')) { + chosenEnv = environment4200; + } else if (domain.includes('dev.orcid.org')) { + chosenEnv = environmentDev; + } + + replaceEnvironmentVars(chosenEnv); + + window.runtimeEnvironment = chosenEnv; + })(); + \ No newline at end of file From 3e7b7d3f21c59bd1479ca5ae8ca420c3c09be432 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Wed, 8 Jan 2025 16:30:12 -0600 Subject: [PATCH 6/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- .gitignore | 2 +- src/assets/local-dev-environment.js | 62 ----------------------------- 2 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 src/assets/local-dev-environment.js diff --git a/.gitignore b/.gitignore index c06dcbee5b..526012effb 100644 --- a/.gitignore +++ b/.gitignore @@ -77,5 +77,5 @@ cypress/plugins/token.json # Packages ignore package-lock to depend only on yarn package-lock.json -src/assets/dev-runtime-environment-setter.js +src/assets/local-dev-environment.js.js diff --git a/src/assets/local-dev-environment.js b/src/assets/local-dev-environment.js deleted file mode 100644 index 95397e981b..0000000000 --- a/src/assets/local-dev-environment.js +++ /dev/null @@ -1,62 +0,0 @@ -//DO NOT MODIFY THIS environment file directly, to updat this file. -//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" - - (function() { - // The raw environment objects - var environmentProduction = {"production":true,"debugger":false,"ROBOTS":"all","API_NEWS":"https://info.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","SHOW_TEST_WARNING_BANNER":false,"GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-WDKLQXL","GOOGLE_RECAPTCHA":"6Lfj4AoTAAAAAAjr0x3Gu2RcVpA1-0LJAhV-GRQj","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335825","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":null,"CAN_DISABLE_TEST_WARNING_BANNER":null}; - var environmentQa = {"production":true,"debugger":true,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-TRLHLRZ","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","ZENDESK":"b8313acd-6439-4894-b431-8c5a2ae9e7cb","HELP_HERO_ID":"oYFQMrzFHA","SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; - var environmentSandbox = {"production":true,"debugger":false,"ROBOTS":"noindex, nofollow","API_NEWS":"https://info.qa.orcid.org/feed/","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.qa.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":false,"GOOGLE_TAG_MANAGER":"GTM-M9Z7DHS","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":false,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":20,"VERBOSE_SNACKBAR_ERRORS_REPORTS":false,"WORDPRESS_S3":"https://homepage-prod.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335828","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文"},"proxyMode":false}; - var environment4200 = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"///v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":true}; - var environmentDev = {"production":false,"debugger":true,"ROBOTS":"all","API_NEWS":"https://www.mocky.io/v2/5dced45b3000007300931ce8","API_PUB":"//pub./v3.0","API_WEB":"///","BASE_URL":"///","INFO_SITE":"https://info.orcid.org/","GOOGLE_ANALYTICS_TESTING_MODE":true,"GOOGLE_TAG_MANAGER":"GTM-0000000","GOOGLE_RECAPTCHA":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI","HELP_HERO_ID":"oYFQMrzFHA","ZENDESK":null,"SHOW_TEST_WARNING_BANNER":true,"CAN_DISABLE_TEST_WARNING_BANNER":true,"INSTITUTIONAL_AUTOCOMPLETE_DISPLAY_AMOUNT":50,"VERBOSE_SNACKBAR_ERRORS_REPORTS":true,"WORDPRESS_S3":"https://homepage-qa.orcid.org","WORDPRESS_S3_FALLBACK":"https://homepage-fallback.orcid.org","NEW_RELIC_APP":"772335827","LANGUAGE_MENU_OPTIONS":{"ar":"العربية","cs":"Čeština","de":"Deutsch","en":"English","es":"Español","fr":"Français","it":"Italiano","ja":"日本語","ko":"한국어","pl":"Polski","pt":"Português","ru":"Русский","tr":"Türkçe","zh-CN":"简体中文","zh-TW":"繁體中文","xx":"** xx","src":"** source","lr":"** lr","rl":"** rl","uk":"** Ukrainian","ca":"** Catalan"},"proxyMode":false}; - - function getCurrentLeanDomain() { - var port = window.location.port ? ':' + window.location.port : ''; - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(-2) -> ["myorg", "com"] - return window.location.hostname.split('.').slice(-2).join('.') + port; - } - - function getSubDomain() { - // e.g. "qa.myorg.com" -> ["qa", "myorg", "com"] - // .slice(0, -2) -> ["qa"] - var subdomain = window.location.hostname.split('.').slice(0, -2).join('.'); - return subdomain ? subdomain + '.' : ''; - } - - function replaceEnvironmentVars(env) { - if (!env) return; - if (env.API_WEB) { - env.API_WEB = env.API_WEB - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - if (env.BASE_URL) { - env.BASE_URL = env.BASE_URL - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - if (env.API_PUB) { - env.API_PUB = env.API_PUB - .replace('', getSubDomain()) - .replace('', getCurrentLeanDomain()); - } - } - - var domain = window.location.hostname + window.location.pathname; - var chosenEnv = environmentProduction; // default to production - - if (domain.includes('qa.orcid.org')) { - chosenEnv = environmentQa; - } else if (domain.includes('sandbox.orcid.org')) { - chosenEnv = environmentSandbox; - } else if (domain.includes('localhost:4200')) { - chosenEnv = environment4200; - } else if (domain.includes('dev.orcid.org')) { - chosenEnv = environmentDev; - } - - replaceEnvironmentVars(chosenEnv); - - window.runtimeEnvironment = chosenEnv; - })(); - \ No newline at end of file From 638a100f58d4b569117fd22184ceca5d2948a755 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Wed, 8 Jan 2025 16:31:21 -0600 Subject: [PATCH 7/8] 9562-implement-dynamic-environment-variable-loading-for-single-artifact-deployment --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 526012effb..f8b6f2d5e4 100644 --- a/.gitignore +++ b/.gitignore @@ -77,5 +77,4 @@ cypress/plugins/token.json # Packages ignore package-lock to depend only on yarn package-lock.json -src/assets/local-dev-environment.js.js - +src/assets/local-dev-environment.js From 3de555c599c8239c05f0157cb2a08954aa5f1979 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Date: Wed, 8 Jan 2025 18:02:26 -0600 Subject: [PATCH 8/8] format-fix --- scripts/utils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/utils.ts b/scripts/utils.ts index f3f8d02e64..0cb193624e 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -100,6 +100,8 @@ export function runtimeEnvironmentScript() { chosenEnv = environment4200; } else if (domain.includes('dev.orcid.org')) { chosenEnv = environmentDev; + } else if (domain.includes('localhost')) { // fallback to dev (e.g. karma testig) + chosenEnv = environmentDev; } replaceEnvironmentVars(chosenEnv);