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
Migrate another set of UI dialogs to or-vaadin-dialog (#3265)
Martin Peeters10408cfaee1f
diff --git a/ui/app/manager/src/components/configuration/or-conf-json.ts b/ui/app/manager/src/components/configuration/or-conf-json.tsindex d4d84296a..16610deac 100644--- a/ui/app/manager/src/components/configuration/or-conf-json.ts+++ b/ui/app/manager/src/components/configuration/or-conf-json.ts@@ -20,11 +20,11 @@ import { html } from "lit";import { OrElement } from "@openremote/or-element";import { customElement, property } from "lit/decorators.js";import "@openremote/or-components/or-ace-editor";-import type { DialogAction } from "@openremote/or-mwc-components/or-mwc-dialog";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { createRef, type Ref, ref } from "lit/directives/ref.js";import type { OrAceEditor, OrAceEditorChangedEvent } from "@openremote/or-components/or-ace-editor";import type { ManagerAppConfig, MapConfig } from "@openremote/model";+import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";@customElement("or-conf-json")export class OrConfJson extends OrElement {@@ -34,6 +34,7 @@ export class OrConfJson extends OrElement {public heading: string;protected _aceEditor: Ref<OrAceEditor> = createRef();+ protected _updateButton: Ref<OrVaadinButton> = createRef();public beforeSave(): false | string | undefined {if (!this._aceEditor.value) {@@ -48,7 +49,7 @@ export class OrConfJson extends OrElement {}protected _showConfigDialog() {- let dialog: OrMwcDialog;+ let dialog: OrVaadinDialog | undefined;const _saveConfig = () => {const config = this.beforeSave();if (config) {@@ -59,55 +60,42 @@ export class OrConfJson extends OrElement {return false;};- const dialogActions: DialogAction[] = [- {- actionName: "cancel",- content: "cancel",- },- {- actionName: "ok",- content: "update",- action: _saveConfig,- },- ];-- dialog = new OrMwcDialog()- .setActions(dialogActions)- .setHeading(this.heading)- .setContent(html`- <or-ace-editor- ${ref(this._aceEditor)}- .value="${this.config}"- @or-ace-editor-changed="${(ev: OrAceEditorChangedEvent) => {- const okButton = dialog.actions?.find((action) => action.actionName === "ok");- if (okButton) {- okButton.disabled = !ev.detail.valid;- dialog.requestUpdate();- }- }}"- ></or-ace-editor>- `)- .setStyles(html`- <style>- .mdc-dialog__surface {- width: 1024px;- overflow-x: visible !important;- overflow-y: visible !important;- }- #dialog-content {- border-top-width: 1px;- border-top-style: solid;- border-bottom-width: 1px;- border-bottom-style: solid;- padding: 0;- overflow: visible;- height: 60vh;- }- </style>- `)- .setDismissAction(null);+ const onCancel = () => {+ dialog?.close();+ };+ const onOk = () => {+ if (_saveConfig()) {+ dialog?.close();+ }+ };- showDialog(dialog);+ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="768px" no-close-on-esc no-close-on-outside-click>+ <h2 slot="header-content">${this.heading}</h2>+ <or-ace-editor+ ${ref(this._aceEditor)}+ .value="${this.config}"+ style="aspect-ratio: 1/1;"+ @or-ace-editor-changed="${(ev: OrAceEditorChangedEvent) => {+ if (this._updateButton.value) {+ this._updateButton.value.disabled = !ev.detail.valid;+ dialog?.requestUpdate();+ }+ }}"+ ></or-ace-editor>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" ${ref(this._updateButton)} @click=${onOk}>+ <or-translate value="update"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `+ );}render() {diff --git a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.tsindex afc104bd7..c5d645aa9 100644--- a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts+++ b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-card.ts@@ -23,7 +23,7 @@ import { when } from "lit/directives/when.js";import "@openremote/or-components/or-file-uploader";import { i18next } from "@openremote/or-translate";import type { MapRealmConfig } from "@openremote/model";-import { type DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { getConfirmDialogContent, showConfirmDialog } from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";import type { OrMapLongPressEvent } from "@openremote/or-map";import type { LngLat } from "maplibre-gl";@@ -57,37 +57,13 @@ export class OrConfMapCard extends OrElement {}protected _showRemoveMapDialog() {- const dialogActions: DialogAction[] = [- {- actionName: "cancel",- content: "cancel",- },- {- default: true,- actionName: "ok",- content: "yes",- action: () => {- this.dispatchEvent(new CustomEvent("remove"));- },- },- ];- showDialog(- new OrMwcDialog()- .setHeading(i18next.t("delete"))- .setActions(dialogActions)- .setContent(html` ${i18next.t("configuration.deleteMapCustomizationConfirm")} `)- .setStyles(html`- <style>- .mdc-dialog__surface {- padding: 4px 8px;- }-- #dialog-content {- padding: 24px;- }- </style>- `)- .setDismissAction(null)+ showConfirmDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-confirm-dialog @confirm=${() => this.dispatchEvent(new CustomEvent("remove"))}>+ ${getConfirmDialogContent("error", "delete", "configuration.deleteMapCustomizationConfirm", "delete", "cancel")}+ </or-vaadin-confirm-dialog>+ `);}diff --git a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.tsindex ab0f752a8..08f881fce 100644--- a/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts+++ b/ui/app/manager/src/components/configuration/or-conf-map/or-conf-map-geojson.ts@@ -17,12 +17,14 @@* SPDX-License-Identifier: AGPL-3.0-or-later*/import type { GeoJsonConfig } from "@openremote/model";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { html } from "lit";import { OrElement } from "@openremote/or-element";import { customElement, property, state } from "lit/decorators.js";import "@openremote/or-components/or-ace-editor";-import type { OrAceEditorChangedEvent } from "@openremote/or-components/or-ace-editor";+import type { OrAceEditor, OrAceEditorChangedEvent } from "@openremote/or-components/or-ace-editor";+import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";+import { createRef, type Ref, ref } from "lit/directives/ref.js";@customElement("or-conf-map-geojson")export class OrConfMapGeoJson extends OrElement {@@ -32,7 +34,7 @@ export class OrConfMapGeoJson extends OrElement {@state()protected _jsonValid: boolean = true;- protected _dialog: OrMwcDialog;+ protected _dialog: OrVaadinDialog;// Value of or-ace-editor without state to prevent UI updateprotected _aceEditorValue: string;@@ -40,63 +42,50 @@ export class OrConfMapGeoJson extends OrElement {protected render() {return html`- <or-vaadin-button @click=${() => this.showDialog()}>+ <or-vaadin-button @click=${() => this._showDialog()}><or-icon slot="prefix" icon="pencil"></or-icon><or-translate value="configuration.geoJson"></or-translate></or-vaadin-button>`;}- protected showDialog() {+ protected _showDialog() {+ const buttonRef: Ref<OrVaadinButton> = createRef();+ const editorRef: Ref<OrAceEditor> = createRef();+ const onOk = () => {+ this.geoJson = this.parseGeoJson(this._aceEditorValue); // update with new value+ this.dispatchEvent(new CustomEvent("update", { detail: { value: this.geoJson } }));+ this._dialog?.close();+ };this._dialog = showDialog(- new OrMwcDialog()- .setHeading("GeoJSON editor")- .setStyles(- html` <style>- .mdc-dialog__surface {- width: 1024px;- overflow-x: visible !important;- overflow-y: visible !important;- }- #dialog-content {- border-top-width: 1px;- border-top-style: solid;- border-bottom-width: 1px;- border-bottom-style: solid;- padding: 0;- overflow: visible;- height: 60vh;- }- </style>`- )- .setActions([- {- actionName: "close",- content: "close",- },- {- actionName: "ok",- content: "update",- disabled: !this._jsonValid,- action: () => {- this.geoJson = this.parseGeoJson(this._aceEditorValue); // update with new value- this.dispatchEvent(new CustomEvent("update", { detail: { value: this.geoJson } }));- },- },- ])- .setContent(- () =>- html` <or-ace-editor- .value="${this.geoJson?.source}"- @or-ace-editor-changed="${(ev: OrAceEditorChangedEvent) => {- this._jsonValid = ev.detail.valid;- if (this._jsonValid) {- this._aceEditorValue = ev.detail.value;- }- }}"- ></or-ace-editor>`- )- .setDismissAction(null)+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="768px" no-close-on-esc no-close-on-outside-click>+ <h2 slot="header-content">+ <span>GeoJSON editor</span>+ </h2>+ <or-ace-editor+ ${ref(editorRef)}+ .value="${this.geoJson?.source}"+ style="width: 100%; aspect-ratio: 1/1;"+ @or-ace-editor-changed="${(ev: OrAceEditorChangedEvent) => {+ this._jsonValid = ev.detail.valid;+ buttonRef.value!.disabled = !this._jsonValid;+ if (this._jsonValid) {+ this._aceEditorValue = ev.detail.value;+ }+ }}"+ ></or-ace-editor>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => this._dialog?.close()}>+ <or-translate value="close"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" ${ref(buttonRef)} disabled @click=${onOk}>+ <or-translate value="update"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}diff --git a/ui/app/manager/src/components/configuration/or-conf-panel.ts b/ui/app/manager/src/components/configuration/or-conf-panel.tsindex b58825665..58e9deb4b 100644--- a/ui/app/manager/src/components/configuration/or-conf-panel.ts+++ b/ui/app/manager/src/components/configuration/or-conf-panel.ts@@ -18,18 +18,18 @@*/import { html, type TemplateResult } from "lit";import { OrElement } from "@openremote/or-element";-import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";import { customElement, property } from "lit/decorators.js";import { when } from "lit/directives/when.js";import type { ManagerAppConfig, MapConfig } from "@openremote/model";-import { type DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";-import { i18next } from "@openremote/or-translate";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";+import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";import "@openremote/or-components/or-loading-indicator";import "./or-conf-map/or-conf-map-card";import "./or-conf-realm/or-conf-realm-card";import type { OrConfRealmCard } from "./or-conf-realm/or-conf-realm-card";import type { OrConfMapCard } from "./or-conf-map/or-conf-map-card";import type { OrVaadinSelect } from "@openremote/or-vaadin-components/or-vaadin-select";+import { createRef, ref, type Ref } from "lit/directives/ref.js";@customElement("or-conf-panel")export class OrConfPanel extends OrElement {@@ -184,39 +184,30 @@ export class OrConfPanel extends OrElement {// Show the dialog to "add realm", that allows users to override realm options.protected _showAddingRealmDialog() {this._addedRealm = null;- const dialogActions: DialogAction[] = [- {- actionName: "cancel",- content: "cancel",- },- {- default: true,- actionName: "ok",- content: "ok",- action: () => {- if (this._addedRealm) {- let realms = this.getRealmsProperty(this.config);- if (!realms) {- realms = {};- }- if (this.isManagerConfig(this.config)) {- realms[this._addedRealm] = {}; // empty object since no fields are required- } else if (this.isMapConfig(this.config)) {- realms[this._addedRealm] = {- bounds: [4.42, 51.88, 4.55, 51.94],- center: [4.485222, 51.911712],- zoom: 14,- minZoom: 14,- maxZoom: 19,- boxZoom: false,- };- }- this.requestUpdate("config");- this.notifyConfigChange(this.config);- }- },- },- ];+ let dialog: OrVaadinDialog | undefined;+ const onOk = () => {+ if (this._addedRealm) {+ let realms = this.getRealmsProperty(this.config);+ if (!realms) {+ realms = {};+ }+ if (this.isManagerConfig(this.config)) {+ realms[this._addedRealm] = {}; // empty object since no fields are required+ } else if (this.isMapConfig(this.config)) {+ realms[this._addedRealm] = {+ bounds: [4.42, 51.88, 4.55, 51.94],+ center: [4.485222, 51.911712],+ zoom: 14,+ minZoom: 14,+ maxZoom: 19,+ boxZoom: false,+ };+ }+ this.requestUpdate("config");+ this.notifyConfigChange(this.config);+ dialog?.close();+ }+ };const headingKey = this.isMapConfig(this.config)? "configuration.addMapCustomization": "configuration.addRealmCustomization";@@ -224,42 +215,38 @@ export class OrConfPanel extends OrElement {value: item.name,label: item.displayName,}));- showDialog(- new OrMwcDialog()- .setHeading(i18next.t(headingKey))- .setActions(dialogActions)- .setContent(html`- <div style="width: 280px; padding: 10px 20px;">- <or-vaadin-select- class="selector"- .items=${realmItems}- @change=${(ev: Event) => (this._addedRealm = (ev.currentTarget as OrVaadinSelect).value)}- >- <or-translate slot="label" value="realm"></or-translate>- </or-vaadin-select>- </div>- `)- .setStyles(html`- <style>- .mdc-dialog__surface {- padding: 4px 8px;- }-- #dialog-content {- flex: 1;- overflow: visible;- min-height: 0;- padding: 0;- }- or-mwc-input.selector {- width: 300px;- display: block;- padding: 10px 20px;- }- </style>- `)- .setDismissAction(null)+ const selectRef: Ref<OrVaadinSelect> = createRef();+ const buttonRef: Ref<OrVaadinButton> = createRef();+ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value=${headingKey}></or-translate>+ </h2>+ <or-vaadin-select+ ${ref(selectRef)}+ required+ class="selector"+ .items=${realmItems}+ @change=${(ev: Event) => {+ this._addedRealm = (ev.currentTarget as OrVaadinSelect).value;+ buttonRef.value!.disabled = !selectRef.value?.checkValidity();+ }}+ >+ <or-translate slot="label" value="realm"></or-translate>+ </or-vaadin-select>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => dialog?.close()}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" ${ref(buttonRef)} disabled @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}}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 52daf6353..3486bccdf 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@@ -35,10 +35,10 @@ import {} from "@openremote/core";import { i18next, translate } from "@openremote/or-translate";import type { FileInfo, ManagerAppRealmConfig } from "@openremote/model";-import { type DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";import { when } from "lit/directives/when.js";import { DefaultHeaderMainMenu, DefaultHeaderSecondaryMenu } from "../../../index";import type { OrVaadinMultiSelectComboBox } from "@openremote/or-vaadin-components/or-vaadin-multi-select-combo-box";+import { getConfirmDialogContent, showConfirmDialog } from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";@customElement("or-conf-realm-card")export class OrConfRealmCard extends translate(i18next)(OrElement) {@@ -229,37 +229,13 @@ export class OrConfRealmCard extends translate(i18next)(OrElement) {}protected _showRemoveRealmDialog() {- const dialogActions: DialogAction[] = [- {- actionName: "cancel",- content: "cancel",- },- {- default: true,- actionName: "ok",- content: "yes",- action: () => {- this.dispatchEvent(new CustomEvent("remove"));- },- },- ];- showDialog(- new OrMwcDialog()- .setHeading(i18next.t("delete"))- .setActions(dialogActions)- .setContent(html` ${i18next.t("configuration.deleteRealmCustomizationConfirm")} `)- .setStyles(html`- <style>- .mdc-dialog__surface {- padding: 4px 8px;- }-- #dialog-content {- padding: 24px;- }- </style>- `)- .setDismissAction(null)+ showConfirmDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-confirm-dialog @confirm=${() => this.dispatchEvent(new CustomEvent("remove"))}>+ ${getConfirmDialogContent("error", "delete", "configuration.deleteRealmCustomizationConfirm", "delete", "cancel")}+ </or-vaadin-confirm-dialog>+ `);}diff --git a/ui/app/manager/src/pages/page-alarms.ts b/ui/app/manager/src/pages/page-alarms.tsindex 260929aa9..38b7f6fe1 100644--- a/ui/app/manager/src/pages/page-alarms.ts+++ b/ui/app/manager/src/pages/page-alarms.ts@@ -999,7 +999,7 @@ export class PageAlarms extends Page<AppStateKeyed> {></or-asset-tree><div slot="footer" style="width: 100%; display: flex; justify-content: space-between;"><or-vaadin-button- theme="tertiary"+ theme="tertiary contrast"@click=${() => {onCancel();dialog?.close();diff --git a/ui/app/manager/src/pages/page-assets.ts b/ui/app/manager/src/pages/page-assets.tsindex 39ef7679a..5f1910b4e 100644--- a/ui/app/manager/src/pages/page-assets.ts+++ b/ui/app/manager/src/pages/page-assets.ts@@ -43,16 +43,16 @@ import {OrAssetTreeRequestSelectionEvent,OrAssetTreeSelectionEvent,} from "@openremote/or-asset-tree";-import manager, { DefaultBoxShadow, DefaultColor5, Util } from "@openremote/core";+import manager, { DefaultBoxShadow, Util } from "@openremote/core";import { type AppStateKeyed, Page, type PageProvider, router } from "@openremote/or-app";import { createSlice, type Store, createSelector } from "@reduxjs/toolkit";-import { type DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";-import { i18next } from "@openremote/or-translate";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { type Asset, AssetEventCause, WellknownAssets } from "@openremote/model";import "@openremote/or-json-forms";import { getAlarmsRoute, getAssetsRoute, getUsersRoute } from "../routes";import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import { getConfirmDialogContent, showConfirmDialog } from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";+import { createRef, ref, type Ref } from "lit/directives/ref.js";export interface PageAssetsConfig {viewer?: ViewerConfig;@@ -274,82 +274,59 @@ export class PageAssets extends Page<AssetsStateKeyed> {}protected _onParentChangeClick() {- let dialog: OrMwcDialog;+ let dialog: OrVaadinDialog | undefined;+ const assetTreeRef: Ref<OrAssetTree> = createRef();- const blockEvent = (ev: Event) => {- ev.stopPropagation();- };-- const dialogContent = html` <or-asset-tree- id="parent-asset-tree"- disableSubscribe- readonly- .selectedIds="${[]}"- @or-asset-tree-request-select="${blockEvent}"- @or-asset-tree-selection-changed="${blockEvent}"- ></or-asset-tree>`;+ const blockEvent = (ev: Event) => ev.stopPropagation();const setParent = () => {- const assetTree = dialog.shadowRoot!.getElementById("parent-asset-tree") as OrAssetTree;+ const assetTree = assetTreeRef.value!;const idd = assetTree.selectedIds!.length === 1 ? assetTree.selectedIds![0] : undefined;this._onAssetParentChange({ parentId: idd, assetIds: this._assetIds });};const clearParent = () => {this._onAssetParentChange({ parentId: undefined, assetIds: this._assetIds });+ dialog?.close();};- const dialogActions: DialogAction[] = [- {- actionName: "clear",- content: "none",- action: clearParent,- },- {- actionName: "ok",- content: "ok",- action: setParent,- },- {- default: true,- actionName: "cancel",- content: "cancel",- },- ];+ const onCancel = () => dialog?.close();+ const onOk = () => {+ setParent();+ dialog?.close();+ };dialog = showDialog(- new OrMwcDialog()- .setContent(dialogContent)- .setActions(dialogActions)- .setStyles(html`- <style>- .mdc-dialog__surface {- width: 400px;- height: 800px;- display: flex;- overflow: visible;- overflow-x: visible !important;- overflow-y: visible !important;- }-- #dialog-content {- flex: 1;- overflow: visible;- min-height: 0;- padding: 0;- }-- footer.mdc-dialog__actions {- border-top: 1px solid ${unsafeCSS(DefaultColor5)};- }-- or-asset-tree {- height: 100%;- }- </style>- `)- .setHeading(i18next.t("setParent"))- .setDismissAction(null)+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="setParent"></or-translate>+ </h2>+ <or-asset-tree+ ${ref(assetTreeRef)}+ disableSubscribe+ readonly+ .selectedIds="${[]}"+ style="width: 100%; aspect-ratio: 1/1.75;"+ @or-asset-tree-request-selection="${blockEvent}"+ @or-asset-tree-selection="${blockEvent}"+ ></or-asset-tree>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <div>+ <or-vaadin-button @click=${clearParent}>+ <or-translate value="clear"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </div>+ </or-vaadin-dialog>+ `);}diff --git a/ui/app/manager/src/pages/page-gateway-tunnel.ts b/ui/app/manager/src/pages/page-gateway-tunnel.tsindex 8066a8d47..8a93adca1 100644--- a/ui/app/manager/src/pages/page-gateway-tunnel.ts+++ b/ui/app/manager/src/pages/page-gateway-tunnel.ts@@ -28,12 +28,14 @@ import { DefaultColor3, manager } from "@openremote/core";import { type Asset, type AssetQuery, type GatewayTunnelInfo, GatewayTunnelInfoType } from "@openremote/model";import type { TableColumn, TableRow } from "@openremote/or-mwc-components/or-mwc-table";import { getAssetsRoute } from "../routes";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import moment from "moment";import type { OrVaadinComboBox } from "@openremote/or-vaadin-components/or-vaadin-combo-box";import type { OrVaadinSelect } from "@openremote/or-vaadin-components/or-vaadin-select";import { getConfirmDialogContent, showConfirmDialog } from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";+import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";+import { createRef, ref, type Ref } from "lit/directives/ref.js";export function pageGatewayTunnelProvider(store: Store<AppStateKeyed>): PageProvider<AppStateKeyed> {return {@@ -313,25 +315,21 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {*/protected _onAddTunnelClick() {const tunnel = {} as GatewayTunnelInfo;- let dialog: OrMwcDialog | undefined;+ let dialog: OrVaadinDialog | undefined;+ const buttonRef: Ref<OrVaadinButton> = createRef();const onAddClick = () => {this._tryStartTunnel(tunnel);+ dialog?.close();};- const updateActions = () => {- dialog.setActions([- { actionName: "cancel", content: "cancel" },- {- actionName: "add",- disabled:- !tunnel.gatewayId ||- (tunnel.hostname && tunnel.hostname.trim().length === 0) ||- (tunnel.targetPort !== undefined && (tunnel.targetPort <= 0 || tunnel.targetPort > 65535)),- content: "add",- action: () => onAddClick(),- },- ]);++ const checkValidity = () => {+ buttonRef.value!.disabled =+ !tunnel.gatewayId ||+ (tunnel.hostname && tunnel.hostname.trim().length === 0) ||+ (tunnel.targetPort !== undefined && (tunnel.targetPort <= 0 || tunnel.targetPort > 65535));};+const gatewayListTemplate = async (): Promise<TemplateResult> => {const gatewayAssets = await this._fetchGatewayAssets();const items: { value: any; label: string }[] = gatewayAssets.map((g) => ({ value: g.id, label: g.name }));@@ -340,13 +338,13 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {label: String(g),}));return html`- <div style="display: flex; flex-direction: column; gap: 20px; width: 360px;">+ <div style="display: flex; flex-direction: column; gap: 20px; width: 100%;"><or-vaadin-combo-box.items=${items}value="${tunnel.gatewayId}"@change=${(ev: Event) => {tunnel.gatewayId = (ev.currentTarget as OrVaadinComboBox).value;- updateActions();+ checkValidity();}}><or-translate slot="label" value="gatewayTunnels.selectAsset"></or-translate>@@ -357,7 +355,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {placeholder=${this.GATEWAY_TUNNEL_PROTOCOL_TYPES?.[0]}@change=${(ev: Event) => {tunnel.type = (ev.currentTarget as OrVaadinSelect).value as GatewayTunnelInfoType;- updateActions();+ checkValidity();}}><or-translate slot="label" value="gatewayTunnels.protocol"></or-translate>@@ -367,7 +365,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {placeholder="localhost"@change=${(ev: Event) => {tunnel.target = (ev.currentTarget as HTMLInputElement).value;- updateActions();+ checkValidity();}}><or-translate slot="label" value="host"></or-translate>@@ -380,7 +378,7 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {@change=${(ev: Event) => {const value = (ev.currentTarget as HTMLInputElement).value;tunnel.targetPort = value ? Number(value) : undefined;- updateActions();+ checkValidity();}}><or-translate slot="label" value="port"></or-translate>@@ -388,12 +386,26 @@ export class PageGatewayTunnel extends Page<AppStateKeyed> {</div>`;};- dialog = new OrMwcDialog()- .setHeading(`${i18next.t("add")} ${i18next.t("tunnel")}`)- .setContent(html` ${until(gatewayListTemplate(), html`${i18next.t("loading")}`)} `);-- updateActions();- showDialog(dialog);+ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="add"></or-translate>+ <or-translate value="tunnel"></or-translate>+ </h2>+ ${until(gatewayListTemplate(), html`<or-translate value="loading"></or-translate>`)}+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => dialog?.close()}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" ${ref(buttonRef)} disabled @click=${() => onAddClick()}>+ <or-translate value="add"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `+ );}/**diff --git a/ui/app/manager/src/pages/page-gateway.ts b/ui/app/manager/src/pages/page-gateway.tsindex 99111b4c7..08446ad13 100644--- a/ui/app/manager/src/pages/page-gateway.ts+++ b/ui/app/manager/src/pages/page-gateway.ts@@ -23,7 +23,8 @@ import { when } from "lit/directives/when.js";import { until } from "lit/directives/until.js";import { createRef, type Ref, ref } from "lit/directives/ref.js";import "@openremote/or-components/or-panel";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog as showVaadinDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import {type AttributeDescriptor,type AttributePredicate,@@ -35,7 +36,7 @@ import {LogicGroupOperator,type GatewayAssetSyncRule,} from "@openremote/model";-import manager, { DefaultColor1, DefaultColor3 } from "@openremote/core";+import manager, { DefaultColor1 } from "@openremote/core";import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";import { type AppStateKeyed, Page, type PageProvider } from "@openremote/or-app";@@ -774,49 +775,57 @@ export class PageGateway extends Page<AppStateKeyed> {* The changed are only applied once the save button is pressed.*/protected _openConnectionJSONEditor(connection?: GatewayConnection) {+ let dialog: OrVaadinDialog | undefined;const editorRef: Ref<OrAceEditor> = createRef();- showDialog(- new OrMwcDialog()- .setHeading("JSON Editor")- .setContent(html`+ const onCancel = () => dialog?.close();+ const onOk = () => {+ const editor = editorRef.value;+ if (!editor.validate()) {+ console.warn("JSON was not valid");+ showSnackbar(undefined, i18next.t("errorOccurred"));+ return;+ }+ try {+ let parsed: GatewayAttributeFilter[] | undefined;+ if (editor.getValue().length > 0) {+ parsed = JSON.parse(editor.getValue());++ // Verify if the JSON is an array. If so; simply accept the format.+ if (!Array.isArray(parsed)) {+ console.warn("Could not parse JSON to GatewayAttributeFilter[], as it was not an array.");+ showSnackbar(undefined, i18next.t("errorOccurred"));+ return;+ }+ }+ this._updateAttributeFilters(parsed);+ dialog?.close();+ } catch (e) {+ console.error(e);+ showSnackbar(undefined, i18next.t("errorOccurred"));+ }+ };+ dialog = showVaadinDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="768px">+ <h2 slot="header-content">+ <span>JSON Editor</span>+ </h2><or-ace-editor${ref(editorRef)}.value="${connection?.attributeFilters}"- style="height: 60vh; width: 1024px;"+ style="width: 100%; aspect-ratio: 1/1;"></or-ace-editor>- `)- .setActions([- { actionName: "cancel", content: "cancel" },- {- actionName: "save",- content: "save",- action: () => {- const editor = editorRef.value;- if (!editor.validate()) {- console.warn("JSON was not valid");- showSnackbar(undefined, i18next.t("errorOccurred"));- return;- }- try {- let parsed: GatewayAttributeFilter[] | undefined;- if (editor.getValue().length > 0) {- parsed = JSON.parse(editor.getValue());-- // Verify if the JSON is an array. If so; simply accept the format.- if (!Array.isArray(parsed)) {- console.warn("Could not parse JSON to GatewayAttributeFilter[], as it was not an array.");- showSnackbar(undefined, i18next.t("errorOccurred"));- return;- }- }- this._updateAttributeFilters(parsed);- } catch (e) {- console.error(e);- showSnackbar(undefined, i18next.t("errorOccurred"));- }- },- },- ])+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="save"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}}diff --git a/ui/app/manager/src/pages/page-notifications.ts b/ui/app/manager/src/pages/page-notifications.tsindex 6159090d5..e7c19c5cf 100644--- a/ui/app/manager/src/pages/page-notifications.ts+++ b/ui/app/manager/src/pages/page-notifications.ts@@ -536,7 +536,7 @@ export class PageNotifications extends Page<AppStateKeyed> {${dialogRenderer(() => this._renderCreateForm(), [this.realm])}${dialogFooterRenderer(() => html`- <or-vaadin-button theme="tertiary" @click="${() => this._cancelCreateDialog()}">+ <or-vaadin-button theme="tertiary contrast" @click="${() => this._cancelCreateDialog()}"><or-translate value="cancel"></or-translate></or-vaadin-button><or-vaadin-buttondiff --git a/ui/app/manager/src/pages/page-realms.ts b/ui/app/manager/src/pages/page-realms.tsindex f5c02710c..350e535f8 100644--- a/ui/app/manager/src/pages/page-realms.ts+++ b/ui/app/manager/src/pages/page-realms.ts@@ -28,8 +28,11 @@ import { type AppStateKeyed, Page, type PageProvider } from "@openremote/or-app"import { ClientRole, type Realm } from "@openremote/model";import { i18next } from "@openremote/or-translate";import type { OrIcon } from "@openremote/or-icon";-import { InputType } from "@openremote/or-mwc-components/or-mwc-input";-import { type DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import {+ getConfirmDialogContent,+ type OrVaadinConfirmDialog,+ showConfirmDialog,+} from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import type { OrVaadinTextField } from "@openremote/or-vaadin-components/or-vaadin-text-field";import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";@@ -522,8 +525,8 @@ export class PageRealms extends Page<AppStateKeyed> {let confirmedName = "";const okBtnRef: Ref<OrVaadinButton> = createRef();- const doDelete = async (dialog: OrMwcDialog) => {- if (okBtnRef.value.disabled) return;+ const doDelete = async (dialog?: OrVaadinConfirmDialog) => {+ if (okBtnRef.value!.disabled) return;try {await manager.rest.api.RealmResource.delete(realm.name);this._realms = this._realms.filter((r) => r !== realm);@@ -531,6 +534,8 @@ export class PageRealms extends Page<AppStateKeyed> {} catch (e) {const snackbarKey = (e as any)?.response?.status === 409 ? "realmDeleteFailedHasAssets" : "realmDeleteFailed";showSnackbar(undefined, snackbarKey, "dismiss");+ } finally {+ dialog?.close();}};@@ -550,45 +555,23 @@ export class PageRealms extends Page<AppStateKeyed> {</or-vaadin-text-field></div>`;- const dialogActions: DialogAction[] = [- {- actionName: "ok",- content: html`<or-mwc-input .type="${InputType.BUTTON}" ${ref(okBtnRef)} disabled label="ok"></or-mwc-input>`,- action: doDelete,- },- {- default: true,- actionName: "cancel",- content: "cancel",- },- ];-- const dialog = showDialog(- new OrMwcDialog()- .setContent(dialogContent)- .setActions(dialogActions)- .setStyles(html`- <style>- .mdc-dialog__surface {- display: flex;- width: 400px;- max-width: 100%;- overflow: visible;- overflow-x: visible !important;- overflow-y: visible !important;- }- #dialog-content {- text-align: center;- flex: 1;- overflow: visible;- min-height: 0;- }- or-asset-tree {- height: 100%;- }- </style>- `)- .setDismissAction(null)+ const dialog = showConfirmDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-confirm-dialog theme="no-header" @confirm=${() => doDelete(dialog)}>+ ${getConfirmDialogContent(+ "error",+ undefined,+ dialogContent,+ html`+ <or-vaadin-button theme="primary error" ${ref(okBtnRef)} disabled slot="confirm-button">+ <or-translate value="delete"></or-translate>+ </or-vaadin-button>+ `,+ "cancel"+ )}+ </or-vaadin-confirm-dialog>+ `);}diff --git a/ui/app/manager/src/pages/page-users.ts b/ui/app/manager/src/pages/page-users.tsindex 59eaefbee..44cda9d54 100644--- a/ui/app/manager/src/pages/page-users.ts+++ b/ui/app/manager/src/pages/page-users.ts@@ -33,7 +33,7 @@ import {type UserSession,} from "@openremote/model";import { i18next } from "@openremote/or-translate";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import { type GenericAxiosResponse, isAxiosError } from "@openremote/rest";import type { OrAssetTreeRequestSelectionEvent, OrAssetTreeSelectionEvent } from "@openremote/or-asset-tree";@@ -826,10 +826,27 @@ export class PageUsers extends Page<AppStateKeyed> {});};- const dialog = showDialog(- new OrMwcDialog()- .setHeading(i18next.t("linkedAssets"))- .setContent(html`+ let dialog: OrVaadinDialog | undefined;+ const onCancel = () => {+ user.userAssetLinks = user.previousAssetLinks;+ user.previousAssetLinks = undefined;+ openBtn.disabled = false;+ dialog?.close();+ };+ const onOk = () => {+ openBtn.disabled = false;+ this.onUserChanged(suffix);+ this.requestUpdate();+ dialog?.close();+ };++ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px" no-close-on-esc no-close-on-outside-click>+ <h2 slot="header-content">+ <or-translate value="linkedAssets"></or-translate>+ </h2><or-asset-treeid="chart-asset-tree"readonly@@ -848,36 +865,16 @@ export class PageUsers extends Page<AppStateKeyed> {}}}"></or-asset-tree>- `)- .setActions([- {- default: true,- actionName: "cancel",- content: "cancel",- action: () => {- user.userAssetLinks = user.previousAssetLinks;- user.previousAssetLinks = undefined;- openBtn.disabled = false;- },- },- {- actionName: "ok",- content: "ok",- action: () => {- openBtn.disabled = false;- this.onUserChanged(suffix);- this.requestUpdate();- },- },- ])- .setDismissAction({- actionName: "cancel",- action: () => {- user.userAssetLinks = user.previousAssetLinks;- user.previousAssetLinks = undefined;- openBtn.disabled = false;- },- })+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}diff --git a/ui/app/manager/test/assets.test.ts b/ui/app/manager/test/assets.test.tsindex 16d4bab65..4dd762019 100644--- a/ui/app/manager/test/assets.test.ts+++ b/ui/app/manager/test/assets.test.ts@@ -195,8 +195,8 @@ test.describe("Parent asset", () => {await assetViewer.switchMode("modify");await page.getByText("Parent Edit").getByRole("button").click();- await page.getByLabel("Select parent asset").getByText("Parent").click();- await page.getByLabel("Select parent asset").getByRole("button", { name: "OK" }).click();+ await page.getByRole("dialog").getByText("Parent").click();+ await page.getByRole("dialog").getByRole("button", { name: "OK" }).click();await page.getByRole("button", { name: "Save" }).click();await expect(page.getByRole("textbox", { name: "Parent" })).toHaveValue("Parent");@@ -217,7 +217,7 @@ test.describe("Parent asset", () => {await assetViewer.switchMode("modify");await page.getByText("Parent Edit").getByRole("button").click();- await page.getByLabel("Select parent asset").getByRole("button", { name: "NONE" }).click();+ await page.getByRole("dialog").getByRole("button", { name: "Clear" }).click();await page.getByRole("button", { name: "Save" }).click();await expect(page.getByRole("textbox", { name: "Parent" })).toBeEmpty();@@ -243,7 +243,7 @@ test.describe("Attributes", () => {await page.getByRole("button", { name: "Add attribute" }).click();- const dialog = page.getByLabel("Add attribute");+ const dialog = page.getByRole("dialog");await dialog.getByLabel("Name").fill("test");await dialog.getByRole("combobox", { name: "Value type", exact: true }).fill("Int");await dialog.getByRole("option", { name: "Integer", exact: true }).click();diff --git a/ui/app/manager/test/fixtures/pages/assets.ts b/ui/app/manager/test/fixtures/pages/assets.tsindex 0d1af3637..6fc996dde 100644--- a/ui/app/manager/test/fixtures/pages/assets.ts+++ b/ui/app/manager/test/fixtures/pages/assets.ts@@ -53,7 +53,7 @@ export class AssetsPage implements BasePage {await this.shared.interceptResponse<Asset>("**/asset", (asset) => {if (asset) this.manager.assets.push(asset);});- await this.page.click("#add-btn");+ await this.page.getByRole("dialog").getByRole("button", { name: "Create asset" }).click();}/**diff --git a/ui/app/manager/test/fixtures/pages/realms.ts b/ui/app/manager/test/fixtures/pages/realms.tsindex e4a726d19..291dc98f3 100644--- a/ui/app/manager/test/fixtures/pages/realms.ts+++ b/ui/app/manager/test/fixtures/pages/realms.ts@@ -60,6 +60,6 @@ export class RealmsPage implements BasePage {await this.page.getByRole("cell", { name: realm }).first().click();await this.page.getByRole("button", { name: "Delete" }).click();await this.page.getByRole("alertdialog").getByRole("textbox", { name: "Realm" }).fill(realm);- await this.page.getByRole("button", { name: "OK" }).click();+ await this.page.getByRole("alertdialog").getByRole("button", { name: "Delete" }).click();}}diff --git a/ui/app/manager/test/rules.test.ts b/ui/app/manager/test/rules.test.tsindex d9d49ff20..89066dd94 100644--- a/ui/app/manager/test/rules.test.ts+++ b/ui/app/manager/test/rules.test.ts@@ -259,17 +259,17 @@ test("Create a When-Then rule for an asset with a email notification action", asawait then.getByRole("textbox", { name: "Subject", exact: true }).clear();await rulesPage.blurActiveField(then);await expect(then.getByRole("textbox", { name: "Subject", exact: true })).toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).toBeDisabled();await then.getByRole("textbox", { name: "Subject", exact: true }).fill("Email notification");await rulesPage.blurActiveField(then);await expect(then.getByRole("textbox", { name: "Subject", exact: true })).not.toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();await then.getByRole("textbox", { name: "Body", exact: true }).fill("Assets that have been impacted: %TRIGGER_ASSETS%");- await then.getByRole("button", { name: "OK", exact: true }).click();+ await then.getByRole("button", { name: "Ok", exact: true }).click();await shared.interceptResponse<number>("**/rules/realm", (rule) => {if (rule) manager.rules.push(rule);@@ -325,24 +325,24 @@ test("Create a When-Then rule for an asset with a push notification action", asyawait then.getByRole("textbox", { name: "Body", exact: true }).clear();await rulesPage.blurActiveField(then);await expect(then.getByRole("textbox", { name: "Body", exact: true })).toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).toBeDisabled();await then.getByRole("textbox", { name: "Body", exact: true }).fill("Impacted assets: %TRIGGER_ASSETS%");await rulesPage.blurActiveField(then);await expect(then.getByRole("textbox", { name: "Body", exact: true })).not.toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();// Fill in website URLawait then.getByRole("textbox", { name: "Website to be opened", exact: true }).fill("https://openremote.io");await expect(then.getByRole("textbox", { name: "Body", exact: true })).not.toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();// Toggle the switch for opening in browserawait then.getByRole("switch", { name: "Open in browser (for external websites)", exact: true }).click();await expect(then.getByRole("textbox", { name: "Body", exact: true })).not.toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();- await then.getByRole("button", { name: "OK", exact: true }).click();+ await then.getByRole("button", { name: "Ok", exact: true }).click();await shared.interceptResponse<number>("**/rules/realm", (rule) => {if (rule) manager.rules.push(rule);@@ -395,18 +395,18 @@ test("Create a When-Then rule for an asset with a alarm action", async ({ page,await then.getByRole("textbox", { name: "Content", exact: true }).clear();await rulesPage.blurActiveField(then);await expect(then.getByRole("textbox", { name: "Content", exact: true })).toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).toBeDisabled();await then.getByRole("textbox", { name: "Content", exact: true }).fill("Warning: %TRIGGER_ASSETS%");await rulesPage.blurActiveField(then);await expect(then.getByRole("textbox", { name: "Content", exact: true })).not.toHaveAttribute("invalid");- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();// Adjust assigneeawait then.getByRole("combobox", { name: "Assignee", exact: true }).click();await then.getByRole("option", { name: "smartcity", exact: true }).click();- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();- await then.getByRole("button", { name: "OK", exact: true }).click();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();+ await then.getByRole("button", { name: "Ok", exact: true }).click();await shared.interceptResponse<number>("**/rules/realm", (rule) => {if (rule) manager.rules.push(rule);@@ -452,7 +452,7 @@ test("Cancelling the alarm settings dialog discards only the changes made insideawait then.getByRole("textbox", { name: "Title", exact: true }).fill("Kept title");await then.getByRole("textbox", { name: "Content", exact: true }).fill("Kept content");await rulesPage.blurActiveField(then);- await then.getByRole("button", { name: "OK", exact: true }).click();+ await then.getByRole("button", { name: "Ok", exact: true }).click();// Severity is edited outside of the dialogawait then.getByRole("button", { name: "Severity" }).click();@@ -517,13 +517,13 @@ test("Create a When-Then rule for an asset with a webhook action", async ({ page// Set up notification message in dialogconst overlay = rulesPage.actionDialogOverlay(then);await expect(overlay).toBeVisible();- await expect(then.getByRole("button", { name: "OK", exact: true })).toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).toBeDisabled();await then.getByRole("button", { name: "Method" }).first().click();await then.getByRole("option", { name: "PUT", exact: true }).click();- await expect(then.getByRole("button", { name: "OK", exact: true })).toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).toBeDisabled();await then.getByRole("textbox", { name: "Web URL", exact: true }).fill("https://localhost");await rulesPage.blurActiveField(then);- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();// Add request headerawait then.getByRole("button", { name: "Add Request Header" }).click();@@ -544,8 +544,8 @@ test("Create a When-Then rule for an asset with a webhook action", async ({ page// Close the dialogawait expect(page.getByRole("button", { name: "Save", exact: true })).toBeDisabled();- await expect(then.getByRole("button", { name: "OK", exact: true })).not.toBeDisabled();- await then.getByRole("button", { name: "OK", exact: true }).click();+ await expect(then.getByRole("button", { name: "Ok", exact: true })).not.toBeDisabled();+ await then.getByRole("button", { name: "Ok", exact: true }).click();await shared.interceptResponse<number>("**/rules/realm", (rule) => {if (rule) manager.rules.push(rule);diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.jsonindex e87d0da42..8acec2bd3 100644--- a/ui/app/shared/locales/en/or.json+++ b/ui/app/shared/locales/en/or.json@@ -102,6 +102,7 @@"lengthLessThan": "Array length less than","valueChanges": "Value changes","save": "Save",+ "update": "Update","create": "Create","close": "Close","active": "Active",@@ -121,6 +122,7 @@"datetime": "Datetime","time": "Time","pickLocation": "Pick a location",+ "gpsCoordinates": "GPS coordinates","triggerType": "Trigger Type","timeOfDay": "Time of Day","offsetInMinutes": "Offset in minutes",@@ -143,7 +145,7 @@"deleteAssets": "Delete asset(s)","deleteAssetsConfirm": "Delete asset(s) and all descendant assets?","deleteAssetsFailed": "Failed to delete requested asset(s)",- "ok": "OK",+ "ok": "Ok","cancel": "Cancel","discard": "Discard","createdOn": "Created on",@@ -532,6 +534,8 @@"editAsset": "Modify","viewAsset": "View","addAsset": "Add asset",+ "createAsset": "Create asset",+ "createNewAsset": "Create new asset","parent": "Parent","none": "None","xAxis": "X-axis",diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.jsonindex 01f9b9a7f..a9a6459ab 100644--- a/ui/app/shared/locales/nl/or.json+++ b/ui/app/shared/locales/nl/or.json@@ -100,6 +100,7 @@"lengthLessThan": "Aantal elementen kleiner dan","valueChanges": "Waarde verandert","save": "Opslaan",+ "update": "Bijwerken","create": "Aanmaken","close": "Sluiten","active": "Actief",@@ -116,6 +117,7 @@"datetime": "Datum en tijd","time": "Tijd","pickLocation": "Kies een locatie",+ "gpsCoordinates": "GPS-coördinaten","triggerType": "Trigger Type","timeOfDay": "Tijdstip","offsetInMinutes": "Afwijking in minuten",@@ -138,7 +140,7 @@"deleteAssets": "Verwijder assets","deleteAssetsConfirm": "Verwijder alle asset(s) en onderliggende assets?","deleteAssetsFailed": "Verwijderen van de asset(s) is niet gelukt",- "ok": "OK",+ "ok": "Ok","cancel": "Annuleren","discard": "weggooien","createdOn": "Aangemaakt op",@@ -523,6 +525,8 @@"editAsset": "Aanpassen","viewAsset": "Bekijk","addAsset": "Asset toevoegen",+ "createAsset": "Asset aanmaken",+ "createNewAsset": "Nieuwe asset aanmaken","parent": "Parent","none": "Geen","xAxis": "X-as",diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.tsindex 102499012..82074d3ca 100644--- a/ui/component/or-asset-tree/src/index.ts+++ b/ui/component/or-asset-tree/src/index.ts@@ -64,12 +64,12 @@ import { getAssetDescriptorIconTemplate, type OrIcon } from "@openremote/or-iconimport type { ListItem } from "@openremote/or-mwc-components/or-mwc-list";import "@openremote/or-mwc-components/or-mwc-list";import { i18next } from "@openremote/or-translate";-import "@openremote/or-mwc-components/or-mwc-dialog";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import type { OrAddAssetDialog, OrAddChangedEvent } from "./or-add-asset-dialog";import "./or-add-asset-dialog";import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import { when } from "lit/directives/when.js";+import { createRef, ref, type Ref } from "lit/directives/ref.js";import debounce from "lodash.debounce";export interface AssetTreeTypeConfig {@@ -1564,108 +1564,105 @@ export class OrAssetTree extends subscribe(manager)(OrElement) {const agentTypes = types.filter((t) => t.descriptorType === "agent");const assetTypes = types.filter((t) => t.descriptorType === "asset");const parent = this._selectedNodes && this._selectedNodes.length === 1 ? this._selectedNodes[0].asset : undefined;- let dialog: OrMwcDialog;+ let dialog: OrVaadinDialog | undefined;+ const addAssetDialogRef: Ref<OrAddAssetDialog> = createRef();+ const addBtnRef: Ref<OrVaadinButton> = createRef();+ const blockEvent = (ev: Event) => ev.stopPropagation();const onAddChanged = (ev: OrAddChangedEvent) => {const nameValid = !!ev.detail.name && ev.detail.name.trim().length > 0 && ev.detail.name.trim().length < 1024;- const addBtn = dialog.shadowRoot!.getElementById("add-btn") as OrVaadinButton;+ const addBtn = addBtnRef.value!;addBtn.disabled = !ev.detail.descriptor || !nameValid;};+ const onCancel = () => dialog?.close();+ const onOk = () => {+ const addAssetDialog = addAssetDialogRef.value!;+ const descriptor = addAssetDialog.selectedType;+ const selectedOptionalAttributes = addAssetDialog.selectedAttributes;+ const name = addAssetDialog.name.trim();+ const parent = addAssetDialog.parent;++ if (!descriptor) {+ return;+ }++ const asset: Asset = {+ name,+ type: descriptor.name,+ realm: manager.displayRealm,+ };++ // Construct attributes+ const assetTypeInfo = AssetModelUtil.getAssetTypeInfo(descriptor.name!);++ if (!assetTypeInfo) {+ return;+ }++ if (assetTypeInfo.attributeDescriptors) {+ asset.attributes = {};+ assetTypeInfo.attributeDescriptors+ .filter((attributeDescriptor) => !attributeDescriptor.optional)+ .forEach((attributeDescriptor) => {+ asset.attributes![attributeDescriptor.name!] = {+ name: attributeDescriptor.name,+ type: attributeDescriptor.type,+ meta: attributeDescriptor.meta ? { ...attributeDescriptor.meta } : undefined,+ } as Attribute<any>;+ });+ }++ if (selectedOptionalAttributes) {+ selectedOptionalAttributes?.forEach((attribute) => {+ asset.attributes![attribute.name!] = {+ name: attribute.name,+ type: attribute.type,+ meta: attribute.meta ? { ...attribute.meta } : undefined,+ };+ });+ }++ if (this.selectedIds) {+ asset.parentId = parent ? parent.id : undefined;+ }+ const detail: AddEventDetail = {+ asset,+ };+ dialog?.close();+ Util.dispatchCancellableEvent(this, new OrAssetTreeRequestAddEvent(detail)).then((detail) => {+ if (detail.allow) {+ this.dispatchEvent(new OrAssetTreeAddEvent(detail.detail));+ }+ });+ };dialog = showDialog(- new OrMwcDialog()- .setHeading(i18next.t("addAsset"))- .setContent(html`+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="958px" no-close-on-esc no-close-on-outside-click>+ <h2 slot="header-content">+ <or-translate value="createNewAsset"></or-translate>+ </h2><or-add-asset-dialog- id="add-panel"+ ${ref(addAssetDialogRef)}+ @or-asset-tree-request-selection="${blockEvent}"+ @or-asset-tree-selection="${blockEvent}".config="${this.config}".agentTypes="${agentTypes}".assetTypes="${assetTypes}".parent="${parent}"@or-add-asset-changed="${onAddChanged}"></or-add-asset-dialog>- `)- .setActions([- {- actionName: "cancel",- content: html`<or-vaadin-button><or-translate value="cancel"></or-translate></or-vaadin-button>`,- },- {- actionName: "add",- content: html`<or-vaadin-button id="add-btn" theme="primary" disabled>- <or-translate value="add"></or-translate>- </or-vaadin-button>`,- action: () => {- const addAssetDialog = dialog.shadowRoot!.getElementById("add-panel") as OrAddAssetDialog;- const descriptor = addAssetDialog.selectedType;- const selectedOptionalAttributes = addAssetDialog.selectedAttributes;- const name = addAssetDialog.name.trim();- const parent = addAssetDialog.parent;-- if (!descriptor) {- return;- }-- const asset: Asset = {- name,- type: descriptor.name,- realm: manager.displayRealm,- };-- // Construct attributes- const assetTypeInfo = AssetModelUtil.getAssetTypeInfo(descriptor.name!);-- if (!assetTypeInfo) {- return;- }-- if (assetTypeInfo.attributeDescriptors) {- asset.attributes = {};- assetTypeInfo.attributeDescriptors- .filter((attributeDescriptor) => !attributeDescriptor.optional)- .forEach((attributeDescriptor) => {- asset.attributes![attributeDescriptor.name!] = {- name: attributeDescriptor.name,- type: attributeDescriptor.type,- meta: attributeDescriptor.meta ? { ...attributeDescriptor.meta } : undefined,- } as Attribute<any>;- });- }-- if (selectedOptionalAttributes) {- selectedOptionalAttributes?.forEach((attribute) => {- asset.attributes![attribute.name!] = {- name: attribute.name,- type: attribute.type,- meta: attribute.meta ? { ...attribute.meta } : undefined,- };- });- }-- if (this.selectedIds) {- asset.parentId = parent ? parent.id : undefined;- }- const detail: AddEventDetail = {- asset,- };- Util.dispatchCancellableEvent(this, new OrAssetTreeRequestAddEvent(detail)).then((detail) => {- if (detail.allow) {- this.dispatchEvent(new OrAssetTreeAddEvent(detail.detail));- }- });- },- },- ])- .setStyles(html`- <style>- .mdc-dialog__content {- padding: 0 !important;- border-bottom: solid var(--or-app-color5, #cccccc) 1px;- border-top: solid var(--or-app-color5, #cccccc) 1px;- }- </style>- `)- .setDismissAction(null)+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" ${ref(addBtnRef)} disabled @click=${onOk}>+ <or-translate value="createAsset"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}diff --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 29c241738..2e491a975 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@@ -36,7 +36,7 @@ import type { OrVaadinTextField } from "@openremote/or-vaadin-components/or-vaadimport type { OrVaadinCheckbox } from "@openremote/or-vaadin-components/or-vaadin-checkbox";import type { OrVaadinListBox, ListItem } from "@openremote/or-vaadin-components/or-vaadin-list-box";import { when } from "lit/directives/when.js";-import { DefaultColor2, DefaultColor3, DefaultColor5, Util } from "@openremote/core";+import { DefaultColor5, Util } from "@openremote/core";import debounce from "lodash.debounce";export type OrAddAssetDetail = {@@ -108,119 +108,125 @@ export class OrAddAssetDialog extends OrElement {public static get styles() {// language=CSSreturn css`- :host{- border-style: solid;- border-color: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});- border-width: 1px 0;- }-- #name-wrapper {- display: flex;- flex-direction: column;- margin-top: 12px;- }-- #toggle-parent-selector,- #remove-parent {- margin: 4px 0 0 5px;- }-- #name-input,- #parent-wrapper {- margin: 10px 0;- }-- #parent-wrapper {- display: flex;- align-items: end;- }-- #parent {- flex: 1 1 auto;- }-- #parent-selector {- max-width: 250px;- border-left: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});- }-- #mdc-dialog-form-add {- display: flex;- height: 600px;- max-height: 600px;- width: 1000px;- }-- .msg {- display: flex;- justify-content: center;- align-items: center;- text-align: center;- height: 100%;- font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";- font-size: 14px;- }-- #asset-type-option-container {- padding: 15px;- flex: 1 1 auto;- overflow: auto;- max-width: 100%;- font-size: 16px;- }-- #type-list-filter {- padding: 7px;- background-color: var(--or-app-color2, ${unsafeCSS(DefaultColor2)}))- }-- #filterInput{- width: 100%;- }-- #type-list {- overflow: auto;- text-transform: capitalize;- }-- #type-list-container {- display: flex;- flex-direction: column;- width: 300px;- border-right: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});- }-- #type-title {- display: flex;- align-items: center;- margin: 9px 4px;- }-- #type-description {- text-transform: capitalize;- color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});- margin-left: 10px;- font-size: 18px;- font-weight: bold;- font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";- }-- .heading,- .mdc-list-group__subheader {- text-transform: uppercase;- font-family: "Segoe UI", Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";- font-weight: bolder;- line-height: 1em;- color: var(--or-app-color3, ${unsafeCSS(DefaultColor3)});- letter-spacing: 0.025em;- font-size: 14px;- margin: 20px 0 10px;- }-- .mdc-list-group__subheader {- margin: 20px 0 0 16px;- }- `;+ :host {+ display: block;+ }++ #name-wrapper {+ display: flex;+ flex-direction: column;+ margin-top: 12px;+ }++ #toggle-parent-selector,+ #remove-parent {+ margin: 4px 0 0 5px;+ }++ #name-input,+ #parent-wrapper {+ margin: 10px 0;+ }++ #parent-wrapper {+ display: flex;+ align-items: end;+ }++ #parent {+ flex: 1 1 auto;+ }++ #parent-selector {+ max-width: 250px;+ border-left: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});+ }++ #mdc-dialog-form-add {+ display: flex;+ gap: var(--lumo-space-s);+ height: 600px;+ }++ .msg {+ display: flex;+ justify-content: center;+ align-items: center;+ text-align: center;+ height: 100%;+ font-size: var(--lumo-font-size-s);+ }++ #asset-type-option-container {+ display: flex;+ flex: 1 1 auto;+ min-width: 0;+ font-size: 16px;+ }++ #asset-type-option-content {+ flex: 1 1 auto;+ box-sizing: border-box;+ padding: var(--lumo-space-m);+ overflow: auto;+ background: var(--lumo-base-color);+ border-radius: var(--lumo-border-radius-m);+ }++ #asset-type-option-content.empty {+ background: none;+ }++ #filterInput {+ width: 100%;+ }++ #type-list {+ flex: 1 1 auto;+ min-height: 0;+ padding: 0 var(--lumo-space-s);+ background: var(--lumo-base-color);+ border-radius: var(--lumo-border-radius-m);+ overflow: auto;+ text-transform: capitalize;+ }++ #type-list-container {+ display: flex;+ flex: 0 0 305px;+ flex-direction: column;+ gap: var(--lumo-space-s);+ min-width: 0;+ }++ #type-list or-vaadin-item::part(content) {+ min-width: 0;+ }++ #type-title {+ display: flex;+ align-items: center;+ gap: var(--lumo-space-s);+ --or-icon-width: 20px;+ --or-icon-height: 20px;+ }++ #type-description {+ text-transform: capitalize;+ color: var(--lumo-header-text-color);+ font-size: var(--lumo-font-size-xl);+ font-weight: 600;+ line-height: var(--lumo-line-height-xs);+ }++ .heading {+ color: var(--vaadin-input-field-label-color, var(--lumo-secondary-text-color));+ font-size: var(--vaadin-input-field-label-font-size, var(--lumo-font-size-s));+ font-weight: var(--vaadin-input-field-label-font-weight, 500);+ line-height: var(--lumo-line-height-xs);+ margin: var(--lumo-space-m) 0 6px;+ }+ `;}constructor() {@@ -264,7 +270,7 @@ export class OrAddAssetDialog extends OrElement {${items.map((item) => html`<or-vaadin-item style=${styleMap(item.styleMap ?? {})}>- <div style="display: flex; align-items: center; gap: 8px;">+ <div style="display: flex; align-items: center; gap: 8px; min-width: 0;"><or-icon icon=${ifDefined(item.icon)}></or-icon><span style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis;">${item.text ?? item.value ?? html`<or-translate value="unknown"></or-translate>`}@@ -293,17 +299,18 @@ export class OrAddAssetDialog extends OrElement {</div><div id="type-list">${when(agentItems.length > 0, () => getListTemplate(filteredAgentItems, true))}- <hr style="color: white;" />${when(assetItems.length > 0, () => getListTemplate(filteredAssetItems, false))}</div></div><div id="asset-type-option-container" class="col">- ${- !this.selectedType- ? html`<div class="msg"><or-translate value="noAssetTypeSelected"></or-translate></div>`- : this.getTypeTemplate(this.selectedType, parentStr)- }+ <div id="asset-type-option-content" class=${this.selectedType ? "" : "empty"}>+ ${+ !this.selectedType+ ? html`<div class="msg"><or-translate value="noAssetTypeSelected"></or-translate></div>`+ : this.getTypeTemplate(this.selectedType, parentStr)+ }+ </div></div>${!this.showParentAssetSelectordiff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex 6c73e026d..0d17bbb35 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -28,12 +28,10 @@ import "@openremote/or-attribute-history";import "@openremote/or-chart";import "@openremote/or-mwc-components/or-mwc-table";import "@openremote/or-components/or-panel";-import "@openremote/or-mwc-components/or-mwc-dialog";-import { showOkCancelDialog } from "@openremote/or-mwc-components/or-mwc-dialog";-import "@openremote/or-mwc-components/or-mwc-list";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { type OrTranslate, translate } from "@openremote/or-translate";-import { InputType, OrInputChangedEvent, OrMwcInput } from "@openremote/or-mwc-components/or-mwc-input";-import manager, { OPENREMOTE_CLIENT_ID, RESTRICTED_USER_REALM_ROLE, subscribe, Util } from "@openremote/core";+import { InputType } from "@openremote/or-mwc-components/or-mwc-input";+import manager, { RESTRICTED_USER_REALM_ROLE, subscribe, Util } from "@openremote/core";import type { OrMwcTable, OrMwcTableRowClickEvent } from "@openremote/or-mwc-components/or-mwc-table";import type { OrChartConfig } from "@openremote/or-chart";import type { HistoryConfig, OrAttributeHistory } from "@openremote/or-attribute-history";@@ -67,10 +65,11 @@ import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import { progressCircular } from "@openremote/or-mwc-components/style";import { when } from "lit/directives/when.js";import { ifDefined } from "lit/directives/if-defined.js";-import type { OrVaadinCheckbox } from "@openremote/or-vaadin-components/or-vaadin-checkbox";import type { OrVaadinInput } from "@openremote/or-vaadin-components/or-vaadin-input";import { OrVaadinDateTimePicker } from "@openremote/or-vaadin-components/or-vaadin-date-time-picker";import { getConfirmDialogContent, showConfirmDialog } from "@openremote/or-vaadin-components/or-vaadin-confirm-dialog";+import type { OrVaadinCheckboxGroup } from "@openremote/or-vaadin-components/or-vaadin-checkbox-group";+import { createRef, type Ref, ref } from "lit/directives/ref.js";declare function require(name: string): any;@@ -841,36 +840,46 @@ function getPanelContent(};const attributePickerModalOpen = () => {- const newlySelectedAttributes = [...selectedAttributes];+ let dialog: OrVaadinDialog | undefined;+ const groupRef: Ref<OrVaadinCheckboxGroup> = createRef();+ const onCancel = () => {+ dialog?.close();+ };+ const onOk = () => {+ const groupElem = groupRef.value;+ if (groupElem) {+ updateSelectedAttributes(groupElem.value);+ dialog?.close();+ }+ };- // TODO: Replace with or-vaadin-dialog, see https://github.com/openremote/core/issues/2594- showOkCancelDialog(- i18next.t("addRemoveAttributes"),+ dialog = showDialog(+ hostElement.shadowRoot!,html`- <div style="display: flex; flex-direction: column;">- ${availableAttributes.sort().map(- (attribute) => html`- <or-vaadin-checkbox- label=${i18next.t(Util.camelCaseToSentenceCase(attribute))}- style="display: inline-flex;"- .checked=${!!selectedAttributes.find((selected) => selected === attribute)}- @change=${(ev: Event) => {- if ((ev.currentTarget as OrVaadinCheckbox).checked) {- newlySelectedAttributes.push(attribute);- } else {- newlySelectedAttributes.splice(newlySelectedAttributes.indexOf(attribute), 1);- }- }}- ></or-vaadin-checkbox>- `- )}- </div>+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="addRemoveAttributes"></or-translate>+ </h2>+ <or-vaadin-checkbox-group ${ref(groupRef)} theme="vertical" .value="${[...selectedAttributes]}">+ ${availableAttributes.sort().map(+ (attr) => html`+ <vaadin-checkbox value=${attr}>+ <or-translate slot="label" value=${Util.camelCaseToSentenceCase(attr)}></or-translate>+ </vaadin-checkbox>+ `+ )}+ </or-vaadin-checkbox-group>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between;">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>`- ).then((ok) => {- if (ok) {- updateSelectedAttributes(newlySelectedAttributes);- }- });+ );};const headersAndRows = getHeadersAndRows();diff --git a/ui/component/or-asset-viewer/src/or-add-attribute-panel.ts b/ui/component/or-asset-viewer/src/or-add-attribute-panel.tsindex 052d4e8c4..919ede184 100644--- a/ui/component/or-asset-viewer/src/or-add-attribute-panel.ts+++ b/ui/component/or-asset-viewer/src/or-add-attribute-panel.ts@@ -70,7 +70,6 @@ export class OrAddAttributePanel extends OrElement {return css`#attribute-creator {min-width: 300px;- padding: 20px;display: flex;flex-direction: column;gap: 10px;@@ -129,11 +128,11 @@ export class OrAddAttributePanel extends OrElement {@change=${(ev: CustomEvent) => this.onValueTypeChanged((ev.currentTarget as OrVaadinComboBox).value)}><or-translate slot="label" value="valueType"></or-translate></or-vaadin-combo-box>- <or-vaadin-checkbox id="array-checkbox" ?readonly=${!this.customAttribute} ?checked=${this.isArray}+ <or-vaadin-checkbox id="array-checkbox" ?readonly=${!this.customAttribute} ?checked=${this.isArray}@change=${(ev: Event) => this.onArrayChanged((ev.currentTarget as OrVaadinCheckbox).checked, 1)}><label slot="label"><or-translate slot="label" value="array"></label></or-translate></or-vaadin-checkbox>- <or-vaadin-number-field id="array-input" ?disabled=${!this.isArray} ?readonly=${!this.customAttribute} value=${this.arrayDimensions} min="1" max="2"+ <or-vaadin-number-field id="array-input" ?disabled=${!this.isArray} ?readonly=${!this.customAttribute} value=${this.arrayDimensions} min="1" max="2"@change=${(ev: Event) => this.onArrayChanged(true, Number((ev.currentTarget as OrVaadinNumberField).value))}><or-translate slot="label" value="arrayDimensions"></or-translate></or-vaadin-number-field>diff --git a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts b/ui/component/or-asset-viewer/src/or-edit-asset-panel.tsindex afddc0df5..2c74c8d5b 100644--- a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts+++ b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts@@ -24,7 +24,7 @@ import {type ValueInputProviderOptions,getValueHolderInputTemplateProvider,} from "@openremote/or-vaadin-components/value-input-provider";-import { InputType, type OrMwcInput, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";+import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";import { i18next } from "@openremote/or-translate";import {type Asset,@@ -36,8 +36,9 @@ import {import { DefaultColor5, DefaultColor3, Util } from "@openremote/core";import "@openremote/or-mwc-components/or-mwc-input";import type { OrIcon } from "@openremote/or-icon";-import { showDialog, OrMwcDialog, type DialogAction } from "@openremote/or-mwc-components/or-mwc-dialog";-import { type ListItem, ListType, type OrMwcList } from "@openremote/or-mwc-components/or-mwc-list";+import { showDialog, type OrVaadinDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";+import type { OrVaadinCheckboxGroup } from "@openremote/or-vaadin-components/or-vaadin-checkbox-group";+import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";import "./or-add-attribute-panel";import { getField, getPanel, getPropertyTemplate } from "./index";import type { OrAddAttributePanelAttributeChangedEvent } from "./or-add-attribute-panel";@@ -591,6 +592,7 @@ export class OrEditAssetPanel extends OrElement {protected _addAttribute() {const asset = this.asset!;let attr: Attribute<any>;+ const addBtnRef: Ref<OrVaadinButton> = createRef();const isDisabled = (attribute: Attribute<any>) => {return !(@@ -602,53 +604,42 @@ export class OrEditAssetPanel extends OrElement {);};- const onAttributeChanged = (attribute: Attribute<any>) => {- const addDisabled = isDisabled(attribute);- const addBtn = dialog!.shadowRoot!.getElementById("add-btn") as OrMwcInput;- addBtn!.disabled = addDisabled;+ const onAttributeChanged = (ev: OrAddAttributePanelAttributeChangedEvent) => {+ const attribute = ev.detail;+ addBtnRef.value!.disabled = isDisabled(attribute);attr = attribute;};+ const onOk = () => {+ if (!isDisabled(attr)) {+ this.asset.attributes![attr.name!] = attr;+ this._onModified();+ this.requestUpdate();+ dialog?.close();+ }+ };+const dialog = showDialog(- new OrMwcDialog()- .setContent(html`+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="addAttribute"></or-translate>+ </h2><or-add-attribute-panel.asset="${asset}"- @or-add-attribute-panel-attribute-changed="${(ev: OrAddAttributePanelAttributeChangedEvent) => onAttributeChanged(ev.detail)}"+ @or-add-attribute-panel-attribute-changed="${onAttributeChanged}"></or-add-attribute-panel>- `)- .setStyles(html`- <style>- .mdc-dialog__surface {- overflow-x: visible !important;- overflow-y: visible !important;- }- #dialog-content {- padding: 0;- overflow: visible;- }- </style>- `)- .setHeading(i18next.t("addAttribute"))- .setActions([- {- actionName: "cancel",- content: "cancel",- },- {- default: true,- actionName: "add",- action: () => {- if (!isDisabled(attr)) {- this.asset.attributes![attr.name!] = attr;- this._onModified();- this.requestUpdate();- }- },- content: html`<or-mwc-input id="add-btn" .type="${InputType.BUTTON}" disabled label="add"></or-mwc-input>`,- },- ])- .setDismissAction(null)+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => dialog?.close()}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" ${ref(addBtnRef)} disabled @click=${onOk}>+ <or-translate value="add"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}@@ -660,85 +651,66 @@ export class OrEditAssetPanel extends OrElement {const meta = attribute.meta || {};- const metaItemList: (ListItem | null)[] = assetTypeInfo.metaItemDescriptors- .map((metaName) => AssetModelUtil.getMetaItemDescriptor(metaName)!)- .filter((descriptor) => !meta.hasOwnProperty(descriptor.name!))- .map((descriptor) => {- return {- text: Util.getMetaLabel(undefined, descriptor, this.asset!.type!, true),- value: descriptor.name!,- translate: false,- };- })- .sort(Util.sortByString((item) => item.text));+ const listRef: Ref<OrVaadinCheckboxGroup> = createRef();+ const onOk = () => {+ const selectedItems = listRef.value?.value;+ if (selectedItems) {+ if (!attribute.meta) {+ attribute.meta = {};+ }+ selectedItems.forEach((item) => {+ const descriptor = AssetModelUtil.getMetaItemDescriptors().find((descriptor) => descriptor.name === item);+ if (descriptor) {+ attribute.meta![descriptor.name!] = descriptor.type === "boolean" ? true : null;+ this._onModified();+ this.requestUpdate();+ }+ });+ }+ dialog?.close();+ };const dialog = showDialog(- new OrMwcDialog()- .setContent(html`- <div id="meta-creator">- <or-mwc-list- id="meta-creator-list"- .type="${ListType.MULTI_CHECKBOX}"- .listItems="${metaItemList}"- ></or-mwc-list>+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="addMetaItems"></or-translate>+ </h2>+ <or-vaadin-checkbox-group theme="vertical" ${ref(listRef)}>+ ${assetTypeInfo.metaItemDescriptors+ .map((metaName) => AssetModelUtil.getMetaItemDescriptor(metaName)!)+ .filter((descriptor) => !meta.hasOwnProperty(descriptor.name!))+ .map((descriptor) => ({+ descriptor,+ label: Util.getMetaLabel(undefined, descriptor, this.asset!.type!, true),+ }))+ .sort(Util.sortByString((item) => item.label))+ .map(+ (item) => html`+ <or-vaadin-checkbox value=${item.descriptor.name!} label=${item.label}></or-vaadin-checkbox>+ `+ )}+ </or-vaadin-checkbox-group>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => dialog?.close()}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="add"></or-translate>+ </or-vaadin-button></div>- `)- .setStyles(html`- <style>- #meta-creator {- height: 600px;- max-height: 100%;- }-- #meta-creator > or-mwc-list {- height: 100%;- }-- .mdc-dialog .mdc-dialog__content {- padding: 0 !important;- }- </style>- `)- .setHeading(i18next.t("addMetaItems"))- .setActions([- {- actionName: "cancel",- content: "cancel",- },- {- default: true,- actionName: "add",- action: () => {- const list = dialog!.shadowRoot!.getElementById("meta-creator-list") as OrMwcList;- const selectedItems = list ? list.selectedItems : undefined;- if (selectedItems) {- if (!attribute.meta) {- attribute.meta = {};- }- selectedItems.forEach((item) => {- const descriptor = AssetModelUtil.getMetaItemDescriptors().find(- (descriptor) => descriptor.name === item.value- );- if (descriptor) {- attribute.meta![descriptor.name!] = descriptor.type === "boolean" ? true : null;- this._onModified();- this.requestUpdate();- }- });- }- },- content: "add",- },- ])- .setDismissAction(null)+ </or-vaadin-dialog>+ `);}protected _getParentTemplate() {- let dialog: OrMwcDialog;+ let dialog: OrVaadinDialog | undefined;+ const assetTreeRef: Ref<OrAssetTree> = createRef();const setParent = () => {- const assetTree = dialog.shadowRoot!.getElementById("parent-asset-tree") as OrAssetTree;+ const assetTree = assetTreeRef.value!;this.asset.parentId = assetTree.selectedIds!.length === 1 ? assetTree.selectedIds![0] : undefined;// Need to update the assets path as wellconst path = [this.asset.id!];@@ -755,74 +727,51 @@ export class OrEditAssetPanel extends OrElement {this.asset.parentId = undefined;this.asset.path = [this.asset.id!];this._onModified();+ dialog?.close();};- const blockEvent = (ev: Event) => {- ev.stopPropagation();- };+ const blockEvent = (ev: Event) => ev.stopPropagation();const parentSelector = (node: UiAssetTreeNode) => node.asset!.id !== this.asset.id;- // Prevent change event from bubbling up as it will affect any ancestor listeners that are interested in a different asset tree- const dialogContent = html`<or-asset-tree- id="parent-asset-tree"- disableSubscribe- readonly- .selectedIds="${this.asset!.parentId ? [this.asset.parentId] : []}"- @or-asset-tree-request-select="${blockEvent}"- @or-asset-tree-selection-changed="${blockEvent}"- .selector="${parentSelector}"- ></or-asset-tree>`;-- const dialogActions: DialogAction[] = [- {- actionName: "clear",- content: "none",- action: clearParent,- },- {- actionName: "ok",- content: "ok",- action: setParent,- },- {- default: true,- actionName: "cancel",- content: "cancel",- },- ];+ const onOk = () => {+ setParent();+ dialog?.close();+ };const openDialog = () => {dialog = showDialog(- new OrMwcDialog()- .setContent(dialogContent)- .setActions(dialogActions)- .setStyles(html`- <style>- .mdc-dialog__surface {- width: 400px;- height: 800px;- display: flex;- overflow: visible;- overflow-x: visible !important;- overflow-y: visible !important;- }- #dialog-content {- flex: 1;- overflow: visible;- min-height: 0;- padding: 0;- }- footer.mdc-dialog__actions {- border-top: 1px solid ${unsafeCSS(DefaultColor5)};- }- or-asset-tree {- height: 100%;- }- </style>- `)- .setHeading(i18next.t("setParent"))- .setDismissAction(null)+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="setParent"></or-translate>+ </h2>+ <or-asset-tree+ ${ref(assetTreeRef)}+ disableSubscribe+ readonly+ .selectedIds="${this.asset!.parentId ? [this.asset.parentId] : []}"+ style="width: 100%; aspect-ratio: 1/1.75;"+ @or-asset-tree-request-selection="${blockEvent}"+ @or-asset-tree-selection="${blockEvent}"+ .selector="${parentSelector}"+ ></or-asset-tree>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => dialog?.close()}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <div>+ <or-vaadin-button @click=${clearParent}>+ <or-translate value="clear"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </div>+ </or-vaadin-dialog>+ `);};diff --git a/ui/component/or-asset-viewer/test/fixtures/index.ts b/ui/component/or-asset-viewer/test/fixtures/index.tsindex 28cffb3b7..32ceba519 100644--- a/ui/component/or-asset-viewer/test/fixtures/index.ts+++ b/ui/component/or-asset-viewer/test/fixtures/index.ts@@ -74,10 +74,11 @@ export class AssetViewer {await configItemLocator.getByRole("button", { name: "Add configuration items" }).click();for (const item of items) {await this.page- .locator("li", { has: this.page.getByText(Util.camelCaseToSentenceCase(item), { exact: true }) })+ .getByRole("dialog")+ .getByRole("checkbox", { name: Util.camelCaseToSentenceCase(item), exact: true }).check();}- await this.page.getByRole("button", { name: "Add", exact: true }).click();+ await this.page.getByRole("dialog").getByRole("button", { name: "Add", exact: true }).click();}/**diff --git a/ui/component/or-attribute-barchart/src/index.ts b/ui/component/or-attribute-barchart/src/index.tsindex 240fb3523..9c867b75a 100644--- a/ui/component/or-attribute-barchart/src/index.ts+++ b/ui/component/or-attribute-barchart/src/index.ts@@ -48,7 +48,7 @@ import { UniversalTransition } from "echarts/features";import moment from "moment";import { getAssetDescriptorIconTemplate } from "@openremote/or-icon";import { isAxiosError } from "@openremote/rest";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";import { cache } from "lit/directives/cache.js";import { createMenuBarItem, type MenuBarItem } from "@openremote/or-vaadin-components/or-vaadin-menu-bar";@@ -144,11 +144,6 @@ const style = css`cursor: pointer;}- .mdc-dialog .mdc-dialog__surface {- min-width: 600px;- height: calc(100vh - 50%);- }-:host([hidden]) {display: none;}@@ -270,13 +265,6 @@ const style = css`}@media screen and (max-width: 769px) {- .mdc-dialog .mdc-dialog__surface {- min-width: auto;-- max-width: calc(100vw - 32px);- max-height: calc(100% - 32px);- }-#container {flex-direction: column;}@@ -648,7 +636,6 @@ export class OrAttributeBarChart extends OrElement {}protected _getTimeControlsTemplate(disabled: boolean): TemplateResult {- console.debug("Disabled?", disabled);const menuItems: MenuBarItem[] = [{component: createMenuBarItem(@@ -855,47 +842,53 @@ export class OrAttributeBarChart extends OrElement {protected _openTimeDialog(startTimestamp?: number, endTimestamp?: number) {const startRef: Ref<OrVaadinDateTimePicker> = createRef();const endRef: Ref<OrVaadinDateTimePicker> = createRef();- showDialog(- new OrMwcDialog()- .setHeading(i18next.t("timeframe"))- .setContent(- () => html`- <div style="max-width: 480px; display: flex; flex-direction: column; gap: 8px;">- <or-vaadin-date-time-picker- ${ref(startRef)}- required- value=${startTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(startTimestamp)) : undefined}- >- <or-translate slot="label" value="start"></or-translate>- </or-vaadin-date-time-picker>- <or-vaadin-date-time-picker- ${ref(endRef)}- required- value=${endTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(endTimestamp)) : undefined}- >- <or-translate slot="label" value="ending"></or-translate>- </or-vaadin-date-time-picker>- </div>- `- )- .setActions([- {- actionName: "cancel",- content: "cancel",- },- {- actionName: "ok",- content: "ok",- action: () => {- if (startRef.value?.value && endRef.value?.value && startRef.value.value < endRef.value.value) {- this._isCustomWindow = true;- this.timeframe = [new Date(startRef.value.value), new Date(endRef.value.value)];- } else {- showSnackbar(undefined, i18next.t("errorOccurred"));- }- },- },- ])+ let dialog: OrVaadinDialog | undefined;++ const onCancel = () => {+ dialog?.close();+ };+ const onOk = () => {+ if (startRef.value?.value && endRef.value?.value && startRef.value.value < endRef.value.value) {+ this._isCustomWindow = true;+ this.timeframe = [new Date(startRef.value.value), new Date(endRef.value.value)];+ dialog?.close();+ } else {+ showSnackbar(undefined, i18next.t("errorOccurred"));+ }+ };+ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="timeframe"></or-translate>+ </h2>+ <div style="padding: 4px 0; max-width: 480px; display: flex; flex-direction: column; gap: 8px;">+ <or-vaadin-date-time-picker+ ${ref(startRef)}+ required+ value=${startTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(startTimestamp)) : undefined}+ >+ <or-translate slot="label" value="beginning"></or-translate>+ </or-vaadin-date-time-picker>+ <or-vaadin-date-time-picker+ ${ref(endRef)}+ required+ value=${endTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(endTimestamp)) : undefined}+ >+ <or-translate slot="label" value="ending"></or-translate>+ </or-vaadin-date-time-picker>+ </div>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between;">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.tsindex e52012a06..089b6234e 100644--- a/ui/component/or-attribute-input/src/index.ts+++ b/ui/component/or-attribute-input/src/index.ts@@ -348,10 +348,11 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(OrEl#wrapper or-map {min-height: 250px;+ aspect-ratio: 3/1 !important;}#wrapper .long-press-msg {- display: none;+ display: none !important;}#wrapper {diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex 376c6abe7..b8b85f16d 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -56,7 +56,8 @@ import { OrAssetTreeSelectionEvent } from "@openremote/or-asset-tree";import { getAssetDescriptorIconTemplate } from "@openremote/or-icon";import { type GenericAxiosResponse, isAxiosError } from "@openremote/rest";import { OrAssetAttributePicker, OrAssetAttributePickerPickedEvent } from "@openremote/or-attribute-picker";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog as showVaadinDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { cache } from "lit/directives/cache.js";import debounce from "lodash.debounce";import { OrVaadinDateTimePicker } from "@openremote/or-vaadin-components/or-vaadin-date-time-picker";@@ -64,6 +65,7 @@ import { when } from "lit/directives/when.js";import { map } from "lit/directives/map.js";import { createRef, type Ref, ref } from "lit/directives/ref.js";import { createMenuBarItem, type MenuBarItem } from "@openremote/or-vaadin-components/or-vaadin-menu-bar";+import { showSnackbar } from "@openremote/or-mwc-components/or-mwc-snackbar";echarts.use([GridComponent,@@ -161,27 +163,27 @@ const tableStyle = require("@material/data-table/dist/mdc.data-table.css");// language=CSSconst style = css`:host {-+--internal-or-chart-background-color: var(--or-chart-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));--internal-or-chart-border-color: var(--or-chart-border-color, rgba(76, 76, 76, 0.6));--internal-or-chart-text-color: var(--or-chart-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));- --internal-or-chart-controls-margin: var(--or-chart-controls-margin, 0 0 20px 0);- --internal-or-chart-controls-margin-children: var(--or-chart-controls-margin-children, 0 auto 20px auto);- --internal-or-chart-graph-fill-color: var(--or-chart-graph-fill-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));- --internal-or-chart-graph-fill-opacity: var(--or-chart-graph-fill-opacity, 0.25);- --internal-or-chart-graph-line-color: var(--or-chart-graph-line-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));+ --internal-or-chart-controls-margin: var(--or-chart-controls-margin, 0 0 20px 0);+ --internal-or-chart-controls-margin-children: var(--or-chart-controls-margin-children, 0 auto 20px auto);+ --internal-or-chart-graph-fill-color: var(--or-chart-graph-fill-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));+ --internal-or-chart-graph-fill-opacity: var(--or-chart-graph-fill-opacity, 0.25);+ --internal-or-chart-graph-line-color: var(--or-chart-graph-line-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));--internal-or-chart-graph-point-color: var(--or-chart-graph-point-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));--internal-or-chart-graph-point-border-color: var(--or-chart-graph-point-border-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));--internal-or-chart-graph-point-radius: var(--or-chart-graph-point-radius, 4);- --internal-or-chart-graph-point-hit-radius: var(--or-chart-graph-point-hit-radius, 20);+ --internal-or-chart-graph-point-hit-radius: var(--or-chart-graph-point-hit-radius, 20);--internal-or-chart-graph-point-border-width: var(--or-chart-graph-point-border-width, 2);- --internal-or-chart-graph-point-hover-color: var(--or-chart-graph-point-hover-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));+ --internal-or-chart-graph-point-hover-color: var(--or-chart-graph-point-hover-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));--internal-or-chart-graph-point-hover-border-color: var(--or-chart-graph-point-hover-border-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));- --internal-or-chart-graph-point-hover-radius: var(--or-chart-graph-point-hover-radius, 4);+ --internal-or-chart-graph-point-hover-radius: var(--or-chart-graph-point-hover-radius, 4);--internal-or-chart-graph-point-hover-border-width: var(--or-chart-graph-point-hover-border-width, 2);-+width: 100%;- display: block;+ display: block;}.line-label {@@ -201,7 +203,7 @@ const style = css`background-size: 10px 16px;background-repeat: repeat-y;}-+.button-icon {align-self: center;padding: 11px 6px;@@ -217,15 +219,10 @@ const style = css`--or-icon-width: 12px;}- .mdc-dialog .mdc-dialog__surface {- min-width: 600px;- height: calc(100vh - 50%);- }-:host([hidden]) {display: none;}-+#container {display: flex;min-width: 0;@@ -233,7 +230,7 @@ const style = css`height: 100%;gap: 8px;}-+#msg {height: 100%;width: 100%;@@ -241,11 +238,11 @@ const style = css`align-items: center;text-align: center;}-+#msg:not([hidden]) {- display: flex;+ display: flex;}-+#period-controls {display: flex;flex-direction: column;@@ -264,7 +261,7 @@ const style = css`#period-dropdown-controls > *:last-child {margin-left: -2px;}-+#controls {display: flex;@@ -284,7 +281,7 @@ const style = css`.attribute-list-dense {flex-wrap: wrap;}-+.attribute-list-item {cursor: pointer;display: flex;@@ -315,7 +312,7 @@ const style = css`.button-clear:hover {--or-icon-fill: var(--or-app-color4);}-+.attribute-list-item-label {display: flex;flex: 1 1 0;@@ -357,13 +354,6 @@ const style = css`}@media screen and (max-width: 769px) {- .mdc-dialog .mdc-dialog__surface {- min-width: auto;-- max-width: calc(100vw - 32px);- max-height: calc(100% - 32px);- }-#container {flex-direction: column;}@@ -1233,45 +1223,53 @@ export class OrChart extends translate(i18next)(OrElement) {protected _openTimeDialog(startTimestamp?: number, endTimestamp?: number) {const startRef: Ref<OrVaadinDateTimePicker> = createRef();const endRef: Ref<OrVaadinDateTimePicker> = createRef();- showDialog(- new OrMwcDialog()- .setHeading(i18next.t("timeframe"))- .setContent(- () => html`- <div style="max-width: 480px; display: flex; flex-direction: column; gap: 8px;">- <or-vaadin-date-time-picker- ${ref(startRef)}- required- value=${startTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(startTimestamp)) : undefined}- >- <or-translate slot="label" value="beginning"></or-translate>- </or-vaadin-date-time-picker>- <or-vaadin-date-time-picker- ${ref(endRef)}- required- value=${endTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(endTimestamp)) : undefined}- >- <or-translate slot="label" value="ending"></or-translate>- </or-vaadin-date-time-picker>- </div>- `- )- .setActions([- {- actionName: "cancel",- content: "cancel",- },- {- actionName: "ok",- content: "ok",- action: () => {- if (startRef.value?.value && endRef.value?.value) {- this._isCustomWindow = true;- this.timeframe = [new Date(startRef.value.value), new Date(endRef.value.value)];- }- },- },- ])+ let dialog: OrVaadinDialog | undefined;++ const onCancel = () => {+ dialog?.close();+ };+ const onOk = () => {+ if (startRef.value?.value && endRef.value?.value && startRef.value.value < endRef.value.value) {+ this._isCustomWindow = true;+ this.timeframe = [new Date(startRef.value.value), new Date(endRef.value.value)];+ dialog?.close();+ } else {+ showSnackbar(undefined, i18next.t("errorOccurred"));+ }+ };+ dialog = showVaadinDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="timeframe"></or-translate>+ </h2>+ <div style="padding: 4px 0; max-width: 480px; display: flex; flex-direction: column; gap: 8px;">+ <or-vaadin-date-time-picker+ ${ref(startRef)}+ required+ value=${startTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(startTimestamp)) : undefined}+ >+ <or-translate slot="label" value="beginning"></or-translate>+ </or-vaadin-date-time-picker>+ <or-vaadin-date-time-picker+ ${ref(endRef)}+ required+ value=${endTimestamp ? OrVaadinDateTimePicker.getLocalizedISOString(new Date(endTimestamp)) : undefined}+ >+ <or-translate slot="label" value="ending"></or-translate>+ </or-vaadin-date-time-picker>+ </div>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between;">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);}diff --git a/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts b/ui/component/or-dashboard-builder/src/panels/assettypes-panel.tsindex 126a31228..d26c2f392 100644--- a/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts+++ b/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts@@ -26,7 +26,7 @@ import { Util } from "@openremote/core";import { when } from "lit/directives/when.js";import { createRef, type Ref, ref } from "lit/directives/ref.js";import type { AssetTreeConfig, OrAssetTree } from "@openremote/or-asset-tree";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import {type ComboBoxLitRenderer,comboBoxRenderer,@@ -314,56 +314,49 @@ export class AssettypesPanel extends OrElement {multiSelect: multi,},} as AssetTreeConfig;- const dialog = showDialog(- new OrMwcDialog()- .setHeading(i18next.t("linkedAssets"))- .setStyles(- html`<style>- or-asset-tree {- min-height: 400px;- max-height: 50vh;- }- </style>`- )- .setContent(html`- <div style="width: 400px;">- <or-asset-tree- ${ref(assetTreeRef)}- id="chart-asset-tree"- readonly- disableSubscribe- .config="${config}"- .selectedIds="${assetIds}"- .showSortBtn="${false}"- .showFilterIcon="${false}"- .checkboxes="${multi}"- ></or-asset-tree>++ let dialog: OrVaadinDialog | undefined;+ const onCancel = () => dialog?.close();+ const onOk = () => {+ const tree = assetTreeRef.value;+ if (tree?.selectedIds) {+ if (multi) {+ this.assetIds = tree.selectedIds;+ } else {+ this.assetIds = tree.selectedIds[0];+ }+ }+ dialog?.close();+ };++ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="linkedAssets"></or-translate>+ </h2>+ <or-asset-tree+ ${ref(assetTreeRef)}+ readonly+ disableSubscribe+ .config="${config}"+ .selectedIds="${assetIds}"+ .showSortBtn="${false}"+ .showFilterIcon="${false}"+ .checkboxes="${multi}"+ style="width: 100%; aspect-ratio: 1/1.75;"+ ></or-asset-tree>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button></div>- `)- .setActions([- {- default: true,- actionName: "cancel",- content: "cancel",- },- {- actionName: "ok",- content: "ok",- action: () => {- const tree = assetTreeRef.value;- if (tree?.selectedIds) {- if (multi) {- this.assetIds = tree.selectedIds;- } else {- this.assetIds = tree.selectedIds[0];- }- }- },- },- ])- .setDismissAction({- actionName: "cancel",- })+ </or-vaadin-dialog>+ `);}}diff --git a/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts b/ui/component/or-dashboard-builder/src/settings/barchart-settings.tsindex b63e15a5d..f3fa49069 100644--- a/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts+++ b/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts@@ -33,9 +33,8 @@ import type { BarChartWidgetConfig } from "../widgets/barchart-widget";import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";import { when } from "lit/directives/when.js";import type moment from "moment/moment";-import { type ListItem, ListType, type OrMwcList } from "@openremote/or-mwc-components/or-mwc-list";import type { OrVaadinSelect, SelectItem } from "@openremote/or-vaadin-components/or-vaadin-select";-import { showDialog, OrMwcDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import {type BarChartAttributeConfig,type BarChartInterval,@@ -48,6 +47,7 @@ import { createRef, type Ref, ref } from "lit/directives/ref.js";import type { AttributesChartPanel } from "../panels/attributes-chart-panel";import debounce from "lodash.debounce";import type { OrVaadinNumberField } from "@openremote/or-vaadin-components/or-vaadin-number-field";+import type { OrVaadinCheckboxGroup } from "@openremote/or-vaadin-components/or-vaadin-checkbox-group";const styling = css`.switch-container {@@ -640,66 +640,60 @@ export class BarChartSettings extends WidgetSettings {"methodModeAttributes","methodSumAttributes",];- const methodList: ListItem[] = methodKeys.map((key) => {- const attributeRefs = this.widgetConfig.attributeSettings[key];- const isActive = attributeRefs?.some(- (attrRef) => attrRef.id === attributeRef.id && attrRef.name === attributeRef.name- );- return {- text: key,- value: key,- data: isActive ? key : undefined,- translate: true,- };- });+ const activeKeys = methodKeys.filter((key) =>+ this.widgetConfig?.attributeSettings?.[key]?.find(+ (ref) => ref.id === attributeRef.id && ref.name === attributeRef.name+ )+ );++ const groupRef: Ref<OrVaadinCheckboxGroup> = createRef();+ let dialog: OrVaadinDialog | undefined;++ const onCancel = () => {+ dialog?.close();+ };+ const onOk = () => {+ const groupElem = groupRef.value;+ if (groupElem) {+ // Find all "active" methods for this AttributeRef, and remove them all. (so they become empty arrays)+ activeKeys.forEach((key) => {+ this.toggleAttributeSetting(key, attributeRef, false);+ });+ // Add the methods that were checked in the checkbox list+ groupElem.value.forEach((key) => {+ this.toggleAttributeSetting(key as keyof BarChartAttributeConfig, attributeRef, false);+ });+ this.notifyConfigUpdate();+ dialog?.close();+ }+ };- const listRef: Ref<OrMwcList> = createRef();-- showDialog(- new OrMwcDialog()- .setContent(html`- <div id="method-creator">- <or-mwc-list- ${ref(listRef)}- id="method-creator-list"- .type="${ListType.MULTI_CHECKBOX}"- .listItems="${methodList}"- .values="${methodList.map((item) => item.data)}"- ></or-mwc-list>+ dialog = showDialog(+ this.shadowRoot!,+ html`+ <or-vaadin-dialog width="384px">+ <h2 slot="header-content">+ <or-translate value="algorithmMethod"></or-translate>+ </h2>+ <or-vaadin-checkbox-group ${ref(groupRef)} theme="vertical" .value="${activeKeys}">+ ${methodKeys.map(+ (method) => html`+ <vaadin-checkbox value=${method}>+ <or-translate slot="label" value=${method}></or-translate>+ </vaadin-checkbox>+ `+ )}+ </or-vaadin-checkbox-group>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between;">+ <or-vaadin-button theme="tertiary contrast" @click=${onCancel}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button theme="primary" @click=${onOk}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button></div>- `)- .setHeading(i18next.t("algorithmMethod"))- .setActions([- {- actionName: "cancel",- content: "cancel",- },- {- default: true,- actionName: "ok",- action: () => {- if (listRef.value) {- // Find all "active" methods for this AttributeRef, and remove them all. (so they become empty arrays)- methodKeys- .filter(- (oldKey) =>- !!this.widgetConfig.attributeSettings[oldKey]?.find(- (attrRef) => attrRef.id === attributeRef.id && attrRef.name === attributeRef.name- )- )- .forEach((oldKey) => this.toggleAttributeSetting(oldKey, attributeRef, false));-- // Add the methods that were checked in the checkbox list- (listRef.value.values as (keyof BarChartAttributeConfig)[] | undefined)?.forEach((s) => {- this.toggleAttributeSetting(s, attributeRef, false);- });- this.notifyConfigUpdate();- }- },- content: "ok",- },- ])- .setDismissAction(null)+ </or-vaadin-dialog>+ `);}diff --git a/ui/component/or-map/package.json b/ui/component/or-map/package.jsonindex f23c06f3d..ab932075d 100644--- a/ui/component/or-map/package.json+++ b/ui/component/or-map/package.json@@ -33,7 +33,6 @@"@openremote/model": "workspace:*","@openremote/or-element": "workspace:*","@openremote/or-icon": "workspace:*",- "@openremote/or-mwc-components": "workspace:*","@openremote/or-translate": "workspace:*","@openremote/or-vaadin-components": "workspace:*","lit": "^3.3.1",diff --git a/ui/component/or-map/src/base-map.ts b/ui/component/or-map/src/base-map.tsindex b48e6962f..fb8c64e0c 100644--- a/ui/component/or-map/src/base-map.ts+++ b/ui/component/or-map/src/base-map.ts@@ -806,7 +806,7 @@ export class BaseMap {});this._map.on("mousedown", (e) => {- if (!pressTimeout) {+ if (!pressTimeout && e.originalEvent.button === 0) {pos = e.lngLat;pressTimeout = setTimeout(() => {this._onLongPress(pos!);@@ -815,7 +815,7 @@ export class BaseMap {}});- this._map.on("dragstart", clearTimeoutFunc);+ this._map.on("movestart", clearTimeoutFunc);this._map.on("mouseup", clearTimeoutFunc);this._map.on("touchend", clearTimeoutFunc);this._map.on("touchcancel", clearTimeoutFunc);diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.tsindex e35953450..327a1bda8 100644--- a/ui/component/or-map/src/index.ts+++ b/ui/component/or-map/src/index.ts@@ -31,9 +31,8 @@ import type {ValueInputProviderGenerator,ValueInputTemplateFunction,} from "@openremote/or-vaadin-components/value-input-provider";-import { OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-dialog";+import { type OrVaadinDialog, showDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { getMarkerIconAndColorFromAssetType } from "./util";-import { i18next } from "@openremote/or-translate";import debounce from "lodash.debounce";import type { AttributeEvent, GeoJsonConfig } from "@openremote/model";import {@@ -46,6 +45,8 @@ import { AssetMap } from "./asset-map";import { OrMapCenterControl } from "./controls/center";import { OrMapGeolocateControl } from "./controls/geolocate";import { ifDefined } from "lit-html/directives/if-defined.js";+import { createRef, ref, type Ref } from "lit/directives/ref.js";+import type { OrVaadinTextField } from "@openremote/or-vaadin-components/or-vaadin-text-field";import type { AssetWithLocation, ClusterConfig, ControlPosition, MapEventDetail, MapFilter } from "./types";// Re-exports@@ -153,10 +154,11 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (// Indirection so the stable geolocate instance can call the per-render setPos.let _setPos: ((lngLat: LngLatLike | null) => void) | undefined;- const controls: (IControl | [IControl, ControlPosition?])[] = [- [centerControl, "bottom-right"],- [coordinatesControl, "top-left"],- ];+ const controls: (IControl | [IControl, ControlPosition?])[] = [[centerControl, "bottom-right"]];+ // The compact dialog has its own coordinates field below the map+ if (!compact) {+ controls.push([coordinatesControl, "top-left"]);+ }if (!readonly) {const userLocationControl = new OrMapGeolocateControl((currentLocation: GeolocationPosition) => {_setPos?.(new LngLat(currentLocation.coords.longitude, currentLocation.coords.latitude));@@ -179,33 +181,38 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (const iconAndColor = getMarkerIconAndColorFromAssetType(assetDescriptor);- let dialog: OrMwcDialog | undefined;+ let dialog: OrVaadinDialog | undefined;+ const orMap: Ref<OrMap> = createRef();+ const coordinatesField: Ref<OrVaadinTextField> = createRef();- _setPos = (lngLat: LngLatLike | null) => {+ const setPos = (lngLat: LngLatLike | null) => {if (readonly || disabled) {return;}pos = lngLat ? Util.getLngLat(lngLat) : null;- if (dialog) {+ if (dialog && orMap.value) {// We're in compact mode modal- const marker = dialog.shadowRoot!.getElementById("geo-json-point-marker") as OrMapMarker;+ const marker = orMap.value.firstElementChild as OrMapMarker;marker.lng = pos ? pos.lng : undefined;marker.lat = pos ? pos.lat : undefined;- center = pos ? Object.values(pos) : undefined;- const centerStr = center ? center.join(", ") : undefined;+ const centerStr = pos ? Object.values(pos).join(", ") : undefined;coordinatesControl.value = centerStr;+ if (coordinatesField.value) {+ coordinatesField.value.value = centerStr ?? "";+ }} else {valueChangeHandler(pos as LngLatLike);}};- const setPos = _setPos;+ _setPos = setPos;- let content = html`+ const mapTemplate = (style?: string) => html`<or-mapid="geo-json-point-map"- class="or-map"+ ${ref(orMap)}+ style=${ifDefined(style)}@or-map-long-press="${(ev: OrMapLongPressEvent) => {setPos(ev.detail.lngLat);}}"@@ -223,53 +230,68 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (.colour="${iconAndColor ? "#" + iconAndColor.color : undefined}"></or-map-marker></or-map>- <span class="long-press-msg">${i18next.t("longPressSetLoc")}</span>`;- if (compact) {- const mapContent = content;+ let content = html`+ ${mapTemplate()}+ <span class="long-press-msg">+ <or-translate value="longPressSetLoc"></or-translate>+ </span>+ `;+ if (compact) {const onClick = () => {+ // Edits in the dialog are a draft that only Ok keeps+ const committedPos = pos;+ let confirmed = false;dialog = showDialog(- new OrMwcDialog()- .setContent(mapContent)- .setStyles(html`- <style>- .dialog-container {- flex-direction: column !important;- }- .dialog-container .long-press-msg {- display: block;- text-align: center;- }- or-map {- width: 600px !important;- min-height: 600px !important;+ document.body,+ html`+ <or-vaadin-dialog+ width="960px"+ @closed=${() => {+ if (!confirmed) {+ pos = committedPos;}- </style>- `)- .setActions([- {- actionName: "none",- content: "none",- action: () => {- setPos(null);- valueChangeHandler(pos as LngLatLike);- },- },- {- actionName: "ok",- content: "ok",- action: () => {- valueChangeHandler(pos as LngLatLike);- },- },- {- default: true,- actionName: "cancel",- content: "cancel",- },- ])+ }}+ >+ <h2 slot="header-content">+ <or-translate value="pickLocation"></or-translate>+ </h2>+ <div style="display: flex; flex-direction: column; gap: var(--lumo-space-s);">+ <or-translate value="longPressSetLoc"></or-translate>+ ${mapTemplate("height: 445px; border-radius: var(--lumo-border-radius-m); overflow: hidden;")}+ <or-vaadin-text-field+ ${ref(coordinatesField)}+ style="width: 100%;"+ clear-button-visible+ value=${ifDefined(centerStr)}+ pattern=${CoordinatesRegexPattern}+ ?readonly=${readonly}+ ?disabled=${disabled}+ @change="${(e: Event) => commitCoordinatesInputValue(e, setPos)}"+ @keyup="${(e: KeyboardEvent) => getCoordinatesInputKeyHandler(setPos)(e)}"+ >+ <or-translate slot="label" value="gpsCoordinates"></or-translate>+ </or-vaadin-text-field>+ </div>+ <div slot="footer" style="width: 100%; display: flex; justify-content: space-between">+ <or-vaadin-button theme="tertiary contrast" @click=${() => dialog?.close()}>+ <or-translate value="cancel"></or-translate>+ </or-vaadin-button>+ <or-vaadin-button+ theme="primary"+ @click=${() => {+ confirmed = true;+ valueChangeHandler(pos as LngLatLike);+ dialog?.close();+ }}+ >+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>+ `);};diff --git a/ui/component/or-map/tsconfig.json b/ui/component/or-map/tsconfig.jsonindex b4a131502..1b3937985 100644--- a/ui/component/or-map/tsconfig.json+++ b/ui/component/or-map/tsconfig.json@@ -12,7 +12,6 @@{ "path": "../rest" },{ "path": "../model" },{ "path": "../or-translate" },- { "path": "../or-mwc-components" },{ "path": "../or-icon" },{ "path": "../or-vaadin-components" }]diff --git a/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts b/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.tsindex 2ee9629cd..c44db5704 100644--- a/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts+++ b/ui/component/or-rules/src/json-viewer/modals/or-rule-radial-modal.ts@@ -18,21 +18,15 @@*/import { html } from "lit";import { OrElement } from "@openremote/or-element";-import { customElement, property } from "lit/decorators.js";+import { customElement, property, query } from "lit/decorators.js";import type { AssetDescriptor, AttributePredicate, AssetQuery, RadialGeofencePredicate } from "@openremote/model";-import { getAssetTypeFromQuery } from "../../index";-import "@openremote/or-mwc-components/or-mwc-input";-import { InputType } from "@openremote/or-mwc-components/or-mwc-input";+import type { OrVaadinDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";import { i18next, translate } from "@openremote/or-translate";import { OrRulesJsonRuleChangedEvent } from "../or-rule-json-viewer";--import {- type DialogAction,- type OrMwcDialog,- OrMwcDialogOpenedEvent,-} from "@openremote/or-mwc-components/or-mwc-dialog";import { type OrMap, OrMapClickedEvent, type LngLatLike } from "@openremote/or-map";import "@openremote/or-map";+import type { OrVaadinNumberField } from "@openremote/or-vaadin-components/or-vaadin-number-field";+import type { OrVaadinButton } from "@openremote/or-vaadin-components/or-vaadin-button";@customElement("or-rule-radial-modal")export class OrRuleRadialModal extends translate(i18next)(OrElement) {@@ -48,21 +42,24 @@ export class OrRuleRadialModal extends translate(i18next)(OrElement) {@property({ type: Object })public query?: AssetQuery;- constructor() {- super();- this.addEventListener(OrMwcDialogOpenedEvent.NAME, this.initRadialMap);- }+ @query("#radial-modal")+ protected _mapDialogElem?: OrVaadinDialog;++ @query("#radial-modal-button")+ protected _mapDialogButton?: OrVaadinButton;initRadialMap() {- const modal = this.shadowRoot!.getElementById("radial-modal");- if (!modal) return;+ if (!this._mapDialogElem) {+ console.warn("Could not find radial map dialog element!");+ return;+ }- const map = modal.shadowRoot!.querySelector(".or-map") as OrMap;+ const map = this._mapDialogElem!.querySelector(".or-map") as OrMap;if (map) {map.addEventListener(OrMapClickedEvent.NAME, (evt: CustomEvent) => {const lngLat: any = evt.detail.lngLat;- const latElement = modal.shadowRoot!.querySelector(".location-lat") as HTMLInputElement;- const lngElement = modal.shadowRoot!.querySelector(".location-lng") as HTMLInputElement;+ const latElement = this._mapDialogElem!.querySelector(".location-lat") as HTMLInputElement;+ const lngElement = this._mapDialogElem!.querySelector(".location-lng") as HTMLInputElement;latElement.value = lngLat.lat;lngElement.value = lngLat.lng;@@ -73,8 +70,8 @@ export class OrRuleRadialModal extends translate(i18next)(OrElement) {this.setValuePredicateProperty("lng", lngLat.lng);});- const latElement = modal.shadowRoot!.querySelector(".location-lat") as HTMLInputElement;- const lngElement = modal.shadowRoot!.querySelector(".location-lng") as HTMLInputElement;+ const latElement = this._mapDialogElem!.querySelector(".location-lat") as HTMLInputElement;+ const lngElement = this._mapDialogElem!.querySelector(".location-lng") as HTMLInputElement;if (lngElement.value && latElement.value) {const LngLat: LngLatLike = [parseFloat(lngElement.value), parseFloat(latElement.value)];map.flyTo(LngLat, 15);@@ -84,10 +81,6 @@ export class OrRuleRadialModal extends translate(i18next)(OrElement) {}}- protected getAttributeName(attributePredicate: AttributePredicate): string | undefined {- return attributePredicate && attributePredicate.name ? attributePredicate.name.value : undefined;- }-protected setValuePredicateProperty(propertyName: string, value: any) {if (!this.attributePredicate) return;if (!this.attributePredicate.value) return;@@ -100,57 +93,54 @@ export class OrRuleRadialModal extends translate(i18next)(OrElement) {this.requestUpdate();}- renderDialogHTML(value: RadialGeofencePredicate) {- const dialog: OrMwcDialog = this.shadowRoot!.getElementById("radial-modal") as OrMwcDialog;-- if (dialog) {- dialog.content = html` <div style="display:grid">- <or-map- class="or-map"- type="VECTOR"- style="border: 1px solid #d5d5d5; height: 400px; min-width: 300px; margin-bottom: 20px;"- >- <or-map-marker- active- color="#FF0000"- icon="information"- lat="${value.lat}"- lng="${value.lng}"- radius="${value.radius}"- ></or-map-marker>- </or-map>-- <div class="layout horizontal">- <input- hidden- class="location-lng"- required- placeholder=" "- type="text"- .value="${value && value.lng ? value.lng : null}"- />- <input- hidden- class="location-lat"- required- placeholder=" "- type="text"- .value="${value && value.lat ? value.lat : null}"- />- </div>-- <label>${i18next.t("radiusMin")}</label>+ getDialogHTML(value: RadialGeofencePredicate) {+ return html` <div style="display:grid">+ <or-map class="or-map" type="VECTOR" style="border: 1px solid #d5d5d5; aspect-ratio: 1/1;">+ <or-map-marker+ active+ color="#FF0000"+ icon="information"+ lat="${value.lat}"+ lng="${value.lng}"+ radius="${value.radius}"+ ></or-map-marker>+ </or-map>++ <div class="layout horizontal"><input- @change="${(e: any) => this.setValuePredicateProperty("radius", parseInt(e.target.value))}"- style="max-width: calc(50% - 30px);"+ hidden+ class="location-lng"requiredplaceholder=" "- min="100"- type="number"- .value="${value && value.radius ? value.radius : 100}"+ type="text"+ .value="${value && value.lng ? value.lng : null}"/>- </div>`;- }+ <input+ hidden+ class="location-lat"+ required+ placeholder=" "+ type="text"+ .value="${value && value.lat ? value.lat : null}"+ />+ </div>++ <or-vaadin-number-field+ style="max-width: 50%; margin-top: var(--lumo-space-m);"+ min="100"+ required+ value=${value.radius ?? 100}+ @change=${(ev: Event) => {+ const elem = ev.currentTarget as OrVaadinNumberField;+ if (elem.checkValidity()) {+ this.setValuePredicateProperty("radius", parseInt(elem.value));+ }+ this._mapDialogButton!.disabled = !elem.checkValidity();+ }}+ >+ <or-translate slot="label" value="radiusMin"></or-translate>+ </or-vaadin-number-field>+ </div>`;}protected render() {@@ -161,44 +151,29 @@ export class OrRuleRadialModal extends translate(i18next)(OrElement) {if (!this.assetDescriptor || !valuePredicate) {return html``;}-- const attributeName = this.getAttributeName(this.attributePredicate);- const assetType = getAssetTypeFromQuery(this.query);// @ts-ignoreconst value: RadialGeofencePredicate = valuePredicate || undefined;- const radiusPickerModalActions: DialogAction[] = [- {- actionName: "cancel",- content: html`<or-mwc-input class="button" .type="${InputType.BUTTON}" label="cancel"></or-mwc-input>`,- action: () => {- // Nothing to do here- },- },- {- actionName: "ok",- default: true,- content: html`<or-mwc-input class="button" .type="${InputType.BUTTON}" label="ok"></or-mwc-input>`,- action: () => {},- },- ];-const radialPickerModalOpen = () => {- const dialog: OrMwcDialog = this.shadowRoot!.getElementById("radial-modal") as OrMwcDialog;- if (dialog) {- dialog.dismissAction = null;- dialog.open();- this.renderDialogHTML(value);- }+ this._mapDialogElem?.open();+ this.initRadialMap();};- this.renderDialogHTML(value);-return html`<or-vaadin-button ?disabled=${this.readonly} @click=${() => radialPickerModalOpen()}><or-translate value="area"></or-translate></or-vaadin-button>- <or-mwc-dialog id="radial-modal" heading="area" .actions="${radiusPickerModalActions}"></or-mwc-dialog>+ <or-vaadin-dialog id="radial-modal" width="512px">+ <h2 slot="header-content">+ <or-translate value="area"></or-translate>+ </h2>+ ${this.getDialogHTML(value)}+ <div slot="footer" style="width: 100%; display: flex; justify-content: end;">+ <or-vaadin-button id="radial-modal-button" theme="primary" @click=${() => this._mapDialogElem?.close()}>+ <or-translate value="ok"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>`;}}diff --git a/ui/component/or-rules/src/json-viewer/or-rule-trigger-query.ts b/ui/component/or-rules/src/json-viewer/or-rule-trigger-query.tsindex b15790469..e3f091859 100644--- a/ui/component/or-rules/src/json-viewer/or-rule-trigger-query.ts+++ b/ui/component/or-rules/src/json-viewer/or-rule-trigger-query.ts@@ -17,26 +17,21 @@* SPDX-License-Identifier: AGPL-3.0-or-later*/import { type GeoJSONPoint, type RuleCondition, SunPositionTriggerPosition } from "@openremote/model";-import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";-import { css, html, type PropertyValues } from "lit";+import { css, html, type TemplateResult, type PropertyValues } from "lit";import { OrElement } from "@openremote/or-element";-import { customElement, property, state } from "lit/decorators.js";+import { customElement, property, query, state } from "lit/decorators.js";import moment from "moment";import { buttonStyle } from "../style";import { OrRulesJsonRuleChangedEvent } from "./or-rule-json-viewer";import { TimeTriggerType } from "../index";import { Util } from "@openremote/core";-import {- type DialogAction,- type OrMwcDialog,- OrMwcDialogOpenedEvent,-} from "@openremote/or-mwc-components/or-mwc-dialog";import { type OrMap, OrMapClickedEvent } from "@openremote/or-map";import { i18next } from "@openremote/or-translate";import type { OrVaadinSelect } from "@openremote/or-vaadin-components/or-vaadin-select";import { when } from "lit/directives/when.js";import { ifDefined } from "lit/directives/if-defined.js";import type { OrVaadinTimePicker } from "@openremote/or-vaadin-components/or-vaadin-time-picker";+import type { OrVaadinDialog } from "@openremote/or-vaadin-components/or-vaadin-dialog";// language=CSSconst style = css`@@ -90,6 +85,9 @@ export class OrRuleTriggerQuery extends OrElement {@state()protected triggerOptions: TimeTrigger[];+ @query("#map-modal")+ protected _mapDialogElem?: OrVaadinDialog;+constructor() {super();this.triggerOptions = [];@@ -100,8 +98,6 @@ export class OrRuleTriggerQuery extends OrElement {this.triggerOptions.push({ key: opt, value: this.triggerToString(opt) });});this.selectedTrigger = this.triggerOptions[0];-- this.addEventListener(OrMwcDialogOpenedEvent.NAME, this.initMap);}updated(changedProperties: PropertyValues) {@@ -123,91 +119,73 @@ export class OrRuleTriggerQuery extends OrElement {/* ---------------------- */initMap() {- const modal = this.shadowRoot!.getElementById("map-modal");- if (!modal) return;-- const map = modal.shadowRoot!.querySelector(".or-map") as OrMap;- if (map) {- map.addEventListener(OrMapClickedEvent.NAME, (evt: CustomEvent) => {- const lngLat: any = evt.detail.lngLat;- this.setLocation({ type: "Point", coordinates: [lngLat.lat, lngLat.lng] });- const latElement = modal.shadowRoot!.querySelector(".location-lat") as HTMLInputElement;- const lngElement = modal.shadowRoot!.querySelector(".location-lng") as HTMLInputElement;- latElement.value = lngLat.lat;- lngElement.value = lngLat.lng;- });+ if (!this._mapDialogElem) {+ console.warn("Could not find map dialog element!");+ return;+ }+ const map = this._mapDialogElem.querySelector(".or-map") as OrMap;+ if (!map) {+ console.warn("Could not find map within dialog element!");+ return;}+ map.addEventListener(OrMapClickedEvent.NAME, (evt: CustomEvent) => {+ const lngLat: any = evt.detail.lngLat;+ this.setLocation({ type: "Point", coordinates: [lngLat.lat, lngLat.lng] });+ const latElement = this._mapDialogElem!.querySelector(".location-lat") as HTMLInputElement;+ const lngElement = this._mapDialogElem!.querySelector(".location-lng") as HTMLInputElement;+ latElement.value = lngLat.lat;+ lngElement.value = lngLat.lng;+ });}- renderDialogHTML(point: GeoJSONPoint | undefined) {- const dialog: OrMwcDialog = this.shadowRoot!.getElementById("map-modal") as OrMwcDialog;- if (dialog) {- dialog.content = html`- <div style="display:grid">- <or-map- class="or-map"- type="VECTOR"- style="border: 1px solid #d5d5d5; height: 400px; min-width: 300px; margin-bottom: 20px;"- >- ${- point && point.coordinates- ? html`- <or-map-marker- class="or-map-marker"- active- color="#FF0000"- icon="white-balance-sunny"- lat="${point.coordinates[0]}"- lng="${point.coordinates[1]}"- ></or-map-marker>- `- : undefined- }- </or-map>- <div class="layout horizontal">- <input- hidden- class="location-lng"- required- placeholder=" "- type="text"- .value="${point && point.coordinates ? point.coordinates[0] : null}"- />- <input- hidden- class="location-lat"- required- placeholder=" "- type="text"- .value="${point && point.coordinates ? point.coordinates[1] : null}"- />- </div>+ renderDialogHTML(point: GeoJSONPoint | undefined): TemplateResult {+ return html`+ <div style="display:grid">+ <or-map class="or-map" type="VECTOR" zoom="12" style="border: 1px solid #d5d5d5; aspect-ratio: 1/1;">+ ${+ point && point.coordinates+ ? html`+ <or-map-marker+ class="or-map-marker"+ active+ color="#FF0000"+ icon="white-balance-sunny"+ lat="${point.coordinates[0]}"+ lng="${point.coordinates[1]}"+ ></or-map-marker>+ `+ : undefined+ }+ </or-map>+ <div class="layout horizontal">+ <input+ hidden+ class="location-lng"+ required+ placeholder=" "+ type="text"+ .value="${point && point.coordinates ? point.coordinates[0] : null}"+ />+ <input+ hidden+ class="location-lat"+ required+ placeholder=" "+ type="text"+ .value="${point && point.coordinates ? point.coordinates[1] : null}"+ /></div>- `;- }+ </div>+ `;}/* ----------------------------- */render() {- const modalActions: DialogAction[] = [- {- actionName: "close",- default: true,- content: html`<or-mwc-input class="button" .type="${InputType.BUTTON}" label="close"></or-mwc-input>`,- action: () => {},- },- ];- const onMapModalOpen = () => {- const dialog: OrMwcDialog = this.shadowRoot!.getElementById("map-modal") as OrMwcDialog;- if (dialog) {- dialog.dismissAction = null;- dialog.open();- this.renderDialogHTML(this.condition.sun?.location);- }+ const openModal = () => {+ this._mapDialogElem?.open();+ this.initMap();};- // Render dialog on every update (for example when changing location in the modal itself)- this.renderDialogHTML(this.condition.sun?.location);return html`<div class="trigger-group">@@ -249,14 +227,20 @@ export class OrRuleTriggerQuery extends OrElement {><or-translate slot="label" value="offsetInMinutes"></or-translate></or-vaadin-number-field>- <or-vaadin-button class="min-width" @click=${() => onMapModalOpen()}>+ <or-vaadin-button class="min-width" @click=${() => openModal()}><or-translate value="location"></or-translate></or-vaadin-button>- <or-mwc-dialog- id="map-modal"- heading="${i18next.t("pickLocation")}"- .actions="${modalActions}"- ></or-mwc-dialog>+ <or-vaadin-dialog id="map-modal" width="512px">+ <h2 slot="header-content">+ <or-translate value="pickLocation"></or-translate>+ </h2>+ ${this.renderDialogHTML(this.condition.sun?.location)}+ <div slot="footer" style="width: 100%; display: flex; justify-content: end;">+ <or-vaadin-button theme="primary" @click=${() => this._mapDialogElem?.close()}>+ <or-translate value="close"></or-translate>+ </or-vaadin-button>+ </div>+ </or-vaadin-dialog>`}`diff --git a/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.ts b/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.tsindex 43b7aaa41..879fb11b1 100644--- a/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.ts+++ b/ui/component/or-vaadin-components/src/or-vaadin-confirm-dialog.ts@@ -55,6 +55,7 @@ export function showConfirmDialog(host: Node, dialog: TemplateResult) {return;}host.appendChild(container);+ return dialogElem;}/**@@ -63,50 +64,53 @@ export function showConfirmDialog(host: Node, dialog: TemplateResult) {* Example: `getConfirmDialogContent("areYouSure", "deleteWarning", "remove", "cancel")`** @param theme - Optional theme to use for the dialog and its buttons (for example 'error').- * @param header - Dialog header that is either a translation key, or a {@link TemplateResult}+ * @param header - Dialog header that is either a translation key, or a {@link TemplateResult}. If `undefined` no header is added; set `theme="no-header"` on the dialog to hide the empty header.* @param content - Dialog content that is either a translation key, or a {@link TemplateResult}- * @param confirmKey - Translation key to display inside the "confirm" button. If `undefined` the button will not be visible.- * @param cancelKey - Translation key to display inside the "cancel" button. If `undefined` the button will not be visible.- * @param rejectKey - Translation key to display inside the "reject" button. If `undefined` the button will not be visible.+ * @param confirm - {@link TemplateResult} or translation key to display inside the "confirm" button. If `undefined` the button will not be visible.+ * @param cancel - {@link TemplateResult} or translation key to display inside the "cancel" button. If `undefined` the button will not be visible.+ * @param reject - {@link TemplateResult} or translation key to display inside the "reject" button. If `undefined` the button will not be visible.*/export function getConfirmDialogContent(theme: string | undefined,- header: TemplateResult | string,+ header: TemplateResult | string | undefined,content: TemplateResult | string,- confirmKey?: string,- cancelKey?: string,- rejectKey?: string+ confirm?: TemplateResult | string,+ cancel?: TemplateResult | string,+ reject?: TemplateResult | string): TemplateResult {return html`${typeof header === "string"? html`<or-translate slot="header" value=${header}></or-translate>`- : html`<div slot="header">${header}</div>`+ : header && html`<div slot="header">${header}</div>`}${typeof content === "string" ? html`<or-translate value=${content}></or-translate>` : content}${when(- confirmKey,+ typeof confirm === "string",() => html`<or-vaadin-button theme=${theme && theme.includes(" ") ? theme : theme + " primary"} slot="confirm-button">- <or-translate value=${confirmKey}></or-translate>+ <or-translate value=${confirm}></or-translate></or-vaadin-button>- `+ `,+ confirm ? () => confirm : undefined)}${when(- cancelKey,+ typeof cancel === "string",() => html`- <or-vaadin-button theme=${theme ? `tertiary ${theme}` : "tertiary"} slot="cancel-button">- <or-translate value=${cancelKey}></or-translate>+ <or-vaadin-button theme="tertiary contrast" slot="cancel-button">+ <or-translate value=${cancel}></or-translate></or-vaadin-button>- `+ `,+ cancel ? () => cancel : undefined)}${when(- rejectKey,+ typeof reject === "string",() => html`<or-vaadin-button theme=${theme ? `tertiary ${theme}` : "tertiary"} slot="reject-button">- <or-translate value=${rejectKey}></or-translate>+ <or-translate value=${reject}></or-translate></or-vaadin-button>- `+ `,+ reject ? () => reject : undefined)}`;}@@ -150,10 +154,10 @@ export class OrVaadinConfirmDialog}::part(header),::part(footer) {- padding: var(--lumo-space-l);+ padding: var(--lumo-space-m);}::part(content) {- padding: 0 var(--lumo-space-l);+ padding: var(--lumo-space-s) var(--lumo-space-m);}`,];diff --git a/ui/component/or-vaadin-components/src/or-vaadin-dialog.ts b/ui/component/or-vaadin-components/src/or-vaadin-dialog.tsindex 689289210..c1c4f584a 100644--- a/ui/component/or-vaadin-components/src/or-vaadin-dialog.ts+++ b/ui/component/or-vaadin-components/src/or-vaadin-dialog.ts@@ -80,10 +80,10 @@ export class OrVaadinDialog extends (Dialog as new () => Dialog & LitElement) im}::part(header),::part(footer) {- padding: var(--lumo-space-l);+ padding: var(--lumo-space-m);}::part(content) {- padding: 0 var(--lumo-space-l);+ padding: 0 var(--lumo-space-m);}`,];diff --git a/ui/component/theme/src/components/index.css b/ui/component/theme/src/components/index.cssindex b1571eb4c..6ca17405e 100644--- a/ui/component/theme/src/components/index.css+++ b/ui/component/theme/src/components/index.css@@ -21,7 +21,6 @@* seems to be an issue when using Rspack.*/@import "./or-vaadin-badge.css";-@import "./or-vaadin-button.css";@import "./or-vaadin-checkbox-group.css";@import "./or-vaadin-checkbox.css"; /* Must be after the checkbox-group */@import "./or-vaadin-combo-box.css";@@ -43,3 +42,4 @@@import "./or-vaadin-text-field.css";@import "./or-vaadin-time-picker.css"; /* Must be after the date-time-picker */@import "./or-vaadin-toggle-group.css"; /* Must be after the checkbox-group */+@import "./or-vaadin-button.css"; /* Must be after every file that imports the Lumo button styles */diff --git a/ui/component/theme/src/components/or-vaadin-button.css b/ui/component/theme/src/components/or-vaadin-button.cssindex 9a559e614..7b3795a11 100644--- a/ui/component/theme/src/components/or-vaadin-button.css+++ b/ui/component/theme/src/components/or-vaadin-button.css@@ -18,8 +18,16 @@*/@import "@vaadin/vaadin-lumo-styles/components/button.css";+/* Buttons size to their label, Lumo sets a minimum width that primary buttons raise further */+@media lumo_components_button-internal {+ :host,+ :host([theme~="primary"]) {+ min-width: var(--vaadin-button-min-width, 0);+ }+}+:root::before,:host::before {--_lumo-vaadin-button-inject: 1;- --_lumo-vaadin-button-inject-modules: lumo_components_button;+ --_lumo-vaadin-button-inject-modules: lumo_components_button, lumo_components_button-internal;}diff --git a/ui/component/theme/src/components/or-vaadin-confirm-dialog.css b/ui/component/theme/src/components/or-vaadin-confirm-dialog.cssindex 1b0f5a18d..fcc7dee93 100644--- a/ui/component/theme/src/components/or-vaadin-confirm-dialog.css+++ b/ui/component/theme/src/components/or-vaadin-confirm-dialog.css@@ -18,9 +18,19 @@*/@import "@vaadin/vaadin-lumo-styles/components/confirm-dialog.css";+@media lumo_components_confirm-dialog-overlay-internal {+ :host([theme~="no-header"]) [part="header"] {+ display: none;+ }+ :host([theme~="no-header"]) [part="content"] {+ padding-top: var(--lumo-space-m) !important;+ }+}+:root::before,:host::before {--_lumo-vaadin-confirm-dialog-overlay-inject: 1;--_lumo-vaadin-confirm-dialog-overlay-inject-modules:- lumo_mixins_overlay, lumo_components_dialog-overlay, lumo_components_confirm-dialog-overlay;+ lumo_mixins_overlay, lumo_components_dialog-overlay, lumo_components_confirm-dialog-overlay,+ lumo_components_confirm-dialog-overlay-internal;}diff --git a/ui/component/theme/src/components/or-vaadin-dialog.css b/ui/component/theme/src/components/or-vaadin-dialog.cssindex 42f4366e0..455f9d28f 100644--- a/ui/component/theme/src/components/or-vaadin-dialog.css+++ b/ui/component/theme/src/components/or-vaadin-dialog.css@@ -23,7 +23,7 @@width: 100%;}:host(:not([has-footer])) [part="content"] {- padding: 0 var(--lumo-space-l) var(--lumo-space-l) !important;+ padding: 0 var(--lumo-space-m) var(--lumo-space-m) !important;}}diff --git a/yarn.lock b/yarn.lockindex 734325c05..92a71fbfe 100644--- a/yarn.lock+++ b/yarn.lock@@ -2241,7 +2241,6 @@ __metadata:"@openremote/model": "workspace:*""@openremote/or-element": "workspace:*""@openremote/or-icon": "workspace:*"- "@openremote/or-mwc-components": "workspace:*""@openremote/or-translate": "workspace:*""@openremote/or-vaadin-components": "workspace:*""@openremote/util": "workspace:*"