100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Bugfix's configurations page (#900)
Neal Geilend85af369ed44
diff --git a/ui/app/manager/src/components/configuration/or-conf-realm/index.ts b/ui/app/manager/src/components/configuration/or-conf-realm/index.tsindex e58f306db..bfd9210f0 100644--- a/ui/app/manager/src/components/configuration/or-conf-realm/index.ts+++ b/ui/app/manager/src/components/configuration/or-conf-realm/index.ts@@ -20,10 +20,10 @@import { css, html, LitElement, PropertyValues } from "lit";import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";import "./or-conf-realm-card";-import {customElement, property} from "lit/decorators.js";+import { customElement, property } from "lit/decorators.js";import manager from "@openremote/core";-import { ManagerAppConfig, ManagerAppRealmConfig } from "@openremote/model";-import { OrMwcDialog, showDialog, DialogAction } from "@openremote/or-mwc-components/or-mwc-dialog";+import { ManagerAppConfig } from "@openremote/model";+import { DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";import { i18next } from "@openremote/or-translate";import "@openremote/or-components/or-loading-indicator";diff --git a/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts b/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.tsindex 2605b3a30..80b320a78 100644--- a/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts+++ b/ui/app/manager/src/components/configuration/or-conf-realm/or-conf-realm-card.ts@@ -36,7 +36,6 @@ import { i18next } from "@openremote/or-translate";import { FileInfo, ManagerAppRealmConfig } from "@openremote/model";import { DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";-@customElement("or-conf-realm-card")export class OrConfRealmCard extends LitElement {@@ -198,39 +197,27 @@ export class OrConfRealmCard extends LitElement {}protected _getImagePath(file:File, fileName: string){- let extension = "";- switch (file.type){- case "image/png":- extension = "png"- break;- case "image/jpg":- extension = "jpg"- break;- case "image/jpeg":- extension = "jpeg"- break;- case "image/vnd.microsoft.icon":- extension = "ico"- break;- case "image/svg+xml":- extension = "svg"- break;+ if (file.type.startsWith("image/")){+ let extension = file.name.slice(file.name.lastIndexOf('.'), file.name.length);+ return "/images/" + this.name + "/" + fileName + extension}- return "/images/" + this.name + "/" + fileName + "." + extension+ return null}protected files: {[name:string] : FileInfo} = {}protected async _setImageForUpload(file: File, fileName: string) {const path = this._getImagePath(file, fileName)- this.files[path] = {- path: path,- contents: await Util.blobToBase64(file),- } as FileInfo;- this.realm[fileName] = path- this[fileName] = this.files[path].contents- this.requestUpdate()- return this.files[path].contents;+ if (path){+ this.files[path] = {+ path: path,+ contents: await Util.blobToBase64(file),+ } as FileInfo;+ this.realm[fileName] = path+ this[fileName] = this.files[path].contents+ this.requestUpdate()+ return this.files[path].contents;+ }}protected _showRemoveRealmDialog(){diff --git a/ui/app/manager/src/pages/page-configuration.ts b/ui/app/manager/src/pages/page-configuration.tsindex 6b385a80d..9aacae748 100644--- a/ui/app/manager/src/pages/page-configuration.ts+++ b/ui/app/manager/src/pages/page-configuration.ts@@ -32,6 +32,7 @@ import { ManagerAppConfig } from "@openremote/model";import { i18next } from "@openremote/or-translate";import "@openremote/or-components/or-loading-indicator";+declare var CONFIG_URL_PREFIX: string;export function pageConfigurationProvider(store: Store<AppStateKeyed>): PageProvider<AppStateKeyed> {return {name: "configuration",@@ -148,8 +149,9 @@ export class PageConfiguration extends Page<AppStateKeyed> {super(store);}+ private urlPrefix:string = (CONFIG_URL_PREFIX || "")private getManagerConfig(): Promise<boolean> {- return fetch("/manager_config.json", { cache: "reload" })+ return fetch(this.urlPrefix + "/manager_config.json", { cache: "reload" }).then(async (response) => {return response.json().then((json) => {this.managerConfiguration = json;@@ -175,12 +177,12 @@ export class PageConfiguration extends Page<AppStateKeyed> {document.addEventListener("saveManagerConfig", (e: CustomEvent) => {manager.rest.api.ConfigurationResource.update(e.detail?.value as ManagerAppConfig).then(() => {- fetch("/manager_config.json", { cache: "reload" });+ fetch(this.urlPrefix + "/manager_config.json", { cache: "reload" });this.managerConfiguration = e.detail?.value as ManagerAppConfig;Object.entries(this.managerConfiguration.realms).map(([name, settings]) => {- fetch(settings?.favicon, { cache: "reload" });- fetch(settings?.logo, { cache: "reload" });- fetch(settings?.logoMobile, { cache: "reload" });+ fetch(this.urlPrefix + settings?.favicon, { cache: "reload" });+ fetch(this.urlPrefix + settings?.logo, { cache: "reload" });+ fetch(this.urlPrefix + settings?.logoMobile, { cache: "reload" });});app.requestUpdate();})@@ -197,25 +199,25 @@ export class PageConfiguration extends Page<AppStateKeyed> {}return html`${this.loading ? html`- <or-loading-indicator .overlay="${true}"></or-loading-indicator>` : ""}- <div id="wrapper">+ <or-loading-indicator .overlay="${true}"></or-loading-indicator>` : html`+ <div id="wrapper"><div id="header-wrapper">- <div id="header-title">- <or-icon icon="palette-outline"></or-icon>- ${i18next.t("appearance")}- </div>- <div id="header-actions">- <or-conf-json .managerConfig="${this.managerConfiguration}" class="hide-mobile"></or-conf-json>- <or-mwc-input id="save-btn" raised="" type="button" .label="${i18next.t("save")}"- @click="${() => {- document.dispatchEvent(new CustomEvent("saveManagerConfig", { detail: { value: this.managerConfiguration } }));- }}"></or-mwc-input>- </div>+ <div id="header-title">+ <or-icon icon="palette-outline"></or-icon>+ ${i18next.t("appearance")}+ </div>+ <div id="header-actions">+ <or-conf-json .managerConfig="${this.managerConfiguration}" class="hide-mobile"></or-conf-json>+ <or-mwc-input id="save-btn" raised="" type="button" .label="${i18next.t("save")}"+ @click="${() => {+ document.dispatchEvent(new CustomEvent("saveManagerConfig", { detail: { value: this.managerConfiguration } }));+ }}"></or-mwc-input>+ </div></div><or-panel .heading="${i18next.t("configuration.realmStyling")}">- <or-conf-realm .config="${this.managerConfiguration}"></or-conf-realm>+ <or-conf-realm .config="${this.managerConfiguration}"></or-conf-realm></or-panel>- </div>+ </div>`}`;