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
Fix default text color example not being shown (#2452)
Koen9a4078d1c28a
diff --git a/ui/app/manager/test/fixtures/data/assets.ts b/ui/app/manager/test/fixtures/data/assets.tsindex 47d23dfe3..014d69036 100644--- a/ui/app/manager/test/fixtures/data/assets.ts+++ b/ui/app/manager/test/fixtures/data/assets.ts@@ -1,5 +1,5 @@import * as Util from "@openremote/core/lib/util";-import { Asset, AssetInfo, AssetTypeInfo } from "@openremote/model";+import { Asset, AssetTypeInfo } from "@openremote/model";export const notes = { name: "notes", type: "text" };export const location = { name: "location", type: "GEO_JSONPoint" };@@ -82,19 +82,20 @@ export const preparedAssetsForInsights: Asset[] = [realm: "smartcity",attributes: {...commonAttrs,- energyLevel: {name: "energyLevel", type: "number", meta: {storeDataPoints: true}},- power: {name: "power", type: "number", meta: {storeDataPoints: true}}- }- }, {+ energyLevel: { name: "energyLevel", type: "number", meta: { storeDataPoints: true } },+ power: { name: "power", type: "number", meta: { storeDataPoints: true } },+ },+ },+ {name: "Energy Asset 2",type: "ThingAsset",realm: "smartcity",attributes: {...commonAttrs,- energyLevel: {name: "energyLevel", type: "number", meta: {storeDataPoints: true}},- power: {name: "power", type: "number", meta: {storeDataPoints: true}}- }- }+ energyLevel: { name: "energyLevel", type: "number", meta: { storeDataPoints: true } },+ power: { name: "power", type: "number", meta: { storeDataPoints: true } },+ },+ },];type AssetNames = (typeof assets)[number]["name"];@@ -165,21 +166,19 @@ const rotterdam: BBox = {};/**- * Assigns a random location within the specified bounding box+ * Assigns location at the specified coordinates** @param asset The asset to assign the location attribute- * @param boundingBox The bounding box to add assets within- * @default {@link rotterdam}+ * @param coordinates The `[lng, lat]` coordinate pair to use for the asset location+ * @default `[4.483890476199264, 51.91547581791727]` (Jufferkade)*/-export function assignLocation(asset: Asset, { south, north, east, west }: BBox = rotterdam): Asset {- const y = randomBetween(south, north);- const x = randomBetween(east, west);-- Object.assign(asset?.attributes ?? {}, {+export function assignLocation(asset: Asset, coordinates = [4.483890476199264, 51.91547581791727]): Asset {+ asset.attributes ??= {};+ Object.assign(asset.attributes, {location: {name: "location",type: "GEO_JSONPoint",- value: { type: "Point", coordinates: [x, y] },+ value: { type: "Point", coordinates },meta: {},},});@@ -187,6 +186,20 @@ export function assignLocation(asset: Asset, { south, north, east, west }: BBoxreturn asset;}+/**+ * Assigns a random location within the specified bounding box+ *+ * @param asset The asset to assign the location attribute+ * @param boundingBox The bounding box to add assets within+ * @default {@link rotterdam}+ */+export function assignRandomLocationInArea(asset: Asset, { south, north, east, west }: BBox = rotterdam): Asset {+ const y = randomBetween(south, north);+ const x = randomBetween(east, west);+ assignLocation(asset, [x, y]);+ return asset;+}+export function getAssetAt(assetInfos: AssetTypeInfo[], index = 0): Asset {const validAssetInfos = assetInfos.filter(({ assetDescriptor }) => assetDescriptor?.name && assetDescriptor.descriptorType === "asset"@@ -202,10 +215,17 @@ export function getAssetAt(assetInfos: AssetTypeInfo[], index = 0): Asset {return { type, name: type, attributes };}-export function getAssetsForAllTypes(assetInfos: AssetTypeInfo[], options?: { realm?: string, limit?: number, bbox?: BBox }): Asset[] {- return Array.from({ length: options?.limit ?? assetInfos.length }).map((_, i) => {- return { ...assignLocation(getAssetAt(assetInfos, i), options?.bbox), name: String(i), realm: options?.realm ?? "smartcity" };- });+export function getAssetsForAllTypes(+ assetInfos: AssetTypeInfo[],+ options?: { realm?: string; limit?: number; bbox?: BBox }+): Asset[] {+ return Array.from({ length: options?.limit ?? assetInfos.length }).map((_, i) => {+ return {+ ...assignRandomLocationInArea(getAssetAt(assetInfos, i), options?.bbox),+ name: String(i),+ realm: options?.realm ?? "smartcity",+ };+ });}export function getAssetTypes(assets: Asset[]) {@@ -216,8 +236,10 @@ export function getAssetTypeColour(type: string, infos: AssetTypeInfo[]) {return infos.find(({ assetDescriptor }) => assetDescriptor?.name === type)?.assetDescriptor?.colour ?? "";}+export const getRGBColor = (el: Element): string[] => window.getComputedStyle(el).color.match(/\d+/g)!;+export function rgbToHex(rgb: string[]) {- return rgb.map((i) => ("0" + parseInt(i).toString(16)).slice(-2)).join("");+ return rgb?.map((i) => ("0" + parseInt(i).toString(16)).slice(-2)).join("");}function randomBetween(max: number, min: number) {diff --git a/ui/app/manager/test/fixtures/manager.ts b/ui/app/manager/test/fixtures/manager.tsindex a79603de4..d045ddee9 100644--- a/ui/app/manager/test/fixtures/manager.ts+++ b/ui/app/manager/test/fixtures/manager.ts@@ -14,12 +14,12 @@ import {type SharedComponentTestFixtures,type Shared,type TestFixture,- withPage+ withPage,} from "@openremote/test";-import {AssetsPage, InsightsPage, RealmsPage, RolesPage, RulesPage, UsersPage} from "./pages";+import { AssetsPage, InsightsPage, RealmsPage, RolesPage, RulesPage, UsersPage } from "./pages";import { AssetViewer } from "../../../../component/or-asset-viewer/test/fixtures";import { CollapsiblePanel } from "../../../../component/or-components/test/fixtures";-import { MwcInput } from "../../../../component/or-mwc-components/test/fixtures";+import { MwcInput, MwcMenu } from "../../../../component/or-mwc-components/test/fixtures";import { JsonForms } from "../../../../component/or-json-forms/test/fixtures";import { AssetTree } from "../../../../component/or-asset-tree/test/fixtures";import { type AxiosRequestConfig } from "axios";@@ -489,6 +489,7 @@ interface ComponentFixtures extends SharedComponentTestFixtures {collapsiblePanel: CollapsiblePanel;jsonForms: JsonForms;mwcInput: MwcInput;+ mwcMenu: MwcMenu;}interface Fixtures extends PageFixtures, ComponentFixtures {@@ -510,4 +511,5 @@ export const test = base.extend<Fixtures>({collapsiblePanel: withPage(CollapsiblePanel),jsonForms: withPage(JsonForms),mwcInput: withPage(MwcInput),+ mwcMenu: withPage(MwcMenu),});diff --git a/ui/app/manager/test/fixtures/pages/insights.ts b/ui/app/manager/test/fixtures/pages/insights.tsindex b2411ef6e..0d74d9d93 100644--- a/ui/app/manager/test/fixtures/pages/insights.ts+++ b/ui/app/manager/test/fixtures/pages/insights.ts@@ -1,5 +1,5 @@-import {BasePage, expect, Page, Shared} from "@openremote/test";-import {Manager} from "../manager";+import { BasePage, expect, Locator, Page, Shared } from "@openremote/test";+import { Manager } from "../manager";export class InsightsPage implements BasePage {constructor(private readonly page: Page, private readonly shared: Shared, private readonly manager: Manager) {}@@ -40,36 +40,82 @@ export class InsightsPage implements BasePage {return this.getDashboardGrid().locator("or-dashboard-widget-container", options);}- async dragAndDropWidget(type: string, location: [number, number] = [0,0], size: [number, number] = [2, 2]) {+ getGridCellDimensions(): Promise<[number, number]> {+ return this.getDashboardGrid().evaluate((el: any) => [el.gridstack.cellWidth(), el.gridstack.getCellHeight()]);+ }++ /**+ * Gets the x and y coordinates for the specified widget+ * @requires the locator to reference a `or-dashboard-widget-container` to be able to get the Gridstack node+ * @param widget The `or-dashboard-widget-container` locator+ * @returns The x and y grid cell coordinates+ */+ getWidgetLocation(widget: Locator): Promise<[number, number]> {+ return widget.locator("..").locator("..").evaluate((el: any) => [el.gridstackNode.x, el.gridstackNode.y]);+ }++ /**+ * Drag an drop a widget on to the insights page grid+ * @param type The widget type to drag and drop+ * @param location The location on the grid where to drop the widget+ * @param cells The area in cells that this widget covers+ */+ async dragAndDropWidget(type: string, [gridX, gridY] = [0, 0], [cellsWidth, cellsHeight] = [2, 2]) {await expect(this.getBuilder()).toBeVisible();await expect(this.getPreview()).toBeVisible();await expect(this.getPreview()).toHaveJSProperty("isLoading", false);await expect(this.getDashboardGrid()).toBeVisible();// Verify the slot is empty- const isEmpty = await this.getDashboardGrid().evaluate((el: any, args) =>- el.gridstack.isAreaEmpty(args.loc[0], args.loc[1], args.size[0], args.size[1]),- { loc: location, size: size }+ const isEmpty = await this.getDashboardGrid().evaluate(+ (el: any, { x, y, width, height }) => el.gridstack.isAreaEmpty(x, y, width, height),+ { x: gridX, y: gridY, width: cellsWidth, height: cellsHeight });expect(isEmpty).toBeTruthy();// Grab the X/Y browser coordinates- const coordinates = await this.getDashboardGrid().evaluate((el: any, args) =>- ([args.loc[0] * args.size[0] * el.gridstack.cellWidth(), args.loc[1] * args.size[1] * el.gridstack.getCellHeight()]),- { loc: location, size: size }- );- expect(coordinates).toBeDefined();+ const [cellWidth, cellHeight] = await this.getGridCellDimensions();+ const [x, y] = [cellWidth * gridX, cellHeight * gridY];// Manual drag and dropconst count = await this.getWidgets().count();- await this.page.locator("#sidebar .grid-stack-item", {hasText: type}).first().hover();- await this.page.mouse.down();- await this.page.mouse.move(-200, 0, { steps: 5 }); // Move tiny bit left, so the hover event is triggered- await this.page.locator(".maingrid").hover({ position: { x: coordinates[0], y: coordinates[1] }});- await this.page.mouse.up();+ await this.page.dragAndDrop(`#sidebar .grid-stack-item :has-text("${type}")`, ".maingrid", {+ sourcePosition: { x: 10, y: 10 }, // To drop the widget at the intended cell, we grab it close to its top left corner+ targetPosition: { x, y },+ steps: 50,+ });await expect(this.getWidgets()).toHaveCount(count + 1);}+ /**+ * Resize a widget from its bottom right corner to the specified grid cell coordinates+ * @param widget The locator of the widget+ * @param to The grid cell coordinates to resize the widget to+ */+ async resizeWidgetTo(widget: Locator, [cellsWidth, cellsHeight] = [8, 8]) {+ const [gridX, gridY] = await this.getWidgetLocation(widget);+ const [cellWidth, cellHeight] = await this.getGridCellDimensions();+ const [width, height] = [cellsWidth * cellWidth, cellsHeight * cellHeight];++ await this.page.dragAndDrop(`.ui-resizable-handle.ui-resizable-se`, ".maingrid", {+ // We apply -cellWidth/Height / 2 as the handle causes the source position to be offset+ targetPosition: {+ x: gridX * cellWidth + width - cellWidth / 2,+ y: gridY * cellHeight + height - cellHeight / 2,+ },+ steps: 10,+ });++ const bbox = await widget.boundingBox();+ // The dashboard dimensions should be equal to the specified cells,+ // or between the specified cells and the specified cells - 1 cell,+ // due to margins.+ expect(bbox?.width).toBeGreaterThan(width - cellWidth);+ expect(bbox?.width).toBeLessThanOrEqual(width);+ expect(bbox?.height).toBeGreaterThan(cellHeight - cellHeight);+ expect(bbox?.height).toBeLessThanOrEqual(height);+ }+async addAttributes(assetName: string, attributeNames: string[]) {await this.getWidgetSettings().getByRole("button", { name: "Attribute" }).click();const dialog = this.page.locator("#dialog");diff --git a/ui/app/manager/test/insights.test.ts b/ui/app/manager/test/insights.test.tsindex e79350a95..ad2ff532c 100644--- a/ui/app/manager/test/insights.test.ts+++ b/ui/app/manager/test/insights.test.ts@@ -1,17 +1,22 @@-import {test, userStatePath} from "./fixtures/manager";-import {Dashboard} from "@openremote/model";-import {preparedAssetsForInsights as assets} from "./fixtures/data/assets.js";+import { test, userStatePath } from "./fixtures/manager";+import { Dashboard } from "@openremote/model";+import {+ preparedAssetsForInsights as assets,+ assignLocation,+ commonAttrs,+ getRGBColor,+ rgbToHex,+} from "./fixtures/data/assets.js";import { expect } from "@openremote/test";-test.use({storageState: userStatePath});--test("Create a Line Chart widget", async ({manager, shared, page, insightsPage}) => {+test.use({ storageState: userStatePath });+test("Create a Line Chart widget", async ({ manager, shared, page, insightsPage }) => {await shared.interceptResponse<Dashboard>("**/dashboard", (dashboard) => {if (dashboard) manager.dashboards.push(dashboard.id!);});- await manager.setup("smartcity", {assets});+ await manager.setup("smartcity", { assets });await manager.goToRealmStartPage("smartcity");await manager.navigateToTab("Insights");@@ -20,34 +25,18 @@ test("Create a Line Chart widget", async ({manager, shared, page, insightsPage})await page.click(".mdi-plus >> nth=0");await expect(insightsPage.getDashboardListItems()).toHaveCount(1);await expect(insightsPage.getWidgets()).toHaveCount(0);- await insightsPage.dragAndDropWidget("Line Chart");+ await insightsPage.dragAndDropWidget("Line Chart", [1, 1]);await expect(insightsPage.getWidgets()).toHaveCount(1);- // Make widget larger by resizing it using the handle+ // Select widget and make widget larger by resizing it using the handleconst chartWidget = insightsPage.getWidgets({ hasText: "Line Chart" }).first();- await expect(chartWidget).toBeVisible();- await chartWidget.hover();- const handle = page.locator(".ui-resizable-handle.ui-resizable-se").first();- await expect(handle).toBeVisible();- await handle.hover();-- const box = await chartWidget.boundingBox();- const startX = box!.x + box!.width - 4;- const startY = box!.y + box!.height - 4;- await page.mouse.down();- await page.mouse.move(startX + (box!.width * 2), startY + (box!.height * 2), { steps: 50 });- await page.mouse.up();- await page.waitForTimeout(100);- await expect(chartWidget).not.toContainClass("ui-resizable-resizing");- await expect.poll(async () => (await chartWidget.boundingBox())!.width).toBeGreaterThan(box!.width * 3);- await expect.poll(async () => (await chartWidget.boundingBox())!.height).toBeGreaterThan(box!.height * 3);+ await chartWidget.click();+ await expect(insightsPage.getBrowser()).toBeHidden();+ await insightsPage.resizeWidgetTo(chartWidget);await expect(insightsPage.getWidgets()).toHaveCount(1);- // Select widget, and add attribute of Asset #2 and Asset #1+ // Add attribute of Asset #2 and Asset #1const attrName = "Energy level";- await expect(chartWidget).toBeVisible();- await chartWidget.click();- await expect(insightsPage.getBrowser()).toBeHidden();await expect(insightsPage.getWidgetSettings({ hasText: "Line Chart" })).toBeVisible();await insightsPage.addAttributes(assets[1].name!, [attrName]);await expect(insightsPage.getWidgetAttributes().getByText(assets[1].name!).first()).toBeVisible();@@ -76,6 +65,94 @@ test("Create a Line Chart widget", async ({manager, shared, page, insightsPage})await expect(insightsPage.getWidgetAttributes().last()).toContainText("Power");});-test.afterEach(async ({manager}) => {+test("Create a Map widget with text thresholds", async ({ manager, shared, page, insightsPage, mwcMenu, mwcInput }) => {+ await shared.interceptResponse<Dashboard>("**/dashboard", (dashboard) => {+ if (dashboard) manager.dashboards.push(dashboard.id!);+ });++ await page.addInitScript(manager.hijackWebSocket());++ await manager.setup("smartcity", {+ assets: [+ assignLocation({+ name: "Thing",+ type: "ThingAsset",+ realm: "smartcity",+ attributes: { ...commonAttrs },+ }),+ ],+ });+ await manager.goToRealmStartPage("smartcity");+ await manager.navigateToTab("Insights");++ // Drag and drop Map widget+ await expect(insightsPage.getDashboardListItems()).toHaveCount(0);+ await page.click(".mdi-plus >> nth=0");+ await expect(insightsPage.getDashboardListItems()).toHaveCount(1);+ await expect(insightsPage.getWidgets()).toHaveCount(0);+ await insightsPage.dragAndDropWidget("Map");+ await expect(insightsPage.getWidgets()).toHaveCount(1);++ // Select widget and make widget larger by resizing it using the handle+ const mapWidget = insightsPage.getWidgets({ hasText: "Map" }).first();+ await insightsPage.resizeWidgetTo(mapWidget);+ await expect(insightsPage.getWidgets()).toHaveCount(1);+ await expect(page.locator(".or-map-marker")).not.toBeVisible();++ // Select the widget and add "notes" as attribute+ const thresholdPanel = insightsPage.getWidgetSettings().locator("thresholds-panel");+ await mapWidget.click();+ await expect(insightsPage.getBrowser()).toBeHidden();+ await expect(insightsPage.getWidgetSettings({ hasText: "Map" })).toBeVisible();+ await page.getByRole("textbox", { name: "Asset type" }).click();+ await mwcMenu.getMenuItem("Thing asset").click();+ await expect(thresholdPanel).toBeHidden();+ await insightsPage.getWidgetSettings().getByRole("button", { name: "Attribute" }).click();+ await mwcInput.getSelectInputOption("Notes", insightsPage.getWidgetSettings()).click();+ await expect(page.locator(".or-map-marker")).toBeVisible();+ await expect(thresholdPanel).toBeVisible();++ // Check default text configuration is correct+ const textThresholds = mwcInput.getInputByType("text", thresholdPanel);+ const thresholdsColors = mwcInput.getInputByType("color", thresholdPanel);+ await expect(textThresholds).toHaveCount(2);+ await expect(textThresholds.first()).toHaveValue("example1");+ await expect(textThresholds.last()).toHaveValue("example2");+ await expect(thresholdsColors).toHaveCount(2);+ await expect(thresholdsColors.first()).toHaveValue("#4caf50");+ await expect(thresholdsColors.last()).toHaveValue("#ff9800");+ await expect+ .poll(() => page.locator('or-icon[icon="or:marker"]').evaluate(getRGBColor).then(rgbToHex))+ .toBe("4c4c4c");++ // Update attribute to match the first threshold+ await manager.sendWebSocketEvent({+ eventType: "attribute",+ ref: { id: manager.assets[0].id, name: "notes" },+ value: "example1",+ });+ await page.getByTitle("Refresh", { exact: true }).click();+ await expect(page.locator(".or-map-marker")).toBeVisible();+ await expect+ .poll(() => page.locator('or-icon[icon="or:marker"]').evaluate(getRGBColor).then(rgbToHex))+ .toBe("4caf50");++ await mapWidget.click();+ await thresholdsColors.last().fill("#000000");++ // Update attribute to match the second threshold+ await manager.sendWebSocketEvent({+ eventType: "attribute",+ ref: { id: manager.assets[0].id, name: "notes" },+ value: "example2",+ });+ await page.getByTitle("Refresh", { exact: true }).click();+ await expect(page.locator(".or-map-marker")).toBeVisible();+ await expect+ .poll(() => page.locator('or-icon[icon="or:marker"]').evaluate(getRGBColor).then(rgbToHex))+ .toBe("000000");+});++test.afterEach(async ({ manager }) => {await manager.cleanUp();});diff --git a/ui/app/manager/test/map.test.ts b/ui/app/manager/test/map.test.tsindex be592f14d..1697882a2 100644--- a/ui/app/manager/test/map.test.ts+++ b/ui/app/manager/test/map.test.ts@@ -1,6 +1,16 @@import { expect } from "@openremote/test";import { adminStatePath, test, userStatePath } from "./fixtures/manager.js";-import { preparedAssetsWithLocation as assets, assignLocation, commonAttrs, getAssetTypeColour, getAssetTypes, getAssetAt, rgbToHex, getAssetsForAllTypes } from "./fixtures/data/assets.js";+import {+ preparedAssetsWithLocation as assets,+ assignRandomLocationInArea,+ commonAttrs,+ getAssetTypeColour,+ getAssetTypes,+ getAssetAt,+ rgbToHex,+ getAssetsForAllTypes,+ getRGBColor,+} from "./fixtures/data/assets.js";import { markers } from "./fixtures/data/manager.js";import type { OrMap, OrClusterMarker } from "@openremote/or-map";import { type Asset, WellknownMetaItems } from "@openremote/model";@@ -122,7 +132,6 @@ test.describe("Map markers", () => {})test.describe("Marker config", () => {- const getRGBColor = (el: Element): string[] => window.getComputedStyle(el).color.match(/\d+/g)!;/*** @given Asset with location is set up in the "smartcity" realm@@ -145,12 +154,12 @@ test.describe("Marker config", () => {await page.addInitScript(manager.hijackWebSocket());- const assets = [assignLocation({+ const assets = [assignRandomLocationInArea({name: "Light",type: "ThingAsset",realm: "smartcity",attributes: { ...commonAttrs, onOff: { name: "onOff", type: "boolean" } }- }, { west: 4.4857, south: 51.9162, east: 4.4865, north: 51.9167 })]+ }, { west: 4.4857, south: 51.9162, east: 4.4865, north: 51.9167 })];await manager.setup("smartcity", { assets });await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, markers: { ThingAsset: markers[0] } } } });await manager.goToRealmStartPage("smartcity");@@ -197,7 +206,7 @@ test.describe("Marker config", () => {await page.addInitScript(manager.hijackWebSocket());- const assets = [assignLocation({+ const assets = [assignRandomLocationInArea({name: "Thermometer",type: "ThingAsset",realm: "smartcity",@@ -261,7 +270,7 @@ test.describe("Marker clustering", () => {const assetInfos = (await manager.api.AssetModelResource.getAssetInfos()).data;const assets = getAssetsForAllTypes(assetInfos, { bbox });const outlierbbox = { west: 4.483812, south: 51.916359, east: 4.484017, north: 51.916495 };- assets.push({ ...assignLocation(getAssetAt(assetInfos), outlierbbox), name: "outlier", realm: "smartcity" })+ assets.push({ ...assignRandomLocationInArea(getAssetAt(assetInfos), outlierbbox), name: "outlier", realm: "smartcity" });await manager.setup("smartcity", { assets });await manager.goToRealmStartPage("smartcity");@@ -413,7 +422,7 @@ test.describe("Asset type legend", () => {test("should not not be shown with 1 asset type", async ({ page, manager, browserName }) => {test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");- const assets = [assignLocation({+ const assets = [assignRandomLocationInArea({name: "Thing",type: "ThingAsset",realm: "smartcity",diff --git a/ui/component/or-dashboard-builder/src/panels/thresholds-panel.ts b/ui/component/or-dashboard-builder/src/panels/thresholds-panel.tsindex a346c493b..cc7d252dd 100644--- a/ui/component/or-dashboard-builder/src/panels/thresholds-panel.ts+++ b/ui/component/or-dashboard-builder/src/panels/thresholds-panel.ts@@ -221,22 +221,14 @@ export class ThresholdsPanel extends LitElement {this.textColors[index][0] = event.detail.value;this.requestUpdate('textColors');}}"-></or-mwc-input>- ${index === 0 ? html`- <button class="button-clear"- style="margin-left: 8px;">- <or-icon icon="lock" style="--or-icon-fill: var(--or-app-color5, ${unsafeCSS(DefaultColor5)});"></or-icon>- </button>- ` : html`- <button class="button-clear"- style="margin-left: 8px;"- @click="${() => {- this.removeThreshold(threshold);- }}">- <or-icon icon="close-circle"></or-icon>- </button>- `}+ <button class="button-clear"+ style="margin-left: 8px;"+ @click="${() => {+ this.removeThreshold(threshold);+ }}">+ <or-icon icon="close-circle"></or-icon>+ </button></div>`})}diff --git a/ui/component/or-dashboard-builder/src/settings/map-settings.ts b/ui/component/or-dashboard-builder/src/settings/map-settings.tsindex 807d5fd91..cde1d1c0e 100644--- a/ui/component/or-dashboard-builder/src/settings/map-settings.ts+++ b/ui/component/or-dashboard-builder/src/settings/map-settings.ts@@ -4,14 +4,14 @@ import {AssetWidgetSettings} from "../util/or-asset-widget";import {i18next} from "@openremote/or-translate";import {InputType, OrInputChangedEvent} from "@openremote/or-mwc-components/or-mwc-input";import {MapWidgetConfig} from "../widgets/map-widget";-import {AttributeMarkerColours, LngLatLike, MapMarkerColours, LngLat} from "@openremote/or-map";+import {LngLatLike, MapMarkerColours, LngLat} from "@openremote/or-map";import "../panels/assettypes-panel";import "../panels/thresholds-panel";import {when} from "lit/directives/when.js";import {AssetIdsSelectEvent, AssetTypeSelectEvent, AssetAllOfTypeSwitchEvent, AssetTypesFilterConfig, AttributeNamesSelectEvent} from "../panels/assettypes-panel";import manager from "@openremote/core";import {showSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";-import {BoolColorsChangeEvent, ThresholdChangeEvent} from "../panels/thresholds-panel";+import {BoolColorsChangeEvent, TextColorsChangeEvent, ThresholdChangeEvent} from "../panels/thresholds-panel";const styling = css`.switchMwcInputContainer {@@ -24,6 +24,19 @@ const styling = css`@customElement("map-settings")export class MapSettings extends AssetWidgetSettings {+ protected static _allowedValueTypes = ["boolean", "number", "integer", "positiveInteger", "positiveNumber", "negativeInteger", "negativeNumber", "text"];+ protected static _config: AssetTypesFilterConfig = {+ assets: {+ enabled: true,+ multi: true,+ allOfTypeOption: true+ },+ attributes: {+ enabled: true,+ valueTypes: MapSettings._allowedValueTypes+ }+ };+protected widgetConfig!: MapWidgetConfig;static get styles() {@@ -31,21 +44,8 @@ export class MapSettings extends AssetWidgetSettings {}protected render(): TemplateResult {- const allowedValueTypes = ["boolean", "number", "integer", "positiveInteger", "positiveNumber", "negativeInteger", "negativeNumber", "text"];- const config = {- assets: {- enabled: true,- multi: true,- allOfTypeOption: true- },- attributes: {- enabled: true,- valueTypes: allowedValueTypes- }- } as AssetTypesFilterConfig;return html`<div>-<!-- Map settings --><settings-panel displayName="configuration.mapSettings" expanded="${true}"><div style="display: flex; flex-direction: column; gap: 8px;">@@ -74,7 +74,7 @@ export class MapSettings extends AssetWidgetSettings {<!-- Panel where Asset type and the selected attribute can be customized --><settings-panel displayName="attributes" expanded="${true}">- <assettypes-panel .assetType="${this.widgetConfig.assetType}" .attributeNames="${this.widgetConfig.attributeName}" .config="${config}"+ <assettypes-panel .assetType="${this.widgetConfig.assetType}" .attributeNames="${this.widgetConfig.attributeName}" .config="${MapSettings._config}".allOfType="${this.widgetConfig.allOfType}" .assetIds="${this.widgetConfig.assetIds}"@assettype-select="${(ev: AssetTypeSelectEvent) => this.onAssetTypeSelect(ev)}"@alloftype-switch="${(ev: AssetAllOfTypeSwitchEvent) => this.onAssetAllOfTypeSwitch(ev)}"@@ -102,14 +102,16 @@ export class MapSettings extends AssetWidgetSettings {</settings-panel><!-- List of customizable thresholds -->- ${when(this.widgetConfig.assetIds.length > 0 || this.widgetConfig.allOfType, () => html`+ ${when(this.widgetConfig.attributeName, () => html`<settings-panel displayName="thresholds" expanded="${true}">- <thresholds-panel .thresholds="${this.widgetConfig.thresholds}"- .boolColors="${this.widgetConfig.boolColors}"- .valueType="${this.widgetConfig.valueType}" style="padding-bottom: 12px;"+ <thresholds-panel .thresholds="${this.widgetConfig.thresholds}"+ .boolColors="${this.widgetConfig.boolColors}"+ .textColors="${this.widgetConfig.textColors}"+ .valueType="${this.widgetConfig.valueType}" style="padding-bottom: 12px;".min="${this.widgetConfig.min}" .max="${this.widgetConfig.max}"@threshold-change="${(ev: ThresholdChangeEvent) => this.onThresholdsChange(ev)}"- @bool-colors-change="${(ev: BoolColorsChangeEvent) => this.onBoolColorsChange(ev)}">+ @bool-colors-change="${(ev: BoolColorsChangeEvent) => this.onBoolColorsChange(ev)}"+ @text-colors-change="${(ev: TextColorsChangeEvent) => this.onTextColorsChange(ev)}"></thresholds-panel></settings-panel>`)}@@ -148,7 +150,7 @@ export class MapSettings extends AssetWidgetSettings {this.widgetConfig.showLabels = false;this.widgetConfig.showUnits = false;this.widgetConfig.boolColors = {type: 'boolean', 'false': '#ef5350', 'true': '#4caf50'};- this.widgetConfig.textColors = [['example', "#4caf50"], ['example2', "#ff9800"]];+ this.widgetConfig.textColors = [['example1', "#4caf50"], ['example2', "#ff9800"]];this.widgetConfig.thresholds = [[0, "#4caf50"], [75, "#ff9800"], [90, "#ef5350"]];this.widgetConfig.assetType = ev.detail;this.notifyConfigUpdate();@@ -222,4 +224,8 @@ export class MapSettings extends AssetWidgetSettings {this.notifyConfigUpdate();}+ protected onTextColorsChange(ev: TextColorsChangeEvent) {+ this.widgetConfig.textColors = ev.detail;+ this.notifyConfigUpdate();+ }}diff --git a/ui/component/or-dashboard-builder/src/widgets/map-widget.ts b/ui/component/or-dashboard-builder/src/widgets/map-widget.tsindex 032efa675..8548034a6 100644--- a/ui/component/or-dashboard-builder/src/widgets/map-widget.ts+++ b/ui/component/or-dashboard-builder/src/widgets/map-widget.ts@@ -45,7 +45,7 @@ function getDefaultWidgetConfig(): MapWidgetConfig {showUnits: false,showGeoJson: true,boolColors: {type: 'boolean', 'false': '#ef5350', 'true': '#4caf50'},- textColors: [['example', '4caf50'], ['example2', 'ef5350']],+ textColors: [['example1', '#4caf50'], ['example2', '#ef5350']],thresholds: [[0, "#4caf50"], [75, "#ff9800"], [90, "#ef5350"]],assetTypes: [],assetType: undefined,diff --git a/ui/component/or-mwc-components/test/fixtures/index.ts b/ui/component/or-mwc-components/test/fixtures/index.tsindex 18687a655..40b8f635a 100644--- a/ui/component/or-mwc-components/test/fixtures/index.ts+++ b/ui/component/or-mwc-components/test/fixtures/index.ts@@ -4,6 +4,16 @@ import type { Page, Locator } from "@openremote/test";export class MwcInput {constructor(private readonly page: Page) {}+ /**+ * Get the underlying native input element of the or-mwc-input element+ * @param type The {@link InputType} to look for+ * @param locator The locator to start from+ * @returns The locator to the underlying <input> element inside the or-mwc-input+ */+ getInputByType(type: `${InputType}`, locator?: Locator) {+ return (locator ?? this.page).locator(`or-mwc-input[type=${type}] #component > input`);+ }+/*** Returns the locator for the specified {@link InputType.SELECT|select input} option*/@@ -12,6 +22,17 @@ export class MwcInput {}}+export class MwcMenu {+ constructor(private readonly page: Page) {}++ /**+ * Returns the locator for the specified menu item+ */+ getMenuItem(option: string, locator?: Locator): Locator {+ return (locator ?? this.page).locator("or-mwc-menu li[role=menuitem]", { hasText: option });+ }+}+export class MwcDialog {constructor(private readonly page: Page) {}