Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Bugfix for appearance logo upload (#1108)

Martin Peeterse10e5c15614c
diff --git a/ui/app/manager/src/components/configuration/or-conf-panel.ts b/ui/app/manager/src/components/configuration/or-conf-panel.ts
index 454da96a6..9747f960c 100644
--- a/ui/app/manager/src/components/configuration/or-conf-panel.ts
+++ b/ui/app/manager/src/components/configuration/or-conf-panel.ts
@@ -22,11 +22,11 @@ export class OrConfPanel extends LitElement {
protected _addedRealm: null | string = null
- public getCardElement(): OrConfRealmCard | OrConfMapCard | undefined {
+ public getCardElements(): OrConfRealmCard[] | OrConfMapCard[] | undefined {
if(this.isManagerConfig(this.config)) {
- return this.shadowRoot?.querySelector('or-conf-realm-card');
+ return Array.from(this.shadowRoot?.querySelectorAll('or-conf-realm-card')) as OrConfRealmCard[];
} else if (this.isMapConfig(this.config)) {
- return this.shadowRoot?.querySelector('or-conf-map-card');
+ return Array.from(this.shadowRoot?.querySelectorAll('or-conf-map-card')) as OrConfMapCard[];
}
}
@@ -92,7 +92,7 @@ export class OrConfPanel extends LitElement {
<!-- Show an "ADD REALM" button if there are realms available to be added -->
<div style="display: flex; justify-content: space-between;">
${when(availableRealms.length > 0, () => html`
- <or-mwc-input id="btn-add-realm" .type="${InputType.BUTTON}" .label="${i18next.t('configuration.addMapCustomization')}" icon="plus"
+ <or-mwc-input id="btn-add-realm" .type="${InputType.BUTTON}" .label="${type === 'mapconfig' ? i18next.t('configuration.addMapCustomization') : i18next.t('configuration.addRealmCustomization')}" icon="plus"
@click="${() => this._showAddingRealmDialog()}"
></or-mwc-input>
`)}
diff --git a/ui/app/manager/src/pages/page-configuration.ts b/ui/app/manager/src/pages/page-configuration.ts
index d41b1b4b2..c2b0956e5 100644
--- a/ui/app/manager/src/pages/page-configuration.ts
+++ b/ui/app/manager/src/pages/page-configuration.ts
@@ -160,7 +160,7 @@ export class PageConfiguration extends Page<AppStateKeyed> {
protected mapConfigChanged = false;
@query("#managerConfig-panel")
- protected realmCardElem?: OrConfPanel;
+ protected realmConfigPanel?: OrConfPanel;
private readonly urlPrefix: string = (CONFIG_URL_PREFIX || "")
@@ -308,11 +308,14 @@ export class PageConfiguration extends Page<AppStateKeyed> {
// Save the images to the server that have been uploaded by the user.
// TODO: Optimize code so it only saves images that have been changed.
const imagePromises = [];
- if(this.realmCardElem !== undefined) {
- const elem = this.realmCardElem?.getCardElement() as OrConfRealmCard;
- Object.entries(elem?.getFiles()).forEach(async ([x, y]) => {
- imagePromises.push(manager.rest.api.ConfigurationResource.fileUpload(y, {path: x}));
- });
+ if(this.realmConfigPanel !== undefined) {
+ const elems = this.realmConfigPanel.getCardElements() as OrConfRealmCard[];
+ elems.forEach((elem, index) => {
+ const files = elem?.getFiles();
+ Object.entries(files).forEach(async ([x, y]) => {
+ imagePromises.push(manager.rest.api.ConfigurationResource.fileUpload(y, {path: x}));
+ });
+ })
}
// Wait for all requests to complete, then finish loading.
diff --git a/ui/component/or-components/src/or-file-uploader.ts b/ui/component/or-components/src/or-file-uploader.ts
index ab7785612..df0d58b48 100644
--- a/ui/component/or-components/src/or-file-uploader.ts
+++ b/ui/component/or-components/src/or-file-uploader.ts
@@ -28,15 +28,15 @@ export class OrFileUploader extends LitElement {
// Contains the content that will be shown towards the user.
@property({ attribute: false })
- public src: string = "";
+ public readonly src: string = "";
@property()
- public title: string = "";
+ public readonly title: string = "";
@property({ attribute: false })
- public accept: string = "image/png,image/jpeg,image/vnd.microsoft.icon,image/svg+xml";
+ public readonly accept: string = "image/png,image/jpeg,image/vnd.microsoft.icon,image/svg+xml";
- private loading: boolean = false;
+ private loading = false;
private files: FileInfo[] = []
get Files(): FileInfo[] {