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 and bug fixes
Rich Turnera7d51b57b2de
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.jsonindex 96fc44ddc..7a026dc70 100644--- a/deployment/manager/shared/locales/en/or.json+++ b/deployment/manager/shared/locales/en/or.json@@ -281,6 +281,7 @@"editCurrentValue": "Decimals","decimals": "Decimals","editAsset": "Edit asset",+ "viewAsset": "View asset","parent": "Parent","none": "None","properties": "Properties",diff --git a/ui/app/or-app/src/index.ts b/ui/app/or-app/src/index.tsindex 56829f634..040e2162e 100644--- a/ui/app/or-app/src/index.ts+++ b/ui/app/or-app/src/index.ts@@ -10,102 +10,34 @@ import {unsafeCSS} from "lit-element";import {unsafeHTML} from "lit-html/directives/unsafe-html";+import {AppConfig, DefaultAppConfig, router} from "./types";import "@openremote/or-translate";import "@openremote/or-mwc-components/dist/or-mwc-menu";import "./or-header";import "@openremote/or-icon";import {updateMetadata} from "pwa-helpers/metadata";import i18next from "i18next";-import Navigo from "navigo";import manager, {Auth, DefaultColor2, DefaultColor3, ManagerConfig, Util, BasicLoginResult} from "@openremote/core";import {DEFAULT_LANGUAGES, HeaderConfig, HeaderItem, Languages} from "./or-header";import {DialogConfig, OrMwcDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";import {AnyAction, EnhancedStore, Unsubscribe} from "@reduxjs/toolkit";-import {AppStateKeyed, updatePage} from "./app";import {ThunkMiddleware} from "redux-thunk";-import { translate } from "@openremote/or-translate";+import {AppStateKeyed, updatePage} from "./app";import { InputType, OrInputChangedEvent } from "@openremote/or-input";+import {getMapRoute} from "./pages/page-map";export * from "./app";export * from "./or-header";+export * from "./types";// Declare MANAGER_URL - Global var injected by webpackdeclare var MANAGER_URL: string;-// Configure routing-export const router = new Navigo(null, true, "#!");export {HeaderConfig};-export interface DefaultAppConfig {- appTitle: string;- logo: HTMLTemplateElement | string;- logoMobile: HTMLTemplateElement | string;- language?: string;- header?: HeaderConfig;- styles?: TemplateResult;-}--export interface RealmAppConfig {- appTitle?: string;- logo?: HTMLTemplateElement | string;- logoMobile?: HTMLTemplateElement | string;- language?: string;- header?: HeaderConfig;- styles?: TemplateResult;-}--export interface AppConfig<S extends AppStateKeyed> {- pages?: {- default: PageProvider<S>;- [name: string]: PageProvider<S>;- };- default?: DefaultAppConfig;- realms?: {- [realm: string]: RealmAppConfig;- };-}--export interface PageProvider<S extends AppStateKeyed> {- routes: string[];- pageCreator: () => Page<S>;-}--export abstract class Page<S extends AppStateKeyed> extends translate(i18next)(LitElement) {-- abstract get name(): string;-- protected _store: EnhancedStore<S, AnyAction, ReadonlyArray<ThunkMiddleware<S>>>;-- protected _storeUnsubscribe!: Unsubscribe;-- constructor(store: EnhancedStore<S, AnyAction, ReadonlyArray<ThunkMiddleware<S>>>) {- super();- this._store = store;- }-- connectedCallback() {- if (super.connectedCallback) {- super.connectedCallback();- }-- this._storeUnsubscribe = this._store.subscribe(() => this.stateChanged(this._store.getState()));- this.stateChanged(this._store.getState());- }-- disconnectedCallback() {- this._storeUnsubscribe();-- if (super.disconnectedCallback) {- super.disconnectedCallback();- }- }-- abstract stateChanged(state: S);-}-export function headerItemMap<S extends AppStateKeyed, A extends AnyAction>(orApp: OrApp<S>): HeaderItem {return {icon: "map",- href: "#!map",+ href: getMapRoute(),text: "map"};}@@ -194,7 +126,7 @@ export function getRealmQueryParameter(): string {return Util.getQueryParameter(location.search, "realm");}if(location.hash) {- let index = location.hash.indexOf("?");+ const index = location.hash.indexOf("?");if(index > -1) {return Util.getQueryParameter(location.hash.substring(index + 1), "realm");}diff --git a/ui/app/or-app/src/or-header.ts b/ui/app/or-app/src/or-header.tsindex 56098f3ac..d16a66098 100644--- a/ui/app/or-app/src/or-header.ts+++ b/ui/app/or-app/src/or-header.ts@@ -13,6 +13,7 @@ import "@openremote/or-mwc-components/dist/or-mwc-dialog";import "@openremote/or-icon";import {getContentWithMenuTemplate, MenuItem} from "@openremote/or-mwc-components/dist/or-mwc-menu";import {Tenant} from "@openremote/model";+import {router} from "./index";export interface HeaderConfig {mainMenu: HeaderItem[];@@ -24,6 +25,7 @@ export interface HeaderItem {text: string;value?: string;href?: string;+ absolute?: boolean;action?: () => void;hideMobile?: boolean;roles?: string[] | {[client: string]: string[]};@@ -459,7 +461,7 @@ class OrHeader extends LitElement {if (headerItem.action) {headerItem.action();} else if (headerItem.href) {- window.location.href = headerItem.href;+ router.navigate(headerItem.href, !!headerItem.absolute);}}diff --git a/ui/app/or-app/src/pages/page-account.ts b/ui/app/or-app/src/pages/page-account.tsindex 08fe69830..609e5db17 100644--- a/ui/app/or-app/src/pages/page-account.ts+++ b/ui/app/or-app/src/pages/page-account.ts@@ -1,9 +1,10 @@-import {css, customElement, html, property, PropertyValues, TemplateResult, unsafeCSS} from "lit-element";+import {css, customElement, html, TemplateResult} from "lit-element";import manager from "@openremote/core";import "@openremote/or-panel";import "@openremote/or-translate";-import {AppStateKeyed, Page} from "../index";import {EnhancedStore} from "@reduxjs/toolkit";+import {AppStateKeyed} from "../app";+import {Page} from "../types";export function pageAccountProvider<S extends AppStateKeyed>(store: EnhancedStore<S>) {return {diff --git a/ui/app/or-app/src/pages/page-assets.ts b/ui/app/or-app/src/pages/page-assets.tsindex 5c92a6739..1247dfc9a 100644--- a/ui/app/or-app/src/pages/page-assets.ts+++ b/ui/app/or-app/src/pages/page-assets.ts@@ -4,7 +4,8 @@ import "@openremote/or-asset-viewer";import {ViewerConfig, OrAssetViewer} from "@openremote/or-asset-viewer";import {AssetTreeConfig, OrAssetTreeSelectionChangedEvent, OrAssetTreeRequestSelectEvent, OrAssetTreeRequestEditToggleEvent, OrAssetTreeEditChangedEvent} from "@openremote/or-asset-tree";import {DefaultBoxShadow} from "@openremote/core";-import {AppStateKeyed, Page, router} from "../index";+import {AppStateKeyed} from "../app";+import {Page, router} from "../types";import {EnhancedStore} from "@reduxjs/toolkit";import { showDialog } from "@openremote/or-mwc-components/dist/or-mwc-dialog";import i18next from "i18next";@@ -31,6 +32,15 @@ export function pageAssetsProvider<S extends AppStateKeyed>(store: EnhancedStore};}+export function getAssetsRoute(editMode?: boolean, assetId?: string) {+ let route = "assets/" + (editMode ? "true" : "false");+ if (assetId) {+ route += "/" + assetId;+ }++ return route;+}+@customElement("page-assets")class PageAssets<S extends AppStateKeyed> extends Page<S> {@@ -184,9 +194,7 @@ class PageAssets<S extends AppStateKeyed> extends Page<S> {if (silent) {router.pause();}- const assetId = this._assetId ? "/" + this._assetId : "";- const editMode = !!this._editMode;- router.navigate("assets/" + editMode + assetId);+ getAssetsRoute(this._editMode, this._assetId);if (silent) {router.resume();}diff --git a/ui/app/or-app/src/pages/page-gateway.ts b/ui/app/or-app/src/pages/page-gateway.tsindex 9529a6f5b..49d71fd99 100644--- a/ui/app/or-app/src/pages/page-gateway.ts+++ b/ui/app/or-app/src/pages/page-gateway.ts@@ -4,7 +4,8 @@ import "@openremote/or-panel";import {ConnectionStatus, GatewayConnection, GatewayConnectionStatusEvent} from "@openremote/model";import manager, {DefaultColor1, OREvent} from "@openremote/core";import {InputType, OrInputChangedEvent} from "@openremote/or-input";-import {AppStateKeyed, Page} from "../index";+import {AppStateKeyed} from "../app";+import {Page} from "../types";import {EnhancedStore} from "@reduxjs/toolkit";export function pageGatewayProvider<S extends AppStateKeyed>(store: EnhancedStore<S>) {diff --git a/ui/app/or-app/src/pages/page-insights.ts b/ui/app/or-app/src/pages/page-insights.tsindex c4de5c1f4..93bf2212e 100644--- a/ui/app/or-app/src/pages/page-insights.ts+++ b/ui/app/or-app/src/pages/page-insights.ts@@ -1,7 +1,8 @@import {css, customElement, html, property, TemplateResult} from "lit-element";import "@openremote/or-data-viewer";import {DataViewerConfig} from "@openremote/or-data-viewer";-import {AppStateKeyed, Page} from "../index";+import {AppStateKeyed} from "../app";+import {Page} from "../types";import {EnhancedStore} from "@reduxjs/toolkit";import i18next from "i18next";diff --git a/ui/app/or-app/src/pages/page-logs.ts b/ui/app/or-app/src/pages/page-logs.tsindex 15d0cf725..239ee956a 100644--- a/ui/app/or-app/src/pages/page-logs.ts+++ b/ui/app/or-app/src/pages/page-logs.ts@@ -1,7 +1,8 @@import {css, customElement, html, property} from "lit-element";import "@openremote/or-log-viewer";import {ViewerConfig} from "@openremote/or-log-viewer";-import {AppStateKeyed, Page} from "../index";+import {AppStateKeyed} from "../app";+import {Page} from "../types";import {EnhancedStore} from "@reduxjs/toolkit";export function pageLogsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?: ViewerConfig) {diff --git a/ui/app/or-app/src/pages/page-map.ts b/ui/app/or-app/src/pages/page-map.tsindex c19fd8c3e..c079a2eb9 100644--- a/ui/app/or-app/src/pages/page-map.ts+++ b/ui/app/or-app/src/pages/page-map.ts@@ -1,14 +1,19 @@-import {customElement, html, property, query, css} from "lit-element";+import {css, customElement, html, property, query} from "lit-element";import {Action, createSlice, EnhancedStore, PayloadAction, ThunkAction} from "@reduxjs/toolkit";import "@openremote/or-map";-import "@openremote/or-map/dist/or-map-asset-card";-import {ViewerConfig} from "@openremote/or-map/dist/or-map-asset-card";-+import {+ MapAssetCardConfig,+ OrMap,+ OrMapAssetCardLoadAssetEvent,+ OrMapClickedEvent,+ OrMapMarkerAsset,+ OrMapMarkerClickedEvent+} from "@openremote/or-map";import manager, {Util} from "@openremote/core";-import {OrMap, OrMapClickedEvent, OrMapMarkerAsset, OrMapMarkerClickedEvent} from "@openremote/or-map";import {createSelector} from "reselect";import {Asset, AssetEvent, AssetEventCause, AttributeEvent, AttributeType, MetaItemType} from "@openremote/model";-import {Page, router} from "../index";+import {getAssetsRoute} from "./page-assets";+import {Page, router} from "../types";import {AppStateKeyed} from "../app";export interface MapState {@@ -82,7 +87,7 @@ const pageMapSlice = createSlice({const {assetEventReceived, attributeEventReceived, setAssetSubscriptionId, setAttributeSubscriptionId} = pageMapSlice.actions;export const pageMapReducer = pageMapSlice.reducer;-export function pageMapProvider<S extends MapStateKeyed>(store: EnhancedStore<S>, config?:ViewerConfig) {+export function pageMapProvider<S extends MapStateKeyed>(store: EnhancedStore<S>, config?:MapAssetCardConfig) {return {routes: ["map",@@ -96,6 +101,15 @@ export function pageMapProvider<S extends MapStateKeyed>(store: EnhancedStore<S>};}+export function getMapRoute(assetId?: string) {+ let route = "map";+ if (assetId) {+ route += "/" + assetId;+ }++ return route;+}+const subscribeAssets = (): ThunkAction<void, MapStateKeyed, unknown, Action<string>> => async (dispatch) => {try {@@ -139,7 +153,7 @@ const unsubscribeAssets = (): ThunkAction<void, MapStateKeyed, unknown, Action<s}};-const mapCardConfig: ViewerConfig = {+const mapCardConfig: MapAssetCardConfig = {default: {exclude: ["userNotes"]},@@ -151,7 +165,7 @@ const mapCardConfig: ViewerConfig = {};@customElement("page-map")-export class PageMap<S extends MapStateKeyed> extends Page<S> {+export class PageMap<S extends MapStateKeyed> extends Page<S> {static get styles() {// language=CSS@@ -188,7 +202,7 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {}@property()- public config?: ViewerConfig;+ public config?: MapAssetCardConfig;@query("#map")protected _map?: OrMap;@@ -226,6 +240,7 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {constructor(store: EnhancedStore<S>) {super(store);+ this.addEventListener(OrMapAssetCardLoadAssetEvent.NAME, this.onLoadAssetEvent);}protected render() {@@ -271,14 +286,18 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {protected onMapMarkerClick(e: OrMapMarkerClickedEvent) {const asset = (e.detail.marker as OrMapMarkerAsset).asset;- router.navigate("map/" + asset.id);+ router.navigate(getMapRoute(asset.id));}protected onMapClick(e: OrMapClickedEvent) {- router.navigate('map');+ router.navigate(getMapRoute());}protected getCurrentAsset() {this._getCurrentAsset(this._store.getState());}++ protected onLoadAssetEvent(loadAssetEvent: OrMapAssetCardLoadAssetEvent) {+ router.navigate(getAssetsRoute(false, loadAssetEvent.detail));+ }}diff --git a/ui/app/or-app/src/pages/page-mobile-onboarding.ts b/ui/app/or-app/src/pages/page-mobile-onboarding.tsindex bd7c84cbe..1915a34cd 100644--- a/ui/app/or-app/src/pages/page-mobile-onboarding.ts+++ b/ui/app/or-app/src/pages/page-mobile-onboarding.ts@@ -1,5 +1,6 @@import {css, customElement, html, property} from "lit-element";-import {AppStateKeyed, Page} from "../index";+import {AppStateKeyed} from "../app";+import {Page} from "../types";import {EnhancedStore} from "@reduxjs/toolkit";import manager from "@openremote/core";diff --git a/ui/app/or-app/src/pages/page-mobile-splash.ts b/ui/app/or-app/src/pages/page-mobile-splash.tsindex d84b222e0..a67725997 100644--- a/ui/app/or-app/src/pages/page-mobile-splash.ts+++ b/ui/app/or-app/src/pages/page-mobile-splash.ts@@ -1,5 +1,6 @@import {css, customElement, html, property} from "lit-element";-import {AppStateKeyed, Page} from "../index";+import {AppStateKeyed} from "../app";+import {Page} from "../types";import {EnhancedStore} from "@reduxjs/toolkit";export interface SplashConfig {diff --git a/ui/app/or-app/src/pages/page-rules.ts b/ui/app/or-app/src/pages/page-rules.tsindex 845aa5357..72ffb60b9 100644--- a/ui/app/or-app/src/pages/page-rules.ts+++ b/ui/app/or-app/src/pages/page-rules.ts@@ -1,9 +1,10 @@import {css, customElement, html, property} from "lit-element";import "@openremote/or-rules";import {RulesConfig} from "@openremote/or-rules";-import {AssetType, RulesetLang, NotificationTargetType} from "@openremote/model";-import {AppStateKeyed, Page} from "../index";+import {AssetType, NotificationTargetType, RulesetLang} from "@openremote/model";import {EnhancedStore} from "@reduxjs/toolkit";+import {AppStateKeyed} from "../app";+import {Page} from "../types";export interface PageRulesConfig {rules: RulesConfig;diff --git a/ui/app/or-app/src/types.ts b/ui/app/or-app/src/types.tsnew file mode 100644index 000000000..0ab5a26f4--- /dev/null+++ b/ui/app/or-app/src/types.ts@@ -0,0 +1,78 @@+import {HeaderConfig} from "./or-header";+import {AppStateKeyed} from "./app";+import { TemplateResult, LitElement } from "lit-element";+import i18next from "i18next";+import { translate } from "@openremote/or-translate";+import { EnhancedStore, AnyAction, Unsubscribe } from "@reduxjs/toolkit";+import {ThunkMiddleware} from "redux-thunk";+import Navigo from "navigo";++// Configure routing+export const router = new Navigo(null, true, "#!");++export interface DefaultAppConfig {+ appTitle: string;+ logo: HTMLTemplateElement | string;+ logoMobile: HTMLTemplateElement | string;+ language?: string;+ header?: HeaderConfig;+ styles?: TemplateResult;+}++export interface RealmAppConfig {+ appTitle?: string;+ logo?: HTMLTemplateElement | string;+ logoMobile?: HTMLTemplateElement | string;+ language?: string;+ header?: HeaderConfig;+ styles?: TemplateResult;+}++export interface AppConfig<S extends AppStateKeyed> {+ pages?: {+ default: PageProvider<S>;+ [name: string]: PageProvider<S>;+ };+ default?: DefaultAppConfig;+ realms?: {+ [realm: string]: RealmAppConfig;+ };+}++export interface PageProvider<S extends AppStateKeyed> {+ routes: string[];+ pageCreator: () => Page<S>;+}++export abstract class Page<S extends AppStateKeyed> extends translate(i18next)(LitElement) {++ abstract get name(): string;++ protected _store: EnhancedStore<S, AnyAction, ReadonlyArray<ThunkMiddleware<S>>>;++ protected _storeUnsubscribe!: Unsubscribe;++ constructor(store: EnhancedStore<S, AnyAction, ReadonlyArray<ThunkMiddleware<S>>>) {+ super();+ this._store = store;+ }++ connectedCallback() {+ if (super.connectedCallback) {+ super.connectedCallback();+ }++ this._storeUnsubscribe = this._store.subscribe(() => this.stateChanged(this._store.getState()));+ this.stateChanged(this._store.getState());+ }++ disconnectedCallback() {+ this._storeUnsubscribe();++ if (super.disconnectedCallback) {+ super.disconnectedCallback();+ }+ }++ abstract stateChanged(state: S);+}diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex 11f5d1d88..c481c3f2a 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -12,11 +12,11 @@ import "@openremote/or-survey-results";import "@openremote/or-table";import "@openremote/or-panel";import "@openremote/or-mwc-components/dist/or-mwc-dialog";-import {DialogAction, OrMwcDialog, showDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";+import {DialogAction, OrMwcDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";import "@openremote/or-mwc-components/dist/or-mwc-list";import {OrTranslate, translate} from "@openremote/or-translate";import {InputType, OrInput, OrInputChangedEvent} from "@openremote/or-input";-import manager, {AssetModelUtil, DefaultColor5, subscribe, Util} from "@openremote/core";+import manager, {AssetModelUtil, subscribe, Util} from "@openremote/core";import {OrTable} from "@openremote/or-table";import {OrChartConfig, OrChartEvent} from "@openremote/or-chart";import {HistoryConfig, OrAttributeHistory, OrAttributeHistoryEvent} from "@openremote/or-attribute-history";@@ -27,12 +27,9 @@ import {AssetType,Attribute,AttributeEvent,- MetaItem,+ ClientRole,MetaItemType,- SharedEvent,- ValueType,- AttributeDescriptor,- ClientRole+ SharedEvent} from "@openremote/model";import {panelStyles, style} from "./style";import i18next from "i18next";@@ -41,7 +38,7 @@ import {classMap} from "lit-html/directives/class-map";import {GenericAxiosResponse} from "axios";import {OrIcon} from "@openremote/or-icon";import "./or-edit-asset-panel";-import { OrEditAssetChangedEvent } from "./or-edit-asset-panel";+import {OrEditAssetChangedEvent} from "./or-edit-asset-panel";export interface PanelConfig {type?: "info" | "history" | "group" | "survey" | "survey-results";diff --git a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts b/ui/component/or-asset-viewer/src/or-edit-asset-panel.tsindex d9d9e4fc0..b8f76ece1 100644--- a/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts+++ b/ui/component/or-asset-viewer/src/or-edit-asset-panel.ts@@ -182,7 +182,7 @@ export class OrEditAssetPanel extends LitElement {</tr></thead><tbody class="mdc-data-table__content">- ${this.attrs!.sort(Util.sortByString((attr: Attribute) => attr.name!.toUpperCase())).map((attr) => this._getEditAttributeTemplate(attr))}+ ${this.attrs!.sort(Util.sortByString((attr: Attribute) => attr.name!.toUpperCase())).map((attr) => this._getEditAttributeTemplate(this.asset.type!, attr))}<tr><td colspan="4"><div class="item-add">@@ -203,7 +203,7 @@ export class OrEditAssetPanel extends LitElement {`;}- protected _getEditAttributeTemplate(attribute: Attribute): TemplateResult {+ protected _getEditAttributeTemplate(assetType: string, attribute: Attribute): TemplateResult {const deleteAttribute = () => {this.attrs!.splice(this.attrs!.indexOf(attribute), 1);@@ -214,7 +214,9 @@ export class OrEditAssetPanel extends LitElement {<tr class="mdc-data-table__row"><td class="mdc-data-table__cell expander-cell"><or-icon icon="chevron-right"></or-icon><span>${attribute.name}</span></td><td class="mdc-data-table__cell">${attribute.type}</td>- <td class="mdc-data-table__cell">${attribute.value}</td>+ <td class="mdc-data-table__cell">+ <or-attribute-input compact .assetType="${assetType}" .label=${null} .readonly="${false}" .attribute="${attribute}" .hasHelperText="${false}" disableWrite disableSubscribe disableButton></or-attribute-input>+ </td><td class="mdc-data-table__cell actions-cell"><or-input type="${InputType.BUTTON}" icon="delete" @click="${deleteAttribute}"></td></tr><tr class="attribute-meta-row">diff --git a/ui/component/or-attribute-input/package.json b/ui/component/or-attribute-input/package.jsonindex 5b58f978b..d0389313d 100644--- a/ui/component/or-attribute-input/package.json+++ b/ui/component/or-attribute-input/package.json@@ -14,6 +14,7 @@"dependencies": {"@openremote/core": "^1.1.0","@openremote/or-input": "^1.1.0",+ "@openremote/or-mwc-components": "^1.1.0","@openremote/or-translate": "^1.1.0","@openremote/or-map": "^1.1.0","lit-element": "^2.2.1"diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.tsindex 2018ca1a9..c48806b77 100644--- a/ui/component/or-attribute-input/src/index.ts+++ b/ui/component/or-attribute-input/src/index.ts@@ -26,6 +26,7 @@ import manager, {AssetModelUtil, DefaultColor4, subscribe, Util} from "@openremoimport "@openremote/or-input";import {InputType, OrInput, OrInputChangedEvent} from "@openremote/or-input";import "@openremote/or-map";+import {showDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";import {getMarkerIconAndColorFromAssetType,LngLat,@@ -64,7 +65,7 @@ declare global {export type AttributeInputCustomProviderResult = ((value: any, timestamp: number | undefined, loading: boolean, sending: boolean, error: boolean) => TemplateResult) | undefined;-export 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 type AttributeInputCustomProvider = (assetType: string | undefined, attribute: AssetAttribute | undefined, attributeDescriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, valueChangeNotifier: (value: any | undefined) => void, attributeInput: OrAttributeInput) => AttributeInputCustomProviderResult;export class CenterControl {protected map?: MapGL;@@ -93,9 +94,88 @@ export class CenterControl {}}-export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (assetType, attribute, attributeDescriptor, valueDescriptor, valueChangeNotifier, readonly, disabled, label) => {+const CoordinatesRegexPattern = "^[ ]*(?:Lat: )?(-?\\d+\\.?\\d*)[, ]+(?:Lng: )?(-?\\d+\\.?\\d*)[ ]*$";++function getCoordinatesInputKeyHandler(valueChangedHandler: (value: LngLat | undefined) => void) {+ return (e: KeyboardEvent) => {+ if (e.code === "Enter" || e.code === "NumpadEnter") {+ const valStr = (e.target as OrInput).value as string;+ let value: LngLat | undefined;++ if (valStr) {+ const lngLatArr = valStr.split(/[ ,]/).filter(v => !!v);+ if (lngLatArr.length === 2) {+ value = new LngLat(+ Number.parseFloat(lngLatArr[0]),+ Number.parseFloat(lngLatArr[1])+ );+ }+ }+ valueChangedHandler(value);+ }+ };+}++export class CoordinatesControl {++ protected map?: MapGL;+ protected elem?: HTMLElement;+ protected input!: OrInput;+ protected _readonly = false;+ protected _value: any;+ protected _valueChangedHandler: (value: LngLat | undefined) => void;++ constructor(disabled: boolean = false, valueChangedHandler: (value: LngLat | undefined) => void) {+ this._readonly = disabled;+ this._valueChangedHandler = valueChangedHandler;+ }++ onAdd(map: MapGL): HTMLElement {+ this.map = map;+ const control = document.createElement("div");+ control.classList.add("mapboxgl-ctrl");+ control.classList.add("mapboxgl-ctrl-group");++ const input = new OrInput();+ 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);++ control.appendChild(input);+ this.elem = control;+ this.input = input;+ return control;+ }++ onRemove(map: MapGL) {+ this.map = undefined;+ this.elem = undefined;+ }++ public set readonly(readonly: boolean) {+ this._readonly = readonly;+ if (this.input) {+ this.input.readonly = readonly;+ }+ }++ public set value(value: any) {+ this._value = value;+ if (this.input) {+ this.input.value = value;+ }+ }+}++export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (assetType, attribute, attributeDescriptor, valueDescriptor, valueChangeNotifier, attributeInput) => {const centerControl = new CenterControl();+ const coordinatesControl = new CoordinatesControl(attributeInput.disabled, valueChangeNotifier);return (value, timestamp, loading, sending, error) => {let pos: LngLat | undefined;@@ -104,11 +184,15 @@ export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (pos = MapUtil.getLngLat(value);center = pos ? pos.toArray() : undefined;}+centerControl.pos = pos;+ coordinatesControl.readonly = !!attributeInput.disabled || !!attributeInput.readonly || sending || loading;+ coordinatesControl.value = center ? center.join(", ") : undefined;+const iconAndColor = getMarkerIconAndColorFromAssetType(assetType);const clickHandler = (mapClickDetail: MapEventDetail) => {- if (!readonly && !disabled && mapClickDetail.doubleClick) {+ if (!attributeInput.readonly && !attributeInput.disabled && mapClickDetail.doubleClick) {const geoJsonPoint = MapUtil.getGeoJSONPoint(mapClickDetail.lngLat);if (valueChangeNotifier) {valueChangeNotifier(geoJsonPoint);@@ -116,19 +200,38 @@ export const GeoJsonPointInputTemplateProvider: AttributeInputCustomProvider = (}};- 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}" .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>- `;+ let 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}" .controls="${[centerControl, [coordinatesControl, "top-left"]]}">+ <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>+ `;++ if (attributeInput.compact) {- return getAttributeInputWrapper(content, loading, !!disabled, getHelperText(sending, false, timestamp), label, undefined);+ const mapContent = content;++ const onClick = () => {+ showDialog(+ {+ content: mapContent,+ });+ };++ content = html`+ <div>+ <or-input .type="${InputType.TEXT}" comfortable outlined .pattern="${CoordinatesRegexPattern}" @keyup="${(e: KeyboardEvent) => getCoordinatesInputKeyHandler(valueChangeNotifier)(e)}"></or-input>+ <or-input .type="${InputType.BUTTON}" compact action icon="crosshairs-gps" @clicked="${onClick}"></or-input>+ </div>+ `;+ }++ return getAttributeInputWrapper(content, loading, !!attributeInput.disabled, getHelperText(sending, false, timestamp), attributeInput.label, undefined);}}@@ -421,6 +524,9 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE@property({type: Boolean})public disableWrite: boolean = false;+ @property({type: Boolean})+ public compact: boolean = false;+@property()protected _attributeEvent?: AttributeEvent;@@ -443,11 +549,8 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEprotected _step?: number;protected _min?: any;protected _max?: any;- protected _label?: string;protected _unit?: string;protected _options?: any;- protected _readonly?: boolean;- protected _disabled?: boolean;protected _showButton?: boolean;protected _valueFormat?: string;protected _sendError = false;@@ -575,26 +678,14 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEthis._step = undefined;this._min = undefined;this._max = undefined;- this._label = undefined;this._unit = undefined;this._options = undefined;- this._disabled = undefined;- this._readonly = undefined;this._showButton = undefined;this._inputType = undefined;this._valueFormat = undefined;- if (this.label) {- this._label = this.label;- } else if (this.label !== "" && this.label !== null) {- const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assetType, this.attribute || this._attributeDescriptor);- this._label = Util.getAttributeLabel(this.attribute, descriptors[0], descriptors[1], true);- }- this._readonly = this.readonly !== undefined ? this.readonly : Util.getMetaValue(MetaItemType.READ_ONLY, this.attribute, this._attributeDescriptor);- this._disabled = this.disabled;-if (this.customProvider) {- this._template = this.customProvider(this.assetType, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor, (v) => this._updateValue(v), this._readonly, this._disabled, this._label);+ this._template = this.customProvider(this.assetType, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor, (v) => this._updateValue(v), this);}if (this._template) {@@ -606,7 +697,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE} else if (this._attributeValueDescriptor) {switch (this._attributeValueDescriptor.name) {case AttributeValueType.GEO_JSON_POINT.name:- this._template = GeoJsonPointInputTemplateProvider(this.assetType, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor, (v) => this._updateValue(v), this._readonly, this._disabled, this._label);+ this._template = GeoJsonPointInputTemplateProvider(this.assetType, this.attribute, this._attributeDescriptor, this._attributeValueDescriptor, (v) => this._updateValue(v), this);return;case AttributeValueType.SWITCH_MOMENTARY.name:this._inputType = InputType.BUTTON_MOMENTARY;@@ -667,10 +758,27 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE}this._valueFormat = Util.getAttributeValueFormat(this.attribute, this._attributeDescriptor, this._attributeValueDescriptor);- this._showButton = !this._readonly && !this._disabled && !this.disableButton && this.inputTypeSupportsButton() && !!this._getAttributeRef();+ this._showButton = !this.isReadonly() && !this.disabled && !this.disableButton && this.inputTypeSupportsButton() && !!this._getAttributeRef();}}+ public getLabel(): string | undefined {+ let label;++ if (this.label) {+ label = this.label;+ } else if (this.label !== "" && this.label !== null) {+ const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.assetType, this.attribute || this._attributeDescriptor);+ label = Util.getAttributeLabel(this.attribute, descriptors[0], descriptors[1], true);+ }++ return label;+ }++ public isReadonly(): boolean {+ return this.readonly !== undefined ? this.readonly : Util.getMetaValue(MetaItemType.READ_ONLY, this.attribute, this._attributeDescriptor);+ }+public render() {// Check if attribute hasn't been loaded yet or pending write@@ -690,7 +798,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEconst helperText = this.hasHelperText ? getHelperText(!!this._writeTimeoutHandler, this._sendError, this.getTimestamp()) : undefined;const buttonIcon = this._writeTimeoutHandler ? "send-clock" : "send";const supportsHelperText = this.inputTypeSupportsHelperText();- let label = this._label;+ let label = this.getLabel();if (helperText && !this.inputTypeSupportsHelperText()) {label = undefined;@@ -698,8 +806,8 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEcontent = html`<or-input id="input" .type="${this._inputType}" .label="${label}" .value="${value}".allowedValues="${this._options}" .min="${this._min}" .max="${this._max}" .format="${this._valueFormat}"- .options="${this._options}" .readonly="${this._readonly}" .disabled="${this._disabled || loading}"- .helperText="${supportsHelperText ? helperText : undefined}" .helperPersistent="${true}" .disableSliderNumberInput="${this._readonly}"+ .options="${this._options}" .readonly="${this.isReadonly()}" .disabled="${this.disabled || loading}"+ .helperText="${supportsHelperText ? helperText : undefined}" .helperPersistent="${true}" .disableSliderNumberInput="${this.isReadonly()}"@keyup="${(e: KeyboardEvent) => {if ((e.code === "Enter" || e.code === "NumpadEnter") && this._inputType !== InputType.JSON && this._inputType !== InputType.TEXTAREA) {this._updateValue(this._attrInput.value);@@ -711,7 +819,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE}}}"></or-input>`;- content = getAttributeInputWrapper(content, loading, !!this._disabled, !supportsHelperText ? helperText : undefined, this._label, this._showButton ? buttonIcon : this.disableButton ? undefined : "", () => this._attrInput.value, (v) => this._updateValue(v));+ content = getAttributeInputWrapper(content, loading, !!this.disabled, !supportsHelperText ? helperText : undefined, this.getLabel(), this._showButton ? buttonIcon : this.disableButton ? undefined : "", () => this._attrInput.value, (v) => this._updateValue(v));}return content;@@ -782,7 +890,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitEprotected _updateValue(newValue: any) {const oldValue = this.getValue();- if (this.readonly || this._readonly) {+ if (this.readonly || this.isReadonly()) {return;}diff --git a/ui/component/or-attribute-input/tsconfig.json b/ui/component/or-attribute-input/tsconfig.jsonindex 0bc413e36..12c131db7 100644--- a/ui/component/or-attribute-input/tsconfig.json+++ b/ui/component/or-attribute-input/tsconfig.json@@ -12,6 +12,7 @@"references": [{ "path": "../core" },{ "path": "../or-translate" },+ { "path": "../or-mwc-components" },{ "path": "../or-map" },{ "path": "../or-input" }]diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.tsindex e6265d437..8cee18245 100644--- a/ui/component/or-input/src/index.ts+++ b/ui/component/or-input/src/index.ts@@ -101,8 +101,7 @@ const style = css`:host([hidden]) {display: none;- }-+ }:host([type=select]) {height: 56px;@@ -158,16 +157,12 @@ const style = css`width: inherit;}- .mdc-text-field--dense:not(.mdc-text-field--no-label):not(.mdc-text-field--outlined) {- height: 52px;+ .mdc-text-field.dense-comfortable {+ height: 48px;}- .mdc-text-field--dense.mdc-text-field--no-label {- height: 40px;- }-- .mdc-text-field--dense .mdc-text-field__input {- white-space: nowrap;+ .mdc-text-field.dense-compact {+ height: 36px;}.mdc-select:not(.mdc-list) {@@ -290,7 +285,10 @@ export class OrInput extends LitElement {public iconTrailing?: string;@property({type: Boolean})- public dense: boolean = false;+ public compact: boolean = false;++ @property({type: Boolean})+ public comfortable: boolean = false;/* BUTTON STYLES START */@@ -562,12 +560,11 @@ export class OrInput extends LitElement {"mdc-icon-button": isIconButton,"mdc-fab": !isIconButton && this.action,"mdc-fab--extended": !isIconButton && this.action && !!this.label,- "mdc-fab--mini": !isIconButton && this.action, // && this.dense,+ "mdc-fab--mini": !isIconButton && this.action && (this.compact || this.comfortable),"mdc-button": !isIconButton && !this.action,"mdc-button--raised": !isIconButton && !this.action && this.raised,"mdc-button--unelevated": !isIconButton && !this.action && this.unElevated,"mdc-button--outlined": !isIconButton && !this.action && this.outlined,- "mdc-button--dense": false, // !isIconButton && !this.action && this.dense,"or-input--rounded": !isIconButton && !this.action && this.rounded};return html`@@ -618,7 +615,7 @@ export class OrInput extends LitElement {case InputType.TEXTAREA:case InputType.JSON: {// The following HTML input types require the values as specially formatted strings- const valMinMax: [any, any, any] = [this.value || "", this.min, this.max];+ const valMinMax: [any, any, any] = [this.value === undefined || this.value === null ? "" : this.value, this.min, this.max];if (valMinMax.some((v) => v !== undefined && v !== null && typeof (v) !== "string")) {@@ -680,8 +677,8 @@ export class OrInput extends LitElement {let label = this.label;let type = this.type;let componentId = "component";- let denseDefault = true;- let denseCompact = false;+ let denseComfortable = this.comfortable;+ let denseCompact = !this.comfortable && this.compact;let rounded = false;if (this.type === InputType.RANGE) {@@ -689,8 +686,7 @@ export class OrInput extends LitElement {label = undefined;outlined = true;hasHelper = false;- denseCompact = true;- denseDefault = false;+ denseComfortable = true;rounded = true;type = InputType.NUMBER;componentId = "number";@@ -704,7 +700,7 @@ export class OrInput extends LitElement {"mdc-text-field--textarea": type === InputType.TEXTAREA || type === InputType.JSON,"mdc-text-field--disabled": this.disabled,"mdc-text-field--fullwidth": this.fullWidth && !outlined,- "dense-default": denseDefault,+ "dense-comfortable": denseComfortable,"dense-compact": denseCompact,"is-rounded": rounded,"mdc-text-field--label-floating" : hasValue,diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.tsindex cfec63279..f18ec821b 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 manager, {EventCallback, MapType, OREvent} 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, Control, IControl} from "mapbox-gl";+import {Control, IControl, LngLat, LngLatBoundsLike, LngLatLike} from "mapbox-gl";import {MapWidget} from "./mapwidget";import {style} from "./style";import {OrMapMarker, OrMapMarkerChangedEvent} from "./markers/or-map-marker";@@ -12,6 +12,7 @@ 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 * from "./or-map-asset-card";export interface ViewSettings {"center": LngLatLike;@@ -62,6 +63,8 @@ declare global {}}+export type ControlPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';+@customElement("or-map")export class OrMap extends LitElement {@@ -102,7 +105,7 @@ export class OrMap extends LitElement {@property({type: Number})public zoom?: number;- public controls?: (Control | IControl)[];+ public controls?: (Control | IControl | [Control | IControl, ControlPosition?])[];protected _initCallback?: EventCallback;protected _map?: MapWidget;diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.tsindex 7aa8a377b..59e6faf84 100644--- a/ui/component/or-map/src/mapwidget.ts+++ b/ui/component/or-map/src/mapwidget.ts@@ -7,7 +7,7 @@ import {LngLatLike, Map as MapGL, MapboxOptions as OptionsGL, Marker as MarkerGLControl,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 {ControlPosition, OrMapClickedEvent, OrMapLoadedEvent, ViewSettings} from "./index";import {OrMapMarker} from "./markers/or-map-marker";@@ -32,7 +32,7 @@ export class MapWidget {protected _viewSettings?: ViewSettings;protected _center?: LngLat | LngLatLike;protected _zoom?: number;- protected _controls?: (Control | IControl)[];+ protected _controls?: (Control | IControl | [Control | IControl, ControlPosition?])[];protected _clickHandlers: Map<OrMapMarker, (ev: MouseEvent) => void> = new Map();constructor(type: MapType, styleParent: Node, mapContainer: HTMLElement) {@@ -118,10 +118,22 @@ export class MapWidget {return this;}- public setControls(controls?: (Control | IControl)[]): this {+ public setControls(controls?: (Control | IControl | [Control | IControl, ControlPosition?])[]): this {this._controls = controls;- if (this._mapGl && this._controls) {- this._controls.forEach((control) => this._mapGl!.addControl(control));+ if (this._mapGl) {+ if (this._controls) {+ this._controls.forEach((control) => {+ if (Array.isArray(control)) {+ const controlAndPosition: [Control | IControl, ControlPosition?] = control;+ this._mapGl!.addControl(controlAndPosition[0], controlAndPosition[1]);+ } else {+ this._mapGl!.addControl(control);+ }+ });+ } else {+ // Add zoom and rotation controls to the map+ this._mapGl.addControl(new NavigationControl());+ }}return this;}@@ -246,10 +258,16 @@ export class MapWidget {this._onMapClick(e.lngLat, true);});-// Add custom controlsif (this._controls) {- this._controls.forEach((control) => this._mapGl!.addControl(control));+ this._controls.forEach((control) => {+ if (Array.isArray(control)) {+ const controlAndPosition: [Control | IControl, ControlPosition?] = control;+ this._mapGl!.addControl(controlAndPosition[0], controlAndPosition[1]);+ } else {+ this._mapGl!.addControl(control);+ }+ });} else {// Add zoom and rotation controls to the mapthis._mapGl.addControl(new NavigationControl());diff --git a/ui/component/or-map/src/or-map-asset-card.ts b/ui/component/or-map/src/or-map-asset-card.tsindex d66ada4d4..51644bca7 100644--- a/ui/component/or-map/src/or-map-asset-card.ts+++ b/ui/component/or-map/src/or-map-asset-card.ts@@ -1,5 +1,4 @@import {- css,CSSResult,CSSResultArray,customElement,@@ -7,25 +6,25 @@ import {LitElement,property,PropertyValues,- TemplateResult,- unsafeCSS+ TemplateResult} from "lit-element";-import {Asset,Attribute, AssetEvent, AssetEventCause, AttributeEvent, AttributeType, AttributeValueType, MetaItemType, AttributeDescriptor, SharedEvent} from "@openremote/model";-import manager, {- AssetModelUtil,- DefaultColor1,- DefaultColor3,- DefaultColor4,- DefaultColor5,- DefaultHeaderHeight,- subscribe,- Util-} from "@openremote/core";+import {+ Asset,+ AssetEvent,+ AssetEventCause,+ Attribute,+ AttributeEvent,+ AttributeType,+ AttributeValueType,+ SharedEvent+} from "@openremote/model";+import manager, {AssetModelUtil, subscribe, Util} from "@openremote/core";import "@openremote/or-icon";import "./or-map-attribute-field";import {orAttributeTemplateProvider} from "./or-map-attribute-field";-import { i18next } from "@openremote/or-translate";import {mapAssetCardStyle} from "./style";+import { InputType } from "@openremote/or-input";+import { i18next } from "@openremote/or-translate";orAttributeTemplateProvider.setTemplate((attribute:Attribute) => {let template;@@ -56,15 +55,33 @@ orAttributeTemplateProvider.setTemplate((attribute:Attribute) => {return template;});-export interface MapAssetCardConfig {+export interface MapAssetCardTypeConfig {include?: string[];exclude?: string[];}+export interface MapAssetCardConfig {+ default?: MapAssetCardTypeConfig;+ assetTypes?: { [assetType: string]: MapAssetCardTypeConfig };+}++export class OrMapAssetCardLoadAssetEvent extends CustomEvent<string> {-export interface ViewerConfig {- default?: MapAssetCardConfig;- assetTypes?: { [assetType: string]: MapAssetCardConfig };+ public static readonly NAME = "or-map-asset-card-load-asset";++ constructor(assetId: string) {+ super(OrMapAssetCardLoadAssetEvent.NAME, {+ bubbles: true,+ composed: true,+ detail: assetId+ });+ }+}++declare global {+ export interface HTMLElementEventMap {+ [OrMapAssetCardLoadAssetEvent.NAME]: OrMapAssetCardLoadAssetEvent;+ }}@customElement("or-map-asset-card")@@ -77,7 +94,7 @@ export class OrMapAssetCard extends subscribe(manager)(LitElement) {public asset?: Asset;@property({type: Object})- public config?: ViewerConfig;+ public config?: MapAssetCardConfig;@property({type: Boolean, attribute: true})public useAssetColor: boolean = true;@@ -141,7 +158,7 @@ export class OrMapAssetCard extends subscribe(manager)(LitElement) {const icon = this.getIcon();const color = this.getColor();- const styleStr = color ? "--internal-or-asset-summary-card-header-color: #" + color + ";" : "";+ const styleStr = color ? "--internal-or-map-asset-card-header-color: #" + color + ";" : "";const cardConfig = this.getCardConfig();const attributes = Util.getAssetAttributes(this.asset).filter((attr) => attr.name !== AttributeType.LOCATION.attributeName);const includedAttributes = cardConfig && cardConfig.include ? cardConfig.include : undefined;@@ -166,12 +183,16 @@ export class OrMapAssetCard extends subscribe(manager)(LitElement) {</ul></div><div id="footer">- <a data-navigo href="#!assets/${this.asset.id}">Asset details</a>+ <or-input .type="${InputType.BUTTON}" .label="${i18next.t("viewAsset")}" @click="${(e: MouseEvent) => {e.preventDefault(); this._loadAsset(this.asset!.id!);}}"></or-input></div>- </div>+ </div>`;}+ protected _loadAsset(assetId: string) {+ this.dispatchEvent(new OrMapAssetCardLoadAssetEvent(assetId));+ }+protected getIcon(): string | undefined {if (this.asset) {const descriptor = AssetModelUtil.getAssetDescriptor(this.asset.type);diff --git a/ui/component/or-map/src/style.ts b/ui/component/or-map/src/style.tsindex a600b618b..0b8ab4931 100644--- a/ui/component/or-map/src/style.ts+++ b/ui/component/or-map/src/style.ts@@ -141,12 +141,12 @@ export const style = css`export const mapAssetCardStyle = css`:host {- --internal-or-asset-summary-card-header-color: var(--or-asset-summary-card-header-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));- --internal-or-asset-summary-card-header-text-color: var(--or-asset-summary-card-header-text-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));- --internal-or-asset-summary-card-header-height: var(--or-asset-summary-card-header-height, calc(${unsafeCSS(DefaultHeaderHeight)} - 10px));- --internal-or-asset-summary-card-background-color: var(--or-asset-summary-card-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));- --internal-or-asset-summary-card-background-text-color: var(--or-asset-summary-card-background-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));- --internal-or-asset-summary-card-separator-color: var(--or-asset-summary-card-separator-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));+ --internal-or-map-asset-card-header-color: var(--or-map-asset-card-header-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));+ --internal-or-map-asset-card-header-text-color: var(--or-map-asset-card-header-text-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));+ --internal-or-map-asset-card-header-height: var(--or-map-asset-card-header-height, calc(${unsafeCSS(DefaultHeaderHeight)} - 10px));+ --internal-or-map-asset-card-background-color: var(--or-map-asset-card-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));+ --internal-or-map-asset-card-background-text-color: var(--or-map-asset-card-background-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));+ --internal-or-map-asset-card-separator-color: var(--or-map-asset-card-separator-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));display: block;}@@ -155,20 +155,20 @@ export const mapAssetCardStyle = css`display: flex;flex-direction: column;height: 100%;- background-color: var(--internal-or-asset-summary-card-background-color);+ background-color: var(--internal-or-map-asset-card-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);}#header {- height: var(--internal-or-asset-summary-card-header-height);- background-color: var(--internal-or-asset-summary-card-header-color);- line-height: var(--internal-or-asset-summary-card-header-height);+ height: var(--internal-or-map-asset-card-header-height);+ background-color: var(--internal-or-map-asset-card-header-color);+ line-height: var(--internal-or-map-asset-card-header-height);border-bottom: 1px solid ${unsafeCSS(DefaultColor5)};text-align: center;- color: var(--internal-or-asset-summary-card-header-text-color);- --or-icon-fill: var(--internal-or-asset-summary-card-header-text-color);+ color: var(--internal-or-map-asset-card-header-text-color);+ --or-icon-fill: var(--internal-or-map-asset-card-header-text-color);--or-icon-width: 20px;--or-icon-height: 20px;z-index: 99999;@@ -184,7 +184,7 @@ export const mapAssetCardStyle = css`#attribute-list {flex: 1;- color: var(--internal-or-asset-summary-card-background-text-color);+ color: var(--internal-or-map-asset-card-background-text-color);padding: 10px 20px;overflow: auto;font-size: 14px;@@ -212,23 +212,13 @@ export const mapAssetCardStyle = css`}#footer {- justify-content: end;- display: flex;- height: var(--internal-or-asset-summary-card-header-height);- border-top: 1px solid var(--internal-or-asset-summary-card-separator-color);+ height: var(--internal-or-map-asset-card-header-height);+ border-top: 1px solid var(--internal-or-map-asset-card-separator-color);text-align: right;+ --or-input-color: var(--internal-or-map-asset-card-background-text-color);+ padding: 5px 12px;}- #footer > a {- line-height: var(--internal-or-asset-summary-card-header-height);- font-weight: 500;- font-size: 14px;- margin-left: auto;- margin-right: 20px;- text-decoration: none;- color: var(--internal-or-asset-summary-card-background-text-color);- }-@media only screen and (min-width: 415px){#card-container {height: 400px; /* fallback for IE */@@ -237,4 +227,4 @@ export const mapAssetCardStyle = css`min-height: 134px;}}-`\ No newline at end of file+`