Skip to content

armgit / core

Public Imported from GitHub
0

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

Migrate Material Design switch to Vaadin toggle (#2982)

Koenbce112957741
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.ts
index e677fb673..afc104bd7 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
@@ -24,7 +24,7 @@ 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 { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";
import type { OrMapLongPressEvent } from "@openremote/or-map";
import type { LngLat } from "maplibre-gl";
import "./or-conf-map-geojson";
@@ -337,16 +337,15 @@ export class OrConfMapCard extends OrElement {
</div>
<div class="input" style="height: 56px;">
- <or-mwc-input
- .value="${map.boxZoom}"
- .type="${InputType.SWITCH}"
- label="BoxZoom"
- @or-mwc-input-changed="${(e: OrInputChangedEvent) => {
- map.boxZoom = e.detail.value;
+ <or-vaadin-toggle
+ ?checked="${map.boxZoom}"
+ @change="${(e: Event) => {
+ map.boxZoom = (e.currentTarget as OrVaadinToggle).checked;
this.notifyConfigChange(map);
}}"
- .step="${1}"
- ></or-mwc-input>
+ >
+ <or-translate slot="label" value="configuration.boxZoom"></or-translate>
+ </or-vaadin-toggle>
</div>
</div>
</div>
diff --git a/ui/app/manager/src/pages/page-gateway.ts b/ui/app/manager/src/pages/page-gateway.ts
index 7639cbf70..034bc5b4e 100644
--- a/ui/app/manager/src/pages/page-gateway.ts
+++ b/ui/app/manager/src/pages/page-gateway.ts
@@ -37,6 +37,7 @@ import {
} from "@openremote/model";
import manager, { DefaultColor1, DefaultColor3 } 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";
import type { Store } from "@reduxjs/toolkit";
import { OrAssetTypeAttributePicker, OrAssetTypeAttributePickerPickedEvent } from "@openremote/or-attribute-picker";
@@ -96,6 +97,13 @@ export class PageGateway extends Page<AppStateKeyed> {
#title div {
display: flex;
align-items: center;
+ gap: var(--lumo-space-s);
+ }
+
+ /* Baseline alignment puts the toggle's label on the same line as the button label */
+ #title #title-actions {
+ align-items: baseline;
+ gap: 20px;
}
#title > div > span {
@@ -106,7 +114,6 @@ export class PageGateway extends Page<AppStateKeyed> {
#title > div > or-icon {
--or-icon-width: 20px;
--or-icon-height: 20px;
- margin-right: 10px;
margin-left: 14px;
}
@@ -312,15 +319,14 @@ export class PageGateway extends Page<AppStateKeyed> {
<or-icon icon="cloud"></or-icon>
<span>${i18next.t("gatewayConnection")}</span>
</div>
- <div style="gap: 20px;">
+ <div id="title-actions">
<div>
<or-translate value="enabled"></or-translate>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- .value="${!connection.disabled}"
+ <or-vaadin-toggle
+ ?checked="${!connection.disabled}"
?disabled="${disabled}"
- @or-mwc-input-changed="${(e: OrInputChangedEvent) => this._setConnectionProperty("disabled", !e.detail.value)}"
- ></or-mwc-input>
+ @change="${(e: Event) => this._setConnectionProperty("disabled", !(e.currentTarget as OrVaadinToggle).checked)}"
+ ></or-vaadin-toggle>
</div>
<or-vaadin-button
theme="primary"
diff --git a/ui/app/manager/src/pages/page-realms.ts b/ui/app/manager/src/pages/page-realms.ts
index 134a32057..7bd9bc70e 100644
--- a/ui/app/manager/src/pages/page-realms.ts
+++ b/ui/app/manager/src/pages/page-realms.ts
@@ -28,11 +28,12 @@ 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, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
import { type DialogAction, OrMwcDialog, showDialog } from "@openremote/or-mwc-components/or-mwc-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";
+import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";
const tableStyle = require("@material/data-table/dist/mdc.data-table.css");
@@ -367,30 +368,27 @@ export class PageRealms extends Page<AppStateKeyed> {
>
<or-translate slot="label" value="loginTheme"></or-translate>
</or-vaadin-text-field>
- <or-mwc-input
+ <or-vaadin-toggle
?readonly="${readonly}"
- label="${i18next.t("resetPasswordAllowed")}"
- .type="${InputType.SWITCH}"
- min="1"
- .value="${realm.resetPasswordAllowed}"
- @or-mwc-input-changed="${(e: OrInputChangedEvent) => (realm.resetPasswordAllowed = e.detail.value)}"
- ></or-mwc-input>
- <or-mwc-input
+ ?checked="${realm.resetPasswordAllowed}"
+ @change="${(e: Event) => (realm.resetPasswordAllowed = (e.currentTarget as OrVaadinToggle).checked)}"
+ >
+ <or-translate slot="label" value="resetPasswordAllowed"></or-translate>
+ </or-vaadin-toggle>
+ <or-vaadin-toggle
?readonly="${readonly}"
- label="${i18next.t("enabled")}"
- .type="${InputType.SWITCH}"
- min="1"
- .value="${realm.enabled}"
- @or-mwc-input-changed="${(e: OrInputChangedEvent) => (realm.enabled = e.detail.value)}"
- ></or-mwc-input>
- <or-mwc-input
+ ?checked="${realm.enabled}"
+ @change="${(e: Event) => (realm.enabled = (e.currentTarget as OrVaadinToggle).checked)}"
+ >
+ <or-translate slot="label" value="enabled"></or-translate>
+ </or-vaadin-toggle>
+ <or-vaadin-toggle
?readonly="${readonly}"
- label="${i18next.t("rememberMe")}"
- .type="${InputType.SWITCH}"
- min="1"
- .value="${realm.rememberMe}"
- @or-mwc-input-changed="${(e: OrInputChangedEvent) => (realm.rememberMe = e.detail.value)}"
- ></or-mwc-input>
+ ?checked="${realm.rememberMe}"
+ @change="${(e: Event) => (realm.rememberMe = (e.currentTarget as OrVaadinToggle).checked)}"
+ >
+ <or-translate slot="label" value="rememberMe"></or-translate>
+ </or-vaadin-toggle>
</div>
<div class="column">
<or-vaadin-text-field
diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.json
index 4a891f5c7..09785ae28 100644
--- a/ui/app/shared/locales/en/or.json
+++ b/ui/app/shared/locales/en/or.json
@@ -992,6 +992,7 @@
"mapSettings": "Map settings",
"maxZoom": "Maximal zoom",
"minZoom": "Minimal zoom",
+ "boxZoom": "Box zoom",
"geoJson": "GeoJSON",
"geoJsonDescription": "Customize the GeoJSON; add points, lines and polygons to be drawn on the map.",
"deleteMapCustomization": "Delete map settings",
diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.json
index f2730d322..7178987ac 100644
--- a/ui/app/shared/locales/nl/or.json
+++ b/ui/app/shared/locales/nl/or.json
@@ -982,6 +982,7 @@
"mapSettings": "Kaartinstelling",
"maxZoom": "Maximale zoom",
"minZoom": "Minimale zoom",
+ "boxZoom": "Zoomen met selectiekader",
"geoJson": "GeoJSON",
"geoJsonDescription": "Bewerk de GeoJSON; voeg punten, lijnen, en andere vormen toe aan de kaart.",
"deleteMapCustomization": "Kaartinstelling verwijderen",
diff --git a/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts b/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts
index fb3e80b87..126a31228 100644
--- a/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts
+++ b/ui/component/or-dashboard-builder/src/panels/assettypes-panel.ts
@@ -21,7 +21,7 @@ import { OrElement } from "@openremote/or-element";
import { customElement, property, state } from "lit/decorators.js";
import { type AssetDescriptor, AssetModelUtil, type AssetTypeInfo } from "@openremote/model";
import { i18next } from "@openremote/or-translate";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";
import { Util } from "@openremote/core";
import { when } from "lit/directives/when.js";
import { createRef, type Ref, ref } from "lit/directives/ref.js";
@@ -193,13 +193,11 @@ export class AssettypesPanel extends OrElement {
return html`
<div style="display: flex; justify-content: space-between; align-items: center;">
<span><or-translate value="allAssetsofType"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="width: 70px;"
- .value="${this.allOfType}"
- .disabled="${!this.assetType}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onAssetAllOfTypeToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.allOfType}"
+ ?disabled="${!this.assetType}"
+ @change="${(ev: Event) => this.onAssetAllOfTypeToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
`;
})}
@@ -304,8 +302,8 @@ export class AssettypesPanel extends OrElement {
}
}
- protected onAssetAllOfTypeToggle(ev: OrInputChangedEvent) {
- this.allOfType = ev.detail.value;
+ protected onAssetAllOfTypeToggle(ev: Event) {
+ this.allOfType = (ev.currentTarget as OrVaadinToggle).checked;
}
protected _openAssetSelector(assetType: string, assetIds?: string[], multi = false) {
diff --git a/ui/component/or-dashboard-builder/src/settings/attribute-input-settings.ts b/ui/component/or-dashboard-builder/src/settings/attribute-input-settings.ts
index d12190ad5..3f2eee883 100644
--- a/ui/component/or-dashboard-builder/src/settings/attribute-input-settings.ts
+++ b/ui/component/or-dashboard-builder/src/settings/attribute-input-settings.ts
@@ -20,7 +20,7 @@ import { css, html, type TemplateResult } from "lit";
import { customElement } from "lit/decorators.js";
import type { AttributeInputWidgetConfig } from "../widgets/attribute-input-widget";
import type { AttributesSelectEvent } from "../panels/attributes-panel";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";
import { AssetWidgetSettings } from "../util/or-asset-widget";
const styling = css`
@@ -53,26 +53,22 @@ export class AttributeInputSettings extends AssetWidgetSettings {
<!-- Other settings -->
<settings-panel displayName="settings" expanded="${true}">
- <div>
+ <div style="display: flex; flex-direction: column; gap: 16px;">
<!-- Toggle readonly -->
<div class="switch-container">
<span><or-translate value="dashboard.userCanEdit"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${!this.widgetConfig.readonly}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onReadonlyToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${!this.widgetConfig.readonly}"
+ @change="${(ev: Event) => this.onReadonlyToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<!-- Toggle helper text -->
<div class="switch-container">
<span><or-translate value="dashboard.showHelperText"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.showHelperText}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onHelperTextToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showHelperText}"
+ @change="${(ev: Event) => this.onHelperTextToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
</settings-panel>
@@ -91,13 +87,13 @@ export class AttributeInputSettings extends AssetWidgetSettings {
this.notifyConfigUpdate();
}
- protected onReadonlyToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.readonly = !ev.detail.value;
+ protected onReadonlyToggle(ev: Event) {
+ this.widgetConfig.readonly = !(ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onHelperTextToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showHelperText = ev.detail.value;
+ protected onHelperTextToggle(ev: Event) {
+ this.widgetConfig.showHelperText = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
}
diff --git a/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts b/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts
index bceb851d0..b63e15a5d 100644
--- a/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts
+++ b/ui/component/or-dashboard-builder/src/settings/barchart-settings.ts
@@ -30,7 +30,7 @@ import type {
} from "../panels/attributes-panel";
import type { Asset, AssetDescriptor, Attribute, AttributeRef } from "@openremote/model";
import type { BarChartWidgetConfig } from "../widgets/barchart-widget";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+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";
@@ -246,32 +246,26 @@ export class BarChartSettings extends WidgetSettings {
<!-- Stacked -->
<div class="switch-container">
<span><or-translate value="dashboard.toggleStackView"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.stacked}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onDefaultStackedToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.stacked}"
+ @change="${(ev: Event) => this.onDefaultStackedToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<!-- Time range selection -->
<div class="switch-container">
<span><or-translate value="dashboard.allowTimerangeSelect"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${!this.widgetConfig.showTimestampControls}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onTimestampControlsToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${!this.widgetConfig.showTimestampControls}"
+ @change="${(ev: Event) => this.onTimestampControlsToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<!-- Show legend -->
<div class="switch-container">
<span><or-translate value="dashboard.showLegend"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.showLegend}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onShowLegendToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showLegend}"
+ @change="${(ev: Event) => this.onShowLegendToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<!-- Decimal places -->
<div>
@@ -299,7 +293,7 @@ export class BarChartSettings extends WidgetSettings {
</div>
`
)}
- <div style="display: flex; align-items: baseline;">
+ <div style="display: flex; align-items: baseline; gap: var(--lumo-space-s);">
${when(
max !== undefined,
() => html`
@@ -320,14 +314,12 @@ export class BarChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
)}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${max !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("left", "max", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${max !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("left", "max", ev)}"
+ ></or-vaadin-toggle>
</div>
- <div style="display: flex; align-items: baseline; margin-top: 12px;">
+ <div style="display: flex; align-items: baseline; margin-top: 12px; gap: var(--lumo-space-s);">
${when(
min !== undefined,
() => html`
@@ -348,12 +340,10 @@ export class BarChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
)}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${min !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("left", "min", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${min !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("left", "min", ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
@@ -387,12 +377,10 @@ export class BarChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
)}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${rightMax !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("right", "max", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${rightMax !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("right", "max", ev)}"
+ ></or-vaadin-toggle>
</div>
<div style="display: flex; margin-top: 12px; align-items: baseline;">
${when(
@@ -415,12 +403,10 @@ export class BarChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
)}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${rightMin !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("right", "min", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${rightMin !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("right", "min", ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
`;
@@ -732,18 +718,18 @@ export class BarChartSettings extends WidgetSettings {
this.notifyConfigUpdate();
}
- protected onTimestampControlsToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showTimestampControls = !ev.detail.value;
+ protected onTimestampControlsToggle(ev: Event) {
+ this.widgetConfig.showTimestampControls = !(ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onShowLegendToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showLegend = ev.detail.value;
+ protected onShowLegendToggle(ev: Event) {
+ this.widgetConfig.showLegend = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onDefaultStackedToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.stacked = ev.detail.value;
+ protected onDefaultStackedToggle(ev: Event) {
+ this.widgetConfig.stacked = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
@@ -763,8 +749,12 @@ export class BarChartSettings extends WidgetSettings {
}
}
- protected onMinMaxValueToggle(axis: "left" | "right", type: "min" | "max", ev: OrInputChangedEvent) {
- this.setAxisMinMaxValue(axis, type, ev.detail.value ? (type === "min" ? 0 : 100) : undefined);
+ protected onMinMaxValueToggle(axis: "left" | "right", type: "min" | "max", ev: Event) {
+ this.setAxisMinMaxValue(
+ axis,
+ type,
+ (ev.currentTarget as OrVaadinToggle).checked ? (type === "min" ? 0 : 100) : undefined
+ );
}
protected onDecimalsChange(ev: Event) {
diff --git a/ui/component/or-dashboard-builder/src/settings/chart-settings.ts b/ui/component/or-dashboard-builder/src/settings/chart-settings.ts
index 83235a450..a65ed7999 100644
--- a/ui/component/or-dashboard-builder/src/settings/chart-settings.ts
+++ b/ui/component/or-dashboard-builder/src/settings/chart-settings.ts
@@ -39,7 +39,7 @@ import {
type AttributeRef,
} from "@openremote/model";
import type { ChartWidgetConfig } from "../widgets/chart-widget";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+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 ChartAttributeConfig, OrChart } from "@openremote/or-chart";
@@ -265,40 +265,32 @@ export class ChartSettings extends WidgetSettings {
<div style="padding-bottom: 12px; display: flex; flex-direction: column; gap: 6px;">
<div class="switch-container">
<span><or-translate value="dashboard.toggleStackView"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.stacked}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onStackViewToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.stacked}"
+ @change="${(ev: Event) => this.onStackViewToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<div class="switch-container">
<span><or-translate value="dashboard.allowTimerangeSelect"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${!this.widgetConfig.showTimestampControls}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onTimestampControlsToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${!this.widgetConfig.showTimestampControls}"
+ @change="${(ev: Event) => this.onTimestampControlsToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<div class="switch-container">
<span><or-translate value="dashboard.showLegend"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.showLegend}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onShowLegendToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showLegend}"
+ @change="${(ev: Event) => this.onShowLegendToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<!-- Datazoombar -->
<div class="switch-container">
<span><or-translate value="dashboard.showZoomBar"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.showZoomBar}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onShowZoomBarToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showZoomBar}"
+ @change="${(ev: Event) => this.onShowZoomBarToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
</settings-panel>
@@ -316,7 +308,7 @@ export class ChartSettings extends WidgetSettings {
</div>
`
)}
- <div style="display: flex; align-items: baseline;">
+ <div style="display: flex; align-items: baseline; gap: var(--lumo-space-s);">
${
max !== undefined
? html`
@@ -337,14 +329,12 @@ export class ChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${max !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("left", "max", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${max !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("left", "max", ev)}"
+ ></or-vaadin-toggle>
</div>
- <div style="display: flex; margin-top: 12px;">
+ <div style="display: flex; margin-top: 12px; align-items: baseline; gap: var(--lumo-space-s);">
${
min !== undefined
? html`
@@ -365,12 +355,10 @@ export class ChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${min !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("left", "min", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${min !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("left", "min", ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
@@ -404,12 +392,10 @@ export class ChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${rightMax !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("right", "max", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${rightMax !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("right", "max", ev)}"
+ ></or-vaadin-toggle>
</div>
<div style="display: flex; margin-top: 12px; align-items: baseline;">
${
@@ -432,12 +418,10 @@ export class ChartSettings extends WidgetSettings {
</or-vaadin-text-field>
`
}
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px 0 0;"
- .value="${rightMin !== undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onMinMaxValueToggle("right", "min", ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${rightMin !== undefined}"
+ @change="${(ev: Event) => this.onMinMaxValueToggle("right", "min", ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
`;
@@ -740,23 +724,23 @@ export class ChartSettings extends WidgetSettings {
this.notifyConfigUpdate();
}
- protected onStackViewToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.stacked = ev.detail.value;
+ protected onStackViewToggle(ev: Event) {
+ this.widgetConfig.stacked = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onTimestampControlsToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showTimestampControls = !ev.detail.value;
+ protected onTimestampControlsToggle(ev: Event) {
+ this.widgetConfig.showTimestampControls = !(ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onShowLegendToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showLegend = ev.detail.value;
+ protected onShowLegendToggle(ev: Event) {
+ this.widgetConfig.showLegend = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onShowZoomBarToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showZoomBar = ev.detail.value;
+ protected onShowZoomBarToggle(ev: Event) {
+ this.widgetConfig.showZoomBar = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
@@ -784,8 +768,12 @@ export class ChartSettings extends WidgetSettings {
}
}
- protected onMinMaxValueToggle(axis: "left" | "right", type: "min" | "max", ev: OrInputChangedEvent) {
- this.setAxisMinMaxValue(axis, type, ev.detail.value ? (type === "min" ? 0 : 100) : undefined);
+ protected onMinMaxValueToggle(axis: "left" | "right", type: "min" | "max", ev: Event) {
+ this.setAxisMinMaxValue(
+ axis,
+ type,
+ (ev.currentTarget as OrVaadinToggle).checked ? (type === "min" ? 0 : 100) : undefined
+ );
}
protected onSamplingQueryChange(ev: Event) {
diff --git a/ui/component/or-dashboard-builder/src/settings/kpi-settings.ts b/ui/component/or-dashboard-builder/src/settings/kpi-settings.ts
index 8e8138f17..c89c139b3 100644
--- a/ui/component/or-dashboard-builder/src/settings/kpi-settings.ts
+++ b/ui/component/or-dashboard-builder/src/settings/kpi-settings.ts
@@ -23,7 +23,7 @@ import { i18next } from "@openremote/or-translate";
import type { KpiWidgetConfig } from "../widgets/kpi-widget";
import type { AttributesSelectEvent } from "../panels/attributes-panel";
import type { Attribute } from "@openremote/model";
-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 { OrVaadinSelect } from "@openremote/or-vaadin-components/or-vaadin-select";
import type { OrVaadinNumberField } from "@openremote/or-vaadin-components/or-vaadin-number-field";
@@ -84,12 +84,10 @@ export class KpiSettings extends AssetWidgetSettings {
</or-vaadin-select>
<div class="switchMwcInputContainer">
<span><or-translate value="dashboard.allowTimerangeSelect"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="margin: 0 -10px;"
- .value="${this.widgetConfig.showTimestampControls}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onTimeframeToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showTimestampControls}"
+ @change="${(ev: Event) => this.onTimeframeToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
</settings-panel>
@@ -135,8 +133,8 @@ export class KpiSettings extends AssetWidgetSettings {
this.notifyConfigUpdate();
}
- protected onTimeframeToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showTimestampControls = ev.detail.value;
+ protected onTimeframeToggle(ev: Event) {
+ this.widgetConfig.showTimestampControls = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
diff --git a/ui/component/or-dashboard-builder/src/settings/map-settings.ts b/ui/component/or-dashboard-builder/src/settings/map-settings.ts
index 93cdfa743..8e59f3d3c 100644
--- a/ui/component/or-dashboard-builder/src/settings/map-settings.ts
+++ b/ui/component/or-dashboard-builder/src/settings/map-settings.ts
@@ -19,7 +19,7 @@
import { css, html, type TemplateResult } from "lit";
import { customElement } from "lit/decorators.js";
import { AssetWidgetSettings } from "../util/or-asset-widget";
-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 { MapWidgetConfig } from "../widgets/map-widget";
import { type LngLatLike, type MapMarkerColours, LngLat } from "@openremote/or-map";
import "../panels/assettypes-panel";
@@ -99,12 +99,10 @@ export class MapSettings extends AssetWidgetSettings {
</or-vaadin-text-field>
<div style="display: flex; justify-content: space-between; align-items: center;">
<span><or-translate value="dashboard.showGeoJson"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="width: 70px;"
- .value="${this.widgetConfig.showGeoJson}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onGeoJsonToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showGeoJson}"
+ @change="${(ev: Event) => this.onGeoJsonToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
</settings-panel>
@@ -124,26 +122,22 @@ export class MapSettings extends AssetWidgetSettings {
></assettypes-panel>
<!-- Other settings like labels and units-->
- <div>
+ <div style="display: flex; flex-direction: column; gap: 8px; margin-top: 12px;">
<div class="switchMwcInputContainer">
<span><or-translate value="dashboard.showLabels"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="width: 70px;"
- .value="${this.widgetConfig.showLabels}"
- .disabled="${!this.widgetConfig.assetType}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onShowLabelsToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showLabels}"
+ ?disabled="${!this.widgetConfig.assetType}"
+ @change="${(ev: Event) => this.onShowLabelsToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
<div class="switchMwcInputContainer">
<span><or-translate value="dashboard.showUnits"></or-translate></span>
- <or-mwc-input
- .type="${InputType.SWITCH}"
- style="width: 70px;"
- .value="${this.widgetConfig.showUnits}"
- .disabled="${!this.widgetConfig.showLabels || !this.widgetConfig.assetType}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => this.onShowUnitsToggle(ev)}"
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${this.widgetConfig.showUnits}"
+ ?disabled="${!this.widgetConfig.showLabels || !this.widgetConfig.assetType}"
+ @change="${(ev: Event) => this.onShowUnitsToggle(ev)}"
+ ></or-vaadin-toggle>
</div>
</div>
</settings-panel>
@@ -199,8 +193,8 @@ export class MapSettings extends AssetWidgetSettings {
}
}
- protected onGeoJsonToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showGeoJson = ev.detail.value;
+ protected onGeoJsonToggle(ev: Event) {
+ this.widgetConfig.showGeoJson = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
@@ -274,13 +268,13 @@ export class MapSettings extends AssetWidgetSettings {
}
}
- protected onShowLabelsToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showLabels = ev.detail.value;
+ protected onShowLabelsToggle(ev: Event) {
+ this.widgetConfig.showLabels = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
- protected onShowUnitsToggle(ev: OrInputChangedEvent) {
- this.widgetConfig.showUnits = ev.detail.value;
+ protected onShowUnitsToggle(ev: Event) {
+ this.widgetConfig.showUnits = (ev.currentTarget as OrVaadinToggle).checked;
this.notifyConfigUpdate();
}
diff --git a/ui/component/or-rules/src/json-viewer/forms/or-rule-form-push-notification.ts b/ui/component/or-rules/src/json-viewer/forms/or-rule-form-push-notification.ts
index a44d92ffb..4a757311c 100644
--- a/ui/component/or-rules/src/json-viewer/forms/or-rule-form-push-notification.ts
+++ b/ui/component/or-rules/src/json-viewer/forms/or-rule-form-push-notification.ts
@@ -19,9 +19,8 @@
import { html, css, type TemplateResult } from "lit";
import { OrElement } from "@openremote/or-element";
import { customElement, property, query } from "lit/decorators.js";
-import "@openremote/or-mwc-components/or-mwc-input";
import { i18next, translate } from "@openremote/or-translate";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import "@openremote/or-vaadin-components/or-vaadin-toggle";
import type { PushNotificationMessage, PushNotificationButton } from "@openremote/model";
import { OrRulesJsonRuleChangedEvent } from "../or-rule-json-viewer";
import { until } from "lit/directives/until.js";
@@ -117,14 +116,12 @@ export class OrRuleFormPushNotification extends translate(i18next)(OrElement) {
</or-vaadin-text-field>
<!-- Open in browser switch -->
- <or-mwc-input
- .value="${message.action?.openInBrowser}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => onchange(ev, message).then((msg) => this._onOpenInBrowserChange(ev, msg))}"
- .label="${i18next.t("openInBrowser")}"
- type="${InputType.SWITCH}"
- fullWidth
- placeholder=" "
- ></or-mwc-input>
+ <or-vaadin-toggle
+ ?checked="${message.action?.openInBrowser}"
+ @change="${(ev: Event) => onchange(ev, message).then((msg) => this._onOpenInBrowserChange(ev, msg))}"
+ >
+ <or-translate slot="label" value="openInBrowser"></or-translate>
+ </or-vaadin-toggle>
<!-- Button controls -->
<div style="display: flex; gap: 20px;">
@@ -183,9 +180,10 @@ export class OrRuleFormPushNotification extends translate(i18next)(OrElement) {
/**
* HTML callback function when the "open in browser switch" of a notification has changed.
*/
- protected _onOpenInBrowserChange(ev: OrInputChangedEvent, message: PushNotificationMessage) {
+ protected _onOpenInBrowserChange(ev: Event, message: PushNotificationMessage) {
message.action = message.action || {};
- message.action.openInBrowser = ev.detail.value;
+ // Read from ev.target (the native input) because this runs after an async gap, where ev.currentTarget is already null.
+ message.action.openInBrowser = (ev.target as HTMLInputElement).checked;
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
}
diff --git a/ui/component/or-rules/src/json-viewer/forms/or-rule-form-webhook.ts b/ui/component/or-rules/src/json-viewer/forms/or-rule-form-webhook.ts
index 202fcf62d..4622f5004 100644
--- a/ui/component/or-rules/src/json-viewer/forms/or-rule-form-webhook.ts
+++ b/ui/component/or-rules/src/json-viewer/forms/or-rule-form-webhook.ts
@@ -23,7 +23,7 @@ import {
type Webhook,
type OAuthPasswordGrant,
} from "@openremote/model";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";
import { i18next } from "@openremote/or-translate";
import { css, html, type TemplateResult } from "lit";
import { OrElement } from "@openremote/or-element";
@@ -159,13 +159,10 @@ export class OrRuleFormWebhook extends OrElement {
<div
style="display: flex; flex-direction: column; gap: 10px; margin-bottom: ${this.webhook.oAuthGrant || this.webhook.usernamePassword ? "28px" : "0"};"
>
- <or-mwc-input
- type="${InputType.SWITCH}"
- fullwidth
- label="${i18next.t("requiresAuthorization")}"
- .value="${this.webhook.oAuthGrant || this.webhook.usernamePassword}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => {
- this.webhook.usernamePassword = ev.detail.value
+ <or-vaadin-toggle
+ ?checked="${this.webhook.oAuthGrant || this.webhook.usernamePassword}"
+ @change="${(ev: Event) => {
+ this.webhook.usernamePassword = (ev.currentTarget as OrVaadinToggle).checked
? {
username: "admin",
password: "secret",
@@ -173,7 +170,9 @@ export class OrRuleFormWebhook extends OrElement {
: undefined;
this.notifyWebhookUpdate();
}}"
- ></or-mwc-input>
+ >
+ <or-translate slot="label" value="requiresAuthorization"></or-translate>
+ </or-vaadin-toggle>
${when(this.webhook.oAuthGrant || this.webhook.usernamePassword, () => {
const values: SelectItem[] = Array.from(this.authMethodOptions.entries()).map(([value, label]) => ({
value,
@@ -199,13 +198,10 @@ export class OrRuleFormWebhook extends OrElement {
${when(
this.webhook.httpMethod != HTTPMethod.GET && this.webhook.httpMethod != HTTPMethod.DELETE,
() => html`
- <or-mwc-input
- type="${InputType.SWITCH}"
- fullwidth
- label="${i18next.t("includeBodyInRequest")}"
- .value="${this.webhook.payload != undefined}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => {
- this.webhook.payload = ev.detail.value
+ <or-vaadin-toggle
+ ?checked="${this.webhook.payload != undefined}"
+ @change="${(ev: Event) => {
+ this.webhook.payload = (ev.currentTarget as OrVaadinToggle).checked
? JSON.stringify(
{
rule: "%RULESET_NAME%",
@@ -217,7 +213,9 @@ export class OrRuleFormWebhook extends OrElement {
: undefined;
this.notifyWebhookUpdate();
}}"
- ></or-mwc-input>
+ >
+ <or-translate slot="label" value="includeBodyInRequest"></or-translate>
+ </or-vaadin-toggle>
${when(this.webhook.payload != undefined, () => {
return html`
<or-vaadin-text-area
diff --git a/ui/component/or-rules/src/or-rule-tree.ts b/ui/component/or-rules/src/or-rule-tree.ts
index 177833c95..0dd0230a7 100644
--- a/ui/component/or-rules/src/or-rule-tree.ts
+++ b/ui/component/or-rules/src/or-rule-tree.ts
@@ -27,7 +27,7 @@ import {
import { css, html, type PropertyValues, type TemplateResult } from "lit";
import manager, { Util } from "@openremote/core";
import { i18next } from "@openremote/or-translate";
-import { InputType, type OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
+import type { OrVaadinToggle } from "@openremote/or-vaadin-components/or-vaadin-toggle";
import {
OrRules,
OrRulesAddEvent,
@@ -64,6 +64,11 @@ const styling = css`
color: var(--or-app-color7, white);
--or-icon-fill: var(--or-app-color7, white);
}
+
+ /* The default off track is a translucent dark, which disappears on this dark header */
+ #rules-tree-global-header or-vaadin-toggle {
+ --or-toggle-track-off-color: color-mix(in srgb, var(--or-app-color7, white) 40%, transparent);
+ }
`;
export interface RuleTreeNode extends TreeNode {
@@ -209,7 +214,7 @@ export class OrRuleTree extends OrTreeMenu {
() => html`
<div id="rules-tree-global-header">
<or-translate value="realmRules"></or-translate>
- <or-mwc-input type=${InputType.SWITCH} @or-mwc-input-changed=${this._onGlobalSwitch}></or-mwc-input>
+ <or-vaadin-toggle @change=${this._onGlobalSwitch}></or-vaadin-toggle>
<or-translate value="globalRules"></or-translate>
</div>
`
@@ -253,8 +258,8 @@ export class OrRuleTree extends OrTreeMenu {
* HTML callback on when the global switch is toggled.
* It normally toggles between 'global' and 'realm' rulesets when the user is a superuser.
*/
- protected _onGlobalSwitch(ev: OrInputChangedEvent) {
- this.global = ev.detail.value;
+ protected _onGlobalSwitch(ev: Event) {
+ this.global = (ev.currentTarget as OrVaadinToggle).checked;
this.refresh();
}