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 updates: Added or-mwc-list and various component and util updates
Rich Turner3ccb9d28a576
diff --git a/deployment/manager/shared/locales/de/or.json b/deployment/manager/shared/locales/de/or.jsonindex 27ed7f35e..262a178e5 100644--- a/deployment/manager/shared/locales/de/or.json+++ b/deployment/manager/shared/locales/de/or.json@@ -145,7 +145,7 @@"matched": "Passend","unmatched": "Nicht passend","wait": "Warte",- "group": "Zugrundeliegende Assets",+ "underlyingAssets": "Zugrundeliegende Assets","groupAssetName": "Assetname","history": "Historie","attributes": "Attribute",diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.jsonindex 81ad27ead..7e3fa0646 100644--- a/deployment/manager/shared/locales/en/or.json+++ b/deployment/manager/shared/locales/en/or.json@@ -146,7 +146,7 @@"matched": "Matched","unmatched": "Unmatched","wait": "Wait",- "group": "Underlying assets",+ "underlyingAssets": "Underlying assets","groupAssetName": "Asset name","history": "History","attributes": "Attributes",@@ -279,5 +279,42 @@"editAttribute": "Change attribute","editDelta": "Delta","editCurrentValue": "Decimals",- "decimals": "Decimals"+ "decimals": "Decimals",+ "editAsset": "Edit asset",+ "parent": "Parent",+ "none": "None",+ "properties": "Properties",+ "metaItemType": {+ "urn:openremote:asset:meta:label": "Label",+ "urn:openremote:asset:meta:description": "Description",+ "urn:openremote:asset:meta:storeDataPoints": "Store data points",+ "urn:openremote:asset:meta:agentLink": "Agent link",+ "urn:openremote:asset:meta:attributeLink": "Attribute link",+ "urn:openremote:asset:meta:showOnDashboard": "Show on dashboard",+ "urn:openremote:asset:meta:format": "Format",+ "urn:openremote:asset:meta:about": "About",+ "urn:openremote:asset:meta:readOnly": "Readonly",+ "urn:openremote:asset:meta:accessRestrictedRead": "Restricted read",+ "urn:openremote:asset:meta:accessRestrictedWrite": "Restricted write",+ "urn:openremote:asset:meta:accessPublicRead": "Public read",+ "urn:openremote:asset:meta:accessPublicWrite": "Public write",+ "urn:openremote:asset:meta:rangeMin": "Value min",+ "urn:openremote:asset:meta:rangeMax": "Value max",+ "urn:openremote:asset:meta:step": "Value step",+ "urn:openremote:asset:meta:pattern": "Value regex",+ "urn:openremote:asset:meta:multiline": "Value multiline",+ "urn:openremote:asset:meta:dataPointsMaxAgeDays": "Data points max age (days)",+ "urn:openremote:asset:meta:disabled": "Disabled",+ "urn:openremote:asset:meta:executable": "Executable",+ "urn:openremote:asset:meta:allowedValues": "Allowed values",+ "urn:openremote:asset:meta:unitType": "Units",+ "urn:openremote:asset:meta:hasPredictedDatapoints": "Has predicted datapoints",+ "urn:openremote:asset:meta:secret": "Secret",+ "urn:openremote:asset:meta:ruleState": "Rule state",+ "urn:openremote:asset:meta:ruleEvent": "Rule event",+ "urn:openremote:asset:meta:ruleEventExpires": "Rule event expires",+ "urn:openremote:asset:meta:protocolConfiguration": "Protocol configuration"+ },+ "addMetaItems": "Add configuration items",+ "customAttribute": "Custom attribute"}diff --git a/deployment/manager/shared/locales/es/or.json b/deployment/manager/shared/locales/es/or.jsonindex 6d0e52062..2941714f2 100644--- a/deployment/manager/shared/locales/es/or.json+++ b/deployment/manager/shared/locales/es/or.json@@ -148,7 +148,7 @@"history": "Historia","attributes": "Atributos","info": "Informacion",- "group":"Activos subyacentes",+ "underlyingAssets":"Activos subyacentes","groupAssetName":"Nombre de activo","notSupported":"No soportado","ruleName":"Nombre de la regla",diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.jsonindex 6aef81a9a..9bd3c21b5 100644--- a/deployment/manager/shared/locales/nl/or.json+++ b/deployment/manager/shared/locales/nl/or.json@@ -146,7 +146,7 @@"matched": "Dezelfde","unmatched": "Niet dezelfde","wait": "Wacht",- "group": "Onderliggende assets",+ "underlyingAssets": "Onderliggende assets","groupAssetName": "Asset naam","history": "Geschiedenis","attributes": "Attributen",diff --git a/ui/component/core/src/defaults.ts b/ui/component/core/src/defaults.tsindex 3a38d54ab..6158d8635 100644--- a/ui/component/core/src/defaults.ts+++ b/ui/component/core/src/defaults.ts@@ -1,4 +1,4 @@-export const DefaultColor4: string = "#1B5630"; // Primary+export const DefaultColor4: string = "#1b5630"; // Primaryexport const DefaultColor7: string = "#FFF"; // Secondaryexport const DefaultColor1: string = "#FFF"; // Surfaceexport const DefaultColor2: string = "#F9F9F9"; // Background@@ -12,4 +12,4 @@ export const DefaultColor11: string = "#FFF"; // On Errorexport const DefaultBoxShadowBottom: string = "0 5px 5px -5px rgba(0,0,0,0.3)";export const DefaultBoxShadow: string = "0 1px 3px 0 rgba(0,0,0,0.21)";export const DefaultHeaderHeight: string = "50px";-export const DefaultDisabledOpacity: string = "0.3";\ No newline at end of file+export const DefaultDisabledOpacity: string = "0.3";diff --git a/ui/component/core/src/event.ts b/ui/component/core/src/event.tsindex bd53a13f8..af09e2b67 100644--- a/ui/component/core/src/event.ts+++ b/ui/component/core/src/event.ts@@ -280,11 +280,7 @@ abstract class EventProviderImpl implements EventProvider {event: {eventType: "read-assets",assetQuery: {- ids: assetIds,- select: {- excludeParentInfo: true,- excludePath: true- }+ ids: assetIds}}}diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.tsindex 1af19c9f1..bbbb16ee7 100644--- a/ui/component/core/src/util.ts+++ b/ui/component/core/src/util.ts@@ -329,6 +329,10 @@ export function getAttributeLabel(attribute: Attribute | undefined, descriptor:return i18next.t(keys) + (units ? " (" + units + ")" : "");}+export function getMetaItemLabel(urn: string): string {+ return i18next.t(["metaItemType." + urn, urn], {nsSeparator: "@"});+}+export function getAttributeValueFormat(attribute: Attribute | undefined, descriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined): string | undefined {let format = getMetaValue(MetaItemType.FORMAT, attribute, descriptor, valueDescriptor) as string;if (!format) {@@ -406,3 +410,17 @@ export function loadJs(url: string) {document.body.appendChild(script);});};++export function sortByString<T>(valueExtractor: (item: T) => string): (a: T, b: T) => number {+ return (a,b) => {+ const v1 = valueExtractor(a);+ const v2 = valueExtractor(b);+ if (v1 > v2) {+ return 1;+ }+ if (v1 < v2) {+ return -1;+ }+ return 0;+ };+}diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.tsindex 6505ba77c..7fe7a60bd 100644--- a/ui/component/or-attribute-card/src/index.ts+++ b/ui/component/or-attribute-card/src/index.ts@@ -1,17 +1,16 @@import {css, customElement, html, LitElement, property, PropertyValues, query, unsafeCSS} from "lit-element";-import {classMap} from "lit-html/directives/class-map";import i18next from "i18next";-import {Asset, AssetAttribute, Attribute, DatapointInterval, MetaItemType, ValueDatapoint, AssetEvent} from "@openremote/model";-import {manager, DefaultColor3, DefaultColor4, Util, AssetModelUtil} from "@openremote/core";+import {Asset, AssetAttribute, AssetEvent, DatapointInterval, MetaItemType, ValueDatapoint} from "@openremote/model";+import {AssetModelUtil, DefaultColor3, DefaultColor4, manager, Util} from "@openremote/core";import Chart, {ChartTooltipCallback} from "chart.js";-import {getContentWithMenuTemplate, OrChartConfig} from "@openremote/or-chart";+import {OrChartConfig} from "@openremote/or-chart";import {InputType, OrInputChangedEvent} from "@openremote/or-input";import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";import "@openremote/or-mwc-components/dist/or-mwc-dialog";-import {getMetaValue} from "@openremote/core/dist/util";import moment from "moment";-import {OrAssetTreeRequestSelectEvent, OrAssetTreeSelectionChangedEvent} from "@openremote/or-asset-tree";-import {DialogAction, OrMwcDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";+import {OrAssetTreeSelectionChangedEvent} from "@openremote/or-asset-tree";+import {OrMwcDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";+import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/dist/or-mwc-menu";export type ContextMenuOptions = "editAttribute" | "editDelta" | "editCurrentValue";diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.tsindex 049c67adb..82b857ca3 100644--- a/ui/component/or-attribute-history/src/index.ts+++ b/ui/component/or-attribute-history/src/index.ts@@ -1,3 +1,6 @@+// Declare require method which we'll use for importing webpack resources (using ES6 imports will confuse typescript parser)+declare function require(name: string): any;+import {css,customElement,diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.tsindex a029e28c5..2018ca1a9 100644--- a/ui/component/or-attribute-input/src/index.ts+++ b/ui/component/or-attribute-input/src/index.ts@@ -1,4 +1,14 @@-import {css, customElement, unsafeCSS, html, LitElement, property, PropertyValues, query, TemplateResult} from "lit-element";+import {+ css,+ customElement,+ html,+ LitElement,+ property,+ PropertyValues,+ query,+ TemplateResult,+ unsafeCSS+} from "lit-element";import {ifDefined} from "lit-html/directives/if-defined";import {i18next, translate} from "@openremote/or-translate";import {@@ -9,14 +19,21 @@ import {AttributeValueDescriptor,AttributeValueType,MetaItemType,- ValueType,- SharedEvent+ SharedEvent,+ ValueType} from "@openremote/model";-import manager, {AssetModelUtil, subscribe, Util, DefaultColor4} from "@openremote/core";+import manager, {AssetModelUtil, DefaultColor4, subscribe, Util} from "@openremote/core";import "@openremote/or-input";import {InputType, OrInput, OrInputChangedEvent} from "@openremote/or-input";import "@openremote/or-map";-import {Util as MapUtil, LngLat, getMarkerIconAndColorFromAssetType, OrMapClickedEvent, MapEventDetail} from "@openremote/or-map";+import {+ getMarkerIconAndColorFromAssetType,+ LngLat,+ MapEventDetail,+ MapGL,+ OrMapClickedEvent,+ Util as MapUtil+} from "@openremote/or-map";export class OrAttributeInputChangedEvent extends CustomEvent<OrAttributeInputChangedEventDetail> {@@ -49,37 +66,70 @@ export type AttributeInputCustomProviderResult = ((value: any, timestamp: numberexport type AttributeInputCustomProvider = (assetType: string | undefined, attribute: AssetAttribute | undefined, attributeDescriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean | undefined, disabled: boolean | undefined, label: string | undefined) => AttributeInputCustomProviderResult;-export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (assetType, attribute, attributeDescriptor, valueDescriptor, valueChangeNotifier, readonly, disabled, label) => (value, timestamp, loading, sending, error) => {- let pos: LngLat | undefined;- let center: number[] | undefined;- if (value) {- pos = MapUtil.getLngLat(value);- center = pos ? pos.toArray() : undefined;+export class CenterControl {+ protected map?: MapGL;+ protected elem?: HTMLElement;+ public pos?: LngLat;++ onAdd(map: MapGL): HTMLElement {+ this.map = map;+ const control = document.createElement("div");+ control.classList.add("mapboxgl-ctrl");+ control.classList.add("mapboxgl-ctrl-group");+ const button = document.createElement("button");+ button.className = "mapboxgl-ctrl-icon mapboxgl-ctrl-geolocate";+ button.addEventListener("click", (ev) => map.flyTo({+ center: this.pos,+ zoom: map.getZoom()+ }));+ control.appendChild(button);+ this.elem = control;+ return control;}- const iconAndColor = getMarkerIconAndColorFromAssetType(assetType);- const clickHandler = (mapClickDetail: MapEventDetail) => {- if (!readonly && !disabled && mapClickDetail.doubleClick) {- const geoJsonPoint = MapUtil.getGeoJSONPoint(mapClickDetail.lngLat);- if (valueChangeNotifier) {- valueChangeNotifier(geoJsonPoint);- }+ onRemove(map: MapGL) {+ this.map = undefined;+ this.elem = undefined;+ }+}++export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (assetType, attribute, attributeDescriptor, valueDescriptor, valueChangeNotifier, readonly, disabled, label) => {++ const centerControl = new CenterControl();++ return (value, timestamp, loading, sending, error) => {+ let pos: LngLat | undefined;+ let center: number[] | undefined;+ if (value) {+ pos = MapUtil.getLngLat(value);+ center = pos ? pos.toArray() : undefined;}- };+ centerControl.pos = pos;+ const iconAndColor = getMarkerIconAndColorFromAssetType(assetType);++ const clickHandler = (mapClickDetail: MapEventDetail) => {+ if (!readonly && !disabled && mapClickDetail.doubleClick) {+ const geoJsonPoint = MapUtil.getGeoJSONPoint(mapClickDetail.lngLat);+ if (valueChangeNotifier) {+ valueChangeNotifier(geoJsonPoint);+ }+ }+ };- const content = html`+ const content = html`<style>or-map {border: #e5e5e5 1px solid;margin: 3px 0;}</style>- <or-map class="or-map" @or-map-clicked="${(ev: OrMapClickedEvent) => clickHandler(ev.detail)}" .center="${center}">+ <or-map class="or-map" @or-map-clicked="${(ev: OrMapClickedEvent) => clickHandler(ev.detail)}" .center="${center}" .controls="${[centerControl]}"><or-map-marker active .lng="${pos ? pos.lng : undefined}" .lat="${pos ? pos.lat : undefined}" .icon="${iconAndColor ? iconAndColor.icon : undefined}" .activeColor="${iconAndColor ? "#" + iconAndColor.color : undefined}" .color="${iconAndColor ? "#" + iconAndColor.color : undefined}"></or-map-marker></or-map>`;- return getAttributeInputWrapper(content, loading, !!disabled, getHelperText(sending, false, timestamp), label, undefined);+ return getAttributeInputWrapper(content, loading, !!disabled, getHelperText(sending, false, timestamp), label, undefined);+ }}export function getAttributeInputWrapper(content: TemplateResult, loading: boolean, disabled: boolean, helperText: string | undefined, label: string | undefined, buttonIcon?: string, valueProvider?: () => any, valueChangeConsumer?: (value: any) => void): TemplateResult {@@ -147,6 +197,10 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEwidth: 100%;}+ #wrapper or-map {+ min-height: 250px;+ }+#wrapper {display: flex;position: relative;@@ -364,6 +418,9 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE@property({type: Boolean})public disableSubscribe: boolean = false;+ @property({type: Boolean})+ public disableWrite: boolean = false;+@property()protected _attributeEvent?: AttributeEvent;@@ -497,7 +554,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEthis._attributeDescriptor = this.attributeDescriptor;this._attributeValueDescriptor = this.attributeValueDescriptor;} else {- const attributeOrDescriptorOrName = this.attributeDescriptor || this.attribute ? this.attribute : this.attributeRef ? this.attributeRef.attributeName! : undefined;+ const attributeOrDescriptorOrName = this.attributeDescriptor || (this.attribute ? this.attribute : this.attributeRef ? this.attributeRef.attributeName! : undefined);if (!attributeOrDescriptorOrName) {this._attributeDescriptor = this.attributeDescriptor;@@ -737,7 +794,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE// the system or for the attribute property to be updated by a parent control or timeout and reset the valueconst attributeRef = this._getAttributeRef();- if (attributeRef) {+ if (attributeRef && !this.disableWrite) {super._sendEvent({eventType: "attribute",diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex c65a2766a..a17a1ecfa 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -30,7 +30,7 @@ import {InputType, OrInputChangedEvent} from "@openremote/or-input";import moment from "moment";import {OrAssetTreeSelectionChangedEvent} from "@openremote/or-asset-tree";import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";-import {MenuItem, OrMwcMenu, OrMwcMenuChangedEvent} from "@openremote/or-mwc-components/dist/or-mwc-menu";+import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/dist/or-mwc-menu";import * as ChartAnnotation from "chartjs-plugin-annotation";export class OrChartEvent extends CustomEvent<OrChartEventDetail> {@@ -303,23 +303,6 @@ const style = css`}`;-export function getContentWithMenuTemplate(content: TemplateResult, menuItems: (MenuItem | MenuItem[] | null)[], selectedValues: string[] | string | undefined, valueChangedCallback: (values: string[] | string) => void, closedCallback?: () => void, multiSelect = false): TemplateResult {-- const openMenu = (evt: Event) => {- if (!menuItems) {- return;- }-- ((evt.currentTarget as Element).parentElement!.lastElementChild as OrMwcMenu).open();- };-- return html`- <span>- <span @click="${openMenu}">${content}</span>- ${menuItems ? html`<or-mwc-menu ?multiselect="${multiSelect}" @or-mwc-menu-closed="${() => {if (closedCallback) { closedCallback(); }} }" @or-mwc-menu-changed="${(evt: OrMwcMenuChangedEvent) => {if (valueChangedCallback) { valueChangedCallback(evt.detail); }} }" .values="${selectedValues}" .menuItems="${menuItems}" id="menu"></or-mwc-menu>` : ``}- </span>- `;-}export interface ChartValueDatapoint<T> {x?: number | string;y?: T;diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.tsindex ed7ca6f40..53fc3efc9 100644--- a/ui/component/or-input/src/index.ts+++ b/ui/component/or-input/src/index.ts@@ -337,22 +337,8 @@ export class OrInput extends LitElement {@property({type: String})public label?: string;- @property()- protected _disabled: boolean = false;-- public set disabled(disabled: boolean) {- this._disabled = disabled;- if (this._mdcComponent) {- (this._mdcComponent as any).disabled = disabled;- }- if (this.type === InputType.RANGE && this._mdcComponent2) {- (this._mdcComponent2 as any).disabled = disabled;- }- }-- public get disabled() {- return this._disabled;- }+ @property({type: Boolean})+ public disabled: boolean = false;/* TEXT INPUT STYLES END */@@ -374,6 +360,24 @@ export class OrInput extends LitElement {protected shouldUpdate(_changedProperties: PropertyValues) {+ if (_changedProperties.has("disabled")) {+ if (this._mdcComponent) {+ (this._mdcComponent as any).disabled = this.disabled;+ }+ if (this.type === InputType.RANGE && this._mdcComponent2) {+ (this._mdcComponent2 as any).disabled = this.disabled;+ }+ }++ if (_changedProperties.has("readonly")) {+ if (this._mdcComponent) {+ (this._mdcComponent as any).readonly = this.readonly;+ }+ if (this.type === InputType.RANGE && this._mdcComponent2) {+ (this._mdcComponent2 as any).readonly = this.readonly;+ }+ }+if (!this.type && this.value) {if (this.value instanceof Date) {this.type = InputType.DATETIME;diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.tsindex ad7c1d3e2..cfec63279 100644--- a/ui/component/or-map/src/index.ts+++ b/ui/component/or-map/src/index.ts@@ -1,7 +1,7 @@import manager, {EventCallback, OREvent, MapType} from "@openremote/core";import {FlattenedNodesObserver} from "@polymer/polymer/lib/utils/flattened-nodes-observer.js";import {CSSResult, customElement, html, LitElement, property, PropertyValues, query} from "lit-element";-import {LngLat, LngLatBoundsLike, LngLatLike} from "mapbox-gl";+import {LngLat, LngLatBoundsLike, LngLatLike, Control, IControl} from "mapbox-gl";import {MapWidget} from "./mapwidget";import {style} from "./style";import {OrMapMarker, OrMapMarkerChangedEvent} from "./markers/or-map-marker";@@ -11,6 +11,7 @@ import * as Util from "./util";export {Util, LngLat};export * from "./markers/or-map-marker";export * from "./markers/or-map-marker-asset";+export {Control, IControl, Map as MapGL} from "mapbox-gl";export interface ViewSettings {"center": LngLatLike;@@ -101,6 +102,8 @@ export class OrMap extends LitElement {@property({type: Number})public zoom?: number;+ public controls?: (Control | IControl)[];+protected _initCallback?: EventCallback;protected _map?: MapWidget;protected _loaded: boolean = false;@@ -125,7 +128,6 @@ export class OrMap extends LitElement {this.loadMap();}}-protected onManagerEvent = (event: OREvent) => {switch (event) {@@ -191,7 +193,8 @@ export class OrMap extends LitElement {if (this._mapContainer && this._slotElement) {this._map = new MapWidget(this.type, this.shadowRoot!, this._mapContainer).setCenter(this.center)- .setZoom(this.zoom);+ .setZoom(this.zoom)+ .setControls(this.controls);this._map.load().then(() => {// Get markers from slotthis._observer = new FlattenedNodesObserver(this._slotElement!, (info: any) => {diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.tsindex 6a472ebf7..d54e70f5e 100644--- a/ui/component/or-map/src/mapwidget.ts+++ b/ui/component/or-map/src/mapwidget.ts@@ -2,7 +2,10 @@///<reference path="../@types/mapbox.js/index.d.ts" />import manager, {MapType} from "@openremote/core";import {LngLatLike, Map as MapGL, MapboxOptions as OptionsGL, Marker as MarkerGL, Style as StyleGL, LngLat,- MapMouseEvent} from "mapbox-gl";+ MapMouseEvent,+ NavigationControl,+ Control,+ IControl} from "mapbox-gl";import L, {Map as MapJS, MapOptions as OptionsJS, Marker as MarkerJS} from "mapbox.js";import {OrMapClickedEvent, OrMapLoadedEvent, ViewSettings} from "./index";import {@@ -29,6 +32,7 @@ export class MapWidget {protected _viewSettings?: ViewSettings;protected _center?: LngLat | LngLatLike;protected _zoom?: number;+ protected _controls?: (Control | IControl)[];protected _clickHandlers: Map<OrMapMarker, (ev: MouseEvent) => void> = new Map();constructor(type: MapType, styleParent: Node, mapContainer: HTMLElement) {@@ -114,6 +118,14 @@ export class MapWidget {return this;}+ public setControls(controls?: (Control | IControl)[]): this {+ this._controls = controls;+ if (this._mapGl && this._controls) {+ this._controls.forEach((control) => this._mapGl!.addControl(control));+ }+ return this;+ }+public async loadViewSettings() {let settingsResponse;if (this._type === MapType.RASTER) {@@ -181,7 +193,6 @@ export class MapWidget {this._mapJs.setMinZoom(minZoom);}}-} else {// Add style to shadow rootconst style = document.createElement("style");@@ -234,6 +245,14 @@ export class MapWidget {this._mapGl.on("dblclick", (e: MapMouseEvent) => {this._onMapClick(e.lngLat, true);});++ // Add zoom and rotation controls to the map+ this._mapGl.addControl(new NavigationControl());++ // Add custom controls+ if (this._controls) {+ this._controls.forEach((control) => this._mapGl!.addControl(control));+ }}this._mapContainer.dispatchEvent(new OrMapLoadedEvent());@@ -365,9 +384,6 @@ export class MapWidget {if (marker.interactive) {this._addMarkerClickHandler(marker, mGl.getElement());}---}if(marker.radius) {this._createMarkerRadius(marker);diff --git a/ui/component/or-mwc-components/src/or-mwc-dialog.ts b/ui/component/or-mwc-components/src/or-mwc-dialog.tsindex 6465a9551..1fcf60acf 100644--- a/ui/component/or-mwc-components/src/or-mwc-dialog.ts+++ b/ui/component/or-mwc-components/src/or-mwc-dialog.ts@@ -1,14 +1,4 @@-import {- css,- customElement,- html,- LitElement,- property,- query,- TemplateResult,- unsafeCSS,- CSSResult-} from "lit-element";+import {css, customElement, html, LitElement, property, query, TemplateResult, unsafeCSS, PropertyValues} from "lit-element";import {MDCDialog} from "@material/dialog";import "@openremote/or-translate";import "@openremote/or-input";@@ -23,13 +13,17 @@ export interface DialogConfig {actions?: DialogAction[];avatar?: boolean;styles?: TemplateResult | string;+ dismissAction?: DialogActionBase | null;+}+export interface DialogActionBase {+ actionName: string;+ action?: () => void;}-export interface DialogAction {+export interface DialogAction extends DialogActionBase {default?: boolean;content: TemplateResult | string;- actionName: string;- action?: () => void;+ disabled?: boolean;}export class OrMwcDialogOpenedEvent extends CustomEvent<void> {@@ -64,6 +58,29 @@ declare global {}}+export function showDialog(config: DialogConfig, hostElement: HTMLElement = document.body): OrMwcDialog | undefined {+ if (!hostElement) {+ return;+ }++ const dialog = new OrMwcDialog();+ dialog.isOpen = true;+ dialog.addEventListener(OrMwcDialogOpenedEvent.NAME, (ev) => {+ ev.stopPropagation();+ });+ dialog.addEventListener(OrMwcDialogClosedEvent.NAME, (ev) => {+ ev.stopPropagation();+ window.setTimeout(() => {+ if (dialog.parentElement) {+ dialog.parentElement.removeChild(dialog);+ }+ }, 0);+ });+ dialog.config = config;+ hostElement.append(dialog);+ return dialog;+}+// language=CSSconst style = css`:host {@@ -82,6 +99,12 @@ const style = css`.mdc-list {padding: 0 24px}++ @media (min-width: 1280px) {+ .mdc-dialog .mdc-dialog__surface {+ max-width: 1024px;+ }+ }`;@customElement("or-mwc-dialog")@@ -100,6 +123,7 @@ export class OrMwcDialog extends LitElement {this.dialogTitle = config.title;this.dialogContent = config.content;this.dialogActions = config.actions;+ this.dismissAction = config.dismissAction;this.avatar = config.avatar;this.styles = config.styles;}@@ -114,12 +138,18 @@ export class OrMwcDialog extends LitElement {@property({type: Array, attribute: false})public dialogActions?: DialogAction[];+ @property({type: Object, attribute: false})+ public dismissAction: DialogActionBase | null | undefined;+@property({type: Boolean})public avatar?: boolean;@property()public styles?: TemplateResult | string;+ @property({attribute: false})+ protected _open: boolean = false;+@query("#dialog")protected _mdcElem!: HTMLElement;@@ -129,10 +159,14 @@ export class OrMwcDialog extends LitElement {return this._mdcComponent ? this._mdcComponent.isOpen : false;}+ public set isOpen(isOpen: boolean) {+ this._open = true;+ }+public open() {if (this._mdcElem && !this._mdcComponent) {this._mdcComponent = new MDCDialog(this._mdcElem);- this._mdcComponent!.scrimClickAction = "";+ this._mdcComponent!.scrimClickAction = this.dismissAction || this.dismissAction === null ? "close" : "";}if (this._mdcComponent) {this._mdcComponent.open();@@ -156,9 +190,8 @@ export class OrMwcDialog extends LitElement {protected render() {return html`+ ${typeof(this.styles) === "string" ? html`<style>${this.styles}</style>` : this.styles || ``}- ${typeof(this.styles) === "string" ? html`<style>${this.styles}</style>` : this.styles}-<div id="dialog"class="mdc-dialog"role="alertdialog"@@ -179,7 +212,7 @@ export class OrMwcDialog extends LitElement {${this.dialogActions ? this.dialogActions.map((action) => {return html`<div class="mdc-button mdc-dialog__button" ?data-mdc-dialog-button-default="${action.default}" data-mdc-dialog-action="${action.actionName}">- ${typeof(action.content) === "string" ? html`<or-input .type="${InputType.BUTTON}" .label="${action.content}"></or-input>` : action.content}+ ${typeof(action.content) === "string" ? html`<or-input .type="${InputType.BUTTON}" .disabled="${action.disabled}" .label="${action.content}"></or-input>` : action.content}</div>`;}) : ``}</footer>@@ -196,17 +229,26 @@ export class OrMwcDialog extends LitElement {`;}+ protected updated(_changedProperties: PropertyValues) {+ super.updated(_changedProperties);+ if (_changedProperties.has("_open") && this._open) {+ this.open();+ }+ }+protected _onDialogOpened() {this.dispatchEvent(new OrMwcDialogOpenedEvent());}protected _onDialogClosed(action?: string) {- this.dispatchEvent(new OrMwcDialogClosedEvent(action));- if (action && this.dialogActions) {+ if (action === "close" && this.dismissAction && this.dismissAction.action) {+ this.dismissAction.action();+ } else if (action && this.dialogActions) {const matchedAction = this.dialogActions.find((dialogAction) => dialogAction.actionName === action);if (matchedAction && matchedAction.action) {matchedAction.action();}}+ this.dispatchEvent(new OrMwcDialogClosedEvent(action));}}diff --git a/ui/component/or-mwc-components/src/or-mwc-menu.ts b/ui/component/or-mwc-components/src/or-mwc-menu.tsindex 554b26892..d1a4425ba 100644--- a/ui/component/or-mwc-components/src/or-mwc-menu.ts+++ b/ui/component/or-mwc-components/src/or-mwc-menu.ts@@ -16,7 +16,6 @@ import { DefaultColor8, DefaultColor4 } from "@openremote/core";const listStyle = require("!!raw-loader!@material/list/dist/mdc.list.css");const menuSurfaceStyle = require("!!raw-loader!@material/menu-surface/dist/mdc.menu-surface.css");const menuStyle = require("!!raw-loader!@material/menu/dist/mdc.menu.css");-const checkboxStyle = require("!!raw-loader!@material/checkbox/dist/mdc.checkbox.css");export interface MenuItem {icon?: string;@@ -108,7 +107,6 @@ export class OrMwcMenu extends LitElement {css`${unsafeCSS(listStyle)}`,css`${unsafeCSS(menuStyle)}`,css`${unsafeCSS(menuSurfaceStyle)}`,- css`${unsafeCSS(checkboxStyle)}`,style];}diff --git a/ui/tslint.json b/ui/tslint.jsonindex 8b4f15fc6..fe087c064 100644--- a/ui/tslint.json+++ b/ui/tslint.json@@ -14,6 +14,7 @@"ban-types": false,"array-type": false,"object-literal-shorthand": false,- "no-string-literal": false+ "no-string-literal": false,+ "no-shadowed-variable": false}-}\ No newline at end of file+}