Skip to content

armgit / core

Public Imported from GitHub
0

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

Feature: Add map preset filter (#2802)

Koenbe39bc82ae5c
diff --git a/setup/src/clustering/java/org/openremote/setup/clustering/ManagerSetup.java b/setup/src/clustering/java/org/openremote/setup/clustering/ManagerSetup.java
index 97b1fc107..32ae453dd 100644
--- a/setup/src/clustering/java/org/openremote/setup/clustering/ManagerSetup.java
+++ b/setup/src/clustering/java/org/openremote/setup/clustering/ManagerSetup.java
@@ -29,10 +29,15 @@ import org.openremote.model.geo.GeoJSONPoint;
import org.reflections.Reflections;
import java.lang.reflect.Modifier;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -46,6 +51,7 @@ public class ManagerSetup extends org.openremote.manager.setup.ManagerSetup {
public static final String OR_SETUP_ASSETS = "OR_SETUP_ASSETS";
private static final Logger LOG = SyslogCategory.getLogger(DATA, org.openremote.manager.setup.ManagerSetup.class);
+ private static final Duration SETUP_MAX_WAIT_DURATION = Duration.ofMinutes(1);
protected Container container;
protected Executor executor;
@@ -68,9 +74,9 @@ public class ManagerSetup extends org.openremote.manager.setup.ManagerSetup {
public void onStart() throws Exception {
super.onStart();
- String defaultTypes = "ThingAsset,LightAsset,RoomAsset,ThermostatAsset";
+ String defaultTypes = "ThingAsset,LightAsset,RoomAsset,ThermostatAsset,BuildingAsset";
String types = getString(container.getConfig(), OR_SETUP_ASSET_TYPES, defaultTypes);
- int assetsPerType = getInteger(container.getConfig(), OR_SETUP_ASSETS, 10000);
+ int assetsPerType = getInteger(container.getConfig(), OR_SETUP_ASSETS, 20000);
Reflections reflections = new Reflections("org.openremote.model.asset.impl");
Set<Class<? extends Asset>> allAvailableClasses = reflections.getSubTypesOf(Asset.class);
@@ -79,30 +85,52 @@ public class ManagerSetup extends org.openremote.manager.setup.ManagerSetup {
.filter(clazz -> !Modifier.isAbstract(clazz.getModifiers()))
.collect(Collectors.toMap(Class::getSimpleName, clazz -> clazz));
- String[] typesToLoad = types.split(",");
-
- for (String typeName : typesToLoad) {
+ List<Class<? extends Asset>> validClasses = new ArrayList<>();
+ for (String typeName : types.split(",")) {
String cleanName = typeName.trim();
Class<? extends Asset> clazz = assetRegistry.get(cleanName);
-
if (clazz == null) {
LOG.severe("Skipping unknown asset type: " + cleanName);
continue;
}
-
// Skip asset types which either can't directly be initialized or are slow to init
if (clazz.equals(UnknownAsset.class) || clazz.equals(GroupAsset.class) || clazz.equals(GatewayAsset.class)) continue;
+ validClasses.add(clazz);
+ }
+
+ int expectedAssetCount = assetsPerType * validClasses.size();
+ AtomicInteger assets = new AtomicInteger(0);
- IntStream.rangeClosed(1, assetsPerType).forEach(i -> {
+ for (Class<? extends Asset> clazz : validClasses) {
+ IntStream.range(0, assetsPerType).forEach(i -> {
executor.execute(() -> {
try {
createAsset(clazz, i);
} catch (Exception e) {
throw new RuntimeException(e);
}
+ assets.incrementAndGet();
});
});
}
+
+ // Wait until all assets are created
+ Instant start = Instant.now();
+ LOG.info(String.format("Waiting for %s assets to be created", expectedAssetCount));
+ while (assets.get() < expectedAssetCount) {
+ LOG.info(String.format("%s/%s devices created", assets.get(), expectedAssetCount));
+ if (Instant.now().isAfter(start.plus(SETUP_MAX_WAIT_DURATION))) {
+ throw new IllegalStateException("Failed to provision all requested devices after " + SETUP_MAX_WAIT_DURATION);
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt(); // restore interrupt flag
+ LOG.info("Setup interrupted while waiting for devices to be created");
+ break;
+ }
+ }
+ LOG.info(String.format("Finished creating %s devices", expectedAssetCount));
}
private void createAsset(Class<? extends Asset> clazz, int i) throws Exception {
diff --git a/ui/app/manager/src/pages/page-map.ts b/ui/app/manager/src/pages/page-map.ts
index 4bce78438..61018c215 100644
--- a/ui/app/manager/src/pages/page-map.ts
+++ b/ui/app/manager/src/pages/page-map.ts
@@ -1,4 +1,4 @@
-import {css, html, PropertyValues} from "lit";
+import {css, html} from "lit";
import {customElement, property, query, state} from "lit/decorators.js";
import {createSlice, Store, PayloadAction} from "@reduxjs/toolkit";
import "@openremote/or-map";
@@ -12,10 +12,8 @@ import {
OrMapGeocoderChangeEvent,
MapMarkerAssetConfig,
OrMapMarkersChangedEvent,
- OrMapLegendEvent,
- OrMapLoadedEvent
} from "@openremote/or-map";
-import manager, {Util} from "@openremote/core";
+import manager, { Util } from "@openremote/core";
import {createSelector} from "reselect";
import {
Asset,
@@ -25,12 +23,12 @@ import {
AttributeEvent,
GeoJSONPoint,
WellknownAttributes,
- WellknownMetaItems
+ WellknownMetaItems,
} from "@openremote/model";
import {getAssetsRoute, getMapRoute} from "../routes";
import {AppStateKeyed, Page, PageProvider, router} from "@openremote/or-app";
import {GenericAxiosResponse} from "@openremote/rest";
-import { ClusterConfig, Util as MapUtil, AssetWithLocation } from "@openremote/or-map";
+import { ClusterConfig, MapFilter, Util as MapUtil, AssetWithLocation } from "@openremote/or-map";
export interface MapState {
locatedAssets: AssetWithLocation[];
@@ -131,7 +129,8 @@ export interface PageMapConfig {
clustering?: ClusterConfig,
card?: MapAssetCardConfig,
assetQuery?: AssetQuery,
- markers?: MapMarkerAssetConfig
+ markers?: MapMarkerAssetConfig,
+ filters?: MapFilter[]
}
export function pageMapProvider(store: Store<MapStateKeyed>, config?: PageMapConfig): PageProvider<MapStateKeyed> {
@@ -169,15 +168,6 @@ export class PageMap extends Page<MapStateKeyed> {
z-index: 3;
}
- or-map-legend {
- position: absolute;
- top: 60px;
- left: 10px;
- width: 254px;
- margin: 10px 0;
- z-index: 1;
- }
-
or-map {
flex: 1 1 auto;
}
@@ -185,24 +175,14 @@ export class PageMap extends Page<MapStateKeyed> {
@media only screen and (min-width: 40em){
or-map-asset-card {
position: absolute;
- top: 10px;
- right: 50px;
+ top: var(--card-top, 56px);
+ left: 10px;
width: 320px;
margin: 0;
height: 400px; /* fallback for IE */
height: max-content;
max-height: calc(100vh - 150px);
- }
-
- or-map-legend {
- position: absolute;
- top: 60px;
- left: 10px;
- width: calc(100%);
- max-width: 254px;
- margin: 0;
- height: max-content;
- max-height: calc(100vh - 150px);
+ z-index: 2;
}
}
`;
@@ -220,12 +200,6 @@ export class PageMap extends Page<MapStateKeyed> {
@state()
protected _currentAsset?: Asset;
- @state()
- protected _assetTypes: string[] = [];
-
- @state()
- protected _excludedTypes: string[] = [];
-
@state()
protected _assetsOnScreen: AssetWithLocation[] = [];
@@ -234,6 +208,11 @@ export class PageMap extends Page<MapStateKeyed> {
protected _paramsSelector = (state: MapStateKeyed) => state.app.params;
protected _realmSelector = (state: MapStateKeyed) => state.app.realm || manager.displayRealm;
+ protected _activeFiltersSelector = createSelector(
+ [this._realmSelector],
+ (realm) => this.config?.filters?.filter(f => !f.realms?.length || f.realms.includes(realm))
+ );
+
protected _assetSubscriptionId: string;
protected _attributeSubscriptionId: string;
@@ -247,8 +226,12 @@ export class PageMap extends Page<MapStateKeyed> {
.map(assetTypeMarkerConfig => assetTypeMarkerConfig.attributeName);
}
+ const filterAttributes = (this.config?.filters ?? [])
+ .flatMap(f => new Util.AssetQueryHelper(f.query).collectAttributeNames());
+
return [
...markerLabelAttributes,
+ ...filterAttributes,
WellknownAttributes.LOCATION,
WellknownAttributes.DIRECTION
];
@@ -314,7 +297,7 @@ export class PageMap extends Page<MapStateKeyed> {
switch (event.cause) {
case "DELETE": this._map?.removeAssets([event.asset.id]); break;
case "CREATE":
- if (MapUtil.isAssetWithLocation(event.asset) && !this._excludedTypes.includes(event.asset?.type)) {
+ if (MapUtil.isAssetWithLocation(event.asset)) {
this._map?.addAsset(event.asset);
}
break;
@@ -342,8 +325,11 @@ export class PageMap extends Page<MapStateKeyed> {
}
this._store.dispatch(attributeEventReceived([attrsOfInterest, event]));
// Add the asset after map state has been updated
- if (interested && asset && !this._excludedTypes.includes(asset.type)) {
- this._map?.addAsset(this._assets.find(asset => asset.id === event.ref.id));
+ if (interested && asset) {
+ const located = this._assets.find(a => a.id === event.ref.id);
+ if (located) {
+ this._map?.addAsset(located);
+ }
}
});
@@ -376,7 +362,6 @@ export class PageMap extends Page<MapStateKeyed> {
protected getRealmState = createSelector(
[this._realmSelector],
async (realm) => {
- this._excludedTypes = [];
this.unsubscribeAssets();
this.subscribeAssets(realm);
this._map?.refresh();
@@ -414,25 +399,15 @@ export class PageMap extends Page<MapStateKeyed> {
this.addEventListener(OrMapAssetCardLoadAssetEvent.NAME, this._onLoadAssetEvent);
}
- shouldUpdate(_changedProperties: PropertyValues): boolean {
- if (_changedProperties.has('_assets')) {
- const newTypes = [];
- for (const { type } of this._assets) {
- if (!newTypes.includes(type)) newTypes.push(type);
- }
- this._assetTypes = newTypes;
- }
- return super.shouldUpdate(_changedProperties);
- }
-
protected render() {
- const showLegend = this.config?.legend?.show !== false && this._assetTypes.length > 1;
+ const filters = this._activeFiltersSelector(this.getState());
+ this.style.setProperty("--card-top", filters?.length ? "56px" : "10px");
+
return html`
${this._currentAsset ? html `<or-map-asset-card .config="${this.config?.card}" .assetId="${this._currentAsset.id}" .markerconfig="${this.config?.markers}"></or-map-asset-card>` : ``}
- ${showLegend ? html`<or-map-legend .assetTypes="${this._assetTypes}" .excludedTypes="${this._excludedTypes}" @or-map-legend-changed="${this._onMapLegendChanged}"></or-map-legend>` : null}
-
- <or-map id="map" class="or-map" .cluster="${this.config.clustering}" showGeoCodingControl @or-map-geocoder-change="${(ev: OrMapGeocoderChangeEvent) => {this._setCenter(ev.detail.geocode);}}">
+ <or-map id="map" class="or-map" .cluster="${this.config.clustering}" .filters="${filters}" ?showLegend="${this.config?.legend?.show !== false}" showGeoCodingControl
+ @or-map-geocoder-change="${(ev: OrMapGeocoderChangeEvent) => {this._setCenter(ev.detail.geocode);}}">
${this._assetsOnScreen.sort((a,b) => {
const pointA = a.attributes[WellknownAttributes.LOCATION].value as GeoJSONPoint;
const pointB = b.attributes[WellknownAttributes.LOCATION].value as GeoJSONPoint;
@@ -451,7 +426,6 @@ export class PageMap extends Page<MapStateKeyed> {
this.addEventListener(OrMapMarkerClickedEvent.NAME, this._onMapMarkerClick);
this.addEventListener(OrMapClickedEvent.NAME, this._onMapClick);
this.addEventListener(OrMapMarkersChangedEvent.NAME, this._onMapMarkersChanged);
- this.addEventListener(OrMapLoadedEvent.NAME, this._onMapLoaded);
}
public disconnectedCallback() {
@@ -459,7 +433,6 @@ export class PageMap extends Page<MapStateKeyed> {
this.removeEventListener(OrMapMarkerClickedEvent.NAME, this._onMapMarkerClick);
this.removeEventListener(OrMapClickedEvent.NAME, this._onMapClick);
this.removeEventListener(OrMapMarkersChangedEvent.NAME, this._onMapMarkersChanged);
- this.removeEventListener(OrMapLoadedEvent.NAME, this._onMapLoaded);
this.unsubscribeAssets();
}
@@ -485,25 +458,4 @@ export class PageMap extends Page<MapStateKeyed> {
protected _onLoadAssetEvent(loadAssetEvent: OrMapAssetCardLoadAssetEvent) {
router.navigate(getAssetsRoute(false, loadAssetEvent.detail));
}
-
- protected _onMapLoaded(e: OrMapLoadedEvent) {
- this._map?.addAssets(this._assets);
- }
-
- protected _onMapLegendChanged(e: OrMapLegendEvent) {
- if (this._map) {
- this._excludedTypes = e.detail;
- const assetsToAdd = [];
- const idsToRemove = [];
- for (const asset of this._assets) {
- if (this._excludedTypes.includes(asset.type)) {
- idsToRemove.push(asset.id);
- } else {
- assetsToAdd.push(asset);
- }
- }
- this._map.removeAssets(idsToRemove);
- this._map.addAssets(assetsToAdd);
- }
- }
}
diff --git a/ui/app/manager/test/fixtures/manager.ts b/ui/app/manager/test/fixtures/manager.ts
index e9bfe7368..8105f4006 100644
--- a/ui/app/manager/test/fixtures/manager.ts
+++ b/ui/app/manager/test/fixtures/manager.ts
@@ -138,6 +138,15 @@ export class Manager {
await this.page.waitForURL("**/auth/realms/**");
}
+ async resetLocale(realm: string, username: Usernames, password: string) {
+ const token = await this.getAccessToken(realm, username, password);
+ await this.axios.put(
+ `${this.managerHost}/api/${realm}/user/locale`,
+ JSON.stringify("en"),
+ { headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" } }
+ );
+ }
+
async getAccessToken(realm: string, username: Usernames, password: string) {
const data = new URLSearchParams();
data.append("client_id", this.clientId);
diff --git a/ui/app/manager/test/map.test.ts b/ui/app/manager/test/map.test.ts
index 0b27c3056..436eab805 100644
--- a/ui/app/manager/test/map.test.ts
+++ b/ui/app/manager/test/map.test.ts
@@ -13,7 +13,7 @@ import {
getRGBColor,
} from "./fixtures/data/assets.js";
import { markers } from "./fixtures/data/manager.js";
-import type { OrMap, OrClusterMarker } from "@openremote/or-map";
+import type { OrMap, OrClusterMarker, MapFilter } from "@openremote/or-map";
import { type Asset, WellknownMetaItems } from "@openremote/model";
test.use({ storageState: userStatePath });
@@ -391,24 +391,21 @@ test.describe("Asset type legend", () => {
await expect(page.locator("or-map")).toBeVisible();
await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
- await page.locator('or-map-legend [icon="menu"]').click();
- await expect(page.locator("or-map-legend #legend-content")).toBeVisible();
+ await page.locator('or-map-legend #legend-title').click();
+ await expect(page.locator("or-map-legend #legend-list")).toBeVisible();
const assetTypes = getAssetTypes(assets);
+ const options = await page.locator("or-map-legend or-vaadin-item").all();
+ expect(options.length).toBe(assetTypes.length);
- const options = await page.locator("or-map-legend #legend-content").getByRole("listitem").all();
- for (const [i, option] of options.entries()) {
- await expect(option).toHaveAttribute("data-asset-type", assetTypes[i]);
- }
-
- let count = 0;
+ // Each type has exactly one asset (getAssetsForAllTypes with limit creates 1 per type)
+ let hidden = 0;
for (const option of options) {
- await expect(option.getByRole("checkbox")).toBeChecked()
- await expect(page.locator(".or-map-marker")).toHaveCount(assets.length - count);
-
- for (const asset of assets) { if (asset.type == (await option.getAttribute("data-asset-type"))) count++ }
+ await expect(option.getByRole("checkbox")).toBeChecked();
+ await expect(page.locator(".or-map-marker")).toHaveCount(assets.length - hidden);
await option.getByRole("checkbox").uncheck();
- await expect(page.locator(".or-map-marker")).toHaveCount(assets.length - count);
+ hidden++;
+ await expect(page.locator(".or-map-marker")).toHaveCount(assets.length - hidden);
}
});
@@ -439,6 +436,50 @@ test.describe("Asset type legend", () => {
await expect(page.locator("or-map-legend")).not.toBeVisible();
});
+ /**
+ * @given assets of two types are set up, with 2 of the first type and 1 of the second
+ * @when navigating to the map page and opening the legend
+ * @then each legend item's count badge shows the number of assets of that type
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should display correct count badge for each asset type", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const assetInfos = (await manager.api.AssetModelResource.getAssetInfos()).data;
+ // 2 of the first type, 1 of the second — gives varied badge values to test
+ const baseAssets = getAssetsForAllTypes(assetInfos, { limit: 2 });
+ const assets = [...baseAssets, { ...baseAssets[0], name: baseAssets[0].name + "_2" }];
+
+ const expectedCounts: Record<string, number> = {};
+ for (const a of assets) {
+ expectedCounts[a.type!] = (expectedCounts[a.type!] ?? 0) + 1;
+ }
+
+ await manager.setup("smartcity", { assets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false } } } });
+ await manager.goToRealmStartPage("smartcity");
+ await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
+
+ await page.locator('or-map-legend #legend-title').click();
+ await expect(page.locator("or-map-legend #legend-list")).toBeVisible();
+
+ // Read the sorted type order directly from the component to correlate items to counts
+ const sortedTypes: string[] = await page.locator("or-map-legend").evaluate((el: any) =>
+ [...el.assetTypes].sort((a: string, b: string) =>
+ (el._assetTypesInfo[a]?.label ?? a).localeCompare(el._assetTypesInfo[b]?.label ?? b)
+ )
+ );
+
+ const items = page.locator("or-map-legend or-vaadin-item");
+ expect(await items.count()).toBe(sortedTypes.length);
+
+ for (let i = 0; i < sortedTypes.length; i++) {
+ const expected = String(expectedCounts[sortedTypes[i]]);
+ await expect(items.nth(i).locator("or-vaadin-badge")).toHaveText(expected);
+ }
+ });
+
test.describe(() => {
test.use({ storageState: adminStatePath });
@@ -477,18 +518,15 @@ test.describe("Asset type legend", () => {
await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
await expect(page.locator(".or-map-marker")).toHaveCount(assets.length);
- await page.locator('or-map-legend [icon="menu"]').click();
- await expect(page.locator("or-map-legend #legend-content")).toBeVisible();
+ await page.locator('or-map-legend #legend-title').click();
+ await expect(page.locator("or-map-legend #legend-list")).toBeVisible();
const assetTypes = getAssetTypes(assets);
-
- const options = await page.locator("or-map-legend #legend-content").getByRole("listitem").all();
- for (const [i, option] of options.entries()) {
- await expect(option).toHaveAttribute("data-asset-type", assetTypes[i]);
- }
+ const options = await page.locator("or-map-legend or-vaadin-item").all();
+ expect(options.length).toBe(assetTypes.length);
for (const option of options) {
- await expect(option.getByRole("checkbox")).toBeChecked()
+ await expect(option.getByRole("checkbox")).toBeChecked();
await option.getByRole("checkbox").uncheck();
}
await expect(page.locator(".or-map-marker")).toHaveCount(0);
@@ -501,14 +539,553 @@ test.describe("Asset type legend", () => {
await manager.switchToRealmByRealmPicker("smartcity");
await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
await expect(page.locator(".or-map-marker")).toHaveCount(assets.length);
- await page.locator('or-map-legend [icon="menu"]').click();
- for (const option of options) {
- await expect(option.getByRole("checkbox")).toBeChecked()
+ // Re-query items — DOM was recreated after realm switch
+ await page.locator('or-map-legend #legend-title').click();
+ const optionsAfterSwitch = await page.locator("or-map-legend or-vaadin-item").all();
+ for (const option of optionsAfterSwitch) {
+ await expect(option.getByRole("checkbox")).toBeChecked();
}
});
});
});
+test.describe("Preset filters", () => {
+ const bbox = { west: 4.4859, south: 51.9163, east: 4.4864, north: 51.9166 };
+
+ // 3 ThingAssets (no notes value) + 2 ThingAssets (notes="error") = 5 total
+ const thingAssets = [0, 1, 2].map(i =>
+ assignRandomLocationInArea(
+ { name: `Thing ${i}`, type: "ThingAsset", realm: "smartcity", attributes: { ...commonAttrs } } as Asset,
+ bbox
+ )
+ );
+
+ const thingAssetsWithError = [0, 1].map(i =>
+ assignRandomLocationInArea(
+ {
+ name: `Thing Error ${i}`,
+ type: "ThingAsset",
+ realm: "smartcity",
+ attributes: { ...commonAttrs, notes: { name: "notes", type: "text", value: "error" } },
+ } as Asset,
+ bbox
+ )
+ );
+
+ const allAssets = [...thingAssets, ...thingAssetsWithError];
+
+ const filters: MapFilter[] = [
+ // Filter 1: match all ThingAssets
+ { query: { types: ["ThingAsset"] } },
+ // Filter 2: match only ThingAssets with notes="error"
+ {
+ query: {
+ types: ["ThingAsset"],
+ attributes: {
+ items: [
+ {
+ name: { predicateType: "string", value: "notes" },
+ value: { predicateType: "string", value: "error" },
+ },
+ ],
+ },
+ },
+ },
+ // Filter 3: match a type that has no assets — label masks the unresolvable asset type name
+ { label: "Water Meters", query: { types: ["WaterMeterAsset"] } },
+ ];
+
+ // Mirrors assetMatchesQuery client-side logic for deriving expected counts from test data
+ function assetMatchesFilter(asset: Asset, filter: MapFilter): boolean {
+ const query = filter.query;
+ if (query.types?.length && !query.types.includes(asset.type!)) return false;
+ const items = ((query.attributes as any)?.items ?? []) as any[];
+ return items.every((item: any) =>
+ asset.attributes?.[item.name?.value]?.value === item.value?.value
+ );
+ }
+
+ // Derive expected counts automatically from the test asset data
+ const filterCases = [
+ { filterIndex: 0, expectedCount: allAssets.length },
+ ...filters.map((f, i) => ({
+ filterIndex: i + 1,
+ expectedCount: allAssets.filter(a => assetMatchesFilter(a, f)).length,
+ })),
+ ];
+ // Resolves to: [{ 0, 5 }, { 1, 5 }, { 2, 2 }, { 3, 0 }]
+
+ /**
+ * @given no filters are configured on the map page
+ * @when navigating to the map page
+ * @then the preset filter component is not rendered
+ * @and the asset card CSS variable is set to top: 10px (no filter offset needed)
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should not render when no filters are configured", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false } } } });
+ await manager.goToRealmStartPage("smartcity");
+
+ await expect(page.locator("or-map-preset-filter")).not.toBeVisible();
+
+ const cardTopVar = await page.locator("page-map").evaluate(
+ (el: HTMLElement) => el.style.getPropertyValue("--card-top")
+ );
+ expect(cardTopVar).toBe("10px");
+ });
+
+ /**
+ * @given filters are configured on the map page
+ * @when navigating to the map page
+ * @then the preset filter component is rendered
+ * @and the asset card CSS variable is set to top: 56px to clear the filter dropdown
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should render and push asset card down when filters are configured", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters } } });
+ await manager.goToRealmStartPage("smartcity");
+
+ await expect(page.locator("or-map-preset-filter")).toBeVisible();
+
+ const cardTopVar = await page.locator("page-map").evaluate(
+ (el: HTMLElement) => el.style.getPropertyValue("--card-top")
+ );
+ expect(cardTopVar).toBe("56px");
+ });
+
+ /**
+ * Parameterised: for each filter option (including "All"), verify marker count and badge text.
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ for (const { filterIndex, expectedCount } of filterCases) {
+ const filterDesc = filterIndex === 0 ? `"All" default selection` : `filter option ${filterIndex}`;
+ const badgeText = String(expectedCount);
+
+ test(`should show ${expectedCount} markers for ${filterDesc}`, async ({ page, manager, browserName }) => {
+ /**
+ * @given assets are set up in the "smartcity" realm
+ * @and preset filters are configured on the map page
+ * @when navigating to the map page
+ * @and selecting filter option at index ${filterIndex}
+ * @then ${expectedCount} asset markers are visible
+ * @and the selected-state counter badge shows ${badgeText}
+ */
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters } } });
+ await manager.goToRealmStartPage("smartcity");
+ await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
+
+ if (filterIndex > 0) {
+ await page.locator("or-vaadin-select").click();
+ // Wait for any option to appear, then select by value intersected with role="option"
+ // to ensure we only click the visible overlay item, not Vaadin's hidden template copy
+ await page.getByRole("option").first().waitFor({ state: "visible" });
+ await page.getByRole("option").and(page.locator(`[value="${filterIndex}"]`)).click();
+ }
+
+ await expect(page.locator(".or-map-marker")).toHaveCount(expectedCount);
+ await expect(page.locator("or-map-preset-filter or-vaadin-select + or-vaadin-badge")).toHaveText(badgeText);
+ });
+ }
+
+ /**
+ * @given filters are configured, one of which has an explicit label and an unresolvable asset type
+ * @when opening the preset filter dropdown
+ * @then the labelled option displays the configured label instead of a derived type name
+ * @when selecting that option
+ * @then the select field shows the configured label as the selected value
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should use label property instead of derived type name", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters } } });
+ await manager.goToRealmStartPage("smartcity");
+
+ await page.locator("or-vaadin-select").click();
+ await page.getByRole("option").first().waitFor({ state: "visible" });
+
+ // "WaterMeterAsset" is not a registered type — without a label, getAssetTypeLabel returns "".
+ // The label: "Water Meters" on filter 3 should appear as the option text instead.
+ await expect(
+ page.getByRole("option").and(page.locator('[value="3"]')).locator(".filter-item__label")
+ ).toHaveText("Water Meters");
+
+ await page.getByRole("option").and(page.locator('[value="3"]')).click();
+ await expect(page.locator("or-vaadin-select")).toContainText("Water Meters");
+ });
+
+ /**
+ * @given assets are set up in the "smartcity" realm
+ * @and preset filters are configured
+ * @when opening the preset filter dropdown
+ * @then each option's count badge matches the number of assets that satisfy that filter
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should display correct count badges for each option in the dropdown", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters } } });
+ await manager.goToRealmStartPage("smartcity");
+ await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
+
+ await page.locator("or-vaadin-select").click();
+ const overlayOptions = page.getByRole("option");
+ await overlayOptions.first().waitFor({ state: "visible" });
+
+ for (const { filterIndex, expectedCount } of filterCases) {
+ const badgeText = String(expectedCount);
+ // Select by value attribute (sort may reorder options relative to filterIndex)
+ await expect(page.getByRole("option").and(page.locator(`[value="${filterIndex}"]`)).locator("or-vaadin-badge")).toHaveText(badgeText);
+ }
+ });
+
+ /**
+ * @given a filter is configured with default: true
+ * @when navigating to the map page for the first time (no stored selection)
+ * @then that filter is pre-selected without any user interaction
+ * @and the marker count reflects the default filter
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should pre-select the filter marked as default", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const filtersWithDefault: MapFilter[] = [
+ { query: { types: ["ThingAsset"] } },
+ {
+ label: "Errors",
+ default: true,
+ query: {
+ types: ["ThingAsset"],
+ attributes: {
+ items: [{
+ name: { predicateType: "string", value: "notes" },
+ value: { predicateType: "string", value: "error" },
+ }],
+ },
+ },
+ },
+ ];
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters: filtersWithDefault } } });
+ await manager.goToRealmStartPage("smartcity");
+ await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
+
+ // The "Errors" filter is default — it should activate without any user interaction
+ const expectedCount = thingAssetsWithError.length;
+ await expect(page.locator(".or-map-marker")).toHaveCount(expectedCount);
+ await expect(page.locator("or-map-preset-filter or-vaadin-select + or-vaadin-badge")).toHaveText(String(expectedCount));
+ });
+
+ test.describe(() => {
+ test.use({ storageState: adminStatePath });
+
+ /**
+ * @given filters configured with different realm restrictions
+ * @when in a realm not included in a filter's realms list
+ * @then that filter is absent from the dropdown
+ * @when switching to a realm that is included
+ * @then the filter appears in the dropdown
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should show realm-scoped filters only in matching realms", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const realmFilters: MapFilter[] = [
+ { label: "Global", query: { types: ["ThingAsset"] } },
+ { label: "Smartcity only", query: { types: ["ThingAsset"] }, realms: ["smartcity"] },
+ ];
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters: realmFilters } } });
+
+ // In master realm: the smartcity-only filter is inactive → "All" + 1 global = 2 options
+ await manager.goToRealmStartPage("master");
+ await expect(page.locator("or-map-preset-filter")).toBeVisible();
+ await page.locator("or-map-preset-filter or-vaadin-select").click();
+ await page.getByRole("option").first().waitFor({ state: "visible" });
+ await expect(page.getByRole("option")).toHaveCount(2);
+ await page.keyboard.press("Escape");
+
+ // Switch to smartcity: both filters are active → "All" + 2 = 3 options
+ await manager.switchToRealmByRealmPicker("smartcity");
+ await expect(page.locator("or-map-preset-filter")).toBeVisible();
+ await page.locator("or-map-preset-filter or-vaadin-select").click();
+ await page.getByRole("option").first().waitFor({ state: "visible" });
+ await expect(page.getByRole("option")).toHaveCount(3);
+ });
+ });
+
+ /**
+ * @given filters are configured and a non-default filter was previously selected
+ * @when the page is reloaded
+ * @then the previously selected filter is restored from localStorage
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should restore last selected filter after page reload", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", { assets: allAssets });
+ await manager.configureAppConfig({ pages: { map: { clustering: { cluster: false }, filters } } });
+ await manager.goToRealmStartPage("smartcity");
+ await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
+
+ // Select the error filter (value="2": filters[1], 2 matching assets)
+ await page.locator("or-vaadin-select").click();
+ await page.getByRole("option").first().waitFor({ state: "visible" });
+ await page.getByRole("option").and(page.locator('[value="2"]')).click();
+ await expect(page.locator(".or-map-marker")).toHaveCount(thingAssetsWithError.length);
+
+ // Reload the page — localStorage persists (only cleared on OREvent.LOGIN / new session, not on reload)
+ await page.reload();
+ await expect(page.locator("or-map")).toBeVisible();
+ await page.locator("or-map").evaluate((map: OrMap) => map.flyTo(undefined, 10));
+
+ // The previously selected filter should be restored
+ await expect(page.locator(".or-map-marker")).toHaveCount(thingAssetsWithError.length);
+ await expect(page.locator("or-map-preset-filter or-vaadin-select + or-vaadin-badge")).toHaveText(String(thingAssetsWithError.length));
+ });
+});
+
+test.describe("Navigation control", () => {
+ const bbox = { west: 4.4859, south: 51.9163, east: 4.4864, north: 51.9166 };
+
+ /**
+ * @given a map is loaded at the default zoom level
+ * @when clicking the zoom in button
+ * @then the map zoom level increases by one step
+ * @when clicking the zoom out button
+ * @then the map zoom level decreases back
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("zoom buttons should increase and decrease map zoom level", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const asset = assignRandomLocationInArea(
+ { name: "Thing", type: "ThingAsset", realm: "smartcity", attributes: { ...commonAttrs } } as Asset,
+ bbox
+ );
+ await manager.setup("smartcity", { assets: [asset] });
+ await manager.goToRealmStartPage("smartcity");
+ await expect(page.locator("or-map")).toBeVisible();
+
+ const getZoom = () => page.locator("or-map").evaluate(el => (el as any)._map?._map?.getZoom() as number);
+ const waitForMapIdle = () => expect.poll(() =>
+ page.locator("or-map").evaluate(el => (el as any)._map?._map?.isMoving())
+ ).toBe(false);
+
+ const zoomBefore = await getZoom();
+
+ await page.getByTitle("Zoom in").click();
+ await waitForMapIdle();
+ expect(await getZoom()).toBeGreaterThan(zoomBefore);
+
+ const zoomAfterIn = await getZoom();
+ await page.getByTitle("Zoom out").click();
+ await waitForMapIdle();
+ expect(await getZoom()).toBeLessThan(zoomAfterIn);
+ });
+
+ /**
+ * @given a map is loaded
+ * @when the map bearing is set to 90 degrees programmatically
+ * @then the compass icon rotates to reflect the inverted bearing (-90 deg)
+ * @when the compass reset button is clicked
+ * @then the map bearing resets to 0 and the compass icon rotation resets to 0 deg
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("compass button should reset bearing to north and update icon rotation", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const asset = assignRandomLocationInArea(
+ { name: "Thing", type: "ThingAsset", realm: "smartcity", attributes: { ...commonAttrs } } as Asset,
+ bbox
+ );
+ await manager.setup("smartcity", { assets: [asset] });
+ await manager.goToRealmStartPage("smartcity");
+ await expect(page.locator("or-map")).toBeVisible();
+
+ await page.locator("or-map").evaluate(el => (el as any)._map?._map?.setBearing(90));
+
+ // OrMapNavigation negates the bearing: _bearing = -getBearing()
+ const compass = page.locator('or-map-navigation or-icon[icon="or:compass"]');
+ await expect(compass).toHaveAttribute("style", "transform: rotate(-90deg)");
+
+ await page.getByTitle("Reset bearing to north").click();
+ await expect.poll(() =>
+ page.locator("or-map").evaluate(el => (el as any)._map?._map?.isMoving())
+ ).toBe(false);
+
+ const bearing = await page.locator("or-map").evaluate(el => (el as any)._map?._map?.getBearing() as number);
+ expect(bearing).toBeCloseTo(0, 1);
+ await expect(compass).toHaveAttribute("style", "transform: rotate(0deg)");
+ });
+});
+
+test.describe("Geocoder control", () => {
+ const nominatimResponse = {
+ type: "FeatureCollection",
+ features: [{
+ type: "Feature",
+ bbox: [4.47, 51.90, 4.50, 51.93],
+ properties: { display_name: "Rotterdam, Netherlands" },
+ geometry: { type: "Point", coordinates: [4.485, 51.915] }
+ }]
+ };
+
+ /**
+ * @given a map with a geocodeUrl configured in mapsettings.json
+ * @when navigating to the map page
+ * @then the geocoder shows a collapsed search button
+ * @when clicking the search button
+ * @then the search combo box becomes visible
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should start collapsed and expand to a combo box on click", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await manager.setup("smartcity", {});
+ await manager.goToRealmStartPage("smartcity");
+ await expect(page.locator("or-map")).toBeVisible();
+
+ await expect(page.getByTitle("Search location")).toBeVisible();
+ await expect(page.locator("or-vaadin-combo-box")).not.toBeVisible();
+
+ await page.getByTitle("Search location").click();
+ await expect(page.locator("or-vaadin-combo-box")).toBeVisible();
+ });
+
+ /**
+ * @given a map with geocoding configured
+ * @and the Nominatim API returns a mocked result
+ * @when typing a search query
+ * @then a suggestion appears in the dropdown
+ * @when selecting the suggestion
+ * @then a marker is placed on the map at the result location
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should show suggestions on typing and place a marker on selection", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ await page.route("https://nominatim.openstreetmap.org/search**", route =>
+ route.fulfill({ contentType: "application/geo+json", json: nominatimResponse })
+ );
+
+ await manager.setup("smartcity", {});
+ await manager.goToRealmStartPage("smartcity");
+ await expect(page.locator("or-map")).toBeVisible();
+
+ await page.getByTitle("Search location").click();
+ await page.locator("or-vaadin-combo-box").getByRole("combobox").pressSequentially("Rotterdam");
+
+ const suggestion = page.locator("vaadin-combo-box-item").filter({ hasText: "Rotterdam, Netherlands" });
+ await expect(suggestion).toBeVisible();
+ await suggestion.click();
+
+ await expect(page.locator(".maplibregl-marker")).toBeVisible();
+ });
+
+ /**
+ * @given a map with bounds configured in mapsettings.json
+ * @when searching for a location outside the configured map bounds (Eindhoven)
+ * @then the Nominatim request includes viewbox and bounded=1 params derived from the map bounds
+ * @and no results are shown because Eindhoven is outside the bounded area
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should restrict geocoder search to configured map bounds", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const emptyResponse = { type: "FeatureCollection", features: [] };
+ await page.route("https://nominatim.openstreetmap.org/search**", route =>
+ route.fulfill({ contentType: "application/geo+json", json: emptyResponse })
+ );
+
+ await manager.setup("smartcity", {});
+ await manager.goToRealmStartPage("smartcity");
+ await expect(page.locator("or-map")).toBeVisible();
+
+ const requestPromise = page.waitForRequest("https://nominatim.openstreetmap.org/search**");
+ await page.getByTitle("Search location").click();
+ await page.locator("or-vaadin-combo-box").getByRole("combobox").pressSequentially("Eindhoven");
+
+ const request = await requestPromise;
+ expect(request.url()).toContain("viewbox=");
+ expect(request.url()).toContain("bounded=1");
+ await expect(page.locator("vaadin-combo-box-item")).not.toBeVisible();
+ });
+});
+
+test.describe("Geolocate control", () => {
+ /**
+ * @given navigator.geolocation is mocked to return a fixed position
+ * @when navigating to the map and clicking the "Find my location" button
+ * @then the map flies to the mocked coordinates
+ *
+ * @skip This test is skipped on Firefox because headless mode does not support WebGL required by maplibre
+ */
+ test("should fly to user location when geolocation is granted", async ({ page, manager, browserName }) => {
+ test.skip(browserName === "firefox", "firefox headless mode does not support webgl required by maplibre");
+
+ const mockLat = 51.9163;
+ const mockLng = 4.4859;
+ await page.addInitScript(({ lat, lng }) => {
+ Object.defineProperty(navigator, "geolocation", {
+ value: {
+ getCurrentPosition: (success: PositionCallback) => {
+ success({
+ coords: { latitude: lat, longitude: lng, accuracy: 10, altitude: null, altitudeAccuracy: null, heading: null, speed: null },
+ timestamp: Date.now(),
+ } as GeolocationPosition);
+ },
+ },
+ configurable: true,
+ });
+ }, { lat: mockLat, lng: mockLng });
+
+ await manager.setup("smartcity", {});
+ await manager.goToRealmStartPage("smartcity");
+ await expect(page.locator("or-map")).toBeVisible();
+
+ await expect(page.getByTitle("Find my location")).toBeVisible();
+ await page.getByTitle("Find my location").click();
+
+ await expect.poll(() =>
+ page.locator("or-map").evaluate(el => (el as any)._map?._map?.isMoving())
+ ).toBe(false);
+
+ const center = await page.locator("or-map").evaluate(el => {
+ const c = (el as any)._map?._map?.getCenter();
+ return { lng: c?.lng as number, lat: c?.lat as number };
+ });
+ expect(center.lng).toBeCloseTo(mockLng, 1);
+ expect(center.lat).toBeCloseTo(mockLat, 1);
+ });
+});
+
test.afterEach(async ({ manager }) => {
await manager.cleanUp();
});
diff --git a/ui/app/manager/test/test.setup.ts b/ui/app/manager/test/test.setup.ts
index 52c008900..11b0dd3b4 100644
--- a/ui/app/manager/test/test.setup.ts
+++ b/ui/app/manager/test/test.setup.ts
@@ -26,6 +26,7 @@ setup(`Wait for the manager to be healthy`, async ({ manager }) => {
intervals: [5_000, 1_000, 2_000, 5_000],
timeout: 60_000
}).toBe(200);
+ await manager.resetLocale("master", "admin", admin.password);
});
setup(`Login as "admin" user`, async ({ page, manager, context }) => {
@@ -77,6 +78,7 @@ setup.describe(async () => {
});
setup(`Login as "smartcity" user`, async ({ page, manager, context }) => {
+ await manager.resetLocale("smartcity", "smartcity", smartcity.password);
await manager.goToRealmStartPage("smartcity");
await manager.login("smartcity");
await page.waitForURL("**/manager/**");
diff --git a/ui/app/shared/locales/en/or.json b/ui/app/shared/locales/en/or.json
index 0a8b95320..8c6c1d267 100644
--- a/ui/app/shared/locales/en/or.json
+++ b/ui/app/shared/locales/en/or.json
@@ -1034,7 +1034,17 @@
"MODE": "Mode",
"SUM": "Sum",
"mapPage": {
- "legendTitle": "Legend"
+ "legendTitle": "Legend",
+ "filterAll": "Show all assets",
+ "filterCustom": "Custom",
+ "zoomIn": "Zoom in",
+ "zoomOut": "Zoom out",
+ "resetBearing": "Reset bearing to north",
+ "searchLocation": "Search location",
+ "searchLocationPlaceholder": "Search location...",
+ "searchNoResults": "No results found",
+ "findMyLocation": "Find my location",
+ "centerOnLocation": "Center on location"
},
"alarm": {
"": "Alarm",
diff --git a/ui/app/shared/locales/nl/or.json b/ui/app/shared/locales/nl/or.json
index efd70e46e..f2c75b8b9 100644
--- a/ui/app/shared/locales/nl/or.json
+++ b/ui/app/shared/locales/nl/or.json
@@ -1026,7 +1026,17 @@
"MODE": "Modus",
"SUM": "Som",
"mapPage": {
- "legendTitle": "Legenda"
+ "legendTitle": "Legenda",
+ "filterAll": "Alle assets weergeven",
+ "filterCustom": "Aangepast",
+ "zoomIn": "Inzoomen",
+ "zoomOut": "Uitzoomen",
+ "resetBearing": "Richting het noorden herstellen",
+ "searchLocation": "Locatie zoeken",
+ "searchLocationPlaceholder": "Locatie zoeken...",
+ "searchNoResults": "Geen resultaten gevonden",
+ "findMyLocation": "Mijn locatie zoeken",
+ "centerOnLocation": "Centreren op locatie"
},
"alarm": {
"": "Alarm",
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 88242c65a..52519c249 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -54,7 +54,8 @@ export enum OREvent {
CONSOLE_READY = "CONSOLE_READY",
TRANSLATE_INIT = "TRANSLATE_INIT",
TRANSLATE_LANGUAGE_CHANGED = "TRANSLATE_LANGUAGE_CHANGED",
- DISPLAY_REALM_CHANGED = "DISPLAY_REALM_CHANGED"
+ DISPLAY_REALM_CHANGED = "DISPLAY_REALM_CHANGED",
+ LOGIN = "LOGIN"
}
export interface LoginOptions {
@@ -987,6 +988,12 @@ export class Manager implements EventProviderFactory {
this._onAuthenticated();
this._createTokenUpdateInterval();
+ const currentSession = this._keycloak.tokenParsed?.session_state;
+ if (currentSession && sessionStorage.getItem("or-session") !== currentSession) {
+ sessionStorage.setItem("or-session", currentSession);
+ this._emitEvent(OREvent.LOGIN);
+ }
+
} else if (this.config.autoLogin) {
this.login();
return false;
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.ts
index 6dc3ae899..d412bb6e2 100644
--- a/ui/component/core/src/util.ts
+++ b/ui/component/core/src/util.ts
@@ -1,7 +1,30 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
import {
Asset,
AssetModelUtil,
AssetDescriptor,
+ AssetQuery,
+ AssetQueryAccess,
+ AssetQueryOrderBy,
+ AssetQuerySelect,
Attribute,
AttributeDescriptor,
AttributeEvent,
@@ -12,12 +35,17 @@ import {
MetaHolder,
NameHolder,
NameValueHolder,
+ ParentPredicate,
+ PathPredicate,
PushNotificationMessage,
+ RealmPredicate,
RuleActionUnion,
RuleCondition,
+ StringPredicate,
ValueDescriptor,
ValueDescriptorHolder,
ValueFormat,
+ ValuePredicateUnion,
WellknownMetaItems,
ValueConstraint,
AbstractNameValueDescriptorHolder,
@@ -1078,3 +1106,114 @@ export function generateUniqueUUID(): string {
(+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
);
}
+
+export class AssetQueryHelper implements AssetQuery {
+ recursive?: boolean;
+ select?: AssetQuerySelect;
+ access?: AssetQueryAccess;
+ ids?: string[];
+ names?: StringPredicate[];
+ parents?: ParentPredicate[];
+ paths?: PathPredicate[];
+ realm?: RealmPredicate;
+ userIds?: string[];
+ types?: string[];
+ attributes?: LogicGroup<AttributePredicate>;
+ orderBy?: AssetQueryOrderBy;
+ limit?: number;
+ offset?: number;
+
+ constructor(query?: AssetQuery) {
+ if (query) Object.assign(this, query);
+ }
+
+ // Single source of truth for which AssetQuery fields matches() evaluates.
+ // getUnsupportedFields derives from this — keep it in sync with matches().
+ private static readonly _SUPPORTED_FIELDS = new Set<string>([
+ "ids", "types", "names", "parents", "paths", "realm", "attributes",
+ ]);
+
+ matches(asset: Asset): boolean {
+ if (this.ids?.length && (!asset.id || !this.ids.includes(asset.id))) return false;
+ if (this.types?.length && (!asset.type || !this.types.includes(asset.type))) return false;
+ if (this.realm?.name && asset.realm !== this.realm.name) return false;
+ if (this.parents?.length && !this.parents.some(p => !p.id || asset.parentId === p.id)) return false;
+ if (this.paths?.length) {
+ const assetPath = asset.path ?? [];
+ if (!this.paths.some(p => (p.path ?? []).every((id, i) => assetPath[i] === id))) return false;
+ }
+ if (this.names?.length && !this.names.every(p => AssetQueryHelper._evalValuePredicate(asset.name, p as ValuePredicateUnion))) return false;
+ if (this.attributes) return AssetQueryHelper._evalGroup(asset, this.attributes as LogicGroup<AttributePredicate>);
+ return true;
+ }
+
+ static getUnsupportedFields(query: AssetQuery): string[] {
+ return Object.keys(query).filter(k => !AssetQueryHelper._SUPPORTED_FIELDS.has(k));
+ }
+
+ collectAttributeNames(): string[] {
+ return this.attributes ? AssetQueryHelper._collectNames(this.attributes) : [];
+ }
+
+ private static _evalValuePredicate(val: unknown, predicate: ValuePredicateUnion): boolean {
+ switch (predicate.predicateType) {
+ case "string": {
+ if (val === null || val === undefined) return false;
+ const haystack = predicate.caseSensitive !== false ? String(val) : String(val).toLowerCase();
+ const needle = predicate.caseSensitive !== false ? predicate.value : predicate.value?.toLowerCase();
+ let m: boolean;
+ switch (predicate.match) {
+ case "BEGIN": m = haystack.startsWith(needle!); break;
+ case "END": m = haystack.endsWith(needle!); break;
+ case "CONTAINS": m = haystack.includes(needle!); break;
+ default: m = haystack === needle;
+ }
+ return predicate.negate ? !m : m;
+ }
+ case "boolean":
+ return val === predicate.value;
+ case "number": {
+ if (typeof val !== "number") return false;
+ let m: boolean;
+ switch (predicate.operator) {
+ case "GREATER_THAN": m = val > predicate.value!; break;
+ case "GREATER_EQUALS": m = val >= predicate.value!; break;
+ case "LESS_THAN": m = val < predicate.value!; break;
+ case "LESS_EQUALS": m = val <= predicate.value!; break;
+ case "BETWEEN": m = val >= predicate.value! && val <= predicate.rangeValue!; break;
+ default: m = val === predicate.value;
+ }
+ return predicate.negate ? !m : m;
+ }
+ }
+ return false;
+ }
+
+ private static _evalPredicate(asset: Asset, predicate: AttributePredicate): boolean {
+ const attrName = predicate.name?.value;
+ if (!attrName) return true;
+ const attribute = asset.attributes?.[attrName];
+ if (!attribute) return predicate.negated ? true : false;
+ const matches = predicate.value
+ ? AssetQueryHelper._evalValuePredicate(attribute.value, predicate.value as ValuePredicateUnion)
+ : true;
+ return predicate.negated ? !matches : matches;
+ }
+
+ private static _evalGroup(asset: Asset, group: LogicGroup<AttributePredicate>): boolean {
+ const operator = group.operator ?? "AND";
+ const results: boolean[] = [
+ ...(group.items ?? []).map(item => AssetQueryHelper._evalPredicate(asset, item)),
+ ...(group.groups ?? []).map(g => AssetQueryHelper._evalGroup(asset, g)),
+ ];
+ if (!results.length) return true;
+ return operator === "OR" ? results.some(Boolean) : results.every(Boolean);
+ }
+
+ private static _collectNames(group: LogicGroup<AttributePredicate>): string[] {
+ return [
+ ...(group.items ?? []).map(item => item.name?.value).filter((n): n is string => !!n),
+ ...(group.groups ?? []).flatMap(g => AssetQueryHelper._collectNames(g)),
+ ];
+ }
+}
diff --git a/ui/component/or-icon/src/or-icon-set.ts b/ui/component/or-icon/src/or-icon-set.ts
index 4da97eff1..9a2165d24 100644
--- a/ui/component/or-icon/src/or-icon-set.ts
+++ b/ui/component/or-icon/src/or-icon-set.ts
@@ -3,9 +3,11 @@ const orIconSet = {
size: 24,
icons: {
"logo": "<path style='pointer-events: var(--or-icon-pointer-events, none);' fill=\"#C4D600\" d=\"m11.96125,23.85096c-6.56773,0 -11.90971,-5.34202 -11.90971,-11.90862l2.49411,0c0,5.19176 4.22389,9.41568 9.41561,9.41568c5.19053,0 9.41561,-4.22392 9.41561,-9.41568c0,-5.19176 -4.22389,-9.41568 -9.41561,-9.41568l0,-2.49413c6.56655,0 11.90971,5.34439 11.90971,11.9098c0,6.5666 -5.34316,11.90862 -11.90971,11.90862l0,0z\" /><path fill=\"#4E9D2D\" d=\"m10.25094,20.38647c-2.26848,-0.47231 -4.21822,-1.80199 -5.48741,-3.74009s-1.70892,-4.25777 -1.23545,-6.52625c0.47347,-2.26965 1.80315,-4.21822 3.74242,-5.48857c1.93926,-1.27035 4.25661,-1.70892 6.52625,-1.23545c4.68471,0.97719 7.70121,5.5828 6.72286,10.26635l-2.39994,-0.49907c0.70149,-3.36085 -1.4623,-6.66585 -4.82431,-7.36734c-1.62866,-0.33969 -3.29105,-0.02559 -4.68238,0.88645c-1.39134,0.91088 -2.34526,2.3092 -2.68495,3.93786c-0.33853,1.62633 -0.02443,3.28988 0.88645,4.68122c0.91088,1.39134 2.3092,2.34526 3.93786,2.68379l-0.50139,2.4011l0,0z\"/><path fill=\"#1D5632\"d=\"m12.03064,17.49616c-0.09524,0 -0.19048,-0.00116 -0.28457,-0.00465c-1.49833,-0.0755 -2.87818,-0.72942 -3.88636,-1.84097c-1.00818,-1.11271 -1.52156,-2.54948 -1.44722,-4.05013l2.44378,0.12196c-0.04181,0.84557 0.24856,1.65745 0.81769,2.28466c0.56681,0.62721 1.34733,0.99656 2.1929,1.03838c0.84208,0.03833 1.65629,-0.2474 2.2835,-0.81653c0.62837,-0.56797 0.99656,-1.34617 1.03954,-2.19174c0.08711,-1.74573 -1.26371,-3.23708 -3.00943,-3.3242l0.12196,-2.44378c3.09422,0.15332 5.4869,2.79455 5.33358,5.88877c-0.07434,1.49949 -0.72942,2.87818 -1.84097,3.8852c-1.04186,0.94313 -2.36945,1.45303 -3.7644,1.45303l0,0z\"/>",
+ "logo-grayscale": "<path fill=\"#e2e2e2\" d=\"m11.96125,23.85096c-6.56773,0 -11.90971,-5.34202 -11.90971,-11.90862l2.49411,0c0,5.19176 4.22389,9.41568 9.41561,9.41568c5.19053,0 9.41561,-4.22392 9.41561,-9.41568c0,-5.19176 -4.22389,-9.41568 -9.41561,-9.41568l0,-2.49413c6.56655,0 11.90971,5.34439 11.90971,11.9098c0,6.5666 -5.34316,11.90862 -11.90971,11.90862l0,0z\" /><path fill=\"#bcbcbc\" d=\"m10.25094,20.38647c-2.26848,-0.47231 -4.21822,-1.80199 -5.48741,-3.74009s-1.70892,-4.25777 -1.23545,-6.52625c0.47347,-2.26965 1.80315,-4.21822 3.74242,-5.48857c1.93926,-1.27035 4.25661,-1.70892 6.52625,-1.23545c4.68471,0.97719 7.70121,5.5828 6.72286,10.26635l-2.39994,-0.49907c0.70149,-3.36085 -1.4623,-6.66585 -4.82431,-7.36734c-1.62866,-0.33969 -3.29105,-0.02559 -4.68238,0.88645c-1.39134,0.91088 -2.34526,2.3092 -2.68495,3.93786c-0.33853,1.62633 -0.02443,3.28988 0.88645,4.68122c0.91088,1.39134 2.3092,2.34526 3.93786,2.68379l-0.50139,2.4011l0,0z\"/><path fill=\"#8f8f8f\"d=\"m12.03064,17.49616c-0.09524,0 -0.19048,-0.00116 -0.28457,-0.00465c-1.49833,-0.0755 -2.87818,-0.72942 -3.88636,-1.84097c-1.00818,-1.11271 -1.52156,-2.54948 -1.44722,-4.05013l2.44378,0.12196c-0.04181,0.84557 0.24856,1.65745 0.81769,2.28466c0.56681,0.62721 1.34733,0.99656 2.1929,1.03838c0.84208,0.03833 1.65629,-0.2474 2.2835,-0.81653c0.62837,-0.56797 0.99656,-1.34617 1.03954,-2.19174c0.08711,-1.74573 -1.26371,-3.23708 -3.00943,-3.3242l0.12196,-2.44378c3.09422,0.15332 5.4869,2.79455 5.33358,5.88877c-0.07434,1.49949 -0.72942,2.87818 -1.84097,3.8852c-1.04186,0.94313 -2.36945,1.45303 -3.7644,1.45303l0,0z\"/>",
"logo-plain": "m11.9925,23.91349c-6.58498,0 -11.94099,-5.35605 -11.94099,-11.9399l2.50066,0c0,5.20539 4.23498,9.44041 9.44033,9.44041c5.20416,0 9.44033,-4.23502 9.44033,-9.44041c0,-5.20539 -4.23498,-9.44041 -9.44033,-9.44041l0,-2.50068c6.5838,0 11.94099,5.35842 11.94099,11.94108c0,6.58385 -5.35719,11.9399 -11.94099,11.9399l0,0zm-1.80787,-3.27769c-2.31323,-0.48163 -4.30141,-1.83755 -5.59563,-3.81389s-1.74263,-4.34178 -1.25982,-6.65502c0.48281,-2.31443 1.83872,-4.30145 3.81623,-5.59686c1.97751,-1.29542 4.34056,-1.74264 6.65497,-1.25983c4.77711,0.99647 7.8531,5.69295 6.85545,10.46891l-2.44727,-0.50891c0.71532,-3.42716 -1.49114,-6.79738 -4.91946,-7.5127c-1.66078,-0.34639 -3.35596,-0.0261 -4.77474,0.90394c-1.41878,0.92886 -2.39152,2.35476 -2.73791,4.01555c-0.3452,1.65842 -0.02491,3.3548 0.90394,4.77359c0.92885,1.41879 2.35475,2.39154 4.01552,2.73675l-0.51128,2.44848l0,0zm1.81499,-2.92536c-0.09727,0 -0.19455,-0.00119 -0.29064,-0.00475c-1.53029,-0.07711 -2.93958,-0.74498 -3.96926,-1.88025c-1.02968,-1.13646 -1.55401,-2.60388 -1.47809,-4.13655l2.49591,0.12456c-0.04271,0.86361 0.25386,1.69282 0.83513,2.33341c0.5789,0.64059 1.37607,1.01783 2.23968,1.06053c0.86005,0.03915 1.69162,-0.25268 2.33221,-0.83395c0.64177,-0.58009 1.01782,-1.3749 1.06171,-2.23851c0.08897,-1.78298 -1.29066,-3.30616 -3.07362,-3.39513l0.12456,-2.49593c3.16022,0.15659 5.60394,2.85419 5.44735,6.01443c-0.07592,1.53149 -0.74498,2.9396 -1.88024,3.9681c-1.06408,0.96326 -2.41999,1.48403 -3.8447,1.48403l0,0z",
"marker": "<ellipse fill=\"#000\" opacity=\"0.2\" ry=\"1.5\" rx=\"4\" cy=\"22.5\" cx=\"12\" /><path style='pointer-events: var(--or-icon-pointer-events, none);' d=\"m11.999999,0a8.437501,8.344057 0 0 1 8.437501,8.344057c0,6.500779 -5.798864,6.280799 -8.437501,14.412461c-2.638637,-8.131662 -8.437501,-7.911683 -8.437501,-14.412461a8.437501,8.344057 0 0 1 8.437501,-8.344057z\" />",
- "trash": "<path d=\"M6 9V19C6 19.5523 6.44772 20 7 20H17C17.5523 20 18 19.5523 18 19V9\" stroke=\"#E21D12\" stroke-width=\"2\"/><path d=\"M14 11L14 16\" stroke=\"#E21D12\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M10 11V16\" stroke=\"#E21D12\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M5 6H8.5H19\" stroke=\"#E21D12\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M8.09516 4.02871L7 6H17L15.9048 4.02871C15.5521 3.39378 14.8829 3 14.1565 3H9.84347C9.11714 3 8.4479 3.39378 8.09516 4.02871Z\" fill=\"#E21D12\"/>"
+ "trash": "<path d=\"M6 9V19C6 19.5523 6.44772 20 7 20H17C17.5523 20 18 19.5523 18 19V9\" stroke=\"#E21D12\" stroke-width=\"2\"/><path d=\"M14 11L14 16\" stroke=\"#E21D12\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M10 11V16\" stroke=\"#E21D12\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M5 6H8.5H19\" stroke=\"#E21D12\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M8.09516 4.02871L7 6H17L15.9048 4.02871C15.5521 3.39378 14.8829 3 14.1565 3H9.84347C9.11714 3 8.4479 3.39378 8.09516 4.02871Z\" fill=\"#E21D12\"/>",
+ "compass": "<path style='fill: rgba(2,3,2,0.94)' d='M11.1679 2.74808C11.5638 2.15434 12.4362 2.15434 12.8321 2.74808L17.3635 9.5453C17.8066 10.2099 17.3302 11.1 16.5315 11.1H7.46852C6.66982 11.1 6.19343 10.2099 6.63647 9.5453L11.1679 2.74808Z'/><path style='fill: rgba(34,38,34,0.26)' d='M12.8321 21.2519C12.4362 21.8457 11.5638 21.8457 11.1679 21.2519L6.63647 14.4547C6.19343 13.7901 6.66982 12.9 7.46852 12.9H16.5315C17.3302 12.9 17.8066 13.7901 17.3635 14.4547L12.8321 21.2519Z'/>"
}
};
diff --git a/ui/component/or-map/@types/maplibre-gl-geocoder.d.ts b/ui/component/or-map/@types/maplibre-gl-geocoder.d.ts
deleted file mode 100644
index 6f8a25396..000000000
--- a/ui/component/or-map/@types/maplibre-gl-geocoder.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-/* eslint:disable:class-name */
-declare module "@maplibre/maplibre-gl-geocoder";
diff --git a/ui/component/or-map/package.json b/ui/component/or-map/package.json
index 684d52615..225e9a028 100644
--- a/ui/component/or-map/package.json
+++ b/ui/component/or-map/package.json
@@ -23,7 +23,6 @@
"repository": "https://github.com/openremote/openremote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "@maplibre/maplibre-gl-geocoder": "^1.5.0",
"@openremote/core": "workspace:*",
"@openremote/model": "workspace:*",
"@openremote/or-icon": "workspace:*",
diff --git a/ui/component/or-map/src/asset-map.ts b/ui/component/or-map/src/asset-map.ts
index f60ceaa21..b26891f24 100644
--- a/ui/component/or-map/src/asset-map.ts
+++ b/ui/component/or-map/src/asset-map.ts
@@ -1,12 +1,14 @@
import { CircleLayerSpecification, GeoJSONFeature, GeoJSONSource, MapSourceDataEvent, Marker } from "maplibre-gl";
import { Feature, Point } from "geojson";
-import { AssetWithLocation, ClusterConfig } from "./types";
+import { AssetWithLocation, ClusterConfig, MapFilter } from "./types";
import { BaseMap } from "./base-map";
import { OrClusterMarker, Slice } from "./markers/or-cluster-marker";
import { getMarkerIconAndColorFromAssetType } from "./util";
import { OrMapLoadedEvent, OrMapMarkersChangedEvent } from ".";
import { Util } from "@openremote/core";
-import { AttributeEvent, WellknownAttributes } from "@openremote/model";
+import { AssetQuery, AttributeEvent, WellknownAttributes } from "@openremote/model";
+import { OrMapLegendControl, OrMapLegendEvent } from "./controls/legend";
+import { OrMapPresetFilterControl, OrMapPresetFilterEvent } from "./controls/preset-filter";
type IdentifiableAsset = AssetWithLocation & { id: string; type: string };
@@ -25,6 +27,9 @@ type IdentifiableAsset = AssetWithLocation & { id: string; type: string };
export class AssetMap extends BaseMap {
private static _clusterProperty = "assetType";
+ // All assets ever added — source of truth for filtering and control counts
+ private _allAssets: Record<string, AssetWithLocation> = {};
+ // Assets currently rendered in the GeoJSON source (visible subset)
protected _assets: Record<string, AssetWithLocation | null> = {};
protected _assetTypeColors: Record<string, string> = {};
protected _assetsOnScreen: Record<string, AssetWithLocation> = {};
@@ -33,6 +38,27 @@ export class AssetMap extends BaseMap {
protected _clusterConfig?: ClusterConfig;
protected _source?: GeoJSONSource;
+ // Filter / legend state
+ private _hostElement: HTMLElement;
+ private _filters?: MapFilter[];
+ private _showLegend: boolean;
+ private _activeFilter: AssetQuery | null = null;
+ private _excludedTypes: string[] = [];
+ private _allAssetTypes: string[] = [];
+ private _allAssetCounts: Record<string, number> = {};
+ private _presetFilterControl?: OrMapPresetFilterControl;
+ private _legendControl?: OrMapLegendControl;
+
+ // Stable event handler refs so they can be removed on cleanup
+ private _onPresetFilter = (e: Event) => {
+ this._activeFilter = (e as OrMapPresetFilterEvent).detail;
+ this._applyVisibilityFilters();
+ };
+ private _onLegendChange = (e: Event) => {
+ this._excludedTypes = (e as OrMapLegendEvent).detail;
+ this._applyVisibilityFilters();
+ };
+
protected _onMove = () => this._updateMarkers();
protected _onMoveEnd = (e: any) => {
// Ensure marker updates happen after the frame
@@ -57,14 +83,20 @@ export class AssetMap extends BaseMap {
constructor(
styleParent: Node,
mapContainer: HTMLElement,
+ hostElement: HTMLElement,
showGeoCodingControl = false,
showBoundaryBox = false,
useZoomControls = true,
showGeoJson = true,
- clusterConfig?: ClusterConfig
+ clusterConfig?: ClusterConfig,
+ filters?: MapFilter[],
+ showLegend = true
) {
super(styleParent, mapContainer, showGeoCodingControl, showBoundaryBox, useZoomControls, showGeoJson);
this._clusterConfig = clusterConfig;
+ this._hostElement = hostElement;
+ this._filters = filters;
+ this._showLegend = showLegend;
}
override async build(): Promise<void> {
@@ -73,67 +105,38 @@ export class AssetMap extends BaseMap {
});
}
- /**
- * Add an asset as (asset) feature to the map.
- *
- * Use {@link addAssets} instead if adding multiple assets.
- * @param asset The asset to add
- */
- public addAsset(asset: AssetWithLocation) {
- if (!this._source) return;
- const features = this._map!.querySourceFeatures("assets");
+ // ── Public asset API (filter-aware) ──────────────────────────────────────
- if (!this._hasRequired(asset) || !this._isMissing(asset, features)) {
- return;
- }
-
- if (!(asset.type in this._assetTypeColors)) {
- this._assetTypeColors[asset.type] = getMarkerIconAndColorFromAssetType(asset.type)?.color as string;
- this._source.workerOptions.clusterProperties = this._getClusterProperties();
- }
-
- this._assets[asset.id] = asset;
- this._source.updateData({ add: [AssetMap._assetToFeature(asset)] });
+ public addAsset(asset: AssetWithLocation) {
+ if (!asset.id) return;
+ this._allAssets[asset.id] = asset;
+ this._syncAssetMeta();
+ if (this._presetFilterControl) this._presetFilterControl.assets = Object.values(this._allAssets);
+ this._sourceAddAsset(asset);
}
- /**
- * Add multiple assets as (asset) features to the map. Optimized for adding multiple assets at once.
- * @param assets The assets to add
- */
public addAssets(assets: AssetWithLocation[]) {
- if (!this._source) return;
- const features = this._map!.querySourceFeatures("assets");
-
- let missing = assets.filter(this._hasRequired);
- if (features?.length) {
- missing = missing.filter((a) => this._isMissing(a, features));
- }
-
- if (!missing.length) {
- return;
- }
-
- for (const asset of missing) {
- if (!(asset.type in this._assetTypeColors)) {
- this._assetTypeColors[asset.type] = getMarkerIconAndColorFromAssetType(asset.type)?.color as string;
- }
- this._assets[asset.id] = asset;
- }
- this._source.workerOptions.clusterProperties = this._getClusterProperties();
-
- this._source.updateData({
- add: missing.map(AssetMap._assetToFeature),
- });
+ for (const asset of assets) if (asset.id) this._allAssets[asset.id] = asset;
+ this._syncAssetMeta();
+ if (this._presetFilterControl) this._presetFilterControl.assets = Object.values(this._allAssets);
+ this._sourceAddAssets(assets);
}
public updateAttribute(event: AttributeEvent) {
const id = event?.ref?.id;
+ if (!id) return;
+
+ if (this._allAssets[id]) {
+ this._allAssets[id] = Util.updateAsset(structuredClone(this._allAssets[id]), event);
+ if (this._presetFilterControl) this._presetFilterControl.assets = Object.values(this._allAssets);
+ }
- if (!this._source || !id || !this._assets[id]) return;
+ // Update the GeoJSON source if the asset is currently visible
+ if (!this._source || !this._assets[id]) return;
if (event.value == null && event.ref?.name === WellknownAttributes.LOCATION) {
this._assets[id] = null;
- this._source?.updateData({ remove: [id] });
+ this._source.updateData({ remove: [id] });
return;
}
@@ -142,39 +145,163 @@ export class AssetMap extends BaseMap {
const newProperties = Object.entries(AssetMap._assetToFeature(asset as IdentifiableAsset).properties).map(
([key, value]) => ({ key, value })
);
- this._source?.updateData({ update: [{ id, newGeometry, addOrUpdateProperties: newProperties }] });
+ this._source.updateData({ update: [{ id, newGeometry, addOrUpdateProperties: newProperties }] });
}
public removeAssets(ids: string[]) {
+ for (const id of ids) delete this._allAssets[id];
+ this._syncAssetMeta();
+ if (this._presetFilterControl) this._presetFilterControl.assets = Object.values(this._allAssets);
for (const id of ids) this._assets[id] = null;
this._source?.updateData({ remove: ids });
}
public removeAllAssets() {
+ this._allAssets = {};
+ this._allAssetTypes = [];
+ this._allAssetCounts = {};
+ this._activeFilter = null;
+ this._excludedTypes = [];
+ this._hostElement.classList.remove('has-legend');
+ this._legendControl?.clear();
+ this._presetFilterControl?.clear();
this._assets = {};
this._source?.updateData({ removeAll: true });
}
- /**
- * Initialize asset sources, layers and data events
- */
- private async load() {
- if (!this._map) {
- console.warn("MapLibre Map not initialized!");
- return;
+ // ── Dynamic control updates ───────────────────────────────────────────────
+
+ public setFilters(filters: MapFilter[] | undefined) {
+ this._filters = filters;
+ if (!this._loaded) return;
+ if (this._presetFilterControl) {
+ this._map?.removeControl(this._presetFilterControl);
+ this._presetFilterControl = undefined;
}
+ if (filters?.length) {
+ this._presetFilterControl = new OrMapPresetFilterControl(filters, Object.values(this._allAssets));
+ this._activeFilter = this._presetFilterControl.getInitialFilter();
+ this._map?.addControl(this._presetFilterControl, 'top-left');
+ } else {
+ this._activeFilter = null;
+ }
+ this._hostElement.classList.toggle('has-filters', Boolean(filters?.length));
+ this._applyVisibilityFilters();
+ }
- if (this._loaded) {
- return;
+ public setShowLegend(showLegend: boolean) {
+ this._showLegend = showLegend;
+ if (!this._loaded) return;
+ if (!showLegend && this._legendControl) {
+ this._map?.removeControl(this._legendControl);
+ this._legendControl = undefined;
+ } else if (showLegend && !this._legendControl) {
+ this._legendControl = new OrMapLegendControl(this._allAssetTypes, this._excludedTypes, this._allAssetCounts);
+ this._map?.addControl(this._legendControl, 'bottom-right');
}
+ this._syncAssetMeta();
+ }
- if (this._map.getSource("assets")) {
- if (this._map.getLayer("asset")) {
- this._map.removeLayer("asset");
+ // ── Source-level helpers (operate on _assets / GeoJSON source only) ───────
+
+ private _sourceAddAsset(asset: AssetWithLocation) {
+ if (!this._source) return;
+ const features = this._map!.querySourceFeatures("assets");
+ if (!this._hasRequired(asset) || !this._isAssetVisible(asset) || !this._isMissing(asset, features)) return;
+ if (!(asset.type in this._assetTypeColors)) {
+ this._assetTypeColors[asset.type] = getMarkerIconAndColorFromAssetType(asset.type)?.color as string;
+ this._source.workerOptions.clusterProperties = this._getClusterProperties();
+ }
+ this._assets[asset.id] = asset;
+ this._source.updateData({ add: [AssetMap._assetToFeature(asset)] });
+ }
+
+ private _sourceAddAssets(assets: AssetWithLocation[]) {
+ if (!this._source) return;
+ const features = this._map!.querySourceFeatures("assets");
+ let missing = assets.filter(this._hasRequired).filter(a => this._isAssetVisible(a));
+ if (features?.length) missing = missing.filter(a => this._isMissing(a, features));
+ if (!missing.length) return;
+ for (const asset of missing) {
+ if (!(asset.type in this._assetTypeColors)) {
+ this._assetTypeColors[asset.type] = getMarkerIconAndColorFromAssetType(asset.type)?.color as string;
}
- if (this._map.getLayer("cluster")) {
- this._map.removeLayer("cluster");
+ this._assets[asset.id] = asset;
+ }
+ this._source.workerOptions.clusterProperties = this._getClusterProperties();
+ this._source.updateData({ add: missing.map(AssetMap._assetToFeature) });
+ }
+
+ // ── Filter / legend internals ─────────────────────────────────────────────
+
+ private _syncAssetMeta() {
+ const counts: Record<string, number> = {};
+ for (const id in this._allAssets) {
+ const type: string | undefined = this._allAssets[id]?.type;
+ if (type !== undefined && type !== '') counts[type] = (counts[type] ?? 0) + 1;
+ }
+ const types = Object.keys(counts);
+ this._allAssetTypes = types;
+ this._allAssetCounts = counts;
+ this._hostElement.classList.toggle('has-legend', this._showLegend && types.length >= 2);
+ this._legendControl?.update(types, counts);
+ }
+
+ private _isAssetVisible(asset: AssetWithLocation): boolean {
+ if (this._activeFilter && !new Util.AssetQueryHelper(this._activeFilter).matches(asset)) return false;
+ if (!asset.type) return true;
+ return !this._excludedTypes.includes(asset.type);
+ }
+
+ private _applyVisibilityFilters() {
+ if (!this._source) return;
+
+ const toRemove: string[] = [];
+ const toAdd: IdentifiableAsset[] = [];
+
+ for (const id in this._assets) {
+ if (this._assets[id] && !this._isAssetVisible(this._assets[id]!)) {
+ this._assets[id] = null;
+ toRemove.push(id);
+ }
+ }
+
+ for (const id in this._allAssets) {
+ const asset = this._allAssets[id];
+ if (!asset || !this._hasRequired(asset) || this._assets[id]) continue;
+ if (this._isAssetVisible(asset)) {
+ const a = asset as IdentifiableAsset;
+ if (!(a.type in this._assetTypeColors)) {
+ this._assetTypeColors[a.type] = getMarkerIconAndColorFromAssetType(a.type)?.color as string;
+ }
+ this._assets[a.id] = a;
+ toAdd.push(a);
}
+ }
+
+ if (!toRemove.length && !toAdd.length) return;
+
+ this._source.workerOptions.clusterProperties = this._getClusterProperties();
+ this._source.updateData({
+ ...(toRemove.length && { remove: toRemove }),
+ ...(toAdd.length && { add: toAdd.map(AssetMap._assetToFeature) }),
+ });
+ }
+
+ public override unload() {
+ this._mapContainer.removeEventListener(OrMapPresetFilterEvent.NAME, this._onPresetFilter);
+ this._mapContainer.removeEventListener(OrMapLegendEvent.NAME, this._onLegendChange);
+ super.unload();
+ }
+
+ // ── Map lifecycle ─────────────────────────────────────────────────────────
+
+ private async load() {
+ if (!this._map || this._loaded) return;
+
+ if (this._map.getSource("assets")) {
+ if (this._map.getLayer("asset")) this._map.removeLayer("asset");
+ if (this._map.getLayer("cluster")) this._map.removeLayer("cluster");
this._map.removeSource("assets");
}
@@ -201,6 +328,30 @@ export class AssetMap extends BaseMap {
this._map.on("data", this._onData);
+ // Create asset-specific controls
+ if (this._filters?.length) {
+ this._presetFilterControl = new OrMapPresetFilterControl(this._filters, Object.values(this._allAssets));
+ this._map?.addControl(this._presetFilterControl, 'top-left');
+ }
+ if (this._showLegend) {
+ this._legendControl = new OrMapLegendControl(this._allAssetTypes, this._excludedTypes, this._allAssetCounts);
+ this._map?.addControl(this._legendControl, 'bottom-right');
+ }
+ this._hostElement.classList.toggle('has-filters', Boolean(this._filters?.length));
+ this._hostElement.classList.toggle('has-legend', this._showLegend && this._allAssetTypes.length >= 2);
+
+ // Listen for filter/legend events from the controls (bubble through _mapContainer)
+ this._mapContainer.addEventListener(OrMapPresetFilterEvent.NAME, this._onPresetFilter);
+ this._mapContainer.addEventListener(OrMapLegendEvent.NAME, this._onLegendChange);
+
+ // Restore the active filter synchronously so the buffer flush below applies it immediately,
+ // preventing _applyVisibilityFilters from needing to removeAll + re-add after load.
+ if (this._presetFilterControl) this._activeFilter = this._presetFilterControl.getInitialFilter();
+
+ // Flush assets that were added before the source was ready
+ const buffered = Object.values(this._allAssets);
+ if (buffered.length) this._sourceAddAssets(buffered);
+
this._mapContainer.dispatchEvent(new OrMapLoadedEvent());
this._loaded = true;
}
diff --git a/ui/component/or-map/src/base-map.ts b/ui/component/or-map/src/base-map.ts
index ca7263d44..a916d9497 100644
--- a/ui/component/or-map/src/base-map.ts
+++ b/ui/component/or-map/src/base-map.ts
@@ -2,21 +2,21 @@ import { GeoJsonConfig } from "@openremote/model";
import manager, { DefaultColor4 } from "@openremote/core";
import maplibregl, {
AddLayerObject,
+ AttributionControl,
IControl,
- GeolocateControl,
LngLat,
+ LngLatBounds,
LngLatLike,
Map as MapGL,
MapOptions,
MapMouseEvent,
Marker,
- NavigationControl,
StyleSpecification,
GeoJSONSourceSpecification,
} from "maplibre-gl";
-import "@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css";
-import MaplibreGeocoder from "@maplibre/maplibre-gl-geocoder";
-import debounce from "lodash.debounce";
+import { OrLogoControl } from "./controls/logo";
+import { OrMapNavigationControl } from "./controls/navigation";
+import { OrMapGeolocateControl } from "./controls/geolocate";
import {
ControlPosition,
OrMapClickedEvent,
@@ -24,13 +24,13 @@ import {
OrMapLongPressEvent,
ViewSettings,
} from "./index";
+import { OrMapGeocoderControl } from "./controls/geocoder";
import { OrMapMarker } from "./markers/or-map-marker";
import { getLngLat, isWebglSupported, metersToPixelsAtMaxZoom } from "./util";
import { isMapboxURL, transformMapboxUrl } from "./util/mapbox-url";
import { Feature, FeatureCollection } from "geojson";
const maplibreGlStyles = require("maplibre-gl/dist/maplibre-gl.css");
-const maplibreGeoCoderStyles = require("@maplibre/maplibre-gl-geocoder/dist/maplibre-gl-geocoder.css");
let pkey: string | null;
@@ -124,8 +124,7 @@ export class BaseMap {
}
});
} else {
- // Add zoom and rotation controls to the map
- this._map.addControl(new NavigationControl());
+ this._map.addControl(new OrMapNavigationControl());
}
}
return this;
@@ -195,16 +194,11 @@ export class BaseMap {
style.textContent = maplibreGlStyles;
this._styleParent.appendChild(style);
- style = document.createElement("style");
- style.id = "maplibreGeoCoderStyles";
- style.textContent = maplibreGeoCoderStyles;
- this._styleParent.appendChild(style);
-
const map: typeof import("maplibre-gl") = await import(/* webpackChunkName: "maplibre-gl" */ "maplibre-gl");
const settings = await this.loadViewSettings();
const options: MapOptions = {
- attributionControl: {compact: true},
+ attributionControl: false,
container: this._mapContainer,
style: settings as StyleSpecification,
transformRequest: (url, resourceType) => {
@@ -255,6 +249,9 @@ export class BaseMap {
await this._styleLoaded();
+ this._map.addControl(new OrLogoControl, 'bottom-left');
+ this._map.addControl(new AttributionControl({ compact: true }), 'bottom-left');
+
this._map.on("click", (e: MapMouseEvent) => {
this._onMapClick(e.lngLat);
});
@@ -264,65 +261,13 @@ export class BaseMap {
});
if (this._showGeoCodingControl && this._viewSettings && this._viewSettings.geocodeUrl) {
- this._geocoder = new MaplibreGeocoder({forwardGeocode: this._forwardGeocode.bind(this), reverseGeocode: this._reverseGeocode }, { maplibregl, showResultsWhileTyping: true });
- // Override the _onKeyDown function from MaplibreGeocoder which has a bug getting the value from the input element
- this._geocoder._onKeyDown = debounce((e: KeyboardEvent) => {
- var ESC_KEY_CODE = 27,
- TAB_KEY_CODE = 9;
-
- if (e.keyCode === ESC_KEY_CODE && this._geocoder.options.clearAndBlurOnEsc) {
- this._geocoder._clear(e);
- return this._geocoder._inputEl.blur();
- }
-
- // if target has shadowRoot, then get the actual active element inside the shadowRoot
- var value = this._geocoder._inputEl.value || e.key;
-
- if (!value) {
- this._geocoder.fresh = true;
- // the user has removed all the text
- if (e.keyCode !== TAB_KEY_CODE) this._geocoder.clear(e);
- return (this._geocoder._clearEl.style.display = "none");
- }
-
- // TAB, ESC, LEFT, RIGHT, UP, DOWN
- if (
- e.metaKey ||
- [TAB_KEY_CODE, ESC_KEY_CODE, 37, 39, 38, 40].indexOf(e.keyCode) !== -1
- )
- return;
-
- // ENTER
- if (e.keyCode === 13) {
- if (!this._geocoder.options.showResultsWhileTyping) {
- if (!this._geocoder._typeahead.list.selectingListItem)
- this._geocoder._geocode(value);
- } else {
- if (this._geocoder.options.showResultMarkers) {
- this._geocoder._fitBoundsForMarkers();
- }
- this._geocoder._inputEl.value = this._geocoder._typeahead.query;
- this._geocoder.lastSelected = null;
- this._geocoder._typeahead.selected = null;
- return;
- }
- }
-
- if (
- value.length >= this._geocoder.options.minLength &&
- this._geocoder.options.showResultsWhileTyping
- ) {
- this._geocoder._geocode(value);
- }
- }, 300);
- this._map!.addControl(this._geocoder, 'top-left');
-
- // There's no callback parameter in the options of the MaplibreGeocoder,
- // so this is how we get the selected result.
- this._geocoder._inputEl.addEventListener("change", () => {
- var selected = this._geocoder._typeahead.selected;
- this._onGeocodeChange(selected);
- });
+ let bbox: [number, number, number, number] | undefined;
+ if (this._viewSettings.bounds) {
+ const b = LngLatBounds.convert(this._viewSettings.bounds as any);
+ bbox = [b.getWest(), b.getSouth(), b.getEast(), b.getNorth()];
+ }
+ this._geocoder = new OrMapGeocoderControl(this._viewSettings.geocodeUrl, bbox);
+ this._map!.addControl(this._geocoder, 'top-right');
}
// Add custom controls
@@ -336,16 +281,8 @@ export class BaseMap {
}
});
} else {
- // Add zoom and rotation controls to the map
- this._map.addControl(new NavigationControl());
- // Add current location controls to the map
- this._map.addControl(new GeolocateControl({
- positionOptions: {
- enableHighAccuracy: true
- },
- showAccuracyCircle: true,
- showUserLocation: true
- }));
+ this._map.addControl(new OrMapNavigationControl());
+ this._map.addControl(new OrMapGeolocateControl());
}
// Unload all GeoJSON that is present, and load new layers if present
diff --git a/ui/component/or-map/src/controls/base.ts b/ui/component/or-map/src/controls/base.ts
new file mode 100644
index 000000000..272de45b7
--- /dev/null
+++ b/ui/component/or-map/src/controls/base.ts
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import type { IControl, Map as MapGL } from "maplibre-gl";
+
+export abstract class OrMapBaseControl implements IControl {
+ protected _container?: HTMLElement;
+
+ protected _createContainer(extra?: Partial<CSSStyleDeclaration>): HTMLElement {
+ const el = document.createElement("div");
+ el.className = "maplibregl-ctrl";
+ Object.assign(el.style, {
+ fontSize: "16px",
+ background: "white",
+ boxShadow: "0px 2px 6px -1px var(--lumo-shade-10pct), 0px 8px 24px -4px var(--lumo-shade-30pct)",
+ borderRadius: "var(--lumo-border-radius-m, 4px)",
+ ...extra,
+ });
+ this._container = el;
+ return el;
+ }
+
+ abstract onAdd(map: MapGL): HTMLElement;
+
+ onRemove(): void {
+ this._container?.remove();
+ this._container = undefined;
+ }
+}
diff --git a/ui/component/or-map/src/controls/center.ts b/ui/component/or-map/src/controls/center.ts
index dab1bce9d..18d814286 100644
--- a/ui/component/or-map/src/controls/center.ts
+++ b/ui/component/or-map/src/controls/center.ts
@@ -1,33 +1,55 @@
-import { LngLatLike, Map as MapGL } from "maplibre-gl";
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import type { LngLatLike, Map as MapGL } from "maplibre-gl";
+import { i18next } from "@openremote/or-translate";
+import { OrMapBaseControl } from "./base";
+import "@openremote/or-vaadin-components/or-vaadin-button";
+import "@openremote/or-icon";
-export class CenterControl {
- protected map?: MapGL;
- protected elem?: HTMLElement;
+export class OrMapCenterControl extends OrMapBaseControl {
+ private _map?: MapGL;
public pos?: LngLatLike;
onAdd(map: MapGL): HTMLElement {
- this.map = map;
- const control = document.createElement("div");
- control.classList.add("maplibregl-ctrl");
- control.classList.add("maplibregl-ctrl-group");
- const button = document.createElement("button");
- button.className = "maplibregl-ctrl-compass";
- button.addEventListener("click", (ev) =>
- map.flyTo({
- center: this.pos,
- zoom: map.getZoom(),
- })
- );
- const buttonIcon = document.createElement("span");
- buttonIcon.className = "maplibregl-ctrl-icon";
- button.appendChild(buttonIcon);
- control.appendChild(button);
- this.elem = control;
- return control;
+ this._map = map;
+ this._createContainer({ overflow: "hidden" });
+
+ const button = document.createElement("or-vaadin-button");
+ button.setAttribute("theme", "icon");
+ button.setAttribute("title", i18next.t("mapPage.centerOnLocation"));
+
+ const icon = document.createElement("or-icon") as HTMLElement;
+ icon.setAttribute("icon", "or:compass");
+ icon.style.cssText = "--or-icon-width: 18px; --or-icon-height: 18px;";
+ button.appendChild(icon);
+
+ button.addEventListener("click", () => {
+ if (this.pos) this._map?.flyTo({ center: this.pos, zoom: this._map.getZoom() });
+ });
+
+ this._container!.appendChild(button);
+ return this._container!;
}
- onRemove(map: MapGL) {
- this.map = undefined;
- this.elem = undefined;
+ onRemove(): void {
+ super.onRemove();
+ this._map = undefined;
}
}
diff --git a/ui/component/or-map/src/controls/coordinates.ts b/ui/component/or-map/src/controls/coordinates.ts
index 130edce3a..8109d57a2 100644
--- a/ui/component/or-map/src/controls/coordinates.ts
+++ b/ui/component/or-map/src/controls/coordinates.ts
@@ -1,12 +1,33 @@
-import { IControl, LngLat, Map as MapGL } from "maplibre-gl";
-import { InputType, OrMwcInput } from "@openremote/or-mwc-components/or-mwc-input";
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { LngLat, Map as MapGL } from "maplibre-gl";
+import { OrMapBaseControl } from "./base";
+import "@openremote/or-vaadin-components/or-vaadin-text-field";
+import "@openremote/or-icon";
export const CoordinatesRegexPattern = "^[ ]*(?:Lat: )?(-?\\d+\\.?\\d*)[, ]+(?:Lng: )?(-?\\d+\\.?\\d*)[ ]*$";
export function getCoordinatesInputKeyHandler(valueChangedHandler: (value: LngLat | undefined) => void) {
return (e: KeyboardEvent) => {
if (e.code === "Enter" || e.code === "NumpadEnter") {
- const valStr = (e.target as OrMwcInput).value as string;
+ const valStr = (e.target as any).value as string;
let value: LngLat | undefined = !valStr ? undefined : {} as LngLat;
if (valStr) {
@@ -23,57 +44,58 @@ export function getCoordinatesInputKeyHandler(valueChangedHandler: (value: LngLa
};
}
-export class CoordinatesControl implements IControl {
- protected map?: MapGL;
- protected elem?: HTMLElement;
- protected input!: OrMwcInput;
+export class CoordinatesControl extends OrMapBaseControl {
+ protected input?: HTMLElement;
protected _readonly = false;
protected _value: any;
protected _valueChangedHandler: (value: LngLat | undefined) => void;
constructor(disabled = false, valueChangedHandler: (value: LngLat | undefined) => void) {
+ super();
this._readonly = disabled;
this._valueChangedHandler = valueChangedHandler;
}
- onAdd(map: MapGL): HTMLElement {
- this.map = map;
- const control = document.createElement("div");
- control.classList.add("maplibregl-ctrl");
- control.classList.add("maplibregl-ctrl-group");
+ onAdd(_map: MapGL): HTMLElement {
+ this._createContainer();
- const input = new OrMwcInput();
- input.type = InputType.TEXT;
- input.outlined = true;
- input.compact = true;
- input.readonly = this._readonly;
- input.icon = "crosshairs-gps";
- input.value = this._value;
- input.pattern = CoordinatesRegexPattern;
- input.onkeyup = getCoordinatesInputKeyHandler(this._valueChangedHandler);
+ const input = document.createElement("or-vaadin-text-field") as HTMLElement;
+ if (this._readonly) input.setAttribute("readonly", "");
+ if (this._value != null) (input as any).value = this._value;
+ input.setAttribute("pattern", CoordinatesRegexPattern);
+ input.addEventListener("keyup", getCoordinatesInputKeyHandler(this._valueChangedHandler) as EventListener);
- control.appendChild(input);
- this.elem = control;
+ const icon = document.createElement("or-icon") as HTMLElement;
+ icon.setAttribute("icon", "mdi:crosshairs");
+ icon.setAttribute("slot", "prefix");
+ icon.style.cssText = "--or-icon-width: 14px; --or-icon-height: 14px; margin-left: 4px; margin-right: 8px;";
+ input.appendChild(icon);
+
+ this._container!.appendChild(input);
this.input = input;
- return control;
+ return this._container!;
}
- onRemove(map: MapGL) {
- this.map = undefined;
- this.elem = undefined;
+ onRemove(): void {
+ super.onRemove();
+ this.input = undefined;
}
public set readonly(readonly: boolean) {
this._readonly = readonly;
if (this.input) {
- this.input.readonly = readonly;
+ if (readonly) {
+ this.input.setAttribute("readonly", "");
+ } else {
+ this.input.removeAttribute("readonly");
+ }
}
}
public set value(value: any) {
this._value = value;
if (this.input) {
- this.input.value = value;
+ (this.input as any).value = value;
}
}
}
diff --git a/ui/component/or-map/src/controls/geocoder.ts b/ui/component/or-map/src/controls/geocoder.ts
new file mode 100644
index 000000000..3aa0dddd8
--- /dev/null
+++ b/ui/component/or-map/src/controls/geocoder.ts
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { css, html, LitElement } from "lit";
+import { customElement, property, state } from "lit/decorators.js";
+import type { Map as MapGL } from "maplibre-gl";
+import { OrMapBaseControl } from "./base";
+import maplibregl from "maplibre-gl";
+import debounce from "lodash.debounce";
+import { i18next } from "@openremote/or-translate";
+import "@openremote/or-vaadin-components/or-vaadin-combo-box";
+import "@openremote/or-vaadin-components/or-vaadin-button";
+import "@openremote/or-icon";
+import type { ComboBoxDataProviderCallback, ComboBoxDataProviderParams } from "@openremote/or-vaadin-components/or-vaadin-combo-box";
+import type { MapGeocoderEventDetail } from "../types";
+
+export class OrMapGeocoderChangeEvent extends CustomEvent<MapGeocoderEventDetail> {
+
+ public static readonly NAME = "or-map-geocoder-change";
+
+ constructor(geocode: any) {
+ super(OrMapGeocoderChangeEvent.NAME, {
+ detail: { geocode },
+ bubbles: true,
+ composed: true,
+ });
+ }
+}
+
+declare global {
+ export interface HTMLElementEventMap {
+ [OrMapGeocoderChangeEvent.NAME]: OrMapGeocoderChangeEvent;
+ }
+}
+
+/**
+ * This is a custom geocoder replacing `@maplibre/maplibre-gl-geocoder` to be able to use Vaadin
+ * components. We talk directly to the Nominatim endpoint which can be configured in the
+ * mapsettings.json.
+ */
+@customElement("or-map-geocoder")
+export class OrMapGeocoder extends LitElement {
+
+ static get styles() {
+ return css`
+ :host { display: block; }
+
+ or-vaadin-button {
+ background: white;
+ border-radius: var(--lumo-border-radius-m);
+ }
+
+ or-icon {
+ --or-icon-width: 18px;
+ --or-icon-height: 18px;
+ color: var(--lumo-secondary-text-color);
+ }
+
+ or-icon[slot="prefix"] {
+ margin-left: 4px;
+ margin-right: 8px;
+ }
+
+ or-vaadin-combo-box {
+ width: 300px;
+ --vaadin-input-field-background: white;
+ }
+
+ /* Hide dropdown toggle — suggestions open when typing */
+ or-vaadin-combo-box::part(toggle-button) {
+ display: none;
+ }
+
+ vaadin-combo-box-item.no-results-item {
+ pointer-events: none;
+ color: var(--lumo-disabled-text-color);
+ }
+
+ @media only screen and (max-width: 450px) {
+ or-vaadin-combo-box {
+ width: 100%;
+ }
+ }
+ `;
+ }
+
+ @property({ type: String })
+ public geocodeUrl = "";
+
+ @property({ type: Array })
+ public bbox?: [west: number, south: number, east: number, north: number];
+
+ @state()
+ private _collapsed = true;
+
+ private _hasValue = false;
+ private _map?: MapGL;
+ private _marker?: any;
+ private _mq = window.matchMedia("(max-width: 450px)");
+ private _onMqChange = (e: MediaQueryList | MediaQueryListEvent) => {
+ if (e.matches) this._collapsed = false;
+ else if (!this._hasValue) this._collapsed = true;
+ };
+ private _onLanguageChanged = () => {
+ (this.shadowRoot?.querySelector("or-vaadin-combo-box") as any)?.clearCache?.();
+ };
+
+ public connectedCallback() {
+ super.connectedCallback();
+ i18next.on("languageChanged", this._onLanguageChanged);
+ this._mq.addEventListener("change", this._onMqChange);
+ this._onMqChange(this._mq);
+ }
+
+ public setMap(map: MapGL): void {
+ this._map = map;
+ }
+
+ protected render() {
+ if (this._collapsed) {
+ return html`
+ <or-vaadin-button theme="icon" .title="${i18next.t("mapPage.searchLocation")}" @click="${this._expand}">
+ <or-icon icon="mdi:magnify"></or-icon>
+ </or-vaadin-button>
+ `;
+ }
+ return html`
+ <or-vaadin-combo-box
+ .dataProvider="${this._dataProvider}"
+ .itemClassNameGenerator="${this._itemClassNameGenerator}"
+ item-label-path="place_name"
+ item-value-path="place_name"
+ placeholder="${i18next.t("mapPage.searchLocationPlaceholder")}"
+ clear-button-visible
+ @selected-item-changed="${this._onItemSelected}"
+ >
+ <or-icon slot="prefix" icon="mdi:magnify"></or-icon>
+ </or-vaadin-combo-box>
+ `;
+ }
+
+ private _expand() {
+ this._collapsed = false;
+ this.updateComplete.then(() => {
+ (this.shadowRoot?.querySelector("or-vaadin-combo-box") as HTMLElement)?.focus?.();
+ });
+ }
+
+ private _dataProvider = (params: ComboBoxDataProviderParams, callback: ComboBoxDataProviderCallback<any>) => {
+ this._fetchSuggestions(params.filter, callback);
+ };
+
+ private _fetchSuggestions = debounce(async (query: string, callback: ComboBoxDataProviderCallback<any>) => {
+ if (!query || query.length < 2) {
+ callback([], 0);
+ return;
+ }
+ const features: any[] = [];
+ try {
+ const params = new URLSearchParams({
+ q: query,
+ format: "geojson",
+ polygon_geojson: "1",
+ addressdetails: "1",
+ "accept-language": i18next.language || "en",
+ });
+ if (this.bbox) {
+ const [west, south, east, north] = this.bbox;
+ params.set("viewbox", `${west},${north},${east},${south}`);
+ params.set("bounded", "1");
+ }
+ const response = await fetch(`${this.geocodeUrl}/search?${params.toString()}`);
+ if (!response.ok) {
+ callback([], 0);
+ return;
+ }
+ const geojson = await response.json();
+ for (const feature of geojson.features) {
+ const center: [number, number] = feature.bbox
+ ? [feature.bbox[0] + (feature.bbox[2] - feature.bbox[0]) / 2,
+ feature.bbox[1] + (feature.bbox[3] - feature.bbox[1]) / 2]
+ : feature.geometry.coordinates;
+ features.push({ place_name: feature.properties.display_name, center });
+ }
+ } catch (e) {
+ console.error("Failed to forwardGeocode:", e);
+ callback([], 0);
+ return;
+ }
+ if (features.length) {
+ callback(features, features.length);
+ } else {
+ const noResults = [{ place_name: i18next.t("mapPage.searchNoResults"), noResults: true }];
+ callback(noResults, noResults.length);
+ }
+ }, 300);
+
+ private _itemClassNameGenerator = (item: any) => item?.noResults ? "no-results-item" : "";
+
+ private _onItemSelected(e: CustomEvent) {
+ const item = e.detail.value;
+ if (item?.noResults) return;
+ if (item) {
+ this._hasValue = true;
+ this._marker?.remove();
+ this._map?.flyTo({ center: item.center, zoom: 14 });
+ this._marker = new maplibregl.Marker().setLngLat(item.center).addTo(this._map!);
+ this.dispatchEvent(new OrMapGeocoderChangeEvent({
+ type: "Feature",
+ geometry: { type: "Point", coordinates: item.center },
+ }));
+ } else if (this._hasValue) {
+ // Clear button was clicked — collapse back (unless small screen keeps it expanded)
+ this._hasValue = false;
+ this._marker?.remove();
+ this._marker = undefined;
+ this._fetchSuggestions.cancel();
+ if (!this._mq.matches) this._collapsed = true;
+ }
+ }
+
+ public disconnectedCallback() {
+ super.disconnectedCallback();
+ i18next.off("languageChanged", this._onLanguageChanged);
+ this._mq.removeEventListener("change", this._onMqChange);
+ this._fetchSuggestions.cancel();
+ this._marker?.remove();
+ }
+}
+
+export class OrMapGeocoderControl extends OrMapBaseControl {
+ constructor(private _geocodeUrl: string, private _bbox?: [number, number, number, number]) { super(); }
+
+ onAdd(map: MapGL): HTMLElement {
+ this._createContainer();
+ this._container!.classList.add("geocoder-control");
+ const component = document.createElement("or-map-geocoder") as OrMapGeocoder;
+ component.geocodeUrl = this._geocodeUrl;
+ if (this._bbox) component.bbox = this._bbox;
+ component.setMap(map);
+ this._container!.appendChild(component);
+ return this._container!;
+ }
+}
diff --git a/ui/component/or-map/src/controls/geolocate.ts b/ui/component/or-map/src/controls/geolocate.ts
new file mode 100644
index 000000000..8b4394a3b
--- /dev/null
+++ b/ui/component/or-map/src/controls/geolocate.ts
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import type { Map as MapGL } from "maplibre-gl";
+import { i18next } from "@openremote/or-translate";
+import "@openremote/or-vaadin-components/or-vaadin-button";
+import "@openremote/or-icon";
+import { OrMapBaseControl } from "./base";
+
+export class OrMapGeolocateControl extends OrMapBaseControl {
+ private _map?: MapGL;
+ private _button?: HTMLElement;
+ private _onLocate?: (pos: GeolocationPosition) => void;
+
+ constructor(onLocate?: (pos: GeolocationPosition) => void) {
+ super();
+ this._onLocate = onLocate;
+ }
+
+ onAdd(map: MapGL): HTMLElement {
+ this._map = map;
+ this._createContainer({ background: "white", overflow: "hidden" });
+
+ this._button = document.createElement("or-vaadin-button");
+ this._button.setAttribute("theme", "icon");
+ this._button.setAttribute("title", i18next.t("mapPage.findMyLocation"));
+ const icon = document.createElement("or-icon") as HTMLElement;
+ icon.setAttribute("icon", "mdi:crosshairs-gps");
+ icon.style.cssText = "--or-icon-width: 18px; --or-icon-height: 18px; color: black;";
+ this._button.appendChild(icon);
+ this._button.addEventListener("click", () => this._locate());
+ this._container!.appendChild(this._button);
+ return this._container!;
+ }
+
+ private _locate() {
+ if (!navigator.geolocation || !this._button) return;
+ this._button.setAttribute("disabled", "");
+ navigator.geolocation.getCurrentPosition(
+ (pos) => {
+ if (this._onLocate) {
+ this._onLocate(pos);
+ } else {
+ this._map?.flyTo({ center: [pos.coords.longitude, pos.coords.latitude], zoom: 14 });
+ }
+ this._button!.removeAttribute("disabled");
+ },
+ () => { this._button!.removeAttribute("disabled"); }
+ );
+ }
+
+ onRemove(): void {
+ super.onRemove();
+ this._map = undefined;
+ this._button = undefined;
+ }
+}
diff --git a/ui/component/or-map/src/controls/legend.ts b/ui/component/or-map/src/controls/legend.ts
new file mode 100644
index 000000000..9f9fb7927
--- /dev/null
+++ b/ui/component/or-map/src/controls/legend.ts
@@ -0,0 +1,263 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { css, CSSResultGroup, html, LitElement, PropertyValues, TemplateResult } from "lit";
+import { countBadgeStyle } from "./styles";
+import { customElement, property, state } from "lit/decorators.js";
+import { AssetModelUtil } from "@openremote/model";
+import { formatCount, getMarkerIconAndColorFromAssetType } from "../util";
+import { Util } from "@openremote/core";
+import type { Map as MapGL } from "maplibre-gl";
+import { OrMapBaseControl } from "./base";
+import "@openremote/or-vaadin-components/or-vaadin-checkbox";
+import "@openremote/or-vaadin-components/or-vaadin-badge";
+import "@openremote/or-icon";
+import "@openremote/or-vaadin-components/or-vaadin-list-box";
+import "@openremote/or-vaadin-components/or-vaadin-item";
+
+export class OrMapLegendEvent extends CustomEvent<string[]> {
+ public static readonly NAME = "or-map-legend-changed";
+
+ constructor(assetTypes: string[]) {
+ super(OrMapLegendEvent.NAME, {
+ bubbles: true,
+ composed: true,
+ detail: assetTypes,
+ });
+ }
+}
+
+declare global {
+ export interface HTMLElementEventMap {
+ [OrMapLegendEvent.NAME]: OrMapLegendEvent;
+ }
+}
+
+@customElement("or-map-legend")
+export class OrMapLegend extends LitElement {
+
+ static get styles(): CSSResultGroup {
+ return [countBadgeStyle, css`
+ :host {
+ display: block;
+ }
+
+ #legend {
+ display: flex;
+ flex-direction: column;
+ min-width: 220px;
+ }
+
+ #legend-title {
+ height: 38px;
+ line-height: 38px;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border-radius: var(--lumo-border-radius-m);
+ font-family: var(--lumo-font-family);
+ font-size: 16px;
+ color: black;
+ padding: 0 20px;
+ }
+ #legend-title.expanded {
+ border-radius: var(--lumo-border-radius-m) var(--lumo-border-radius-m) 0 0;
+ }
+
+ or-icon {
+ --or-icon-width: 18px;
+ --or-icon-height: 18px;
+ margin-right: 4px;
+ }
+
+ or-vaadin-item {
+ min-height: 30px;
+ padding: 4px 16px;
+ margin: 0 4px;
+ box-sizing: border-box;
+ font-size: var(--lumo-font-size-m);
+ /* Remove hover highlight */
+ --lumo-primary-color-10pct: transparent;
+ cursor: pointer;
+ }
+ or-vaadin-item:last-child {
+ margin-bottom: 4px;
+ }
+
+ or-vaadin-item::part(checkmark) {
+ display: none;
+ }
+
+ /* List: flat top connecting to title, rounded bottom */
+ #legend-list {
+ min-width: 220px;
+ margin: 0;
+ background: var(--lumo-base-color, white);
+ border-radius: 0 0 var(--lumo-border-radius-m) var(--lumo-border-radius-m);
+ max-height: 0;
+ overflow: hidden;
+ opacity: 0;
+ transition: max-height 0.14s ease, opacity 0.1s ease;
+ }
+
+ #legend-list.expanded {
+ max-height: 600px;
+ opacity: 1;
+ }
+ `];
+ }
+
+ @property({ type: Array })
+ public assetTypes: string[] = [];
+
+ @property({ type: Array })
+ public excludedTypes: string[] = [];
+
+ @property({ type: Object })
+ public assetCounts: Record<string, number> = {};
+
+ @state()
+ private _contentHidden = true;
+
+ protected _assetTypesInfo: any = {};
+
+ protected shouldUpdate(changedProperties: PropertyValues): boolean {
+ if (changedProperties.has("assetTypes")) {
+ this._assetTypesInfo = {};
+ this.assetTypes.forEach((assetType: string) => {
+ const descriptor = AssetModelUtil.getAssetDescriptor(assetType);
+ this._assetTypesInfo[assetType] = {
+ icon: getMarkerIconAndColorFromAssetType(descriptor)?.icon,
+ color: getMarkerIconAndColorFromAssetType(descriptor)?.color,
+ label: Util.getAssetTypeLabel(descriptor),
+ };
+ });
+ }
+ return super.shouldUpdate(changedProperties);
+ }
+
+ private _setExcluded(assetType: string, excluded: boolean) {
+ if (excluded === this.excludedTypes.includes(assetType)) return;
+ this.excludedTypes = excluded
+ ? [...this.excludedTypes, assetType]
+ : this.excludedTypes.filter(t => t !== assetType);
+ this.dispatchEvent(new OrMapLegendEvent(this.excludedTypes));
+ }
+
+ private _toggleType(assetType: string) {
+ this._setExcluded(assetType, !this.excludedTypes.includes(assetType));
+ }
+
+ protected render(): TemplateResult | typeof html {
+ if (this.assetTypes.length < 2) return html``;
+ const sortedTypes = [...this.assetTypes].sort((a, b) =>
+ (this._assetTypesInfo[a]?.label ?? a).localeCompare(this._assetTypesInfo[b]?.label ?? b)
+ );
+ return html`
+ <div id="legend">
+ <div id="legend-title" class="${!this._contentHidden ? 'expanded' : ''}" @click="${() => { this._contentHidden = !this._contentHidden; }}">
+ <or-translate value="mapPage.legendTitle"></or-translate>
+ <or-icon style="cursor: pointer" icon="${this._contentHidden ? 'mdi:chevron-up' : 'mdi:chevron-down'}"></or-icon>
+ </div>
+ <or-vaadin-list-box id="legend-list" class="${this._contentHidden ? '' : 'expanded'}">
+ ${sortedTypes.map((assetType) => html`
+ <or-vaadin-item @click="${() => this._toggleType(assetType)}">
+ <div style="display: flex; align-items: center; width: 100%; gap: 6px; min-width: 200px;">
+ <or-icon
+ icon="${this._assetTypesInfo[assetType].icon}"
+ style="color: #${this._assetTypesInfo[assetType].color}; flex-shrink: 0; --or-icon-width: 20px; --or-icon-height: 20px;"
+ ></or-icon>
+ <span style="flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
+ ${this._assetTypesInfo[assetType].label}
+ </span>
+ <or-vaadin-badge style="flex-shrink: 0;">${formatCount(this.assetCounts[assetType] ?? 0)}</or-vaadin-badge>
+ <or-vaadin-checkbox
+ .checked="${!this.excludedTypes.includes(assetType)}"
+ @click="${(e: Event) => e.stopPropagation()}"
+ @change="${(ev: Event) => {
+ const checked = (ev.currentTarget as any).checked;
+ this._setExcluded(assetType, !checked);
+ }}"
+ ></or-vaadin-checkbox>
+ </div>
+ </or-vaadin-item>
+ `)}
+ </or-vaadin-list-box>
+ </div>
+ `;
+ }
+}
+
+export class OrMapLegendControl extends OrMapBaseControl {
+ private _component?: OrMapLegend;
+
+ constructor(
+ private _assetTypes: string[],
+ private _excludedTypes: string[],
+ private _assetCounts: Record<string, number>
+ ) { super(); }
+
+ onAdd(_map: MapGL): HTMLElement {
+ this._createContainer();
+ this._container!.classList.add("legend-control");
+ this._component = document.createElement("or-map-legend") as OrMapLegend;
+ this._component.assetTypes = this._assetTypes;
+ this._component.excludedTypes = this._excludedTypes;
+ this._component.assetCounts = this._assetCounts;
+ this._container!.appendChild(this._component);
+ return this._container!;
+ }
+
+ onRemove(): void {
+ super.onRemove();
+ this._component = undefined;
+ }
+
+ update(types: string[], counts: Record<string, number>) {
+ const prevTypes = new Set(this._assetTypes);
+ const typesChanged = types.length !== prevTypes.size || types.some(t => !prevTypes.has(t));
+ if (typesChanged) this.assetTypes = types;
+ this.assetCounts = counts;
+ }
+
+ clear() {
+ this.assetTypes = [];
+ this.assetCounts = {};
+ this.excludedTypes = [];
+ }
+
+ set assetTypes(types: string[]) {
+ this._assetTypes = types;
+ if (this._component) this._component.assetTypes = types;
+ }
+
+ set assetCounts(counts: Record<string, number>) {
+ this._assetCounts = counts;
+ if (this._component) this._component.assetCounts = counts;
+ }
+
+ set excludedTypes(types: string[]) {
+ this._excludedTypes = types;
+ if (this._component) this._component.excludedTypes = types;
+ }
+
+ get element(): OrMapLegend | undefined {
+ return this._component;
+ }
+}
diff --git a/ui/component/or-map/src/controls/logo.ts b/ui/component/or-map/src/controls/logo.ts
new file mode 100644
index 000000000..e1d108eef
--- /dev/null
+++ b/ui/component/or-map/src/controls/logo.ts
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { OrMapBaseControl } from "./base";
+import "@openremote/or-icon";
+
+export class OrLogoControl extends OrMapBaseControl {
+ onAdd(): HTMLElement {
+ const a = document.createElement("a");
+ a.href = "https://openremote.io/";
+ a.target = "_blank";
+ a.rel = "noopener noreferrer";
+ a.style.cssText = "margin-left:10px;height:24px;pointer-events:auto;";
+ const icon = document.createElement("or-icon");
+ icon.setAttribute("icon", "or:logo-grayscale");
+ a.appendChild(icon);
+ return (this._container = a);
+ }
+}
diff --git a/ui/component/or-map/src/controls/navigation.ts b/ui/component/or-map/src/controls/navigation.ts
new file mode 100644
index 000000000..2129df178
--- /dev/null
+++ b/ui/component/or-map/src/controls/navigation.ts
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { css, html, LitElement } from "lit";
+import { customElement, state } from "lit/decorators.js";
+import type { Map as MapGL } from "maplibre-gl";
+import { OrMapBaseControl } from "./base";
+import { i18next } from "@openremote/or-translate";
+import "@openremote/or-vaadin-components/or-vaadin-button";
+import "@openremote/or-icon";
+
+@customElement("or-map-navigation")
+export class OrMapNavigation extends LitElement {
+
+ static get styles() {
+ return css`
+ :host {
+ display: flex;
+ flex-direction: column;
+ background: white;
+ overflow: hidden;
+ border-radius: var(--lumo-border-radius-m, 4px);
+ }
+
+ or-vaadin-button {
+ --lumo-border-radius-m: 0;
+ }
+
+ or-icon {
+ --or-icon-width: 18px;
+ --or-icon-height: 18px;
+ color: black;
+ transition: transform 0.1s ease;
+ }
+ `;
+ }
+
+ @state()
+ private _bearing = 0;
+
+ private _map?: MapGL;
+
+ private _onRotate = () => {
+ this._bearing = -(this._map?.getBearing() ?? 0);
+ };
+
+ public setMap(map: MapGL): void {
+ this._map = map;
+ map.on("rotate", this._onRotate);
+ }
+
+ public disconnectedCallback() {
+ super.disconnectedCallback();
+ this._map?.off("rotate", this._onRotate);
+ }
+
+ protected render() {
+ return html`
+ <or-vaadin-button theme="icon" title="${i18next.t("mapPage.zoomIn")}" @click="${() => this._map?.zoomIn()}">
+ <or-icon icon="mdi:plus"></or-icon>
+ </or-vaadin-button>
+ <or-vaadin-button theme="icon" title="${i18next.t("mapPage.zoomOut")}" @click="${() => this._map?.zoomOut()}">
+ <or-icon icon="mdi:minus"></or-icon>
+ </or-vaadin-button>
+ <or-vaadin-button theme="icon" title="${i18next.t("mapPage.resetBearing")}" @click="${() => this._map?.resetNorthPitch({ duration: 200 })}">
+ <or-icon icon="or:compass" style="transform: rotate(${this._bearing}deg)"></or-icon>
+ </or-vaadin-button>
+ `;
+ }
+}
+
+export class OrMapNavigationControl extends OrMapBaseControl {
+ private _component?: OrMapNavigation;
+
+ onAdd(map: MapGL): HTMLElement {
+ this._createContainer();
+ this._component = document.createElement("or-map-navigation") as OrMapNavigation;
+ this._component.setMap(map);
+ this._container!.appendChild(this._component);
+ return this._container!;
+ }
+
+ onRemove(): void {
+ super.onRemove();
+ this._component = undefined;
+ }
+}
diff --git a/ui/component/or-map/src/controls/preset-filter.ts b/ui/component/or-map/src/controls/preset-filter.ts
new file mode 100644
index 000000000..bde606115
--- /dev/null
+++ b/ui/component/or-map/src/controls/preset-filter.ts
@@ -0,0 +1,289 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { css, html, LitElement, nothing, PropertyValues, TemplateResult } from "lit";
+import { countBadgeStyle } from "./styles";
+import { customElement, property, state } from "lit/decorators.js";
+import manager, { OREvent, Util } from "@openremote/core";
+import { i18next } from "@openremote/or-translate";
+import "@openremote/or-vaadin-components/or-vaadin-badge";
+import "@openremote/or-vaadin-components/or-vaadin-select";
+import "@openremote/or-vaadin-components/or-vaadin-item";
+import "@openremote/or-vaadin-components/or-vaadin-list-box";
+import { selectRenderer } from "@openremote/or-vaadin-components/or-vaadin-select"
+import type { Map as MapGL } from "maplibre-gl";
+import { OrMapBaseControl } from "./base";
+import { AssetWithLocation, MapFilter } from "../types";
+import { formatCount } from "../util";
+
+import { AssetQuery } from "@openremote/model";
+
+export class OrMapPresetFilterEvent extends CustomEvent<AssetQuery | null> {
+ public static readonly NAME = "or-map-preset-filter-changed";
+
+ constructor(filter: AssetQuery | null) {
+ super(OrMapPresetFilterEvent.NAME, {
+ bubbles: true,
+ composed: true,
+ detail: filter
+ });
+ }
+}
+
+declare global {
+ export interface HTMLElementEventMap {
+ [OrMapPresetFilterEvent.NAME]: OrMapPresetFilterEvent;
+ }
+}
+
+// Registered once at module load — survives SPA navigation so it fires on login
+// regardless of which page is active.
+manager.addListener((event) => {
+ if (event !== OREvent.LOGIN) return;
+ for (let i = localStorage.length - 1; i >= 0; i--) {
+ const key = localStorage.key(i);
+ if (key?.startsWith("or-map-filter:")) localStorage.removeItem(key);
+ }
+});
+
+@customElement("or-map-preset-filter")
+export class OrMapPresetFilter extends LitElement {
+
+ static get styles() {
+ return [countBadgeStyle, css`
+ :host {
+ display: block;
+ }
+ .filter-container {
+ position: relative;
+ display: block;
+ }
+ or-vaadin-select {
+ width: 320px;
+ --vaadin-input-field-background: white;
+ }
+ vaadin-select-item::part(content) {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: calc(100% - 60px);
+ }
+ @media only screen and (max-width: 40em) {
+ :host {
+ width: 100%;
+ }
+ or-vaadin-select {
+ width: 100%;
+ }
+ }
+ .filter-field-count {
+ position: absolute;
+ right: 40px;
+ top: 50%;
+ transform: translateY(-50%);
+ pointer-events: none;
+ }
+ `];
+ }
+
+ @property({ type: Array })
+ public filters: MapFilter[] = [];
+
+ @property({ type: Array })
+ public assets: AssetWithLocation[] = [];
+
+ @state()
+ protected _activeIndex = 0;
+
+ protected _getFilterLabel(filter: MapFilter): string {
+ if (filter.label) return filter.label;
+ const { query } = filter;
+ const types = query.types;
+ const typeLabel = types?.length
+ ? types.map(t => Util.getAssetTypeLabel(t).replace(/\s*asset\s*$/i, "").trim()).join(" + ")
+ : i18next.t("mapPage.filterCustom");
+ const attrValues = (query.attributes?.items ?? [] as any[])
+ .map((item: any) => {
+ const val = item.value?.value;
+ if (val === undefined || val === null) return null;
+ if (typeof val === "string") {
+ return val.replace(/_/g, " ").toLowerCase().replace(/^\w/, c => c.toUpperCase());
+ }
+ return String(val);
+ })
+ .filter(Boolean);
+ return attrValues.length ? `${typeLabel}: ${attrValues.join(", ")}` : typeLabel;
+ }
+
+ protected _getFilterCount(filterIndex: number): number {
+ if (filterIndex === 0) return this.assets.length;
+ const query = new Util.AssetQueryHelper(this.filters[filterIndex - 1].query);
+ return this.assets.filter(a => query.matches(a)).length;
+ }
+
+ protected _buildOptions() {
+ const all = { value: "0", label: i18next.t("mapPage.filterAll"), count: this.assets.length, warning: undefined as string | undefined };
+ const filters = this.filters
+ .map((filter, i) => {
+ const unsupported = Util.AssetQueryHelper.getUnsupportedFields(filter.query);
+ return {
+ value: String(i + 1),
+ label: this._getFilterLabel(filter),
+ count: this._getFilterCount(i + 1),
+ warning: unsupported.length ? `Filter ${i + 1}: ${unsupported.join(", ")} not supported` : undefined,
+ };
+ })
+ .sort((a, b) => a.label.localeCompare(b.label));
+ return [all, ...filters];
+ }
+
+ protected _renderFilterOptions(): TemplateResult {
+ const options = this._buildOptions();
+ return html`
+ <style>
+ .filter-item {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--lumo-space-l) + var(--lumo-border-radius-m) / 4);
+ padding-right: 4px;
+ }
+ .filter-item__label {
+ flex: 1;
+ }
+ .filter-item__label--warning {
+ color: var(--lumo-warning-text-color, #c46c0c);
+ }
+ .filter-item__warning {
+ font-size: var(--lumo-font-size-xs);
+ color: var(--lumo-warning-text-color, #c46c0c);
+ white-space: nowrap;
+ }
+ or-vaadin-item.filter-option {
+ padding: unset;
+ }
+ ${countBadgeStyle}
+ </style>
+ <or-vaadin-list-box>
+ ${options.map(opt => html`
+ <or-vaadin-item class="filter-option" value="${opt.value}" label="${opt.label}">
+ <div class="filter-item">
+ <span class="filter-item__label ${opt.warning ? 'filter-item__label--warning' : ''}">${opt.warning ? '⚠ ' : ''}${opt.label}</span>
+ ${opt.warning ? html`<span class="filter-item__warning">${opt.warning}</span>` : nothing}
+ <or-vaadin-badge class="filter-item__count">${formatCount(opt.count)}</or-vaadin-badge>
+ </div>
+ </or-vaadin-item>
+ `)}
+ </or-vaadin-list-box>
+ `;
+ }
+
+ protected render() {
+ const currentCount = this._getFilterCount(this._activeIndex);
+ return html`
+ <div class="filter-container">
+ <or-vaadin-select
+ .value="${String(this._activeIndex)}"
+ ${selectRenderer(this._renderFilterOptions, [this.filters, this.assets])}
+ @change="${this._onChange}"
+ ></or-vaadin-select>
+ <or-vaadin-badge class="filter-field-count">${formatCount(currentCount)}</or-vaadin-badge>
+ </div>
+ `;
+ }
+
+ private _cachedStorageKey?: string;
+
+ private _getStorageKey(): string {
+ if (!this._cachedStorageKey) {
+ this._cachedStorageKey = `or-map-filter:${manager.displayRealm}:${manager.username}`;
+ }
+ return this._cachedStorageKey;
+ }
+
+ protected updated(changedProperties: PropertyValues) {
+ if (changedProperties.has("filters") && this.filters.length) {
+ const stored = localStorage.getItem(this._getStorageKey());
+ const storedIndex = stored !== null ? parseInt(stored, 10) : -1;
+ const isValidStored = storedIndex >= 0 && storedIndex <= this.filters.length;
+
+ if (isValidStored) {
+ this._activeIndex = storedIndex;
+ } else {
+ const defaultIndex = this.filters.findIndex(f => f.default);
+ if (defaultIndex >= 0) this._activeIndex = defaultIndex + 1;
+ }
+
+ if (this._activeIndex > 0) {
+ this.dispatchEvent(new OrMapPresetFilterEvent(this.filters[this._activeIndex - 1].query));
+ }
+ }
+ }
+
+ protected _onChange(e: Event) {
+ this._activeIndex = parseInt((e.target as HTMLInputElement).value, 10) || 0;
+ localStorage.setItem(this._getStorageKey(), String(this._activeIndex));
+ const filter = this._activeIndex > 0 ? this.filters[this._activeIndex - 1].query : null;
+ this.dispatchEvent(new OrMapPresetFilterEvent(filter));
+ }
+}
+
+export class OrMapPresetFilterControl extends OrMapBaseControl {
+ private _component?: OrMapPresetFilter;
+
+ constructor(private _filters: MapFilter[], private _assets: AssetWithLocation[]) { super(); }
+
+ onAdd(_map: MapGL): HTMLElement {
+ this._createContainer();
+ this._container!.classList.add("preset-filter-control");
+ this._component = document.createElement("or-map-preset-filter") as OrMapPresetFilter;
+ this._component.filters = this._filters;
+ this._component.assets = this._assets;
+ this._container!.appendChild(this._component);
+ return this._container!;
+ }
+
+ onRemove(): void {
+ super.onRemove();
+ this._component = undefined;
+ }
+
+ set assets(assets: AssetWithLocation[]) {
+ this._assets = assets;
+ if (this._component) this._component.assets = assets;
+ }
+
+ clear() {
+ this.assets = [];
+ }
+
+ /** Returns the initial filter synchronously by reading localStorage — call before flushing the asset buffer. */
+ getInitialFilter(): AssetQuery | null {
+ const key = `or-map-filter:${manager.displayRealm}:${manager.username}`;
+ const stored = localStorage.getItem(key);
+ const storedIndex = stored !== null ? parseInt(stored, 10) : -1;
+ const isValid = storedIndex >= 0 && storedIndex <= this._filters.length;
+ if (isValid && storedIndex > 0) return this._filters[storedIndex - 1].query;
+ const defaultIndex = this._filters.findIndex(f => f.default);
+ if (defaultIndex >= 0) return this._filters[defaultIndex].query;
+ return null;
+ }
+
+ get element(): OrMapPresetFilter | undefined {
+ return this._component;
+ }
+}
diff --git a/ui/component/or-map/src/controls/styles.ts b/ui/component/or-map/src/controls/styles.ts
new file mode 100644
index 000000000..93dd38206
--- /dev/null
+++ b/ui/component/or-map/src/controls/styles.ts
@@ -0,0 +1,11 @@
+import { css } from "lit";
+
+export const countBadgeStyle = css`
+ or-vaadin-badge {
+ --vaadin-badge-background: var(--shades-contrast-10, #3A463A0D);
+ border-radius: calc(var(--lumo-border-radius-m) + 2px);
+ font-size: 12px;
+ color: var(--lumo-secondary-text-color);
+ padding: 0 calc(var(--lumo-space-m) - 4px);
+ }
+`;
diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.ts
index abebdd017..dd2571cc3 100644
--- a/ui/component/or-map/src/index.ts
+++ b/ui/component/or-map/src/index.ts
@@ -1,18 +1,36 @@
-import manager, {EventCallback} from "@openremote/core";
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import manager, { EventCallback } from "@openremote/core";
import {html, LitElement, PropertyValues} from "lit";
import {customElement, property, query} from "lit/decorators.js";
-import {IControl, LngLat, LngLatLike, GeolocateControl} from "maplibre-gl";
+import {IControl, LngLat, LngLatLike} from "maplibre-gl";
import {style} from "./style";
import "./markers/or-map-marker";
import "./markers/or-map-marker-asset";
import "@openremote/or-vaadin-components/or-vaadin-text-field"
import {OrMapMarker, OrMapMarkerChangedEvent} from "./markers/or-map-marker";
import * as Util from "./util";
-import {
- InputType,
+import type {
ValueInputProviderGenerator,
ValueInputTemplateFunction
-} from "@openremote/or-mwc-components/or-mwc-input";
+} from "@openremote/or-vaadin-components/value-input-provider";
import {OrMwcDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";
import {getMarkerIconAndColorFromAssetType} from "./util";
import {i18next} from "@openremote/or-translate";
@@ -20,9 +38,10 @@ import debounce from "lodash.debounce";
import { AttributeEvent, GeoJsonConfig } from "@openremote/model";
import { CoordinatesControl, CoordinatesRegexPattern, getCoordinatesInputKeyHandler } from "./controls/coordinates";
import { AssetMap } from "./asset-map";
-import { CenterControl } from "./controls/center";
+import { OrMapCenterControl } from "./controls/center";
+import { OrMapGeolocateControl } from "./controls/geolocate";
import { ifDefined } from "lit-html/directives/if-defined.js";
-import type { AssetWithLocation, ClusterConfig, ControlPosition, MapEventDetail, MapGeocoderEventDetail } from "./types";
+import type { AssetWithLocation, ClusterConfig, ControlPosition, MapEventDetail, MapFilter } from "./types";
// Re-exports
export {Util, LngLatLike, LngLat};
@@ -31,7 +50,9 @@ export * from "./markers/or-map-marker-asset";
export * from "./markers/or-cluster-marker";
export {IControl} from "maplibre-gl";
export * from "./or-map-asset-card";
-export * from "./or-map-legend";
+export * from "./controls/legend";
+export * from "./controls/preset-filter";
+export * from "./controls/geocoder";
export type * from "./types";
export class OrMapLoadedEvent extends CustomEvent<void> {
@@ -78,21 +99,6 @@ export class OrMapLongPressEvent extends CustomEvent<MapEventDetail> {
}
}
-export class OrMapGeocoderChangeEvent extends CustomEvent<MapGeocoderEventDetail> {
-
- public static readonly NAME = "or-map-geocoder-change";
-
- constructor(geocode: any) {
- super(OrMapGeocoderChangeEvent.NAME, {
- detail: {
- geocode
- },
- bubbles: true,
- composed: true
- });
- }
-}
-
export class OrMapMarkersChangedEvent extends CustomEvent<AssetWithLocation[]> {
public static readonly NAME = "or-map-markers-changed";
@@ -111,7 +117,6 @@ declare global {
[OrMapClickedEvent.NAME]: OrMapClickedEvent;
[OrMapLoadedEvent.NAME]: OrMapLoadedEvent;
[OrMapLongPressEvent.NAME]: OrMapLongPressEvent;
- [OrMapGeocoderChangeEvent.NAME]: OrMapGeocoderChangeEvent;
[OrMapMarkersChangedEvent.NAME]: OrMapMarkersChangedEvent;
}
}
@@ -121,8 +126,7 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
const disabled = !!(options && options.disabled);
const readonly = !!(options && options.readonly);
const compact = !!(options && options.compact);
- const comfortable = !!(options && options.comfortable);
- const centerControl = new CenterControl();
+ const centerControl = new OrMapCenterControl();
const valueChangeHandler = (value: LngLatLike | undefined) => {
if (!valueChangeNotifier) {
@@ -140,6 +144,19 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
const coordinatesControl = new CoordinatesControl(disabled, valueChangeHandler);
let pos: { lng: number, lat: number } | null | undefined;
+ // 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"],
+ ];
+ if (!readonly) {
+ const userLocationControl = new OrMapGeolocateControl((currentLocation: GeolocationPosition) => {
+ _setPos?.(new LngLat(currentLocation.coords.longitude, currentLocation.coords.latitude));
+ });
+ controls.push([userLocationControl, "bottom-right"]);
+ }
+
const templateFunction: ValueInputTemplateFunction = (value, focused, loading, sending, error, helperText) => {
let center: number[] | undefined;
@@ -157,7 +174,7 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
let dialog: OrMwcDialog | undefined;
- const setPos = (lngLat: LngLatLike | null) => {
+ _setPos = (lngLat: LngLatLike | null) => {
if (readonly || disabled) {
return;
}
@@ -176,27 +193,7 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
valueChangeHandler(pos as LngLatLike);
}
};
-
- const controls = [[centerControl, "bottom-left"], [coordinatesControl, "top-right"]]
-
- if (!readonly) {
-
- const userLocationControl = new GeolocateControl({
- positionOptions: {
- enableHighAccuracy: true
- },
- showAccuracyCircle: false,
- showUserLocation: false
- });
-
- userLocationControl.on('geolocate', (currentLocation: GeolocationPosition) => {
- setPos(new LngLat(currentLocation.coords.longitude, currentLocation.coords.latitude));
- });
- userLocationControl.on('outofmaxbounds', (currentLocation: GeolocationPosition) => {
- setPos(new LngLat(currentLocation.coords.longitude, currentLocation.coords.latitude));
- });
- controls.push([userLocationControl, "bottom-left"]);
- }
+ const setPos = _setPos;
let content = html`
<or-map id="geo-json-point-map" class="or-map" @or-map-long-press="${(ev: OrMapLongPressEvent) => {setPos(ev.detail.lngLat);}}" .center="${center}" .controls="${controls}" .showGeoCodingControl=${!readonly}>
@@ -268,10 +265,6 @@ export const geoJsonPointInputTemplateProvider: ValueInputProviderGenerator = (a
<or-vaadin-button theme="icon" @click=${onClick}>
<or-icon icon="crosshairs-gps"></or-icon>
</or-vaadin-button>
- <!--<div style="display: flex">
- <or-mwc-input .comfortable="${comfortable}" .type="${InputType.TEXT}" .value="${centerStr}" .pattern="${CoordinatesRegexPattern}" @keyup="${(e: KeyboardEvent) => getCoordinatesInputKeyHandler(valueChangeHandler)(e)}"></or-mwc-input>
- <or-mwc-input style="width: unset" .type="${InputType.BUTTON}" compact icon="crosshairs-gps" @or-mwc-input-changed="${onClick}"></or-mwc-input>
- </div>-->
</div>
`;
}
@@ -344,6 +337,12 @@ export class OrMap extends LitElement {
@property({type: Array})
public boundary: string[] = [];
+ @property({type: Array})
+ public filters?: MapFilter[];
+
+ @property({type: Boolean})
+ public showLegend: boolean = true;
+
public controls?: (IControl | [IControl, ControlPosition?])[];
protected _initCallback?: EventCallback;
@@ -372,7 +371,7 @@ export class OrMap extends LitElement {
}
public updateAttribute(event: AttributeEvent) {
- this._map?.updateAttribute(event)
+ this._map?.updateAttribute(event);
}
public removeAssets(ids: string[]) {
@@ -404,9 +403,6 @@ export class OrMap extends LitElement {
<div id="container">
<div id="map"></div>
<slot></slot>
- <a id="openremote" href="https://openremote.io/" target="_blank">
- <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAABGdBTUEAAYagMeiWXwAAAAJiS0dEAP+Hj8y/AAAESUlEQVRIx5XVbWzdZRnH8c//f07POe36sK7SrYXZjYGzbBokOqd4QtKATdnMDFFSkoFzmWGRQOAFSoYnsBSzxBdmGsN4Y7LEFwZkUdHpDoja/AnJjBvp1sm2upW5PtAV+zBS+7Tz//tiLe0emPF+d9/39fvmunJf9+8K3HBF1drFzurVn5+5XkTwPwBNOt1s0pCjDnnT+Xzy/wOa5jaXnLLfLwzlF0WENwaYckyvUTHS1tnjl+6JFqk+JoMOqqy2JqjPVpXP1k7U1+Ty8paBPk97NX/pYwEdgZUetNkdlirDrHGnyv6y5r3lm4M2WVzwpJfz8XUBHTntnrJO6qqLWE9u/125zBNq0WebN/PXAjqq/cBOVWDasCEsd5MsmEzt/3xP+S6fwNsezPdfBejI6fCEDMa95oAT/t31pVxDQ6p6oy2WYSb18w0D2V3Klez2w3y8CNAR2G6vShxXUCxMkXLvS7Y6E/5+3emaJ92JqezzG+8M2nHW/flTi59xladU4phtfluYgnsDWUt8Nv7+8UfO73UUuenvDLxuCKu0RQt90BFo14wxzzpamD8uExtHSsu5HSP7XMCtZ5uTPyO0SdVCBlXahHjNG4WFrGY9Y4tXzODL7zb7NYJS64eHzWK92xYAa9yBKa8Wphf0xaQ4XOz0qF9JhMnXh//mIm4dnDSMOusWALepwQUnrm2t4pi9hrGyP+ccloxV6kOZFemoWi2mOpclaQycqGlt9R8XHS/GixinnVWvbDpjDEEpNpdnWrtd+HvZWzMQT9xjj1iXzUau6MPS9X9NKOeTmqzPpZWwfMkEKnza2ivimqxCKZjQa9BMmFI2D+gxibql4z7EiobYOSy1o7V6Xt1aYacGvD/7lse1+GZ9t0Zc8kHaGcOa1K6o+FePL1iy7K7wYHy70FZa9+qVWOm7tgslfpecKcy46GS0xXKM6g6d14VU+RfTnRJ8Y223w8j4tkMOOeR1j6nAMT8tzkCUcvlbn3ImbJn0RyWC+1af1Iv6ukcbf+aIRKDR3b5ipVCiy+PenaupWRsSfzCWim0ftUmdiqrJwWLpbmk3196UfXG0X6NKIWKDXva0I0UQZT2nRaDfc/mhgCj0PS9ImZzefbg5fliIvuTA++/0ZaYDTDqqpzhn6lHoW36iSuLHnslfCiBqdMBGDI6/0LUhfkgGiWFbC29c+epRaJMX3YJuD+R75l15wG4DaKh5dsPJsj0GXLaawavkWY/MyUcU/JOPHCkK7fAjNZiIf/PeX/vWx1814muF0Y/EKWs95mFVuKhgX352EYAoY5vnNSDRF/9p/MgHfQ2dldNIqbPeJm2aBBix20vzg26RpUUpLfb43FxZU4YMmEJGoxXKQeIfCg4uzMkrTDVitZ0ecst1B05i0Cv26Vk8H68JjFKabXa/Zkul5w5Lxp120EHdlyu/AQCiQI1P+YxaGcwY1+20kasnM/wXCa5/Ik1hKTEAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDgtMjBUMTU6MTc6NTUrMDA6MDCwJSdSAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTA4LTIwVDE1OjE3OjU1KzAwOjAwwXif7gAAAABJRU5ErkJggg==" />
- </a>
</div>
`;
}
@@ -419,6 +415,12 @@ export class OrMap extends LitElement {
if (changedProperties.has("boundary") && this.showBoundaryBoxControl){
this._map?.createBoundaryBox(this.boundary)
}
+ if (changedProperties.has("filters")) {
+ this._map?.setFilters(this.filters);
+ }
+ if (changedProperties.has("showLegend")) {
+ this._map?.setShowLegend(this.showLegend);
+ }
}
public refresh() {
@@ -437,7 +439,7 @@ export class OrMap extends LitElement {
}
if (this._mapContainer && this._slotElement) {
- this._map = new AssetMap(this.shadowRoot!, this._mapContainer, this.showGeoCodingControl, this.showBoundaryBoxControl, this.useZoomControl, this.showGeoJson, this.cluster)
+ this._map = new AssetMap(this.shadowRoot!, this._mapContainer, this, this.showGeoCodingControl, this.showBoundaryBoxControl, this.useZoomControl, this.showGeoJson, this.cluster, this.filters, this.showLegend)
.setCenter(this.center)
.setZoom(this.zoom)
.setControls(this.controls)
diff --git a/ui/component/or-map/src/markers/or-cluster-marker.ts b/ui/component/or-map/src/markers/or-cluster-marker.ts
index f3297595c..8fb93a8bb 100644
--- a/ui/component/or-map/src/markers/or-cluster-marker.ts
+++ b/ui/component/or-map/src/markers/or-cluster-marker.ts
@@ -1,4 +1,5 @@
import { svg as html /** Aliased for syntax highlighting */, LitElement, TemplateResult, SVGTemplateResult } from "lit";
+import { formatCount } from "../util";
import { customElement } from "lit/decorators.js";
import { GeoJSONSource, Map } from "maplibre-gl";
@@ -19,9 +20,6 @@ export class OrClusterMarker extends LitElement {
protected _clusterId?: number;
protected _map: Map;
- protected _highThreshold = 99;
- protected _midTreshold = this._highThreshold / 10;
- protected _lowTreshold = this._midTreshold / 10;
constructor(slices: Slice[], clusterId: number, lng: number, lat: number, map: Map) {
super();
@@ -61,15 +59,13 @@ export class OrClusterMarker extends LitElement {
total += slice[2];
}
- const fontSize = total >= this._highThreshold ? 18 : total >= this._midTreshold ? 16 : total >= this._lowTreshold ? 14 : 12;
- const r = total >= this._highThreshold ? 32 : total >= this._midTreshold ? 26 : total >= this._lowTreshold ? 16 : 12;
- const r2 = total >= this._highThreshold ? 28 : total >= this._midTreshold ? 24 : total >= this._lowTreshold ? 16 : 8;
+ const fontSize = total >= 1000 ? 18 : total >= 100 ? 16 : 14;
+ const r = total >= 1000 ? 32 : total >= 100 ? 26 : 16;
+ const r2 = total >= 1000 ? 28 : total >= 100 ? 24 : 16;
const dR = r - r2;
const innerRadius: number = Math.round(r * 0.6);
const w: number = r * 2;
- const isClusterCountlimitSurpassed = total > this._highThreshold
-
return html`
<svg
width="${w}"
@@ -86,7 +82,7 @@ export class OrClusterMarker extends LitElement {
))}
<circle cx="${r}" cy="${r}" r="${innerRadius}" fill="white" />
<text dominant-baseline="central" transform="translate(${r}, ${r})">
- ${(isClusterCountlimitSurpassed ? this._highThreshold : total).toLocaleString() + (isClusterCountlimitSurpassed ? "+" : "")}
+ ${formatCount(total)}
</text>
</svg>
`;
diff --git a/ui/component/or-map/src/or-map-legend.ts b/ui/component/or-map/src/or-map-legend.ts
deleted file mode 100644
index 06b66f29b..000000000
--- a/ui/component/or-map/src/or-map-legend.ts
+++ /dev/null
@@ -1,107 +0,0 @@
-import { CSSResultGroup, html, LitElement, PropertyValues } from "lit";
-import { customElement, property, query } from "lit/decorators.js";
-import { mapAssetLegendStyle } from "./style";
-import { AssetModelUtil } from "@openremote/model";
-import { getMarkerIconAndColorFromAssetType } from "./util";
-import { Util } from "@openremote/core";
-import { InputType, OrInputChangedEvent } from "@openremote/or-mwc-components/or-mwc-input";
-
-export class OrMapLegendEvent extends CustomEvent<string[]> {
- public static readonly NAME = "or-map-legend-changed";
-
- constructor(assetTypes: string[]) {
- super(OrMapLegendEvent.NAME, {
- bubbles: false,
- composed: false,
- detail: assetTypes,
- });
- }
-}
-
-declare global {
- export interface HTMLElementEventMap {
- [OrMapLegendEvent.NAME]: OrMapLegendEvent;
- }
-}
-
-@customElement("or-map-legend")
-export class OrMapLegend extends LitElement {
-
- static get styles(): CSSResultGroup {
- return mapAssetLegendStyle;
- }
-
- @property({ type: Array })
- public assetTypes: string[] = [];
-
- @property({ type: Array })
- public excludedTypes: string[] = [];
-
- protected _assetTypesInfo: any;
-
- @query("#legend-content")
- protected _showLegend?: HTMLDivElement;
-
- protected shouldUpdate(changedProperties: PropertyValues): boolean {
- if (changedProperties.has("assetTypes")) {
- this._assetTypesInfo = {};
-
- this.assetTypes.forEach((assetType: string) => {
- const descriptor = AssetModelUtil.getAssetDescriptor(assetType);
- const icon = getMarkerIconAndColorFromAssetType(descriptor)?.icon;
- const color = getMarkerIconAndColorFromAssetType(descriptor)?.color;
- const label = Util.getAssetTypeLabel(descriptor);
-
- this._assetTypesInfo[assetType] = {
- icon: icon,
- color: color,
- label: label,
- };
- });
- }
-
- return super.shouldUpdate(changedProperties);
- }
-
- protected _onHeaderClick() {
- if (this._showLegend) {
- this._showLegend.hidden = !this._showLegend.hidden;
- }
- }
-
- protected render() {
- return html`
- <div id="legend">
- <div id="legend-title" @click="${() => this._onHeaderClick()}">
- <or-translate value="mapPage.legendTitle"></or-translate><or-icon style="cursor: pointer" icon="menu"></or-icon>
- </div>
- <div id="legend-content" hidden>
- <ul>
- ${this.assetTypes.map(
- (assetType) => html`<li id="asset-legend" data-asset-type="${assetType}" style="display: flex;">
- <or-icon
- icon="${this._assetTypesInfo[assetType].icon}"
- style="color: #${this._assetTypesInfo[assetType].color}"
- ></or-icon>
- <span id="asset-label" style="flex: 1">${this._assetTypesInfo[assetType].label}</span>
- <or-mwc-input
- .type="${InputType.CHECKBOX}"
- .value="${!this.excludedTypes.includes(assetType)}"
- @or-mwc-input-changed="${(ev: OrInputChangedEvent) => {
- if (ev.detail.value) {
- this.excludedTypes.splice(this.excludedTypes.indexOf(assetType), 1);
- } else {
- this.excludedTypes.push(assetType);
- }
- this.requestUpdate();
- this.dispatchEvent(new OrMapLegendEvent(this.excludedTypes));
- }}"
- ></or-mwc-input>
- </li>`
- )}
- </ul>
- </div>
- </div>
- `;
- }
-}
diff --git a/ui/component/or-map/src/style.ts b/ui/component/or-map/src/style.ts
index ff217bdb6..dd8f99e18 100644
--- a/ui/component/or-map/src/style.ts
+++ b/ui/component/or-map/src/style.ts
@@ -1,5 +1,5 @@
import {css, unsafeCSS} from "lit";
-import { DefaultColor1, DefaultColor2, DefaultColor3, DefaultColor4, DefaultColor5, DefaultHeaderHeight, DefaultBoxShadow} from "@openremote/core";
+import { DefaultColor1, DefaultColor2, DefaultColor3, DefaultColor4, DefaultColor5, DefaultHeaderHeight } from "@openremote/core";
export const markerColorVar = "--internal-or-map-marker-color";
export const markerActiveColorVar = "--internal-or-map-marker-active-color";
@@ -69,9 +69,51 @@ export const style = css`
}
/* Prevents overflow from elements outside the map component (like menu overlays). See #1844 */
- .maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-top-left, .maplibregl-ctrl-top-right {
+ .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-top-left {
z-index: 1;
}
+
+ .maplibregl-ctrl-bottom-right {
+ z-index: 1;
+ }
+
+ .maplibregl-ctrl-top-right {
+ transition: top 0.3s;
+ }
+
+ @media only screen and (max-width: 40em){
+ :host(.has-filters) .maplibregl-ctrl-top-right {
+ top: 46px;
+ }
+ :host(.has-filters) .maplibregl-ctrl-top-left {
+ right: 10px;
+ }
+ :host(.has-filters) .maplibregl-ctrl-top-left .preset-filter-control {
+ float: none;
+ }
+ .maplibregl-ctrl-bottom-right {
+ left: 10px;
+ }
+ .maplibregl-ctrl-bottom-right .legend-control {
+ float: none;
+ }
+ :host(.has-legend) .maplibregl-ctrl-bottom-left {
+ bottom: 50px;
+ }
+ }
+
+ @media only screen and (max-width: 450px) {
+ :host(#map) .maplibregl-ctrl-top-right {
+ left: 10px;
+ }
+ :host(#map) .maplibregl-ctrl-top-right .maplibregl-ctrl-group {
+ display: none;
+ }
+ :host(#map) .maplibregl-ctrl-top-right .geocoder-control {
+ width: calc(100% - 10px);
+ }
+ }
+
.maplibregl-marker {
pointer-events: none !important;
}
@@ -127,25 +169,14 @@ export const style = css`
--or-icon-height: var(--internal-or-map-marker-icon-active-height);
}
- #openremote {
- position: absolute;
- bottom: 25px;
- right: 5px;
- height: 20px;
- width: 20px;
- cursor: pointer;
- }
-
- #openremote img {
- height: 20px;
- width: 20px;
+ .maplibregl-ctrl-bottom-left {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
}
-
- @media only screen and (max-width: 640px) {
- #openremote {
- bottom: 40px;
- right: 12px;
- }
+
+ .maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib {
+ order: 1;
}
`;
@@ -241,71 +272,3 @@ export const mapAssetCardStyle = css`
}
`;
-export const mapAssetLegendStyle = css`
- :host {
- --internal-or-map-asset-legend-background-color: var(--or-map-asset-card-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
- --internal-or-map-asset-legend-header-height: var(--or-map-asset-card-header-height, calc(${unsafeCSS(DefaultHeaderHeight)} - 10px));
-
- display: block;
- }
-
- #legend {
- display: flex;
- flex-direction: column;
- }
-
- #legend-title {
- height: var(--internal-or-map-asset-legend-header-height);
- background-color: var(--internal-or-map-asset-legend-background-color);
- -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
- -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
- box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
- line-height: var(--internal-or-map-asset-legend-header-height);
- border-bottom: 1px solid ${unsafeCSS(DefaultColor5)};
- z-index: 99999;
- padding-left: 10px;
- padding-right: 10px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-radius: 3px;
- }
-
- #legend-content {
- -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
- -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
- box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
- background-color: var(--internal-or-map-asset-legend-background-color);
- margin-top: 10px;
- border-radius: 3px;
- padding: 5px 0 5px 10px;
- }
-
- #title {
- font-weight: 500;
- }
-
- #asset-legend {
- display: flex;
- align-items: center;
- }
-
- #asset-label {
- margin-left: 5px;
- }
-
- ul {
- list-style-type: none;
- margin: 0;
- padding: 0;
- }
-
- li {
- display: flex;
- line-height: 30px;
- -webkit-user-select: none;
- -ms-user-select: none;
- user-select: none;
- }
-}
-`
diff --git a/ui/component/or-map/src/types.ts b/ui/component/or-map/src/types.ts
index 3c6e4bfd4..327fa3770 100644
--- a/ui/component/or-map/src/types.ts
+++ b/ui/component/or-map/src/types.ts
@@ -1,4 +1,23 @@
-import { Asset, Attribute, GeoJsonConfig, WellknownAttributes } from "@openremote/model";
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+import { Asset, AssetQuery, Attribute, GeoJsonConfig, WellknownAttributes } from "@openremote/model";
import { LngLat, LngLatBoundsLike, LngLatLike } from "maplibre-gl";
import { Point } from "geojson";
@@ -10,6 +29,13 @@ export interface AssetWithLocation extends Asset {
};
}
+export interface MapFilter {
+ label?: string;
+ query: AssetQuery;
+ realms?: string[];
+ default?: boolean;
+}
+
export interface ClusterConfig {
cluster: boolean;
clusterRadius: number;
diff --git a/ui/component/or-map/src/util/index.ts b/ui/component/or-map/src/util/index.ts
index 84fb88009..d6f550518 100644
--- a/ui/component/or-map/src/util/index.ts
+++ b/ui/component/or-map/src/util/index.ts
@@ -1,3 +1,22 @@
+/*
+ * Copyright 2026, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
import {LngLat, LngLatBounds, LngLatBoundsLike, LngLatLike} from "maplibre-gl";
import {
Asset,
@@ -13,6 +32,19 @@ import {AttributeMarkerColoursRange, MapMarkerColours} from "../markers/or-map-m
import { Util } from "@openremote/core";
import { AssetWithLocation } from "..";
+let _compactFormatter: Intl.NumberFormat | undefined;
+
+export function formatCount(n: number): string {
+ if (!_compactFormatter) {
+ _compactFormatter = new Intl.NumberFormat("en", {
+ notation: "compact",
+ compactDisplay: "short",
+ maximumFractionDigits: 1
+ });
+ }
+ return _compactFormatter.format(n).toLowerCase();
+}
+
export function metersToPixelsAtMaxZoom(meters: number, latitude: number) {
return meters / 0.075 / Math.cos(latitude * Math.PI / 180);
}
diff --git a/ui/component/or-map/tsconfig.json b/ui/component/or-map/tsconfig.json
index e9bfba522..117f4e770 100644
--- a/ui/component/or-map/tsconfig.json
+++ b/ui/component/or-map/tsconfig.json
@@ -6,7 +6,6 @@
},
"include": [
"./src",
- "../or-map/@types"
],
"references": [
{ "path": "../core" },
diff --git a/ui/component/or-vaadin-components/package.json b/ui/component/or-vaadin-components/package.json
index 9bbb0103b..f0d6d2791 100644
--- a/ui/component/or-vaadin-components/package.json
+++ b/ui/component/or-vaadin-components/package.json
@@ -31,6 +31,7 @@
"dependencies": {
"@openremote/core": "workspace:*",
"@openremote/model": "workspace:*",
+ "@vaadin/badge": "~25.1.4",
"@vaadin/button": "~25.1.4",
"@vaadin/checkbox": "~25.1.4",
"@vaadin/checkbox-group": "~25.1.4",
diff --git a/ui/component/or-vaadin-components/src/or-vaadin-badge.ts b/ui/component/or-vaadin-components/src/or-vaadin-badge.ts
new file mode 100644
index 000000000..744754229
--- /dev/null
+++ b/ui/component/or-vaadin-components/src/or-vaadin-badge.ts
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2025, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import {customElement} from "lit/decorators.js";
+import {Badge} from "@vaadin/badge";
+import {OrVaadinComponent} from "./util";
+import {type LitElement} from "lit";
+
+@customElement("or-vaadin-badge")
+export class OrVaadinBadge extends (Badge as new () => Badge & LitElement) implements OrVaadinComponent {
+}
diff --git a/ui/component/or-vaadin-components/src/or-vaadin-select.ts b/ui/component/or-vaadin-components/src/or-vaadin-select.ts
index e410cd1d2..96e716084 100644
--- a/ui/component/or-vaadin-components/src/or-vaadin-select.ts
+++ b/ui/component/or-vaadin-components/src/or-vaadin-select.ts
@@ -23,6 +23,7 @@ import {OrVaadinComponent} from "./util";
import {type LitElement} from "lit";
export {SelectItem} from "@vaadin/select";
+export {selectRenderer} from "@vaadin/select/lit.js";
/**
* @slot label - The label element
diff --git a/ui/component/theme/src/components/index.css b/ui/component/theme/src/components/index.css
index bb38f7847..af002a593 100644
--- a/ui/component/theme/src/components/index.css
+++ b/ui/component/theme/src/components/index.css
@@ -22,6 +22,7 @@
* The import order can affect whether styling will be applied or not. This only
* 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 */
diff --git a/ui/component/theme/src/components/or-vaadin-badge.css b/ui/component/theme/src/components/or-vaadin-badge.css
new file mode 100644
index 000000000..c7d3b6798
--- /dev/null
+++ b/ui/component/theme/src/components/or-vaadin-badge.css
@@ -0,0 +1,7 @@
+@import "@vaadin/vaadin-lumo-styles/components/badge.css";
+
+:root::before,
+:host::before {
+ --_lumo-vaadin-badge-inject: 1;
+ --_lumo-vaadin-badge-inject-modules: lumo_components_badge;
+}
diff --git a/ui/test/app.config.cts b/ui/test/app.config.cts
index a6fd5f7fa..94882b322 100644
--- a/ui/test/app.config.cts
+++ b/ui/test/app.config.cts
@@ -65,6 +65,7 @@ export const defineAppConfig = (path: string) => {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "retain-on-failure",
video: "on",
+ locale: "en",
},
webServer: {
command: `node ${join(__dirname, "manager.cjs")}`,
diff --git a/yarn.lock b/yarn.lock
index e96919a3e..d6d5a0787 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -865,20 +865,6 @@ __metadata:
languageName: node
linkType: hard
-"@maplibre/maplibre-gl-geocoder@npm:^1.5.0":
- version: 1.5.0
- resolution: "@maplibre/maplibre-gl-geocoder@npm:1.5.0"
- dependencies:
- lodash.debounce: "npm:^4.0.6"
- subtag: "npm:^0.5.0"
- suggestions-list: "npm:^0.0.2"
- xtend: "npm:^4.0.1"
- peerDependencies:
- maplibre-gl: ">=1.14.0"
- checksum: 10c0/99b911f0081ef41c446ecc8458ce124a6405ff87e449444ca029cbc579d4d727701863e21ee5f1407da80e9f61a788615384bae91fe086562c69e48d077996ff
- languageName: node
- linkType: hard
-
"@maplibre/maplibre-gl-style-spec@npm:^24.4.1":
version: 24.10.0
resolution: "@maplibre/maplibre-gl-style-spec@npm:24.10.0"
@@ -2047,7 +2033,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@openremote/or-map@workspace:ui/component/or-map"
dependencies:
- "@maplibre/maplibre-gl-geocoder": "npm:^1.5.0"
"@openremote/core": "workspace:*"
"@openremote/model": "workspace:*"
"@openremote/or-icon": "workspace:*"
@@ -2204,6 +2189,7 @@ __metadata:
dependencies:
"@openremote/core": "workspace:*"
"@openremote/model": "workspace:*"
+ "@vaadin/badge": "npm:~25.1.4"
"@vaadin/button": "npm:~25.1.4"
"@vaadin/checkbox": "npm:~25.1.4"
"@vaadin/checkbox-group": "npm:~25.1.4"
@@ -3910,6 +3896,18 @@ __metadata:
languageName: node
linkType: hard
+"@vaadin/badge@npm:~25.1.4":
+ version: 25.1.4
+ resolution: "@vaadin/badge@npm:25.1.4"
+ dependencies:
+ "@vaadin/a11y-base": "npm:~25.1.4"
+ "@vaadin/component-base": "npm:~25.1.4"
+ "@vaadin/vaadin-themable-mixin": "npm:~25.1.4"
+ lit: "npm:^3.0.0"
+ checksum: 10c0/bffeb9145c28ba00251171962f757f92ed7aed62aa5bf9fe458ce351cfb1c1cf92b09207a55ce781a1e8e663e489b660c3631751e23746e1fb733ad98ad2fec5
+ languageName: node
+ linkType: hard
+
"@vaadin/button@npm:~25.1.4":
version: 25.1.4
resolution: "@vaadin/button@npm:25.1.4"
@@ -7203,13 +7201,6 @@ __metadata:
languageName: node
linkType: hard
-"fuzzy@npm:^0.1.1":
- version: 0.1.3
- resolution: "fuzzy@npm:0.1.3"
- checksum: 10c0/584fcd57a03431707a6d0c1c4a41f17368cdb23d37dcb176d6cbbeeaecaac51be15dec229b3547acfb7db052cb066fcd86db907d40112ac4a3d3a368f88e7105
- languageName: node
- linkType: hard
-
"gaugeJS@npm:1.3.9":
version: 1.3.9
resolution: "gaugeJS@npm:1.3.9"
@@ -8429,7 +8420,7 @@ __metadata:
languageName: node
linkType: hard
-"lodash.debounce@npm:^4.0.6, lodash.debounce@npm:^4.0.8":
+"lodash.debounce@npm:^4.0.8":
version: 4.0.8
resolution: "lodash.debounce@npm:4.0.8"
checksum: 10c0/762998a63e095412b6099b8290903e0a8ddcb353ac6e2e0f2d7e7d03abd4275fe3c689d88960eb90b0dde4f177554d51a690f22a343932ecbc50a5d111849987
@@ -10821,23 +10812,6 @@ __metadata:
languageName: node
linkType: hard
-"subtag@npm:^0.5.0":
- version: 0.5.0
- resolution: "subtag@npm:0.5.0"
- checksum: 10c0/f2827c76458cc1871c12c98d11d519c6027dee796c250fee0c5dc47d8afbab634afe9fe992de51887c5dd7172dd115501dcfc077f098bae81471f241260eb115
- languageName: node
- linkType: hard
-
-"suggestions-list@npm:^0.0.2":
- version: 0.0.2
- resolution: "suggestions-list@npm:0.0.2"
- dependencies:
- fuzzy: "npm:^0.1.1"
- xtend: "npm:^4.0.0"
- checksum: 10c0/76ffa6031c355b1c89b340ee6e24a0deee479357e51f3c4a1d9a7c12a6fd96b6351c465043d9948da52c0eb7888e96cadba737c9aeb2720231eaec9398bf807a
- languageName: node
- linkType: hard
-
"supercluster@npm:^8.0.1":
version: 8.0.1
resolution: "supercluster@npm:8.0.1"
@@ -11808,13 +11782,6 @@ __metadata:
languageName: node
linkType: hard
-"xtend@npm:^4.0.0, xtend@npm:^4.0.1":
- version: 4.0.2
- resolution: "xtend@npm:4.0.2"
- checksum: 10c0/366ae4783eec6100f8a02dff02ac907bf29f9a00b82ac0264b4d8b832ead18306797e283cf19de776538babfdcb2101375ec5646b59f08c52128ac4ab812ed0e
- languageName: node
- linkType: hard
-
"yallist@npm:^4.0.0":
version: 4.0.0
resolution: "yallist@npm:4.0.0"