100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
UI cleanup
Rich Turner9e8c5829fb6a
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.tsindex a886bad89..e61e5c8d2 100644--- a/ui/component/core/src/util.ts+++ b/ui/component/core/src/util.ts@@ -28,8 +28,8 @@ export class Deferred<T> {}export interface GeoNotification {- predicate: RadialGeofencePredicate- notification: PushNotificationMessage+ predicate: RadialGeofencePredicate;+ notification: PushNotificationMessage;}export function getGeoNotificationsFromRulesSet(rulesetDefinition: JsonRulesetDefinition): GeoNotification[] {diff --git a/ui/component/or-icon/src/icon-set-svg.ts b/ui/component/or-icon/src/icon-set-svg.tsindex 468c26839..2fb87174d 100644--- a/ui/component/or-icon/src/icon-set-svg.ts+++ b/ui/component/or-icon/src/icon-set-svg.ts@@ -1,15 +1,15 @@import {IconSet} from "./index";export class IconSetSvg implements IconSet {- icons: { [icon: string]: string };- size: number;+ public icons: { [icon: string]: string };+ public size: number;constructor(size: number, icons: { [icon: string]: string }) {this.size = size;this.icons = icons;}- getIcon(icon: string): Element | undefined {+ public getIcon(icon: string): Element | undefined {if (!icon) {return undefined;}@@ -18,16 +18,16 @@ export class IconSetSvg implements IconSet {return undefined;}- let iconData = this.icons[icon];- let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");+ const iconData = this.icons[icon];+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");svg.setAttribute("viewBox", "0 0 " + this.size + " " + this.size);svg.style.cssText = "pointer-events: none; display: block; width: 100%; height: 100%;";svg.setAttribute("preserveAspectRatio", "xMidYMid meet");svg.setAttribute("focusable", "false");- if (iconData.startsWith("<path")) {+ if (iconData.startsWith("<")) {svg.innerHTML = iconData;} else {- let path = document.createElementNS("http://www.w3.org/2000/svg", "path");+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");path.setAttribute("d", iconData);svg.appendChild(path);}diff --git a/ui/component/or-icon/src/index.ts b/ui/component/or-icon/src/index.tsindex 3d5b2801d..2863073ab 100644--- a/ui/component/or-icon/src/index.ts+++ b/ui/component/or-icon/src/index.ts@@ -51,7 +51,7 @@ export class OrIcon extends LitElement {}`;- @property({type: String})+ @property({type: String, reflect: true})icon?: string;protected _iconElement?: Element;@@ -81,7 +81,7 @@ export class OrIcon extends LitElement {protected _updateIcon(requestUpdate: boolean) {this._iconElement = undefined;window.removeEventListener(IconEvent.ICONSET_ADDED, this._handler);- let parts = (this.icon || '').split(':');+ let parts = (this.icon || "").split(":");let iconName = parts.pop();let iconSetName = parts.pop() || OrIcon._DEFAULT_ICONSET;if (!iconSetName || iconSetName === "" || !iconName || iconName === "") {diff --git a/ui/component/or-icon/src/or-icons.ts b/ui/component/or-icon/src/or-icons.tsindex 66fc4e109..3317a5b73 100644--- a/ui/component/or-icon/src/or-icons.ts+++ b/ui/component/or-icon/src/or-icons.ts@@ -1,8 +1,9 @@import {IconSetSvg} from "./icon-set-svg";-let or: IconSetSvg = new IconSetSvg(24, {- "logo": "<path fill=\"#C4D600\" d=\"M11.93,21.851c-5.551,0-10.066-4.515-10.066-10.065h2.108c0,4.388,3.57,7.958,7.958,7.958 c4.387,0,7.958-3.57,7.958-7.958c0-4.388-3.57-7.958-7.958-7.958V1.72c5.55,0,10.066,4.517,10.066,10.066 C21.996,17.336,17.48,21.851,11.93,21.851L11.93,21.851z\" /><path fill=\"#4E9D2D\" d=\"M10.406,19.088c-1.95-0.406-3.626-1.549-4.717-3.215s-1.469-3.66-1.062-5.61 c0.407-1.951,1.55-3.626,3.217-4.718c1.667-1.092,3.659-1.469,5.61-1.062c4.027,0.84,6.62,4.799,5.779,8.825l-2.063-0.429 c0.603-2.889-1.257-5.73-4.147-6.333c-1.4-0.292-2.829-0.022-4.025,0.762C7.802,8.091,6.982,9.293,6.69,10.693 c-0.291,1.398-0.021,2.828,0.762,4.024c0.783,1.196,1.985,2.016,3.385,2.307L10.406,19.088L10.406,19.088z\"/><path fill=\"#1D5632\"d=\"M11.936,16.622c-0.082,0-0.164-0.001-0.245-0.004c-1.29-0.065-2.478-0.628-3.346-1.585 c-0.868-0.958-1.31-2.195-1.246-3.487l2.104,0.105c-0.036,0.728,0.214,1.427,0.704,1.967c0.488,0.54,1.16,0.858,1.888,0.894 c0.725,0.033,1.426-0.213,1.966-0.703c0.541-0.489,0.858-1.159,0.895-1.887c0.075-1.503-1.088-2.787-2.591-2.862l0.105-2.104 c2.664,0.132,4.724,2.406,4.592,5.07c-0.064,1.291-0.628,2.478-1.585,3.345C14.28,16.183,13.137,16.622,11.936,16.622L11.936,16.622 z\"/>",- "logo-plain": "M11.93,21.851c-5.551,0-10.066-4.515-10.066-10.065h2.108c0,4.388,3.57,7.958,7.958,7.958 c4.387,0,7.958-3.57,7.958-7.958c0-4.388-3.57-7.958-7.958-7.958V1.72c5.55,0,10.066,4.517,10.066,10.066 C21.996,17.336,17.48,21.851,11.93,21.851L11.93,21.851z M10.406,19.088c-1.95-0.406-3.626-1.549-4.717-3.215s-1.469-3.66-1.062-5.61 c0.407-1.951,1.55-3.626,3.217-4.718c1.667-1.092,3.659-1.469,5.61-1.062c4.027,0.84,6.62,4.799,5.779,8.825l-2.063-0.429 c0.603-2.889-1.257-5.73-4.147-6.333c-1.4-0.292-2.829-0.022-4.025,0.762C7.802,8.091,6.982,9.293,6.69,10.693 c-0.291,1.398-0.021,2.828,0.762,4.024c0.783,1.196,1.985,2.016,3.385,2.307L10.406,19.088L10.406,19.088z M11.936,16.622c-0.082,0-0.164-0.001-0.245-0.004c-1.29-0.065-2.478-0.628-3.346-1.585 c-0.868-0.958-1.31-2.195-1.246-3.487l2.104,0.105c-0.036,0.728,0.214,1.427,0.704,1.967c0.488,0.54,1.16,0.858,1.888,0.894 c0.725,0.033,1.426-0.213,1.966-0.703c0.541-0.489,0.858-1.159,0.895-1.887c0.075-1.503-1.088-2.787-2.591-2.862l0.105-2.104 c2.664,0.132,4.724,2.406,4.592,5.07c-0.064,1.291-0.628,2.478-1.585,3.345C14.28,16.183,13.137,16.622,11.936,16.622L11.936,16.622 z"+let orIcons: IconSetSvg = new IconSetSvg(24, {+ "logo": "<path 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-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 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\" />"});-export default or;\ No newline at end of file+export default orIcons;\ No newline at end of filediff --git a/ui/component/or-map/src/util.ts b/ui/component/or-map/src/util.tsnew file mode 100644index 000000000..9c27ae389--- /dev/null+++ b/ui/component/or-map/src/util.ts@@ -0,0 +1,64 @@+import {LngLat, LngLatBounds, LngLatBoundsLike, LngLatLike} from "mapbox-gl";+import L, {LatLng, LatLngBounds} from "mapbox.js";++export function getLngLat(lngLatLike?: LngLatLike): LngLat | undefined {+ if (lngLatLike) {++ if (lngLatLike instanceof LngLat) {+ return lngLatLike as LngLat;+ }++ const obj = lngLatLike as object;++ if (obj.hasOwnProperty("lng")) {+ const lngLatObj = obj as { lng: number; lat: number; };+ return new LngLat(lngLatObj.lng, lngLatObj.lat);+ }++ if (obj.hasOwnProperty("lon")) {+ const lonLatObj = obj as { lon: number; lat: number; };+ return new LngLat(lonLatObj.lon, lonLatObj.lat);+ }+ const lonLatArr = obj as number[];++ if (lonLatArr.length === 2) {+ return new LngLat(lonLatArr[0], lonLatArr[1]);+ }+ }+}++export function getLngLatBounds(lngLatBoundsLike?: LngLatBoundsLike): LngLatBounds | undefined {+ if (lngLatBoundsLike) {++ if (lngLatBoundsLike instanceof LngLatBounds) {+ return lngLatBoundsLike as LngLatBounds;+ }++ const arr = lngLatBoundsLike as any[];+ if (arr.length === 2) {+ const sw = getLngLat(arr[0]);+ const ne = getLngLat(arr[1]);+ if (sw && ne) {+ return new LngLatBounds(sw, ne);+ }+ }++ if (arr.length === 4) {+ return new LngLatBounds([arr[0], arr[1], arr[2], arr[3]]);+ }+ }+}++export function getLatLng(lngLatLike?: LngLatLike): LatLng | undefined {+ const lngLat = getLngLat(lngLatLike);+ if (lngLat) {+ return L.latLng(lngLat.lat, lngLat.lng);+ }+}++export function getLatLngBounds(lngLatBoundsLike?: LngLatBoundsLike): LatLngBounds | undefined {+ const lngLatBounds = getLngLatBounds(lngLatBoundsLike);+ if (lngLatBounds) {+ return L.latLngBounds(getLatLng(lngLatBounds.getNorthEast())!, getLatLng(lngLatBounds.getSouthWest())!);+ }+}\ No newline at end of filediff --git a/ui/demo/demo-core/src/index.ts b/ui/demo/demo-core/src/index.tsindex 1a84aa24b..27fbaf079 100644--- a/ui/demo/demo-core/src/index.ts+++ b/ui/demo/demo-core/src/index.ts@@ -1,5 +1,5 @@import {html, render} from "lit-html";- import {when} from "lit-html/directives/when";+import {when} from "lit-html/directives/when";import rest from "@openremote/rest";import openremote, {Auth, Manager, OREvent} from "@openremote/core";import "@openremote/or-icon";@@ -10,7 +10,7 @@ import {AssetQuery,AttributeEvent,BaseAssetQueryInclude,- BaseAssetQueryMatch+ BaseAssetQueryMatch, StringPredicate} from "@openremote/model";let alarmEnabled = false;@@ -39,7 +39,7 @@ let mainTemplate = (openremote: Manager) => html`<p><b>Config: </b> ${openremote.config ? JSON.stringify(openremote.config, null, 2) : ""}</p><p><b>Console Registration: </b>${openremote.console ? JSON.stringify(openremote.console.registration, null, 2) : ""}</p><p><b>Icon Example (Material Design icon set): </b><or-icon icon="access-point" /></p>-<p><b>Icon Example (OR icon set): </b><or-icon icon="or:logo"></or-icon><or-icon icon="or:logo-plain"></or-icon></p>+<p><b>Icon Example (OR icon set): </b><or-icon icon="or:logo"></or-icon><or-icon icon="or:logo-plain"></or-icon><or-icon style="fill: #C4D600;" icon="or:marker"></or-icon></p><p><b>Icon Example (dynamic Set click to add): </b><button @click="${() => {createIconSet()}}">Load</button>: <or-icon icon="test:x"></or-icon></p>`;