From 2fc5a3d4146ec796be862c17b380e6965d325920 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Wed, 15 Dec 2021 15:34:05 +0100 Subject: [PATCH] pass blueprint configuration to client --- zero.Backoffice.UI/app/axios.config.ts | 43 +++++----- .../app/components/ui-add-button.vue | 79 +++++++++---------- zero.Backoffice.UI/app/forms/ui-form.vue | 1 - zero.Backoffice.UI/app/services/request.ts | 39 +++------ .../app/styles/Core/_typography.scss | 4 +- zero.Backoffice.UI/app/ui/api.ts | 4 +- zero.Backoffice.UI/app/ui/store.ts | 7 +- zero.Backoffice.UI/app/ui/ui.d.ts | 1 + zero.Backoffice/Endpoints/UI/UIController.cs | 15 ++++ .../Architecture/Blueprints/Blueprint.cs | 2 + .../Blueprints/BlueprintOptions.cs | 6 +- .../Blueprints/BlueprintService.cs | 11 +++ zero.Demo/Program.cs | 6 ++ 13 files changed, 119 insertions(+), 99 deletions(-) diff --git a/zero.Backoffice.UI/app/axios.config.ts b/zero.Backoffice.UI/app/axios.config.ts index a715c31f..8e65fcb9 100644 --- a/zero.Backoffice.UI/app/axios.config.ts +++ b/zero.Backoffice.UI/app/axios.config.ts @@ -16,15 +16,7 @@ Axios.defaults.paramsSerializer = (params) => }; Axios.interceptors.response.use( - response => - { - //if (response.headers['x-variant'] == 'api-response') - //{ - // return response.data; - //} - - return response; - }, + response => response, error => { if (error.response && error.response.headers['x-variant'] == 'api-response') @@ -45,18 +37,31 @@ Axios.interceptors.response.use( Axios.interceptors.request.use(config => { - if (location.search) + if (!config.params) { - var query = Qs.parse(location.search.substring(1)); - if (query.scope) - { - if (!config.params) - { - config.params = {}; - } - config.params['scope'] = query.scope; - } + config.params = {}; } + + let locationQuery = Qs.parse(location.search.substring(1)); + let appKey = 'hofbauer'; + + // set app key to system when required + if (config.params['zero.system'] === true || locationQuery['zero.shared'] === "true") + { + delete config.params['zero.system']; + appKey = 'system'; + } + + // rewrite URLs to replace {app} placeholder + if (config.url != null && config.url.indexOf('{app}') > -1) + { + config.url = config.url.replace('{app}', appKey); + } + if (config.baseURL != null && config.baseURL.indexOf('{app}') > -1) + { + config.baseURL = config.baseURL.replace('{app}', appKey); + } + return config; }, error => Promise.reject(error)); diff --git a/zero.Backoffice.UI/app/components/ui-add-button.vue b/zero.Backoffice.UI/app/components/ui-add-button.vue index 23464f47..3a21666d 100644 --- a/zero.Backoffice.UI/app/components/ui-add-button.vue +++ b/zero.Backoffice.UI/app/components/ui-add-button.vue @@ -35,36 +35,6 @@ - -