From 0fd7817ff5c7ec39d342a3da7a4e5a0ff65b8acf Mon Sep 17 00:00:00 2001 From: Matthew Ross Date: Tue, 2 Jun 2020 10:43:32 -0400 Subject: [PATCH 1/2] Make base-href dynamic --- src/app/app.module.ts | 11 +++++++++-- src/index.html | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0077bfc..4b8938d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; +import { APP_BASE_HREF } from '@angular/common'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { RouterModule } from '@angular/router'; import { DragDropModule } from '@angular/cdk/drag-drop'; @@ -30,11 +31,17 @@ import { SharedModule } from './shared/shared.module'; RouterModule.forRoot(ROUTES) ], - providers: [{ + providers: [ + { provide: HTTP_INTERCEPTORS, useClass: ApiInterceptor, multi: true - }], + }, + { + provide: APP_BASE_HREF, + useValue: window['base-href'] + } + ], declarations: [ AppComponent, diff --git a/src/index.html b/src/index.html index 8341307..9113165 100644 --- a/src/index.html +++ b/src/index.html @@ -1,10 +1,6 @@ - - TaskBoard - Kanban App - - @@ -23,6 +19,12 @@ + + TaskBoard - Kanban App + + From 308debb82bd7dd0d8efb651248491084c246548d Mon Sep 17 00:00:00 2001 From: Matthew Ross Date: Tue, 2 Jun 2020 11:31:47 -0400 Subject: [PATCH 2/2] Actual dynamic base href --- src/app/app.module.ts | 12 +++++++++++- src/index.html | 4 ---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 4b8938d..24f72c9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -17,6 +17,16 @@ import { FileModule } from './files/file-viewer.module'; import { SettingsModule } from './settings/settings.module'; import { SharedModule } from './shared/shared.module'; +function getBasePath() { + let path = window.location.pathname; + + ['/boards', '/settings', '/dashboard'].forEach(p => { + path = path.replace(p, ''); + }); + + return path; +} + @NgModule({ imports: [ BrowserModule, @@ -39,7 +49,7 @@ import { SharedModule } from './shared/shared.module'; }, { provide: APP_BASE_HREF, - useValue: window['base-href'] + useFactory: getBasePath } ], diff --git a/src/index.html b/src/index.html index 9113165..0c0c8b6 100644 --- a/src/index.html +++ b/src/index.html @@ -21,10 +21,6 @@ TaskBoard - Kanban App - -