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
Improve UX consistency across several settings pages (#2793)
Martin Peeters4331e393f222
diff --git a/ui/app/manager/src/components/configuration/or-conf-panel.ts b/ui/app/manager/src/components/configuration/or-conf-panel.tsindex 9afb3f8fb..12e7a948f 100644--- a/ui/app/manager/src/components/configuration/or-conf-panel.ts+++ b/ui/app/manager/src/components/configuration/or-conf-panel.ts@@ -173,11 +173,12 @@ export class OrConfPanel extends LitElement {}},];+ const headingKey = this.isMapConfig(this.config) ? 'configuration.addMapCustomization' : 'configuration.addRealmCustomization';showDialog(new OrMwcDialog()- .setHeading(i18next.t('configuration.addMapCustomization'))+ .setHeading(i18next.t(headingKey)).setActions(dialogActions).setContent(html`- <or-mwc-input class="selector" label="Realm" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._addedRealm = e.detail.value}" .type="${InputType.SELECT}"+ <or-mwc-input class="selector" label="${i18next.t('realm')}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._addedRealm = e.detail.value}" .type="${InputType.SELECT}".options="${Object.entries(this.getAvailableRealms(this.config, this.realmOptions)).map(([, value]) => {return [value.name, value.displayName]})}"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 32cb16071..223a79cf5 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@@ -33,7 +33,7 @@ import {manager,Util,} from "@openremote/core";-import { i18next } from "@openremote/or-translate";+import { i18next, translate } from "@openremote/or-translate";import { FileInfo, ManagerAppRealmConfig } from "@openremote/model";import { DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";import {when} from 'lit/directives/when.js';@@ -41,7 +41,7 @@ import ISO6391 from 'iso-639-1';import {DefaultHeaderMainMenu, DefaultHeaderSecondaryMenu} from "../../../index";@customElement("or-conf-realm-card")-export class OrConfRealmCard extends LitElement {+export class OrConfRealmCard extends translate(i18next)(LitElement) {static styles = css`.language {@@ -134,16 +134,14 @@ export class OrConfRealmCard extends LitElement {protected headerListPrimary: string[] = Object.keys(DefaultHeaderMainMenu);protected headerListSecondary: string[] = Object.keys(DefaultHeaderSecondaryMenu);- protected commonLanguages: string[] = Object.entries(DEFAULT_LANGUAGES).map(entry => ISO6391.getName(entry[0]));- protected _languages: string[][] = [];-- connectedCallback() {- const languageNames = ISO6391.getAllNames();- this._languages = ISO6391.getAllCodes()- .map((code, index) => ([code, languageNames[index]]))+ protected get _languages(): string[][] {+ return Object.entries(DEFAULT_LANGUAGES)+ .map(([code, key]) => [code, i18next.t(key)]).sort((a, b) => a[1].localeCompare(b[1]));+ }- return super.connectedCallback();+ protected get commonLanguages(): string[] {+ return this._languages.map(entry => entry[1]);}protected _getColors() {@@ -283,14 +281,14 @@ export class OrConfRealmCard extends LitElement {${app.name}</div><div slot="content" class="panel-content">- <div class="subheader">${i18next.t("configuration.main")}</div>- <or-mwc-input class="appTitle" .type="${InputType.TEXT}" .label="${i18next.t("configuration.realmTitle")}" value="${app.realm?.appTitle}"+ <div class="subheader"><or-translate value="configuration.main"></or-translate></div>+ <or-mwc-input class="appTitle" .type="${InputType.TEXT}" label="${i18next.t("configuration.realmTitle")}" value="${app.realm?.appTitle}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => {app.realm.appTitle = e.detail.value;app.notifyConfigChange(app.realm);}}"></or-mwc-input>- <or-mwc-input class="language" .type="${InputType.SELECT}" .label="${i18next.t("configuration.defaultLanguage")}" value="${app.realm?.language}"+ <or-mwc-input class="language" .type="${InputType.SELECT}" label="${i18next.t("configuration.defaultLanguage")}" value="${app.realm?.language}".options="${Object.entries(DEFAULT_LANGUAGES).map(([key, value]) => [key, i18next.t(value)])}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => {app.realm.language = e.detail.value;@@ -298,7 +296,7 @@ export class OrConfRealmCard extends LitElement {}}"></or-mwc-input><div class="logo-group">- <div class="subheader">${i18next.t("configuration.images")}</div>+ <div class="subheader"><or-translate value="configuration.images"></or-translate></div><div class="d-inline-flex"><or-file-uploader .title="${i18next.t('configuration.logo')}"@change="${async (e: CustomEvent) => await app._setImageForUpload(e.detail.value[0], "logo")}"@@ -312,39 +310,39 @@ export class OrConfRealmCard extends LitElement {</div></div><div class="color-group">- <div class="subheader">${i18next.t('configuration.realmColors')}</div>+ <div class="subheader"><or-translate value="configuration.realmColors"></or-translate></div><div><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color4"]}"- .label="${i18next.t('configuration.--or-app-color4')}"+ label="${i18next.t('configuration.--or-app-color4')}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color4", e.detail.value)}"></or-mwc-input><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color5"]}"- .label="${i18next.t('configuration.--or-app-color5')}"+ label="${i18next.t('configuration.--or-app-color5')}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color5", e.detail.value)}"></or-mwc-input><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color6"]}"- .label="${i18next.t("configuration.--or-app-color6")}"+ label="${i18next.t("configuration.--or-app-color6")}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color6", e.detail.value)}"></or-mwc-input><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color1"]}"- .label="${i18next.t("configuration.--or-app-color1")}"+ label="${i18next.t("configuration.--or-app-color1")}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color1", e.detail.value)}"></or-mwc-input><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color2"]}"- .label="${i18next.t("configuration.--or-app-color2")}"+ label="${i18next.t("configuration.--or-app-color2")}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color2", e.detail.value)}"></or-mwc-input><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color3"]}"- .label="${i18next.t("configuration.--or-app-color3")}"+ label="${i18next.t("configuration.--or-app-color3")}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color3", e.detail.value)}"></or-mwc-input><or-mwc-input class="color-item" .type="${InputType.COLOUR}" value="${colors["--or-app-color8"]}"- .label="${i18next.t("configuration.--or-app-color8")}"+ label="${i18next.t("configuration.--or-app-color8")}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => app._setColor("--or-app-color8", e.detail.value)}"></or-mwc-input></div></div><div class="header-group">- <div class="subheader">${i18next.t("configuration.navigation")}</div>- <span>${i18next.t("configuration.navigationDescription")}</span>+ <div class="subheader"><or-translate value="configuration.navigation"></or-translate></div>+ <span><or-translate value="configuration.navigationDescription"></or-translate></span><div><or-mwc-input.type="${InputType.SELECT}" multipleclass="header-item"- .label="${i18next.t("configuration.primaryNavigation")}"+ label="${i18next.t("configuration.primaryNavigation")}".value="${!!app.realm.headers ? app.realm.headers?.filter(function(ele: string) {return app.headerListPrimary.includes(ele);}) : app.headerListPrimary}"@@ -354,7 +352,7 @@ export class OrConfRealmCard extends LitElement {<or-mwc-input.type="${InputType.SELECT}" multipleclass="header-item"- .label="${i18next.t("configuration.secondaryNavigation")}"+ label="${i18next.t("configuration.secondaryNavigation")}".value="${!!app.realm.headers ? app.realm.headers?.filter(function(ele: string) {return app.headerListSecondary.includes(ele);}) : app.headerListSecondary}"@@ -364,14 +362,14 @@ export class OrConfRealmCard extends LitElement {</div></div><div class="header-group">- <div class="subheader">${i18next.t("configuration.notificationLanguages")}</div>- <span>${i18next.t("configuration.notificationLanguagesDesc")}</span>+ <div class="subheader"><or-translate value="configuration.notificationLanguages"></or-translate></div>+ <span><or-translate value="configuration.notificationLanguagesDesc"></or-translate></span><div><or-mwc-input.type="${InputType.SELECT}" multipleclass="header-item"searchLabel="configuration.notificationLanguagesLabel"- .label="${i18next.t("configuration.notificationLanguages")}"+ label="${i18next.t("configuration.notificationLanguages")}".value="${app.realm.notifications?.languages || []}".options="${this._languages}".searchProvider="${searchProvider}"@@ -390,7 +388,7 @@ export class OrConfRealmCard extends LitElement {<or-mwc-input.type="${InputType.SELECT}"class="header-item"- .label="${i18next.t("configuration.defaultLanguage")}"+ label="${i18next.t("configuration.defaultLanguage")}".value="${app.realm.notifications?.defaultLanguage || []}".options="${this._languages.filter(entry => app.realm.notifications?.languages.includes(entry[0]))}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => {@@ -403,7 +401,7 @@ export class OrConfRealmCard extends LitElement {<or-mwc-input.type="${InputType.SELECT}" disabledclass="header-item"- .label="${i18next.t("configuration.defaultLanguage")}"+ label="${i18next.t("configuration.defaultLanguage")}"></or-mwc-input>`)}</div>diff --git a/ui/app/manager/src/pages/page-account.ts b/ui/app/manager/src/pages/page-account.tsindex 7ed43c5fe..00e4f8cc0 100644--- a/ui/app/manager/src/pages/page-account.ts+++ b/ui/app/manager/src/pages/page-account.ts@@ -200,10 +200,10 @@ export class PageAccount extends Page<AppStateKeyed> {</div><div id="content" class="panel">- <p class="panel-title">${i18next.t("user")} ${i18next.t("settings")}</p>+ <p class="panel-title" style="gap: 0.25em;"><or-translate value="user"></or-translate><or-translate value="settings"></or-translate></p><!-- Account settings row -->- ${guard([this._user], () => until(+ ${guard([this._user, this._language], () => until(this._getAccountRowTemplate(this._user, readonly, (_user, dirty, invalid) => {this._dirty = dirty;this._invalid = invalid;@@ -248,9 +248,9 @@ export class PageAccount extends Page<AppStateKeyed> {<div class="row"><div class="column"><!-- user details -->- <h5>${i18next.t("details")}</h5>+ <h5><or-translate value="details"></or-translate></h5><or-mwc-input id="new-username" class="validate"- .label="${i18next.t("username")}"+ label="${i18next.t("username")}".type="${InputType.TEXT}"?required="${!registrationEmailAsUsername}".disabled="${true}"@@ -264,7 +264,7 @@ export class PageAccount extends Page<AppStateKeyed> {></or-mwc-input><!-- if identity provider is set to use email as username, make it required --><or-mwc-input id="new-email" class="validate"- .label="${i18next.t("email")}"+ label="${i18next.t("email")}".type="${InputType.EMAIL}"?required="${registrationEmailAsUsername}"?readonly="${(!!user?.id && registrationEmailAsUsername) || readonly}"@@ -278,7 +278,7 @@ export class PageAccount extends Page<AppStateKeyed> {}}"></or-mwc-input><or-mwc-input id="new-firstName" class="validate"- .label="${i18next.t("firstName")}"+ label="${i18next.t("firstName")}".type="${InputType.TEXT}"?readonly="${readonly}".disabled="${!user}"@@ -290,7 +290,7 @@ export class PageAccount extends Page<AppStateKeyed> {}}"></or-mwc-input><or-mwc-input id="new-surname" class="validate"- .label="${i18next.t("surname")}"+ label="${i18next.t("surname")}".type="${InputType.TEXT}"?readonly="${readonly}".disabled="${!user}"@@ -303,11 +303,11 @@ export class PageAccount extends Page<AppStateKeyed> {</or-mwc-input></div><div class="column">- <h5>${i18next.t("password")}</h5>+ <h5><or-translate value="password"></or-translate></h5>${registrationEmailAsUsername ? html`<!-- Reset password button when email as username is configured --><or-mwc-input id="reset-password" raised- .label="${i18next.t("resetPassword")}"+ label="${i18next.t("resetPassword")}".type="${InputType.BUTTON}".disabled="${!user.email}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => this._onResetPasswordBtnClick(e)}"@@ -315,7 +315,7 @@ export class PageAccount extends Page<AppStateKeyed> {` : html`<!-- Direct password input fields when email as username not configured --><or-mwc-input id="new-password" class="validate"- .label="${i18next.t("password")}"+ label="${i18next.t("password")}".type="${InputType.PASSWORD}"?readonly="${readonly}".disabled="${!user}"@@ -326,7 +326,7 @@ export class PageAccount extends Page<AppStateKeyed> {}}"></or-mwc-input><or-mwc-input id="new-repeatPassword"- .label="${i18next.t("repeatPassword")}"+ label="${i18next.t("repeatPassword")}".type="${InputType.PASSWORD}"helperPersistent?readonly="${readonly}"@@ -354,7 +354,7 @@ export class PageAccount extends Page<AppStateKeyed> {return html`<div class="row" style="justify-content: end; margin-top: 20px;"><or-mwc-input id="savebtn" style="margin: 0;" raised- .label="${i18next.t(user.id ? "save" : "create")}"+ label="${i18next.t(user.id ? "save" : "create")}".type="${InputType.BUTTON}".disabled="${invalid || !dirty}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => this._onSaveBtnClick(e)}"diff --git a/ui/app/manager/src/pages/page-provisioning.ts b/ui/app/manager/src/pages/page-provisioning.tsindex ab6cd7d4d..a8825735f 100644--- a/ui/app/manager/src/pages/page-provisioning.ts+++ b/ui/app/manager/src/pages/page-provisioning.ts@@ -8,7 +8,7 @@ import {AppStateKeyed, Page, PageProvider} from "@openremote/or-app";import {ClientRole, ProvisioningConfig, X509ProvisioningData} from "@openremote/model";import {i18next} from "@openremote/or-translate";import {OrIcon} from "@openremote/or-icon";-import {InputType, OrInputChangedEvent} from "@openremote/or-mwc-components/or-mwc-input";+import {InputType, OrInputChangedEvent, OrMwcInput} from "@openremote/or-mwc-components/or-mwc-input";import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";import {GenericAxiosResponse} from "@openremote/rest";@@ -66,19 +66,25 @@ export class PageProvisioning extends Page<AppStateKeyed> {border-radius: 5px;position: relative;margin: 5px auto;- padding: 24px;+ padding: 12px 24px 24px;}.panel-title {+ display: flex;+ align-items: center;text-transform: uppercase;font-weight: bolder;line-height: 1em;- color: var(--internal-or-asset-viewer-title-text-color);- margin-bottom: 20px;+ color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});+ margin-bottom: 10px;margin-top: 0;flex: 0 0 auto;letter-spacing: 0.025em;- color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});+ min-height: 36px;+ }++ .panel-title p {+ margin: 0;}#table-users,@@ -201,6 +207,8 @@ export class PageProvisioning extends Page<AppStateKeyed> {protected _roleOptions?: [string, string][];@state()protected _realmOptions?: string[];+ @state()+ protected _configFilter: (configs: ProvisioningConfig<any, any>[]) => ProvisioningConfig<any, any>[] = (configs) => configs;get name(): string {return "autoProvisioning";@@ -233,6 +241,12 @@ export class PageProvisioning extends Page<AppStateKeyed> {</div><div class="panel">+ <div class="panel-title" style="justify-content: space-between;">+ <p><or-translate value="provisioningConfigs"></or-translate></p>+ <or-mwc-input style="margin: 0; text-transform: none;" type="${InputType.TEXT}" iconTrailing="magnify" placeholder="${i18next.t('search')}" compact outlined+ @input="${(ev: InputEvent) => this.onConfigSearch(ev)}"+ ></or-mwc-input>+ </div><div id="table-users" class="mdc-data-table"><table class="mdc-data-table__table" aria-label="attribute list"><thead>@@ -252,7 +266,7 @@ export class PageProvisioning extends Page<AppStateKeyed> {</tr></thead><tbody class="mdc-data-table__content">- ${this._configs.map((config, index) => this._getConfigTemplate(() => {+ ${this._configFilter(this._configs).map((config, index) => this._getConfigTemplate(() => {this._configs.pop(); this._configs = [...this._configs];}, config))}${(this._configs.length === 0 || (this._configs.length > 0 && !!this._configs[this._configs.length - 1].id)) ? html`@@ -260,7 +274,7 @@ export class PageProvisioning extends Page<AppStateKeyed> {this._configs = [...this._configs, {type: "x509"}];}}"><td colspan="100%">- <a class="button"><or-icon icon="plus"></or-icon>${i18next.t("add")}</a>+ <a class="button"><or-icon icon="plus"></or-icon>${i18next.t("add")} ${i18next.t("provisioningConfig")}</a></td></tr>` : ``}@@ -368,12 +382,12 @@ export class PageProvisioning extends Page<AppStateKeyed> {const data = config.data as X509ProvisioningData;typeColumnContents = html`- <or-mwc-input .label="${i18next.t("CACertPem")}" required+ <or-mwc-input label="${i18next.t("CACertPem")}" required.type="${InputType.TEXTAREA}".value="${data.CACertPEM}"resizeVertical- @or-mwc-input-changed="${(e: OrInputChangedEvent) => data.CACertPEM = e.detail.value}"></or-mwc-input>- <or-mwc-input .label="${i18next.t("ignoreExpiryDate")}"+ @or-mwc-input-changed="${(e: OrInputChangedEvent) => { data.CACertPEM = e.detail.value; this.requestUpdate(); }}"></or-mwc-input>+ <or-mwc-input label="${i18next.t("ignoreExpiryDate")}".type="${InputType.CHECKBOX}".value="${data.ignoreExpiryDate}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => data.ignoreExpiryDate = !e.detail.value}"@@ -406,38 +420,38 @@ export class PageProvisioning extends Page<AppStateKeyed> {<div class="item-row-content"><div class="row"><div class="column">- <or-mwc-input .label="${i18next.t("name")}"+ <or-mwc-input label="${i18next.t("name")}".type="${InputType.TEXT}" min="1" required.value="${config.name}"- @or-mwc-input-changed="${(e: OrInputChangedEvent) => config.name = e.detail.value}"></or-mwc-input>+ @or-mwc-input-changed="${(e: OrInputChangedEvent) => { config.name = e.detail.value; this.requestUpdate(); }}"></or-mwc-input><or-mwc-input ?disabled="${!!config.id}" required- .label="${i18next.t("type")}"+ label="${i18next.t("type")}".type="${InputType.SELECT}".options="${[["x509", "X.509"]]}".value="${!config.type ? "x509" : config.type}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => config.type = e.detail.value}"></or-mwc-input><or-mwc-input ?disabled="${!!config.id}" required- .label="${i18next.t("realm")}"+ label="${i18next.t("realm")}".type="${InputType.SELECT}".options="${this._realmOptions}".value="${config.realm}"- @or-mwc-input-changed="${(e: OrInputChangedEvent) => config.realm = e.detail.value}"></or-mwc-input>+ @or-mwc-input-changed="${(e: OrInputChangedEvent) => { config.realm = e.detail.value; this.requestUpdate(); }}"></or-mwc-input><or-mwc-input ?disabled="${!!config.id}".value="${config.userRoles}".type="${InputType.SELECT}" multiple.options="${this._roleOptions}"- .label="${i18next.t("role_plural")}"+ label="${i18next.t("role_plural")}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => config.userRoles = e.detail.value as ClientRole[]}"></or-mwc-input>- <or-mwc-input .label="${i18next.t("assetTemplate")}"+ <or-mwc-input label="${i18next.t("assetTemplate")}".type="${InputType.JSON}".value="${config.assetTemplate ? JSON.stringify(JSON.parse(config.assetTemplate), null, 2) : undefined}"resizeVertical@or-mwc-input-changed="${(e: OrInputChangedEvent) => config.assetTemplate = e.detail.value ? JSON.stringify(e.detail.value) : undefined}"></or-mwc-input>- <or-mwc-input .label="${i18next.t("createAsRestrictedUser")}"+ <or-mwc-input label="${i18next.t("createAsRestrictedUser")}".type="${InputType.CHECKBOX}".value="${config.restrictedUser}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => config.restrictedUser = e.detail.value}"></or-mwc-input>- <or-mwc-input .label="${i18next.t("disabled")}"+ <or-mwc-input label="${i18next.t("disabled")}".type="${InputType.CHECKBOX}".value="${config.disabled}"@or-mwc-input-changed="${(e: OrInputChangedEvent) => config.disabled = e.detail.value}"></or-mwc-input>@@ -460,6 +474,7 @@ export class PageProvisioning extends Page<AppStateKeyed> {<or-mwc-input class="savebtn" style="margin-left: auto;"label="${config.id ? "save" : "create"}".type="${InputType.BUTTON}"+ ?disabled="${!config.id && (!config.name || !config.realm || !config.type || !(config.data as X509ProvisioningData)?.CACertPEM)}"@or-mwc-input-changed="${() => this._createUpdateConfig(config)}"></or-mwc-input></div></div>@@ -467,4 +482,17 @@ export class PageProvisioning extends Page<AppStateKeyed> {</tr>`}++ protected onConfigSearch(ev: InputEvent) {+ const value = (ev.target as OrMwcInput).nativeValue?.toLowerCase();+ if (!value) {+ this._configFilter = (configs) => configs;+ } else {+ this._configFilter = (configs) => configs.filter(c =>+ (c.name as string)?.toLowerCase().includes(value) ||+ (c.realm as string)?.toLowerCase().includes(value) ||+ (c.type as string)?.toLowerCase().includes(value)+ );+ }+ }}diff --git a/ui/app/manager/src/pages/page-realms.ts b/ui/app/manager/src/pages/page-realms.tsindex 860c4fe58..3bd532bf6 100644--- a/ui/app/manager/src/pages/page-realms.ts+++ b/ui/app/manager/src/pages/page-realms.ts@@ -1,7 +1,7 @@import {css, html, PropertyValues, TemplateResult, unsafeCSS,} from "lit";import {createSelector} from "reselect";import {createRef, Ref, ref} from "lit/directives/ref.js";-import {customElement, property} from "lit/decorators.js";+import {customElement, property, state} from "lit/decorators.js";import manager, {DefaultColor3} from "@openremote/core";import "@openremote/or-components/or-panel";import "@openremote/or-translate";@@ -63,25 +63,31 @@ export class PageRealms extends Page<AppStateKeyed> {.panel {width: calc(100% - 90px);- padding: 0 20px;max-width: 1310px;background-color: white;border: 1px solid #e5e5e5;border-radius: 5px;position: relative;margin: 0 auto;- padding: 24px;+ padding: 12px 24px 24px;}.panel-title {+ display: flex;+ align-items: center;text-transform: uppercase;font-weight: bolder;line-height: 1em;color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});- margin-bottom: 20px;+ margin-bottom: 10px;margin-top: 0;flex: 0 0 auto;letter-spacing: 0.025em;+ min-height: 36px;+ }++ .panel-title p {+ margin: 0;}@@ -219,6 +225,8 @@ export class PageRealms extends Page<AppStateKeyed> {@property()protected _realms: Realm[] = [];+ @state()+ protected _realmFilter: (realms: Realm[]) => Realm[] = (realms) => realms;protected _realmSelector = (state: AppStateKeyed) => state.app.realm || manager.displayRealm;@@ -226,6 +234,13 @@ export class PageRealms extends Page<AppStateKeyed> {return "realm_plural";}+ protected _onRealmNameChanged(e: OrInputChangedEvent, realm: Realm): void {+ realm.name = e.detail.value;+ const isDuplicate = this._realms.some(r => r !== realm && r.name === realm.name);+ (e.target as OrMwcInput).setCustomValidity(isDuplicate ? i18next.t('realmAlreadyExists') : undefined);+ this.requestUpdate();+ }+protected getRealmState = createSelector([this._realmSelector],async (realm) => {@@ -269,7 +284,12 @@ export class PageRealms extends Page<AppStateKeyed> {)}</div><div class="panel">- <p class="panel-title">${i18next.t("realm_plural")}</p>+ <div class="panel-title" style="justify-content: space-between;">+ <p><or-translate value="realm_plural"></or-translate></p>+ <or-mwc-input style="margin: 0; text-transform: none;" type="${InputType.TEXT}" iconTrailing="magnify" placeholder="${i18next.t('search')}" compact outlined+ @input="${(ev: InputEvent) => this.onRealmSearch(ev)}"+ ></or-mwc-input>+ </div><div id="table-roles" class="mdc-data-table"><table class="mdc-data-table__table" aria-label="realm list" ><thead>@@ -280,7 +300,7 @@ export class PageRealms extends Page<AppStateKeyed> {</tr></thead><tbody class="mdc-data-table__content">- ${this._realms.map(+ ${this._realmFilter(this._realms).map((realm, index) => {return html`@@ -304,15 +324,15 @@ export class PageRealms extends Page<AppStateKeyed> {<div class="row"><div class="column">- <or-mwc-input ?readonly="${realm.id}" .label="${i18next.t("realm")}" .type="${InputType.TEXT}" min="1" required .value="${realm.name}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => realm.name = e.detail.value}"></or-mwc-input>- <or-mwc-input ?readonly="${readonly}" .label="${i18next.t("loginTheme", Util.camelCaseToSentenceCase("loginTheme"))}" .type="${InputType.TEXT}" .value="${realm.loginTheme}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => realm.loginTheme = e.detail.value}"></or-mwc-input>- <or-mwc-input ?readonly="${readonly}" .label="${i18next.t("resetPasswordAllowed")}" .type="${InputType.SWITCH}" min="1" .value="${realm.resetPasswordAllowed}" @or-mwc-input-changed="${(e: OrInputChangedEvent) =>realm.resetPasswordAllowed = e.detail.value}"></or-mwc-input>- <or-mwc-input ?readonly="${readonly}" .label="${i18next.t("enabled")}" .type="${InputType.SWITCH}" min="1" .value="${realm.enabled}" @or-mwc-input-changed="${(e: OrInputChangedEvent) =>realm.enabled = e.detail.value}"></or-mwc-input>- <or-mwc-input ?readonly="${readonly}" .label="${i18next.t("rememberMe")}" .type="${InputType.SWITCH}" min="1" .value="${realm.rememberMe}" @or-mwc-input-changed="${(e: OrInputChangedEvent) =>realm.rememberMe = e.detail.value}"></or-mwc-input>+ <or-mwc-input ?readonly="${realm.id}" label="${i18next.t("realm")}" .type="${InputType.TEXT}" min="1" required .value="${realm.name}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._onRealmNameChanged(e, realm)}"></or-mwc-input>+ <or-mwc-input ?readonly="${readonly}" label="${i18next.t("loginTheme", Util.camelCaseToSentenceCase("loginTheme"))}" .type="${InputType.TEXT}" .value="${realm.loginTheme}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => realm.loginTheme = e.detail.value}"></or-mwc-input>+ <or-mwc-input ?readonly="${readonly}" label="${i18next.t("resetPasswordAllowed")}" .type="${InputType.SWITCH}" min="1" .value="${realm.resetPasswordAllowed}" @or-mwc-input-changed="${(e: OrInputChangedEvent) =>realm.resetPasswordAllowed = e.detail.value}"></or-mwc-input>+ <or-mwc-input ?readonly="${readonly}" label="${i18next.t("enabled")}" .type="${InputType.SWITCH}" min="1" .value="${realm.enabled}" @or-mwc-input-changed="${(e: OrInputChangedEvent) =>realm.enabled = e.detail.value}"></or-mwc-input>+ <or-mwc-input ?readonly="${readonly}" label="${i18next.t("rememberMe")}" .type="${InputType.SWITCH}" min="1" .value="${realm.rememberMe}" @or-mwc-input-changed="${(e: OrInputChangedEvent) =>realm.rememberMe = e.detail.value}"></or-mwc-input></div><div class="column">- <or-mwc-input .label="${i18next.t("displayName")}" .type="${InputType.TEXT}" min="1" required .value="${realm.displayName}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => realm.displayName = e.detail.value}"></or-mwc-input>- <or-mwc-input ?readonly="${readonly}" .label="${i18next.t("emailTheme", Util.camelCaseToSentenceCase("emailTheme"))}" .type="${InputType.TEXT}" .value="${realm.emailTheme}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => realm.emailTheme = e.detail.value}"></or-mwc-input>+ <or-mwc-input label="${i18next.t("displayName")}" .type="${InputType.TEXT}" min="1" required .value="${realm.displayName}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => { realm.displayName = e.detail.value; this.requestUpdate(); }}"></or-mwc-input>+ <or-mwc-input ?readonly="${readonly}" label="${i18next.t("emailTheme", Util.camelCaseToSentenceCase("emailTheme"))}" .type="${InputType.TEXT}" .value="${realm.emailTheme}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => realm.emailTheme = e.detail.value}"></or-mwc-input></div></div>@@ -324,7 +344,7 @@ export class PageRealms extends Page<AppStateKeyed> {<or-mwc-input style="margin-left: auto;" label="save" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRealm(realm)}"></or-mwc-input>` : !readonly ? html`<or-mwc-input label="cancel" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => {this._realms.splice(-1,1); this._realms = [...this._realms]}}"></or-mwc-input>- <or-mwc-input style="margin-left: auto;" label="create" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._createRealm(realm)}"></or-mwc-input>+ <or-mwc-input ?disabled="${!realm.name || !realm.displayName || this._realms.some(r => r !== realm && r.name === realm.name)}" style="margin-left: auto;" label="create" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._createRealm(realm)}"></or-mwc-input>`: ``}</div></div>@@ -335,7 +355,7 @@ export class PageRealms extends Page<AppStateKeyed> {${this._realms.length > 0 && !!this._realms[this._realms.length -1].id && !readonly ? html`<tr class="mdc-data-table__row"><td colspan="100%">- <a class="button" @click="${() => this._realms = [...this._realms, {displayName:"", enabled: true}]}"><or-icon icon="plus"></or-icon>${i18next.t("add")} ${i18next.t("realm")}</a>+ <a class="button" @click="${() => this._realms = [...this._realms, {enabled: true}]}"><or-icon icon="plus"></or-icon>${i18next.t("add")} ${i18next.t("realm")}</a></td></tr>` : ``}@@ -363,23 +383,21 @@ export class PageRealms extends Page<AppStateKeyed> {const response = await manager.rest.api.RealmResource.update(realm.name, realm);if (response.status === 204) {showSnackbar(undefined, "saveRealmSucceeded");+ this.dispatchEvent(new CustomEvent("realms-changed", { bubbles: true, composed: true }));} else {showSnackbar(undefined, "saveRealmFailed");}- //TODO improve this so that header realm picker is updated- window.location.reload();}private async _createRealm(realm) {- await manager.rest.api.RealmResource.create(realm).then(response => {- if (response.status === 204) {- showSnackbar(undefined, "saveRealmSucceeded");- } else {- showSnackbar(undefined, "saveRealmFailed");- }- //TODO improve this so that header realm picker is updated- window.location.reload();- });+ const response = await manager.rest.api.RealmResource.create(realm);+ if (response.status === 204) {+ showSnackbar(undefined, "saveRealmSucceeded");+ await this._getRealms();+ this.dispatchEvent(new CustomEvent("realms-changed", { bubbles: true, composed: true }));+ } else {+ showSnackbar(undefined, "saveRealmFailed");+ }}private _deleteRealm(realm: Realm) {@@ -392,6 +410,7 @@ export class PageRealms extends Page<AppStateKeyed> {try {await manager.rest.api.RealmResource.delete(realm.name);this._realms = this._realms.filter(r => r !== realm);+ this.dispatchEvent(new CustomEvent("realms-changed", { bubbles: true, composed: true }));} catch (e) {showSnackbar(undefined, "realmDeleteFailed", "dismiss");}@@ -406,7 +425,7 @@ export class PageRealms extends Page<AppStateKeyed> {const dialogContent = html`<div><p style="text-align: justify; font-weight: bold;">${i18next.t("realmDeleteConfirm", {realmName: realm.name})}</p>- <or-mwc-input .type="${InputType.TEXT}" @input=${(ev: Event) => inputChanged((ev.target as OrMwcInput).nativeValue)} .label="${i18next.t("realm")}"></or-mwc-input>+ <or-mwc-input .type="${InputType.TEXT}" @input=${(ev: Event) => inputChanged((ev.target as OrMwcInput).nativeValue)} label="${i18next.t("realm")}"></or-mwc-input></div>`;const dialogActions: DialogAction[] = [@@ -449,6 +468,18 @@ export class PageRealms extends Page<AppStateKeyed> {.setDismissAction(null));}+ protected onRealmSearch(ev: InputEvent) {+ const value = (ev.target as OrMwcInput).nativeValue?.toLowerCase();+ if (!value) {+ this._realmFilter = (realms) => realms;+ } else {+ this._realmFilter = (realms) => realms.filter(r =>+ (r.name as string)?.toLowerCase().includes(value) ||+ (r.displayName as string)?.toLowerCase().includes(value)+ );+ }+ }+private async _doDelete(realm) {await manager.rest.api.RealmResource.delete(realm.realm);this._realms = [...this._realms.filter(u => u.id != realm.id)];diff --git a/ui/app/manager/src/pages/page-roles.ts b/ui/app/manager/src/pages/page-roles.tsindex ce0a840a9..e6982b38c 100644--- a/ui/app/manager/src/pages/page-roles.ts+++ b/ui/app/manager/src/pages/page-roles.ts@@ -15,7 +15,7 @@ import {AppStateKeyed} from "@openremote/or-app";import { ClientRole, Role } from "@openremote/model";import { i18next } from "@openremote/or-translate";import { OrIcon } from "@openremote/or-icon";-import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";+import { InputType, OrInputChangedEvent, OrMwcInput } from "@openremote/or-mwc-components/or-mwc-input";import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";const tableStyle = require("@material/data-table/dist/mdc.data-table.css");@@ -71,18 +71,25 @@ export class PageRoles extends Page<AppStateKeyed> {border-radius: 5px;position: relative;margin: 0 auto;- padding: 18px 24px 24px;+ padding: 12px 24px 24px;}.panel-title {+ display: flex;+ align-items: center;text-transform: uppercase;font-weight: bolder;line-height: 1em;color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});- margin-bottom: 20px;+ margin-bottom: 10px;margin-top: 0;flex: 0 0 auto;letter-spacing: 0.025em;+ min-height: 36px;+ }++ .panel-title p {+ margin: 0;}#table-roles,@@ -111,6 +118,7 @@ export class PageRoles extends Page<AppStateKeyed> {max-height: 0;transition: max-height 0.25s ease-out;padding-left: 16px;+ padding-right: 16px;}or-mwc-input {@@ -227,6 +235,9 @@ export class PageRoles extends Page<AppStateKeyed> {@state()protected _rolesMapper = {};+ @state()+ protected _roleFilter: (roles: Role[]) => Role[] = (roles) => roles;+@state()public realm?: string;@@ -234,6 +245,13 @@ export class PageRoles extends Page<AppStateKeyed> {return "role_plural";}+ protected _onRoleNameChanged(e: OrInputChangedEvent, role: Role): void {+ role.name = e.detail.value;+ const isDuplicate = this._compositeRoles.some(r => r !== role && r.name === role.name);+ (e.target as OrMwcInput).setCustomValidity(isDuplicate ? i18next.t('roleAlreadyExists') : undefined);+ this.requestUpdate();+ }+public shouldUpdate(_changedProperties: PropertyValues): boolean {if (_changedProperties.has("realm")) {@@ -333,7 +351,12 @@ export class PageRoles extends Page<AppStateKeyed> {<or-icon icon="account-box-multiple"></or-icon>${i18next.t("role_plural")}</div><div class="panel">- <p class="panel-title">${i18next.t("role")}</p>+ <div class="panel-title" style="justify-content: space-between;">+ <p style="margin: 0;"><or-translate value="role"></or-translate></p>+ <or-mwc-input style="margin: 0; text-transform: none;" type="${InputType.TEXT}" iconTrailing="magnify" placeholder="${i18next.t('search')}" compact outlined+ @input="${(ev: InputEvent) => this.onRoleSearch(ev)}"+ ></or-mwc-input>+ </div><div id="table-roles" class="mdc-data-table"><table class="mdc-data-table__table" aria-label="attribute list"><thead>@@ -350,7 +373,7 @@ export class PageRoles extends Page<AppStateKeyed> {</tr></thead><tbody class="mdc-data-table__content">- ${this._compositeRoles.map((role, index) => {+ ${this._roleFilter(this._compositeRoles).map((role, index) => {const compositeRoleName = role.compositeRoleIds.map(id => this._rolesMapper[id]).sort((a, b) => a.localeCompare(b)).join(', '); return html`<tr id="mdc-data-table-row-${index}" class="mdc-data-table__row" @click="${() => this.expanderToggle(index)}"><td class="padded-cell mdc-data-table__cell">@@ -370,23 +393,23 @@ export class PageRoles extends Page<AppStateKeyed> {<div class="row"><div class="column">- <or-mwc-input .label="${i18next.t("role")}" .type="${InputType.TEXT}" min="1" required .value="${role.name}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => role.name = e.detail.value}"></or-mwc-input>+ <or-mwc-input label="${i18next.t("role")}" .type="${InputType.TEXT}" min="1" required .value="${role.name || undefined}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._onRoleNameChanged(e, role)}"></or-mwc-input></div><div class="column">- <or-mwc-input .label="${i18next.t("description")}" .type="${InputType.TEXT}" min="1" required .value="${role.description}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => role.description = e.detail.value}"></or-mwc-input>+ <or-mwc-input label="${i18next.t("description")}" .type="${InputType.TEXT}" min="1" required .value="${role.description}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => role.description = e.detail.value}"></or-mwc-input></div></div><div class="row"><div class="column">- <strong class="column-title">${i18next.t("readPermissions")}</strong> ${readRoles.map(r => {+ <strong class="column-title"><or-translate value="readPermissions"></or-translate></strong> ${readRoles.map(r => {return html`<or-mwc-input ?readonly="${readonly}" .label="${r.name.split(":")[1]}: ${r.description}" .type="${InputType.CHECKBOX}" .value="${role.compositeRoleIds && role.compositeRoleIds.find(id => id === r.id)}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.addRemoveRole(e, r, index)}"></or-mwc-input>` })}</div><div class="column">- <strong class="column-title">${i18next.t("writePermissions")}</strong> ${writeRoles.map(r => {+ <strong class="column-title"><or-translate value="writePermissions"></or-translate></strong> ${writeRoles.map(r => {return html`<or-mwc-input ?readonly="${readonly}" .label="${r.name.split(":")[1]}: ${r.description}" .type="${InputType.CHECKBOX}" .value="${role.compositeRoleIds && role.compositeRoleIds.find(id => id === r.id)}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.addRemoveRole(e, r, index)}"></or-mwc-input>` })}@@ -406,10 +429,10 @@ export class PageRoles extends Page<AppStateKeyed> {<div class="row" style="margin-bottom: 0;">${role.id ? html`<or-mwc-input label="delete" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._deleteRole(role, index)}"></or-mwc-input>- <or-mwc-input ?disabled="${this._compositeRoles.some(role => role.compositeRoleIds.length === 0)}" style="margin-left: auto;" label="save" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRoles()}"></or-mwc-input>+ <or-mwc-input ?disabled="${this._compositeRoles.some(r => r.compositeRoleIds.length === 0) || this._compositeRoles.some((r, i) => this._compositeRoles.some((o, j) => i !== j && r.name && r.name === o.name))}" style="margin-left: auto;" label="save" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRoles()}"></or-mwc-input>` : html`<or-mwc-input label="cancel" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => { this._compositeRoles.splice(-1, 1); this._compositeRoles = [...this._compositeRoles] }}"></or-mwc-input>- <or-mwc-input ?disabled="${this._compositeRoles.some(role => role.compositeRoleIds.length === 0)}" style="margin-left: auto;" label="create" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRoles()}"></or-mwc-input>+ <or-mwc-input ?disabled="${this._compositeRoles.some(r => r.compositeRoleIds.length === 0) || this._compositeRoles.some((r, i) => this._compositeRoles.some((o, j) => i !== j && r.name && r.name === o.name))}" style="margin-left: auto;" label="create" .type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._updateRoles()}"></or-mwc-input>`}</div>`}@@ -432,6 +455,18 @@ export class PageRoles extends Page<AppStateKeyed> {`;}+ protected onRoleSearch(ev: InputEvent) {+ const value = (ev.target as OrMwcInput).nativeValue?.toLowerCase();+ if (!value) {+ this._roleFilter = (roles) => roles;+ } else {+ this._roleFilter = (roles) => roles.filter(r =>+ (r.name as string)?.toLowerCase().includes(value) ||+ (r.description as string)?.toLowerCase().includes(value)+ );+ }+ }+public stateChanged(state: AppStateKeyed) {this.realm = state.app.realm;}diff --git a/ui/app/manager/test/fixtures/pages/realms.ts b/ui/app/manager/test/fixtures/pages/realms.tsindex 68e8ab475..8d96da914 100644--- a/ui/app/manager/test/fixtures/pages/realms.ts+++ b/ui/app/manager/test/fixtures/pages/realms.ts@@ -19,8 +19,13 @@ export class RealmsPage implements BasePage {console.warn(`Realm "${name}" already present`);} else {await this.page.click("text=Add Realm");- await this.page.locator("#realm-row-1 label").filter({ hasText: "Realm" }).fill(name);- await this.page.locator("#realm-row-1 label").filter({ hasText: "Friendly name" }).fill(name);+ const realmRow = this.page.locator("#realm-row-1");+ const realmNameInput = realmRow.locator("or-mwc-input").filter({ hasText: "Realm" }).locator("input");+ const displayNameInput = realmRow.locator("or-mwc-input").filter({ hasText: "Friendly name" }).locator("input");+ await realmNameInput.fill(name);+ await realmNameInput.dispatchEvent("change");+ await displayNameInput.fill(name);+ await displayNameInput.dispatchEvent("change");await this.page.getByRole("button", { name: "create" }).click();}}diff --git a/ui/component/or-app/src/index.ts b/ui/component/or-app/src/index.tsindex 3e0e66e46..ea643e19c 100644--- a/ui/component/or-app/src/index.ts+++ b/ui/component/or-app/src/index.ts@@ -183,12 +183,14 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {super.connectedCallback();this._storeUnsubscribe = this._store.subscribe(() => this.stateChanged(this.getState()));document.addEventListener("visibilitychange", this._onVisibilityChanged);+ this.addEventListener("realms-changed", this._onRealmsChanged);this.stateChanged(this.getState());}disconnectedCallback() {this._storeUnsubscribe();- document.removeEventListener("visibilityChange", this._onVisibilityChanged);+ document.removeEventListener("visibilitychange", this._onVisibilityChanged);+ this.removeEventListener("realms-changed", this._onRealmsChanged);manager.removeListener(this._onEvent);super.disconnectedCallback();}@@ -246,8 +248,7 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {}// Load available realm info- const response = await manager.rest.api.RealmResource.getAccessible();- this._realms = response.data;+ await this._refreshRealms();let realm: string | null | undefined = undefined;@@ -444,6 +445,19 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {this._offline = state.app!.offline;}+ protected _onRealmsChanged = () => this._refreshRealms();++ protected async _refreshRealms() {+ try {+ const response = await manager.rest.api.RealmResource.getAccessible();+ this._realms = response.data;+ this.requestUpdate();+ } catch (e) {+ console.error(e);+ showErrorDialog("errorOccurred", document.body);+ }+ }+protected _handleEvent(event: OREvent) {if(event === OREvent.OFFLINE) {if(!this._offline) {@@ -560,8 +574,8 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {.setHeading(html`<img id="login-logo" src="${this._config.logoMobile || this._config.logo}" /></or-icon><or-translate value="login"></or-translate>`).setContent(html`<div id="login_wrapper">- <or-mwc-input .label="${i18next.t("user")}" .type="${InputType.TEXT}" min="1" required .value="${username}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => u = e.detail.value}"></or-mwc-input>- <or-mwc-input .label="${i18next.t("password")}" .type="${InputType.PASSWORD}" min="1" required .value="${password}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => p = e.detail.value}"></or-mwc-input>+ <or-mwc-input label="${i18next.t("user")}" .type="${InputType.TEXT}" min="1" required .value="${username}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => u = e.detail.value}"></or-mwc-input>+ <or-mwc-input label="${i18next.t("password")}" .type="${InputType.PASSWORD}" min="1" required .value="${password}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => p = e.detail.value}"></or-mwc-input></div>`).setActions([@@ -575,7 +589,7 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {password: p!});},- content: html`<or-mwc-input .type=${InputType.BUTTON} .label="${i18next.t("submit")}" raised></or-mwc-input>`+ content: html`<or-mwc-input .type=${InputType.BUTTON} label="${i18next.t("submit")}" raised></or-mwc-input>`}]), document.body); // Attach to document as or-app isn't visible until initialiseddiff --git a/ui/component/or-asset-tree/src/or-add-asset-dialog.ts b/ui/component/or-asset-tree/src/or-add-asset-dialog.tsindex d8e4574ff..db05dafc3 100644--- a/ui/component/or-asset-tree/src/or-add-asset-dialog.ts+++ b/ui/component/or-asset-tree/src/or-add-asset-dialog.ts@@ -307,9 +307,9 @@ export class OrAddAssetDialog extends LitElement {<or-translate id="type-description" .value="${Util.getAssetTypeLabel(descriptor)}"></or-translate></div><div id="name-wrapper">- <or-mwc-input id="name-input" .type="${InputType.TEXT}" min="1" max="1023" required .label="${i18next.t("name")}" .value="${this.name}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.onNameChanged(e.detail.value)}"></or-mwc-input>+ <or-mwc-input id="name-input" .type="${InputType.TEXT}" min="1" max="1023" required label="${i18next.t("name")}" .value="${this.name}" @or-mwc-input-changed="${(e: OrInputChangedEvent) => this.onNameChanged(e.detail.value)}"></or-mwc-input><div id="parent-wrapper">- <or-mwc-input id="parent" .type="${InputType.TEXT}" readonly .label="${i18next.t("parent")}" .value="${parentStr}" @click="${() => this._onToggleParentAssetSelector()}"></or-mwc-input>+ <or-mwc-input id="parent" .type="${InputType.TEXT}" readonly label="${i18next.t("parent")}" .value="${parentStr}" @click="${() => this._onToggleParentAssetSelector()}"></or-mwc-input><or-mwc-input id="remove-parent" ?disabled="${!this.parent}" type="${InputType.BUTTON}" icon="close" @or-mwc-input-changed="${() => this._onDeselectClicked()}"></or-mwc-input><or-mwc-input id="toggle-parent-selector" icon="${this.showParentAssetSelector ? "pencil-off" : "pencil"}" type="${InputType.BUTTON}" @or-mwc-input-changed="${() => this._onToggleParentAssetSelector()}"></or-mwc-input></div>@@ -319,11 +319,11 @@ export class OrAddAssetDialog extends LitElement {? html``: html`<div>- <div class="heading">${i18next.t("attribute_plural")}</div>+ <div class="heading"><or-translate value="attribute_plural"></or-translate></div><div style="display: grid">${attributes.sort(Util.sortByString((attribute) => attribute.name!)).map(attribute => html`- <or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(undefined, attribute, undefined, true)}"+ <or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(undefined, attribute, descriptor.name, true)}".disabled="${true}" .value="${true}"></or-mwc-input>`)}</div>@@ -333,11 +333,11 @@ export class OrAddAssetDialog extends LitElement {? html``: html`<div>- <div class="heading">${i18next.t("optional_attributes")}</div>+ <div class="heading"><or-translate value="optional_attributes"></or-translate></div><div style="display: grid">${optionalAttributes.sort(Util.sortByString((attribute) => attribute.name!)).map(attribute => html`- <or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(undefined, attribute, undefined, true)}"+ <or-mwc-input .type="${InputType.CHECKBOX}" .label="${Util.getAttributeLabel(undefined, attribute, descriptor.name, true)}".value="${this.selectedAttributes.find((selected) => selected === attribute)}"@or-mwc-input-changed="${(evt: OrInputChangedEvent) => evt.detail.value ? this.selectedAttributes.push(attribute) : this.selectedAttributes.splice(this.selectedAttributes.findIndex((s) => s === attribute), 1)}"></or-mwc-input>`)}diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex 76e2b879f..1032579b3 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -842,7 +842,7 @@ export class OrChart extends translate(i18next)(LitElement) {<div id="attribute-list" class="${this.denseLegend ? 'attribute-list-dense' : undefined}">${this.assetAttributes == null || this.assetAttributes.length == 0 ? html`<div>- <span>${i18next.t('noAttributesConnected')}</span>+ <span><or-translate value="noAttributesConnected"></or-translate></span></div>` : undefined}${map(this.assetAttributes?.map(([assetIndex, attr], index) => {@@ -1077,7 +1077,7 @@ export class OrChart extends translate(i18next)(LitElement) {.setHeading(i18next.t('timeframe')).setContent(() => html`<div>- <or-mwc-input ${ref(startRef)} type="${InputType.DATETIME}" required label="${i18next.t('start')}" .value="${startTimestamp}"></or-mwc-input>+ <or-mwc-input ${ref(startRef)} type="${InputType.DATETIME}" required label="${i18next.t('beginning')}" .value="${startTimestamp}"></or-mwc-input><or-mwc-input ${ref(endRef)} type="${InputType.DATETIME}" required label="${i18next.t('ending')}" .value="${endTimestamp}"></or-mwc-input></div>`)diff --git a/ui/component/or-dashboard-builder/src/index.ts b/ui/component/or-dashboard-builder/src/index.tsindex f95622272..13af51982 100644--- a/ui/component/or-dashboard-builder/src/index.ts+++ b/ui/component/or-dashboard-builder/src/index.ts@@ -17,7 +17,7 @@ import {ListItem} from "@openremote/or-mwc-components/or-mwc-list";import {OrMwcTabItem} from "@openremote/or-mwc-components/or-mwc-tabs";import "@openremote/or-mwc-components/or-mwc-tabs";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";-import {i18next} from "@openremote/or-translate";+import {i18next, translate} from "@openremote/or-translate";import {showOkCancelDialog} from "@openremote/or-mwc-components/or-mwc-dialog";import {DashboardKeyEmitter} from "./or-dashboard-keyhandler";import {OrDashboardPreview} from "./or-dashboard-preview";@@ -225,7 +225,7 @@ export function registerWidgetTypes() {}@customElement("or-dashboard-builder")-export class OrDashboardBuilder extends LitElement {+export class OrDashboardBuilder extends translate(i18next)(LitElement) {// Importing Styles; the unsafe GridStack css, and all custom cssstatic get styles() {@@ -603,7 +603,7 @@ export class OrDashboardBuilder extends LitElement {<div id="header-title"><or-icon icon="view-dashboard"></or-icon>${this.selectedDashboard != null ? html`- <or-mwc-input .type="${InputType.TEXT}" min="1" max="1023" comfortable required outlined .label="${i18next.t('name')}"+ <or-mwc-input .type="${InputType.TEXT}" min="1" max="1023" comfortable required outlined label="${i18next.t('name')}"?readonly="${this._isReadonly() || !this._hasEditAccess()}" .value="${this.selectedDashboard.displayName}".disabled="${this.isLoading}" style="width: 300px;"@or-mwc-input-changed="${(event: OrInputChangedEvent) => { this.changeDashboardName(event.detail.value); }}"@@ -684,7 +684,7 @@ export class OrDashboardBuilder extends LitElement {></or-dashboard-preview>` : html`<div style="display: flex; justify-content: center; align-items: center; height: 100%;">- <span>${i18next.t('noDashboardSelected')}</span>+ <span><or-translate value="noDashboardSelected"></or-translate></span></div>`}</div>diff --git a/ui/component/or-dashboard-builder/src/or-dashboard-boardsettings.ts b/ui/component/or-dashboard-builder/src/or-dashboard-boardsettings.tsindex ddb9e1df2..abb39c2e4 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-boardsettings.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-boardsettings.ts@@ -3,7 +3,7 @@ import {css, html, LitElement} from "lit";import {customElement, property} from "lit/decorators.js";import {InputType, OrInputChangedEvent} from "@openremote/or-mwc-components/or-mwc-input";import {style} from './style';-import {i18next} from "@openremote/or-translate";+import {i18next, translate} from "@openremote/or-translate";import {unsafeHTML} from 'lit/directives/unsafe-html.js';import {when} from "lit/directives/when.js";import {dashboardAccessToString, scalingPresetToString, sortScreenPresets} from ".";@@ -16,7 +16,7 @@ const boardSettingsStyling = css``@customElement("or-dashboard-boardsettings")-export class OrDashboardBoardsettings extends LitElement {+export class OrDashboardBoardsettings extends translate(i18next)(LitElement) {@property({ type: Object })public readonly dashboard!: Dashboard;diff --git a/ui/component/or-dashboard-builder/src/or-dashboard-preview.ts b/ui/component/or-dashboard-builder/src/or-dashboard-preview.tsindex 039768049..f5a228e20 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-preview.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-preview.ts@@ -11,7 +11,7 @@ import "@openremote/or-components/or-loading-indicator";import {repeat} from 'lit/directives/repeat.js';import {GridItemHTMLElement, GridStack, GridStackElement, GridStackNode} from "gridstack";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";-import {i18next} from "@openremote/or-translate";+import {i18next, translate} from "@openremote/or-translate";import {when} from "lit/directives/when.js";import {cache} from "lit/directives/cache.js";import {guard} from "lit/directives/guard.js";@@ -123,7 +123,7 @@ export interface DashboardPreviewSize {/* ------------------------------------------------------------ */@customElement("or-dashboard-preview")-export class OrDashboardPreview extends LitElement {+export class OrDashboardPreview extends translate(i18next)(LitElement) {// Monitoring the changes in the template, save the changes to this.latestChanges,// so we can check afterwards which changes are made. Used fordiff --git a/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts b/ui/component/or-dashboard-builder/src/or-dashboard-tree.tsindex e2decc039..2044adbcd 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-tree.ts@@ -8,7 +8,7 @@ import manager, {Util} from '@openremote/core';import {ListItem} from '@openremote/or-mwc-components/or-mwc-list';import '@openremote/or-mwc-components/or-mwc-menu';import {showOkCancelDialog} from '@openremote/or-mwc-components/or-mwc-dialog';-import {i18next} from '@openremote/or-translate';+import {i18next, translate} from '@openremote/or-translate';import {showSnackbar} from '@openremote/or-mwc-components/or-mwc-snackbar';import {style as OrAssetTreeStyle} from '@openremote/or-asset-tree';import {DashboardService, DashboardSizeOption} from './service/dashboard-service';@@ -34,7 +34,7 @@ const treeStyling = css``;@customElement('or-dashboard-tree')-export class OrDashboardTree extends LitElement {+export class OrDashboardTree extends translate(i18next)(LitElement) {static get styles() {return [style, treeStyling, OrAssetTreeStyle];diff --git a/ui/component/or-dashboard-builder/src/or-dashboard-widgetsettings.ts b/ui/component/or-dashboard-builder/src/or-dashboard-widgetsettings.tsindex 0b523373b..6425d3f2d 100644--- a/ui/component/or-dashboard-builder/src/or-dashboard-widgetsettings.ts+++ b/ui/component/or-dashboard-builder/src/or-dashboard-widgetsettings.ts@@ -3,7 +3,7 @@ import {html, LitElement, TemplateResult, unsafeCSS } from "lit";import { customElement, property, state } from "lit/decorators.js";import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";import {style} from './style';-import { i18next } from "@openremote/or-translate";+import { i18next, translate } from "@openremote/or-translate";import { until } from "lit/directives/until.js";import {WidgetService} from "./service/widget-service";import {WidgetSettings, WidgetSettingsChangedEvent} from "./util/widget-settings";@@ -15,7 +15,7 @@ const tableStyle = require("@material/data-table/dist/mdc.data-table.css");/* ------------------------------------ */@customElement("or-dashboard-widgetsettings")-export class OrDashboardWidgetsettings extends LitElement {+export class OrDashboardWidgetsettings extends translate(i18next)(LitElement) {static get styles() {return [unsafeCSS(tableStyle), style]