-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from TAMULib/sprint9-staging-config-improvement
Fetch config before bootstrap
- Loading branch information
Showing
36 changed files
with
175 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
|
||
interface AppConfig { | ||
baseUrl: string; | ||
assetsUrl?: string; | ||
} | ||
|
||
const APP_CONFIG = new InjectionToken<AppConfig>('APP_CONFIG'); | ||
|
||
export { | ||
AppConfig, | ||
APP_CONFIG | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { AppConfig, APP_CONFIG } from './app-config'; | ||
export { testAppConfig } from './test-app-config'; |
6 changes: 6 additions & 0 deletions
6
projects/wvr-elements/src/lib/shared/config/test-app-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { AppConfig } from './app-config'; | ||
|
||
export const testAppConfig: AppConfig = { | ||
baseUrl: 'http://localhost:4200', | ||
assetsUrl: 'http://localhost:4200/assets' | ||
}; |
27 changes: 27 additions & 0 deletions
27
projects/wvr-elements/src/lib/shared/utility/bootstrap.utility.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Type } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { AppConfig, APP_CONFIG } from '../config'; | ||
|
||
const obtainConfigPath = (): string => { | ||
const componentScript = document.getElementsByTagName('script'); | ||
const componentScriptSrc = componentScript[componentScript.length - 1].src; | ||
const componentScriptSrcPathParts = componentScriptSrc.split('/'); | ||
componentScriptSrcPathParts.pop(); | ||
const configBasePath = componentScriptSrcPathParts.join('/'); | ||
|
||
return `${configBasePath}/config.json`; | ||
}; | ||
|
||
const weaverBootstrap = (module: Type<unknown>) => () => fetch(obtainConfigPath()) | ||
.then((response: Response) => response.json()) | ||
.then((appConfig: AppConfig) => platformBrowserDynamic([{ | ||
provide: APP_CONFIG, | ||
useValue: appConfig | ||
}]) | ||
.bootstrapModule(module) | ||
.catch((err: any) => { console.error(err); })); | ||
|
||
export { | ||
obtainConfigPath, | ||
weaverBootstrap | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { obtainConfigPath, weaverBootstrap } from './bootstrap.utility'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,4 @@ | |
<ng-content select="wvr-dropdown-menu"></ng-content> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.