From 7919f78cbd9485a0728543a60fa3cf8da9a77935 Mon Sep 17 00:00:00 2001 From: Willem Veelenturf Date: Wed, 15 Nov 2023 17:13:34 +0100 Subject: [PATCH] Fix dashboard rm prefix (#1592) * Remove prefix from path * Remove slash --- .../src/app/app-routing.module.ts | 20 ----------- .../src/app/app.component.html | 8 ++--- .../src/app/app.component.ts | 1 - .../src/app/app.settings.ts | 36 ++----------------- .../src/app/bakery.service.ts | 2 +- .../src/app/instances/instances.component.ts | 2 +- .../src/app/recipes/recipes.component.ts | 2 +- 7 files changed, 10 insertions(+), 61 deletions(-) diff --git a/http/baker-http-dashboard/src/app/app-routing.module.ts b/http/baker-http-dashboard/src/app/app-routing.module.ts index ca7b49749..17fe6f00b 100644 --- a/http/baker-http-dashboard/src/app/app-routing.module.ts +++ b/http/baker-http-dashboard/src/app/app-routing.module.ts @@ -29,26 +29,6 @@ const routes: Routes = [ "component": InstancesComponent, "path": "instances/:recipeInstanceId", }, - { - "component": HomeComponent, - "path": ":prefix" - }, - { - "component": RecipesComponent, - "path": ":prefix/recipes" - }, - { - "component": InteractionsComponent, - "path": ":prefix/interactions", - }, - { - "component": InstancesComponent, - "path": ":prefix/instances", - }, - { - "component": InstancesComponent, - "path": ":prefix/instances/:recipeInstanceId", - }, { "component": NotFoundComponent, "path": "**", diff --git a/http/baker-http-dashboard/src/app/app.component.html b/http/baker-http-dashboard/src/app/app.component.html index bc60e1d24..0833fdd40 100644 --- a/http/baker-http-dashboard/src/app/app.component.html +++ b/http/baker-http-dashboard/src/app/app.component.html @@ -9,10 +9,10 @@

{{ title }}

- Home - Recipes - Interactions - Instances + Home + Recipes + Interactions + Instances diff --git a/http/baker-http-dashboard/src/app/app.component.ts b/http/baker-http-dashboard/src/app/app.component.ts index 2bd0882cf..80df3c651 100644 --- a/http/baker-http-dashboard/src/app/app.component.ts +++ b/http/baker-http-dashboard/src/app/app.component.ts @@ -10,7 +10,6 @@ import {wasmFolder} from "@hpcc-js/wasm"; }) export class AppComponent implements OnDestroy, OnInit { title = AppSettingsService.settings.applicationName; - prefix = AppSettingsService.prefix.prefix; mobileQuery: MediaQueryList; private readonly mobileQueryListener: () => void; diff --git a/http/baker-http-dashboard/src/app/app.settings.ts b/http/baker-http-dashboard/src/app/app.settings.ts index f8d33a7d3..676f8c6af 100644 --- a/http/baker-http-dashboard/src/app/app.settings.ts +++ b/http/baker-http-dashboard/src/app/app.settings.ts @@ -4,11 +4,6 @@ import {Value} from "./baker-value.api"; const LOCAL_SETTINGS_LOCATION = "/assets/settings/settings.json"; const SETTINGS_LOCATION = "dashboard_config"; - -export interface PrefixSettings { - prefix: string; -} - export interface AppSettings { applicationName: string; apiPath: string; @@ -17,13 +12,12 @@ export interface AppSettings { @Injectable() export class AppSettingsService { - static prefix: PrefixSettings; static settings: AppSettings; constructor (private http: HttpClient) { } - public getAppSettings(prefix: String):Promise { + public getAppSettings():Promise { return new Promise((resolve, reject) => { // //For testing purposes: // AppSettingsService.settings = { @@ -33,7 +27,7 @@ export class AppSettingsService { // }; // resolve() - this.http.get(prefix + "/" + SETTINGS_LOCATION).toPromise().then(response => { + this.http.get(SETTINGS_LOCATION).toPromise().then(response => { AppSettingsService.settings = response; resolve(); }).catch((response: any) => { @@ -43,32 +37,8 @@ export class AppSettingsService { } load () { - const url = new URL(window.location.href); - - // if there is an empty path or just a / the prefix is empty - if(url.pathname == "/" || url.pathname.length == 0) { - AppSettingsService.prefix = {"prefix": url.pathname.substring(url.pathname.lastIndexOf('/') + 1)} - } - // If there is a path we need to ensure they are not part of the path - else { - var temp = url.pathname; - if(temp.includes('/recipes')) { - temp = temp.substring(0, temp.lastIndexOf('/recipes')) - } - if(temp.includes('/interactions')) { - temp = temp.substring(0, temp.lastIndexOf('/interactions')) - } - if(temp.includes('/instances')) { - temp = temp.substring(0, temp.lastIndexOf('/instances')) - } - if(temp.lastIndexOf("/") > 0) { - temp = temp.substring(0, temp.lastIndexOf('/')) - } - AppSettingsService.prefix = {"prefix": temp} - } - return new Promise((resolve, reject) => { - this.getAppSettings(AppSettingsService.prefix.prefix) + this.getAppSettings() .then(_ => resolve()) }); } diff --git a/http/baker-http-dashboard/src/app/bakery.service.ts b/http/baker-http-dashboard/src/app/bakery.service.ts index 0b9f2a9d5..618736552 100644 --- a/http/baker-http-dashboard/src/app/bakery.service.ts +++ b/http/baker-http-dashboard/src/app/bakery.service.ts @@ -32,7 +32,7 @@ import {Value} from "./baker-value.api"; @Injectable({"providedIn": "root"}) export class BakeryService { - private baseUrl = AppSettingsService.prefix.prefix + AppSettingsService.settings.apiPath; + private baseUrl = AppSettingsService.settings.apiPath; httpOptions = { "headers": new HttpHeaders({"Content-Type": "application/json"}) diff --git a/http/baker-http-dashboard/src/app/instances/instances.component.ts b/http/baker-http-dashboard/src/app/instances/instances.component.ts index 73c06f098..3ce881663 100644 --- a/http/baker-http-dashboard/src/app/instances/instances.component.ts +++ b/http/baker-http-dashboard/src/app/instances/instances.component.ts @@ -59,7 +59,7 @@ export class InstancesComponent implements OnInit { updateInstance(event: Event): void { (event.target as HTMLInputElement)?.blur(); - this.router.navigateByUrl(AppSettingsService.prefix.prefix + `/instances/${this.instanceId}`).then(() => this.instanceChanged()); + this.router.navigateByUrl(`/instances/${this.instanceId}`).then(() => this.instanceChanged()); } instanceChanged (): void { diff --git a/http/baker-http-dashboard/src/app/recipes/recipes.component.ts b/http/baker-http-dashboard/src/app/recipes/recipes.component.ts index d9f16d0da..a51156cf3 100644 --- a/http/baker-http-dashboard/src/app/recipes/recipes.component.ts +++ b/http/baker-http-dashboard/src/app/recipes/recipes.component.ts @@ -47,7 +47,7 @@ export class RecipesComponent implements OnInit { bakeRecipe(recipeId: string): void { const instanceId = this.randomId(8) this.bakeryService.postBake(instanceId, recipeId).subscribe(() => { - window.location.href = AppSettingsService.prefix.prefix + `/instances/${instanceId}` + window.location.href = `/instances/${instanceId}` }); }