From ce9a7456a6110be65a0912c1329f09cdce81dc8f Mon Sep 17 00:00:00 2001 From: shyallegro Date: Wed, 11 May 2022 10:45:21 +0300 Subject: [PATCH] Feature/clearml server root url #21 - missing files --- src/env.js | 7 +++++++ src/main.ts | 14 +++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 src/env.js diff --git a/src/env.js b/src/env.js new file mode 100644 index 00000000..ac8a26e1 --- /dev/null +++ b/src/env.js @@ -0,0 +1,7 @@ +(function (window) { + window.__env = window.__env || {}; + + // Sub_Path + window.__env.subPath = '${CLEARML_SERVER_SUB_PATH}'; + +}(this)); diff --git a/src/main.ts b/src/main.ts index 492cbba1..68420fd9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,8 @@ import {enableProdMode} from '@angular/core'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; - -import {AppModule} from './app/app.module'; -import {ConfigurationService} from './app/webapp-common/shared/services/configuration.service'; +import {AppModule} from '~/app.module'; +import {ConfigurationService} from '@common/shared/services/configuration.service'; +import {updateHttpUrlBaseConstant} from '~/app.constants'; const environment = ConfigurationService.globalEnvironment; if (environment.production) { @@ -10,7 +10,7 @@ if (environment.production) { } if (window.navigator && navigator.serviceWorker) { - navigator.serviceWorker.getRegistrations().then(function (registrations) { + navigator.serviceWorker.getRegistrations().then(registrations => { for (const registration of registrations) { registration.unregister(); } @@ -31,4 +31,8 @@ if (savedData) { } } -platformBrowserDynamic().bootstrapModule(AppModule); +(async () => { + const baseHref = ( window as any ).__env.subPath || '' as string; + updateHttpUrlBaseConstant({...environment, ...(baseHref && !baseHref.startsWith('${') && {apiBaseUrl: baseHref + environment.apiBaseUrl})}); + await platformBrowserDynamic().bootstrapModule(AppModule); +})();