Skip to content

armgit / core

Public Imported from GitHub
0

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

UI updates: Added or-asset-viewer and or-attribute-input (old or-input is now just a generic input component with material design styling), also includes refactoring

Rich Turner489a0ae31426
diff --git a/client/src/main/webapp/package.json b/client/src/main/webapp/package.json
index 6e717cbfa..422c84899 100644
--- a/client/src/main/webapp/package.json
+++ b/client/src/main/webapp/package.json
@@ -13,22 +13,29 @@
"tests"
],
"dependencies": {
- "@polymer/polymer": "^2.6.1",
- "@webcomponents/webcomponentsjs": "^1.1.0",
- "@polymer/iron-flex-layout": "^1.3.1-pre.3",
"@polymer/app-localize-behavior": "^0.10.1-pre.3",
"@polymer/app-route": "^0.9.3-pre.3",
+ "@polymer/iron-flex-layout": "^1.3.1-pre.3",
+ "@polymer/polymer": "^2.6.1",
"@webcomponents/shadycss": "^1.1.1",
+ "@webcomponents/webcomponentsjs": "^1.1.0",
+ "chart.js": "^2.7.0",
"font-awesome": "^4.7.0",
- "moment": "^2.20.1",
"intl": "^1.2.5",
- "chart.js": "^2.7.0"
+ "moment": "^2.20.1"
},
"resolutions": {
"@polymer/polymer": "^2.6.1",
"@polymer/promise-polyfill": "^1.0.1-pre.3"
},
"workspaces": {
- "nohoist": ["@polymer/**", "@webcomponents/**", "font-awesome", "moment", "intl", "chart.js"]
+ "nohoist": [
+ "@polymer/**",
+ "@webcomponents/**",
+ "font-awesome",
+ "moment",
+ "intl",
+ "chart.js"
+ ]
}
-}
\ No newline at end of file
+}
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index ff47c6f8d..851bd9fbd 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -70,6 +70,12 @@
"name": "Name",
"deleteAssetsNoChildrenAllowed": "Only assets that have no descendants can be deleted, please remove descendents first.",
"confirmDeleteAssets": "Remove assets?",
- "ok": "ok",
- "cancel": "cancel"
+ "ok": "OK",
+ "cancel": "Cancel",
+ "loading": "Loading",
+ "createdOn": "Created on",
+ "accessPublicRead": "Public read",
+ "type": "Type",
+ "path": "Path",
+ "showOnMap": "Show on map"
}
\ No newline at end of file
diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.json
index 0d66aba92..5dc96fd46 100644
--- a/deployment/manager/shared/locales/nl/or.json
+++ b/deployment/manager/shared/locales/nl/or.json
@@ -70,6 +70,11 @@
"name": "Naam",
"deleteAssetsNoChildrenAllowed": "Only assets that have no descendants can be deleted, please remove descendents first.",
"confirmDeleteAssets": "Asset verwijderen?",
- "ok": "ok",
- "cancel": "cancel"
+ "ok": "OK",
+ "cancel": "Cancel",
+ "createdOn": "Created on",
+ "accessPublicRead": "Public read",
+ "type": "Type",
+ "path": "Path",
+ "showOnMap": "Show on map"
}
\ No newline at end of file
diff --git a/ui/app/smart-building-v1/package.json b/ui/app/smart-building-v1/package.json
index 306346121..66bcc2803 100644
--- a/ui/app/smart-building-v1/package.json
+++ b/ui/app/smart-building-v1/package.json
@@ -5,7 +5,5 @@
"author": "OpenRemote Inc. <[email protected]>",
"description": "OpenRemote SmartHome Example App",
"main": "index.html",
- "license": "AGPL-3.0-or-later",
- "dependencies": {
- }
-}
\ No newline at end of file
+ "license": "AGPL-3.0-or-later"
+}
diff --git a/ui/component/core/src/asset-mixin.ts b/ui/component/core/src/asset-mixin.ts
index 021f4de21..8a5cac663 100644
--- a/ui/component/core/src/asset-mixin.ts
+++ b/ui/component/core/src/asset-mixin.ts
@@ -1,36 +1,39 @@
/* tslint:disable:no-empty */
import {EventProviderFactory, EventProviderStatus} from "./event";
import {arraysEqual} from "./util";
-import {AttributeEvent, AssetEvent, AssetEventCause} from "@openremote/model";
+import {AssetEvent, AttributeEvent, AttributeRef} from "@openremote/model";
declare type Constructor<T = {}> = new (...args: any[]) => T;
-export const subscribe = (eventProviderFactory: EventProviderFactory) => <T extends Constructor>(base: T) => {
+interface CustomElement {
+ connectedCallback?(): void;
+ disconnectedCallback?(): void;
+ readonly isConnected: boolean;
+}
- return class extends base {
+export const subscribe = (eventProviderFactory: EventProviderFactory) => <T extends Constructor<CustomElement>>(base: T) =>
+
+ class extends base {
public _connectRequested = false;
public _assetSubscriptionId?: string;
public _attributeSubscriptionId?: string;
public _assetIds?: string[];
+ public _attributeRefs?: AttributeRef[];
public _statusCallback = (status: EventProviderStatus) => this._onEventProviderStatusChanged(status);
- public connectedCallback() {
- // @ts-ignore
+ connectedCallback() {
if (super.connectedCallback) {
- // @ts-ignore
super.connectedCallback();
}
this.connect();
}
- public disconnectedCallback() {
+ disconnectedCallback() {
this.disconnect();
- // @ts-ignore
if (super.disconnectedCallback) {
- // @ts-ignore
super.disconnectedCallback();
}
}
@@ -54,16 +57,19 @@ export const subscribe = (eventProviderFactory: EventProviderFactory) => <T exte
return;
}
- if (!this._assetIds || this._assetIds.length === 0) {
- return;
- }
-
if (eventProviderFactory.getEventProvider()!.status !== EventProviderStatus.CONNECTED) {
return;
}
- this._assetSubscriptionId = await eventProviderFactory.getEventProvider()!.subscribeAssetEvents(this._assetIds, (event) => this._onAssetEvent(event));
- this._attributeSubscriptionId = await eventProviderFactory.getEventProvider()!.subscribeAttributeEvents(this._assetIds, false, (event) => this._onAttributeEvent(event));
+ const ids: string[] | AttributeRef[] | undefined = this._attributeRefs ? this._attributeRefs : this._assetIds;
+
+ if (ids && ids.length > 0) {
+ this._assetSubscriptionId = await eventProviderFactory.getEventProvider()!.subscribeAssetEvents(ids, true, (event) => this._onAssetEvent(event));
+ this._attributeSubscriptionId = await eventProviderFactory.getEventProvider()!.subscribeAttributeEvents(ids, false, (event) => this._onAttributeEvent(event));
+ } else if (this._attributeRefs && this._attributeRefs.length > 0) {
+
+ }
+ this.onStatusChange(EventProviderStatus.CONNECTED);
}
public disconnect() {
@@ -84,6 +90,7 @@ export const subscribe = (eventProviderFactory: EventProviderFactory) => <T exte
eventProviderFactory.getEventProvider()!.unsubscribe(this._attributeSubscriptionId!);
this._assetSubscriptionId = undefined;
this._attributeSubscriptionId = undefined;
+ this.onStatusChange(EventProviderStatus.DISCONNECTED);
}
public set assetIds(assetIds: string[] | undefined) {
@@ -96,6 +103,16 @@ export const subscribe = (eventProviderFactory: EventProviderFactory) => <T exte
this._doConnect();
}
+ public set attributeRefs(attributes: AttributeRef[] | undefined) {
+ if (arraysEqual(this._attributeRefs, attributes)) {
+ return;
+ }
+
+ this._attributeRefs = attributes;
+ this._doDisconnect();
+ this._doConnect();
+ }
+
public _onEventProviderStatusChanged(status: EventProviderStatus) {
switch (status) {
case EventProviderStatus.DISCONNECTED:
@@ -123,10 +140,18 @@ export const subscribe = (eventProviderFactory: EventProviderFactory) => <T exte
this.onAssetEvent(event);
}
+ public _sendEvent(event: AttributeEvent) {
+ if (eventProviderFactory.getEventProvider()!.status === EventProviderStatus.CONNECTED) {
+ eventProviderFactory.getEventProvider()!.sendEvent(event);
+ }
+ }
+
+ // noinspection JSUnusedLocalSymbols
+ public onStatusChange(status: EventProviderStatus) {}
+
// noinspection JSUnusedLocalSymbols
public onAttributeEvent(event: AttributeEvent) {}
// noinspection JSUnusedLocalSymbols
public onAssetEvent(event: AssetEvent) {}
};
-};
diff --git a/ui/component/core/src/console.ts b/ui/component/core/src/console.ts
index 32a1c4277..544c02504 100644
--- a/ui/component/core/src/console.ts
+++ b/ui/component/core/src/console.ts
@@ -3,8 +3,6 @@ import rest from "@openremote/rest";
import openremote from "./index";
import {AxiosResponse} from "axios";
-declare function require(name: string): any;
-
// No ES6 module support in platform lib
let platform = require('platform');
diff --git a/ui/component/core/src/event.ts b/ui/component/core/src/event.ts
index 535ca5b3f..0aa54de92 100644
--- a/ui/component/core/src/event.ts
+++ b/ui/component/core/src/event.ts
@@ -9,7 +9,8 @@ import {
ReadAssetAttributesEvent,
AssetEvent,
ReadAssetEvent,
- TriggeredEventSubscription
+ TriggeredEventSubscription,
+ AttributeRef
} from "@openremote/model";
export enum EventProviderStatus {
@@ -33,9 +34,9 @@ export interface EventProvider {
unsubscribe<T extends SharedEvent>(subscriptionId: string): void;
- subscribeAssetEvents(assetIds: string[] | null, callback: (event: AssetEvent) => void): Promise<string>;
+ subscribeAssetEvents(ids: string[] | AttributeRef[] | null, requestCurrentValues: boolean, callback: (event: AssetEvent) => void): Promise<string>;
- subscribeAttributeEvents(assetIds: string[], requestCurrentValues: boolean, callback: (event: AttributeEvent) => void): Promise<string>;
+ subscribeAttributeEvents(ids: string[] | AttributeRef[], requestCurrentValues: boolean, callback: (event: AttributeEvent) => void): Promise<string>;
sendEvent<T extends SharedEvent>(event: T): void;
}
@@ -212,25 +213,29 @@ abstract class EventProviderImpl implements EventProvider {
this._doSend(event);
}
- public async subscribeAssetEvents(assetIds: string[] | null, callback: (event: AssetEvent) => void): Promise<string> {
+ public async subscribeAssetEvents(ids: string[] | AttributeRef[] | null, requestCurrentValues: boolean, callback: (event: AssetEvent) => void): Promise<string> {
+
let subscription: EventSubscription<AssetEvent> = {
eventType: "asset"
};
- if (assetIds && assetIds.length > 0) {
+ if (ids && ids.length > 0) {
subscription.filter = {
filterType: "asset-id",
- assetIds: assetIds
+ assetIds: ids
};
}
+ const isAttributeRef = ids && typeof ids[0] !== "string";
+ const assetIds = isAttributeRef ? (ids as AttributeRef[]).map((id) => id.entityId!) : ids as string[] | null;
+
let subscriptionId: string | null = null;
try {
subscriptionId = await this.subscribe(subscription, callback);
// Get the current state of each asset
- if (assetIds) {
+ if (assetIds && requestCurrentValues) {
assetIds.forEach(assetId => {
let readEvent: ReadAssetEvent = {
assetId: assetId,
@@ -241,7 +246,7 @@ abstract class EventProviderImpl implements EventProvider {
});
}
} catch (e) {
- console.error("Failed to subscribe to asset events for assets: " + assetIds);
+ console.error("Failed to subscribe to asset events for assets: " + ids);
if (subscriptionId) {
this.unsubscribe(subscriptionId);
}
@@ -251,7 +256,16 @@ abstract class EventProviderImpl implements EventProvider {
return subscriptionId!;
}
- public async subscribeAttributeEvents(assetIds: string[], requestCurrentValues: boolean, callback: (event: AttributeEvent) => void): Promise<string> {
+ public async subscribeAttributeEvents(ids: string[] | AttributeRef[], requestCurrentValues: boolean, callback: (event: AttributeEvent) => void): Promise<string> {
+
+ if (!ids || ids.length === 0) {
+ throw new Error("At least one ID must be provided");
+ }
+
+ const isAttributeRef = typeof ids[0] !== "string";
+ const assetIds = isAttributeRef ? (ids as AttributeRef[]).map((id) => id.entityId!) : ids as string[];
+ const attributes = isAttributeRef ? ids as AttributeRef[] : undefined;
+
let subscription: EventSubscription<AttributeEvent> = {
eventType: "attribute",
filter: {
@@ -263,21 +277,32 @@ abstract class EventProviderImpl implements EventProvider {
let subscriptionId: string | null = null;
try {
- subscriptionId = await this.subscribe(subscription, callback);
+ subscriptionId = await this.subscribe(subscription, (evt) => {
+ if(attributes) {
+ // Filter events for these attributes
+ const eventRef = evt.attributeState!.attributeRef!;
+ if (attributes.findIndex((attrRef) => eventRef.entityId === attrRef.entityId && eventRef.attributeName === attrRef.attributeName) >= 0) {
+ callback(evt);
+ }
+ } else {
+ callback(evt);
+ }
+ });
// Get the current value of each assets attributes
if (requestCurrentValues) {
- assetIds.forEach(assetId => {
+ assetIds.forEach((assetId) => {
let readEvent: ReadAssetAttributesEvent = {
assetId: assetId,
eventType: "read-asset-attributes",
+ attributeNames: attributes ? attributes.filter((attr) => attr.entityId === assetId).map((attr) => attr.attributeName!) : undefined,
subscriptionId: subscriptionId!
};
this.sendEvent(readEvent);
});
}
} catch (e) {
- console.error("Failed to subscribe to attribute events for assets: " + assetIds);
+ console.error("Failed to subscribe to attribute events for assets/attributes: " + assetIds.join(", "));
if (subscriptionId) {
this.unsubscribe(subscriptionId);
}
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 0e2282792..ff769a234 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -6,7 +6,8 @@ import {AxiosRequestConfig} from "axios";
import {EventProvider, EventProviderFactory, EventProviderStatus, WebSocketEventProvider} from "./event";
import i18next from "i18next";
import i18nextXhr from "i18next-xhr-backend";
-import {AssetDescriptor, AttributeDescriptor, AttributeValueDescriptor, MetaItemDescriptor} from "@openremote/model";
+import {AssetDescriptor, AttributeDescriptor, AttributeValueDescriptor, MetaItemDescriptor, Asset, AssetAttribute,
+ MetaItem} from "@openremote/model";
import * as Util from "./util";
export declare type KeycloakPromise<T> = {
@@ -32,13 +33,17 @@ export declare type Keycloak = {
export {Util};
-export const DefaultColor1: string = "#FFF"; // Header
+export const DefaultColor4: string = "#1B5630"; // Primary
+export const DefaultColor7: string = "#FFF"; // Secondary
+export const DefaultColor1: string = "#FFF"; // Surface
export const DefaultColor2: string = "#F9F9F9"; // Background
-export const DefaultColor3: string = "#4c4c4c"; // Text
-export const DefaultColor4: string = "#1B5630"; // Buttons
export const DefaultColor5: string = "#CCC"; // Borders and lines
export const DefaultColor6: string = "#be0000"; // Invalid/Error
-export const DefaultColor7: string = "#FFF"; // Panels
+export const DefaultColor8: string = "#FFF"; // On Primary
+export const DefaultColor3: string = "#4c4c4c"; // Text / On Secondary
+export const DefaultColor9: string = "#000"; // On Background
+export const DefaultColor10: string = "#000"; // On Surface
+export const DefaultColor11: string = "#FFF"; // On Error
export 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";
@@ -156,7 +161,7 @@ export class AssetModelUtil {
});
}
- public static getAttributeDescriptorFromAsset(assetType?: string, attributeName?: string): AttributeDescriptor | undefined {
+ public static getAttributeDescriptorFromAsset(attributeName: string, assetType?: string): AttributeDescriptor | undefined {
if (!attributeName) {
return;
}
@@ -174,16 +179,23 @@ export class AssetModelUtil {
return this.getAttributeDescriptor(attributeName);
}
- public static getAttributeValueDescriptor(name?: string): AttributeValueDescriptor | undefined {
- if (!name) {
- return;
- }
-
+ public static getAttributeValueDescriptor(name: string): AttributeValueDescriptor | undefined {
return this._attributeValueDescriptors.find((attributeValueDescriptor) => {
return attributeValueDescriptor.name === name;
});
}
+ public static getAttributeValueDescriptorFromAsset(name: string, assetType?: string, attributeName?: string) : AttributeValueDescriptor | undefined {
+ if (attributeName) {
+ const attributeDescriptor = this.getAttributeDescriptorFromAsset(attributeName, assetType);
+ if (attributeDescriptor) {
+ return attributeDescriptor.valueDescriptor;
+ }
+ }
+
+ return this.getAttributeValueDescriptor(name);
+ }
+
public static getMetaItemDescriptor(urn?: string): MetaItemDescriptor | undefined {
if (!urn) {
return;
@@ -204,6 +216,17 @@ export class AssetModelUtil {
return attributeValueDescriptor1.name === attributeValueDescriptor2.name && attributeValueDescriptor1.valueType === attributeValueDescriptor2.valueType;
}
+ public static getMetaValue(metaItemUrn: string | MetaItemDescriptor, metaItems: MetaItem[] | undefined): any {
+ if (!metaItems) {
+ return;
+ }
+
+ const urn = typeof metaItemUrn === "string" ? metaItemUrn : (metaItemUrn as MetaItemDescriptor).urn;
+
+ const mi = metaItems.find((mi) => mi.name === urn);
+ return mi ? mi.value : undefined;
+ }
+
public static getMetaInitialValueFromMetaDescriptors(metaItemUrn: MetaItemDescriptor | string, metaItemDescriptors: MetaItemDescriptor[] | undefined): any | undefined {
if (!metaItemDescriptors) {
return;
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.ts
index aa0f07db5..4dae94341 100644
--- a/ui/component/core/src/util.ts
+++ b/ui/component/core/src/util.ts
@@ -7,11 +7,11 @@ import {
RuleCondition,
LogicGroup,
Asset,
- AssetAttribute,
+ Attribute,
AttributeEvent,
- MetaItem
+ MetaItem,
+ AssetAttribute
} from "@openremote/model";
-import {Util} from "./index";
export class Deferred<T> {
@@ -204,18 +204,19 @@ export function getQueryParameter(name: string): string {
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
-export function getAssetAttribute(asset: Asset, attributeName: string): AssetAttribute | undefined {
+export function getAssetAttribute(asset: Asset, attributeName: string): Attribute | undefined {
if (asset.attributes && asset.attributes.hasOwnProperty(attributeName)) {
- const attr = asset.attributes[attributeName] as AssetAttribute;
+ const attr = asset.attributes[attributeName] as Attribute;
attr.name = attributeName;
return attr;
}
}
-export function getAssetAttributes(asset: Asset): AssetAttribute[] {
+export function getAssetAttributes(asset: Asset, exclude?: string[]): AssetAttribute[] {
if (asset.attributes) {
- return Object.entries(asset.attributes as {[s: string]: AssetAttribute}).map(([name, attr]) => {
+ return Object.entries(asset.attributes as {[s: string]: AssetAttribute}).filter(([name, attr]) => !exclude || exclude.indexOf(name) >= 0).map(([name, attr]) => {
attr.name = name;
+ attr.assetId = asset.id;
return attr;
});
}
@@ -223,6 +224,14 @@ export function getAssetAttributes(asset: Asset): AssetAttribute[] {
return [];
}
+export function getFirstMetaItem(attribute: Attribute | undefined, name: string): MetaItem | undefined {
+ if (!attribute || !attribute.meta) {
+ return;
+ }
+
+ return attribute.meta.find((metaItem) => metaItem.name === name);
+}
+
/**
* Immutable update of an asset using the supplied attribute event
*/
diff --git a/ui/component/model/package.json b/ui/component/model/package.json
index 7b7a1d50f..6a5aa24bd 100644
--- a/ui/component/model/package.json
+++ b/ui/component/model/package.json
@@ -10,7 +10,6 @@
},
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
- "dependencies": {},
"devDependencies": {
"tslint": "^5.11.0",
"typescript": "^3.4.5"
@@ -18,4 +17,4 @@
"files": [
"dist"
]
-}
\ No newline at end of file
+}
diff --git a/ui/component/or-asset-tree/package.json b/ui/component/or-asset-tree/package.json
index f6ded862a..51f3e9f46 100644
--- a/ui/component/or-asset-tree/package.json
+++ b/ui/component/or-asset-tree/package.json
@@ -17,7 +17,7 @@
"@openremote/or-select": "^1.0.0",
"@openremote/or-translate": "^1.0.0",
"@openremote/rest": "^1.0.2",
- "lit-element": "^2.1.0",
+ "lit-element": "^2.2.1",
"moment": "^2.24.0"
},
"devDependencies": {
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 0d3ff0cf5..e9b2a9a33 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -1,13 +1,12 @@
-import {customElement, html, LitElement, property, PropertyValues, TemplateResult, query} from "lit-element";
+import {customElement, html, LitElement, property, PropertyValues, query, TemplateResult} from "lit-element";
import "@openremote/or-select";
import "@openremote/or-icon";
-import {TenantRuleset, Asset, AssetQuery, Tenant, AssetTreeNode, AssetType} from "@openremote/model";
+import {Asset, AssetQuery, AssetTreeNode, AssetType, Tenant} from "@openremote/model";
import "@openremote/or-translate";
import {style} from "./style";
import openremote, {AssetModelUtil} from "@openremote/core";
import rest from "@openremote/rest";
import {OrSelectChangedEvent} from "@openremote/or-select";
-import "@openremote/or-icon";
import Qs from "qs";
export interface UiAssetTreeNode extends AssetTreeNode {
@@ -190,6 +189,8 @@ export class OrAssetTree extends LitElement {
}
protected firstUpdated(_changedProperties: PropertyValues): void {
+ super.firstUpdated(_changedProperties);
+
this.addEventListener("click", (evt) => {
if (this._sortMenu.hasAttribute("data-visible") && !this._sortMenu.contains(evt.target as Node)) {
this._sortMenu.toggleAttribute("data-visible");
@@ -347,6 +348,7 @@ export class OrAssetTree extends LitElement {
this.selectedIds = actuallySelectedIds;
this._selectedNodes = selectedNodes;
+ this.dispatchEvent(new OrAssetTreeSelectionChangedEvent(this._selectedNodes));
}
@@ -429,7 +431,7 @@ export class OrAssetTree extends LitElement {
let deselectOthers = true;
if (this.multiSelect) {
- if (evt.ctrlKey) {
+ if (evt.ctrlKey || evt.metaKey) {
deselectOthers = false;
if (index >= 0 && selectedIds.length > 1) {
select = false;
diff --git a/ui/component/or-asset-tree/src/style.ts b/ui/component/or-asset-tree/src/style.ts
index 5c59ee78a..e758cee45 100644
--- a/ui/component/or-asset-tree/src/style.ts
+++ b/ui/component/or-asset-tree/src/style.ts
@@ -1,5 +1,5 @@
import {css, unsafeCSS} from "lit-element";
-import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultColor4, DefaultColor7, DefaultBoxShadow, DefaultDisabledOpacity,
+import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultColor4, DefaultBoxShadow, DefaultDisabledOpacity,
DefaultBoxShadowBottom} from "@openremote/core";
import mdi from "@openremote/or-icon/dist/mdi-icons";
@@ -8,11 +8,11 @@ export const style = css`
:host {
--internal-or-asset-tree-header-color: var(--or-asset-tree-header-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
- --internal-or-asset-tree-header-text-color: var(--or-asset-tree-header-text-color, var(--or-app-color7, ${unsafeCSS(DefaultColor7)}));
+ --internal-or-asset-tree-header-text-color: var(--or-asset-tree-header-text-color, var(--or-app-color7, ${unsafeCSS(DefaultColor1)}));
--internal-or-asset-tree-header-menu-background-color: var(--or-asset-tree-header-menu-background-color, var(--internal-or-asset-tree-header-text-color));
--internal-or-asset-tree-header-menu-text-color: var(--or-asset-tree-header-menu-text-color, inherit);
--internal-or-asset-tree-header-height: var(--or-asset-tree-header-height, 40px);
- --internal-or-asset-tree-background-color: var(--or-asset-tree-background-color, var(--or-app-color7, ${unsafeCSS(DefaultColor7)}));
+ --internal-or-asset-tree-background-color: var(--or-asset-tree-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
--internal-or-asset-tree-text-color: var(--or-asset-tree-text-color, inherit);
--internal-or-asset-tree-item-height: var(--or-asset-tree-item-height, 24px);
--internal-or-asset-tree-item-padding: var(--or-asset-tree-item-padding, 10px);
diff --git a/ui/component/or-asset-viewer/.npmignore b/ui/component/or-asset-viewer/.npmignore
new file mode 100644
index 000000000..ca658009d
--- /dev/null
+++ b/ui/component/or-asset-viewer/.npmignore
@@ -0,0 +1,3 @@
+build/
+build.gradle
+test/
\ No newline at end of file
diff --git a/ui/component/or-asset-viewer/README.md b/ui/component/or-asset-viewer/README.md
new file mode 100644
index 000000000..aea7d59d4
--- /dev/null
+++ b/ui/component/or-asset-viewer/README.md
@@ -0,0 +1,31 @@
+# @openremote/or-asset-tree \<or-asset-tree\>
+[![NPM Version][npm-image]][npm-url]
+[![Linux Build][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+Web Component for displaying an asset tree. This component requires an OpenRemote Manager to retrieve, save and query assets.
+
+## Install
+```bash
+npm i @openremote/or-asset-list
+yarn add @openremote/or-asset-list
+```
+
+## Usage
+For a full list of properties, methods and options refer to the TypeDoc generated [documentation]().
+
+
+## Supported Browsers
+The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition,
+Internet Explorer 11 is also supported.
+
+
+## License
+[GNU AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
+
+[npm-image]: https://img.shields.io/npm/v/live-xxx.svg
+[npm-url]: https://npmjs.org/package/@openremote/or-asset-list
+[travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
+[travis-url]: https://travis-ci.org/live-js/live-xxx
+[coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
+[coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master
\ No newline at end of file
diff --git a/ui/component/or-asset-viewer/build.gradle b/ui/component/or-asset-viewer/build.gradle
new file mode 100644
index 000000000..9abc9f80f
--- /dev/null
+++ b/ui/component/or-asset-viewer/build.gradle
@@ -0,0 +1,13 @@
+buildDir = "dist"
+
+task clean() {
+ doLast {
+ delete "dist"
+ }
+}
+
+npmBuild.dependsOn resolveTask(":ui:component:or-translate:build"), resolveTask(":ui:component:or-select:build"), resolveTask(":ui:component:or-input:build")
+
+task build() {
+ dependsOn npmBuild
+}
\ No newline at end of file
diff --git a/ui/component/or-asset-viewer/package.json b/ui/component/or-asset-viewer/package.json
new file mode 100644
index 000000000..23b2c0009
--- /dev/null
+++ b/ui/component/or-asset-viewer/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "@openremote/or-asset-viewer",
+ "version": "1.0.0",
+ "description": "OpenRemote Asset Viewer",
+ "main": "dist/index.js",
+ "types": "src/index.ts",
+ "scripts": {
+ "build": "npx tsc",
+ "test": "echo \"No tests\" && exit 0"
+ },
+ "author": "OpenRemote",
+ "license": "AGPL-3.0-or-later",
+ "dependencies": {
+ "@openremote/core": "^1.0.2",
+ "@openremote/model": "^1.0.2",
+ "@openremote/or-icon": "^1.0.0",
+ "@openremote/or-select": "^1.0.0",
+ "@openremote/or-translate": "^1.0.0",
+ "@openremote/rest": "^1.0.2",
+ "@types/simplebar": "^2.4.2",
+ "lit-element": "^2.2.1",
+ "simplebar": "^4.2.3"
+ },
+ "devDependencies": {
+ "tslint": "^5.11.0",
+ "typescript": "^3.4.5"
+ }
+}
diff --git a/ui/component/or-asset-viewer/src/components/or-asset-info.ts b/ui/component/or-asset-viewer/src/components/or-asset-info.ts
new file mode 100644
index 000000000..252e02972
--- /dev/null
+++ b/ui/component/or-asset-viewer/src/components/or-asset-info.ts
@@ -0,0 +1,56 @@
+import {customElement, html, LitElement, property, PropertyValues, TemplateResult, css} from "lit-element";
+import "@openremote/or-select";
+import "@openremote/or-icon";
+import "@openremote/or-translate";
+import "@openremote/or-icon";
+
+
+@customElement("or-asset-info")
+export class OrAssetInfo extends LitElement {
+
+ @property({type: Boolean, reflect: true})
+ public show: boolean = false;
+
+ @property({type: Boolean})
+ public dismissible: boolean = true;
+
+ public static get styles() {
+ return css`
+ :host {
+ position: relative;
+ }
+
+ div[hidden] {
+ height: 0px;
+ }
+
+ div {
+ transition: all 0.8s ease-in;
+ position: absolute;
+ height: auto;
+ }
+ `;
+ }
+
+ protected updated(_changedProperties: PropertyValues): void {
+ super.updated(_changedProperties);
+
+ if (_changedProperties.has("show") && this.dismissible) {
+ if (this.show) {
+ document.body.addEventListener("click", this._onMouseClick);
+ } else {
+ document.body.removeEventListener("click", this._onMouseClick)
+ }
+ }
+ }
+
+ protected _onMouseClick(evt: MouseEvent) {
+ if (!this.contains(evt.target as Node)) {
+ this.show = false;
+ }
+ }
+
+ protected render(): TemplateResult | void {
+ return html`<div ?hidden="${!this.show}">TEST</div>`;
+ }
+}
\ No newline at end of file
diff --git a/ui/component/or-asset-viewer/src/components/or-panel.ts b/ui/component/or-asset-viewer/src/components/or-panel.ts
new file mode 100644
index 000000000..2ac7bfb34
--- /dev/null
+++ b/ui/component/or-asset-viewer/src/components/or-panel.ts
@@ -0,0 +1,61 @@
+import {css, customElement, html, LitElement, PropertyValues, query, unsafeCSS, property} from "lit-element";
+import "@openremote/or-select";
+import "@openremote/or-icon";
+import "@openremote/or-translate";
+import SimpleBar from "simplebar";
+
+// TODO: Add webpack/rollup to build so consumers aren't forced to use the same tooling
+const scrollStyle = require("simplebar/dist/simplebar.css");
+
+// language=CSS
+const style = css`
+ :host {
+ display: block;
+ }
+
+ :host([hidden]) {
+ display: none;
+ }
+
+ #panel {
+ height: 100%;
+ }
+`;
+
+@customElement("or-panel")
+export class OrPanel extends LitElement {
+
+ static get styles() {
+ return [
+ css `${unsafeCSS(scrollStyle)}`,
+ style
+ ];
+ }
+
+ @property({type: Boolean})
+ autoHide = true;
+
+ @property({type: Boolean})
+ forceVisible?: boolean;
+
+ @query("#panel")
+ protected _panel!: HTMLDivElement;
+
+ protected firstUpdated(_changedProperties: PropertyValues): void {
+ super.firstUpdated(_changedProperties);
+
+ if (this._panel) {
+ new SimpleBar(this._panel, {
+ autoHide: this.autoHide,
+ // @ts-ignore
+ forceVisible: this.forceVisible
+ });
+ }
+ }
+
+ render() {
+ return html`
+ <div id="panel"><slot></slot></div>
+ `;
+ }
+}
\ No newline at end of file
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
new file mode 100644
index 000000000..18d196888
--- /dev/null
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -0,0 +1,385 @@
+import {customElement, html, LitElement, property, PropertyValues, TemplateResult, query} from "lit-element";
+import "@openremote/or-select";
+import "@openremote/or-icon";
+import "@openremote/or-input";
+import "@openremote/or-attribute-input";
+import "@openremote/or-translate";
+import {translate} from "@openremote/or-translate/dist/translate-mixin";
+import {InputType, OrInput} from "@openremote/or-input";
+import {Asset, AttributeEvent, AssetEvent, Attribute, AssetAttribute, AttributeType, MetaItemType} from "@openremote/model";
+import {style} from "./style";
+import "./components/or-panel";
+import openremote from "@openremote/core";
+import rest from "@openremote/rest";
+import {subscribe} from "@openremote/core/dist/asset-mixin";
+import {getAssetAttributes, getFirstMetaItem} from "@openremote/core/dist/util";
+import i18next from "i18next";
+import {styleMap} from "lit-html/directives/style-map";
+import "@openremote/or-map";
+import {Type as MapType} from "@openremote/or-map";
+import {getLngLat} from "@openremote/or-map/dist/util";
+
+export interface PanelConfig {
+ name: string;
+ scrollable?: boolean;
+ hide?: boolean;
+ include?: string[];
+ exclude?: string[];
+ readonly?: string[];
+ panelStyles?: { [style: string]: string };
+ fieldStyles?: { [field: string]: { [style: string]: string } };
+}
+
+export interface ViewerConfig {
+ default?: PanelConfig[];
+ assetTypes?: { [assetType: string]: PanelConfig[] };
+ propertyViewProvider?: (property: string, value: any) => TemplateResult | undefined;
+ attributeViewProvider?: (attribute: Attribute) => TemplateResult | undefined;
+ assetNameProvider?: (id: string) => string;
+ mapType?: MapType;
+}
+
+@customElement("or-asset-viewer")
+export class OrAssetViewer extends subscribe(openremote)(translate(i18next)(LitElement)) {
+
+ public static DEFAULT_CONFIG: PanelConfig[] = [
+ {
+ name: "info",
+ fieldStyles: {
+ name: {
+ width: "60%"
+ },
+ createdOn: {
+ width: "40%",
+ paddingLeft: "20px",
+ boxSizing: "border-box"
+ }
+ }
+ },
+ {
+ name: "location",
+ scrollable: false,
+ include: ["location"],
+ fieldStyles: {
+ location: {
+ height: "100%",
+ margin: "0"
+ }
+ }
+ },
+ {name: "attributes"},
+ {
+ exclude: [
+ ""
+ ],
+ name: "history",
+ scrollable: false,
+ }
+ ];
+
+ public static DEFAULT_INFO_PROPERTIES = [
+ "name",
+ "createdOn",
+ "type",
+ "path",
+ "accessPublicRead"
+ ];
+
+ static get styles() {
+ return [
+ style
+ ];
+ }
+
+ @property({type: Object, reflect: false})
+ public asset?: Asset;
+
+ @property({type: String})
+ public assetId?: string;
+
+ @property({type: Object})
+ public config?: ViewerConfig;
+
+ @query("#property-path")
+ protected _pathFieldInput!: OrInput;
+
+ @property()
+ protected _loading: boolean = false;
+
+ protected render() {
+
+ if (this._loading) {
+ return html`
+ <div>LOADING</div>
+ `;
+ }
+
+ if (!this.asset && !this.assetId) {
+ return html``;
+ }
+
+ if (!this.asset) {
+ return html`
+ <div><or-translate value="notFound"></or-translate></div>
+ `;
+ }
+
+ const panelConfigs = this._getPanelConfig(this.asset!);
+ const attributes = getAssetAttributes(this.asset);
+
+ return html`
+ <div id="container">
+ ${html`${panelConfigs.map((config) => {
+ const panelTemplate = this._getPanel(config.name, config, this._getPanelContent(config.name, attributes, config));
+ return panelTemplate || ``;
+ })}`
+ }`;
+ }
+
+ protected _getInfoProperties(config?: PanelConfig): string[] {
+ let properties = config && config.include ? config.include : OrAssetViewer.DEFAULT_INFO_PROPERTIES;
+
+ if (config && config.exclude) {
+ properties = properties.filter((p) => !config.exclude!.find((excluded) => excluded === p))
+ }
+
+ return properties;
+ }
+
+ protected _getPanel(name: string, config: PanelConfig | undefined, content: TemplateResult | undefined) {
+ if (!content) {
+ return;
+ }
+
+ return html`
+ <div class="panel" id="${name}-panel" style="${config && config.panelStyles ? styleMap(config.panelStyles) : ""}">
+
+ <div class="panel-title">
+ <or-translate value="${name}"></or-translate>
+ </div>
+ ${!config || config.scrollable === undefined || config.scrollable ? html`
+ <or-panel class="panel-content-wrapper">
+ <div class="panel-content">
+ ${content}
+ </div>
+ </or-panel>
+ `: html`
+ <div class="panel-content">
+ ${content}
+ </div>
+ `}
+ </div>
+ `;
+ }
+
+ protected _getPanelContent(panelName: string, attributes: AssetAttribute[], config: PanelConfig): TemplateResult | undefined {
+ if (config.hide || attributes.length === 0) {
+ return;
+ }
+
+ let styles = config ? config.fieldStyles : undefined;
+
+ // Special handling for info panel which only shows properties
+ if (panelName === "info") {
+ let properties = this._getInfoProperties(config);
+
+ if (properties.length === 0) {
+ return;
+ }
+
+ return html`
+ ${properties.map((prop) => {
+ let style = styles ? styles[prop!] : undefined;
+ return prop === "attributes" ? `` : this._getField(prop, true, style, this._getPropertyTemplate(prop, (this.asset! as {[index: string]:any})[prop]));
+ })}
+ `;
+ }
+
+ // Special handling for history panel
+ if (panelName === "history") {
+ return html``;
+ }
+
+ const includedAttributes = config && config.include ? config.include : undefined;
+ const excludedAttributes = config && config.exclude ? config.exclude : [];
+ const attrs = attributes.filter((attr) =>
+ (!includedAttributes || includedAttributes.indexOf(attr.name!) >= 0)
+ && (!excludedAttributes || excludedAttributes.indexOf(attr.name!) < 0));
+
+ return html`
+ ${attrs.sort((attr1, attr2) => attr1.name! < attr2.name! ? -1 : attr1.name! > attr2.name! ? 1 : 0).map((attr) => {
+ let style = styles ? styles[attr.name!] : undefined;
+ return this._getField(attr.name!, false, style, this._getAttributeTemplate(panelName, attr));
+ })}
+ `;
+ }
+
+ protected _getPropertyTemplate(property: string, value: any) {
+ let type = InputType.TEXT;
+ let minLength: number | undefined;
+ let maxLength: number | undefined;
+
+ if (this.config && this.config.propertyViewProvider) {
+ const result = this.config.propertyViewProvider(property, value);
+ if (result) {
+ return result;
+ }
+ }
+
+ switch(property) {
+ case "path":
+ if (!value || !(Array.isArray(value))) {
+ return;
+ }
+
+ // Populate value when we get the response
+ this._getAssetNames(value as string[]).then(
+ (names) => {
+ if (this._pathFieldInput) {
+ this._pathFieldInput.value = names.reverse().join(" > ");
+ }
+ }
+ );
+ value = i18next.t("loading");
+ break;
+ case "createdOn":
+ type = InputType.DATETIME;
+ break;
+ case "accessPublicRead":
+ type = InputType.CHECKBOX;
+ break;
+ case "name":
+ minLength = 1;
+ maxLength = 1023;
+ break;
+ }
+
+ return html`<or-input id="property-${property}" type="${type}" .minLength="${minLength}" .maxLength="${maxLength}" dense .value="${value}" readonly label="${i18next.t(property)}"></or-input>`;
+ }
+
+ protected _getAttributeTemplate(panel: string, attribute: AssetAttribute) {
+ if (this.config && this.config.attributeViewProvider) {
+ const result = this.config.attributeViewProvider(attribute);
+ if (result) {
+ return result;
+ }
+ }
+
+ // Special control for main asset location attribute when shown in the location panel
+ if (panel === "location" && attribute.name === AttributeType.LOCATION.attributeName) {
+
+ const mapType = this.config && this.config.mapType ? this.config.mapType : MapType.VECTOR;
+ const lngLat = getLngLat(attribute);
+ const center = lngLat ? lngLat.toArray() : undefined;
+ const showOnMapMeta = getFirstMetaItem(attribute, MetaItemType.SHOW_ON_DASHBOARD.urn!);
+
+ return html`
+ <style>
+ #location-map-container {
+ height: 100%;
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ }
+ #location-map-container > or-map {
+ flex: 1;
+ }
+ #location-map-input {
+ flex: 0 0 auto;
+ padding: 20px 0 0 0;
+ }
+ </style>
+ <div id="location-map-container">
+ <or-map id="location-map" class="or-map" .center="${center}" type="${mapType}">
+ <or-map-marker-asset active .asset="${this.asset}"></or-map-marker-asset>
+ </or-map>
+ <or-input id="location-map-input" type="${InputType.SWITCH}" readonly dense .value="${showOnMapMeta ? showOnMapMeta.value : undefined}" label="${i18next.t("showOnMap")}"></or-input>
+ </div>
+ `;
+ }
+
+ return html`
+ <or-attribute-input dense .assetType="${this.asset!.type}" .attribute="${attribute}" .label="${i18next.t(attribute.name!)}"></or-attribute-input>
+ `;
+ }
+
+ protected _getField(name: string, isProperty: boolean, styles: { [style: string]: string } | undefined, content: TemplateResult | undefined) {
+ if (!content) {
+ return ``;
+ }
+
+ return html`
+ <div id="field-${name}" style="${styles ? styleMap(styles) : ""}" class="field ${isProperty ? "field-property" : "field-attribute"}">
+ ${content}
+ </div>
+ `;
+ }
+
+ protected updated(_changedProperties: PropertyValues) {
+ super.updated(_changedProperties);
+
+ if (_changedProperties.has("assetId")) {
+ this.asset = undefined;
+ if (this.assetId) {
+ this._loading = true;
+ super.assetIds = [this.assetId];
+ } else {
+ super.assetIds = undefined;
+ }
+ }
+ }
+
+ public onAttributeEvent(event: AttributeEvent) {
+ const attrName = event.attributeState!.attributeRef!.attributeName!;
+
+ if (this.asset && this.asset.attributes && this.asset.attributes.hasOwnProperty(attrName)) {
+ if (event.attributeState!.deleted) {
+ delete this.asset.attributes[attrName];
+ } else {
+ const attr = this.asset.attributes[attrName]! as Attribute;
+ attr.valueTimestamp = event.timestamp;
+ attr.value = event.attributeState!.value;
+ this.asset.attributes[attrName] = {...attr};
+ }
+ this.asset = {...this.asset}
+ }
+ }
+
+ public onAssetEvent(event: AssetEvent) {
+ this.asset = event.asset;
+ this._loading = false;
+ }
+
+ protected _getPanelConfig(asset: Asset) {
+ let config = this.config && this.config.default ? this.config.default : OrAssetViewer.DEFAULT_CONFIG;
+
+ if (this.config) {
+ if (this.config.assetTypes && this.config.assetTypes.hasOwnProperty(asset.type!)) {
+ config = this.config.assetTypes[asset.type!];
+ }
+ }
+
+ return config;
+ }
+
+ protected async _getAssetNames(ids: string[]): Promise<string[]> {
+ if (this.config && this.config.assetNameProvider) {
+ return ids.map((id) => this.config!.assetNameProvider!(id));
+ }
+
+ const response = await rest.api.AssetResource.queryAssets({
+ select: {
+ excludePath: true,
+ excludeParentInfo: true,
+ excludeRealm: true
+ },
+ ids: ids
+ });
+
+ if (response.status !== 200 || !response.data || response.data.length !== ids.length) {
+ return ids;
+ }
+
+ return ids.map((id) => response.data.find((asset) => asset.id === id)!.name!);
+ }
+}
diff --git a/ui/component/or-asset-viewer/src/style.ts b/ui/component/or-asset-viewer/src/style.ts
new file mode 100644
index 000000000..60ae24e6e
--- /dev/null
+++ b/ui/component/or-asset-viewer/src/style.ts
@@ -0,0 +1,388 @@
+import {css, unsafeCSS} from "lit-element";
+import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultColor4, DefaultBoxShadow, DefaultDisabledOpacity,
+ DefaultBoxShadowBottom} from "@openremote/core";
+import mdi from "@openremote/or-icon/dist/mdi-icons";
+
+// language=CSS
+export const style = css`
+
+ :host {
+ --internal-or-asset-viewer-background-color: var(--or-asset-viewer-background-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));
+ --internal-or-asset-viewer-grid-template-columns: var(--or-asset-viewer-grid-template-columns, repeat(12, 1fr));
+ --internal-or-asset-viewer-grid-template-rows: var(--or-asset-viewer-grid-template-rows, repeat(auto-fill, 1fr));
+ --internal-or-asset-viewer-grid-template-auto-rows: var(--or-asset-viewer-grid-template-auto-rows, minmax(min-content, 1fr));
+ --internal-or-asset-viewer-panel-margin: var(--or-asset-viewer-panel-margin, 15px);
+ --internal-or-asset-viewer-panel-padding: var(--or-asset-viewer-panel-padding, 20px);
+ --internal-or-asset-viewer-text-color: var(--or-asset-viewer-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));
+ --internal-or-asset-viewer-title-text-color: var(--or-asset-viewer-title-text-color, var(--or-app-color3, ${unsafeCSS(DefaultColor3)}));
+ --internal-or-asset-viewer-panel-color: var(--or-asset-viewer-panel-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
+ --internal-or-asset-viewer-line-color: var(--or-asset-viewer-line-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));
+ --internal-or-asset-viewer-info-columm-start: var(--or-asset-viewer-info-columm-start, 1);
+ --internal-or-asset-viewer-info-columm-end: var(--or-asset-viewer-info-columm-end, 7);
+ --internal-or-asset-viewer-info-row-start: var(--or-asset-viewer-info-row-start, 1);
+ --internal-or-asset-viewer-info-row-end: var(--or-asset-viewer-info-row-end, 2);
+ --internal-or-asset-viewer-info-height: var(--or-asset-viewer-info-height, unset);
+ --internal-or-asset-viewer-info-min-height: var(--or-asset-viewer-info-min-height, unset);
+ --internal-or-asset-viewer-location-columm-start: var(--or-asset-viewer-location-columm-start, 7);
+ --internal-or-asset-viewer-location-columm-end: var(--or-asset-viewer-location-columm-end, 13);
+ --internal-or-asset-viewer-location-row-start: var(--or-asset-viewer-location-row-start, 1);
+ --internal-or-asset-viewer-location-row-end: var(--or-asset-viewer-location-row-end, 3);
+ --internal-or-asset-viewer-location-height: var(--or-asset-viewer-location-height, unset);
+ --internal-or-asset-viewer-location-min-height: var(--or-asset-viewer-location-min-height, unset);
+ --internal-or-asset-viewer-attributes-columm-start: var(--or-asset-viewer-attributes-columm-start, 1);
+ --internal-or-asset-viewer-attributes-columm-end: var(--or-asset-viewer-attributes-columm-end, 7);
+ --internal-or-asset-viewer-attributes-row-start: var(--or-asset-viewer-attributes-row-start, 2);
+ --internal-or-asset-viewer-attributes-row-end: var(--or-asset-viewer-attributes-row-end, 4);
+ --internal-or-asset-viewer-attributes-height: var(--or-asset-viewer-attributes-height, unset);
+ --internal-or-asset-viewer-attributes-min-height: var(--or-asset-viewer-attributes-min-height, unset);
+ --internal-or-asset-viewer-history-columm-start: var(--or-asset-viewer-history-columm-start, 7);
+ --internal-or-asset-viewer-history-columm-end: var(--or-asset-viewer-history-columm-end, 13);
+ --internal-or-asset-viewer-history-row-start: var(--or-asset-viewer-history-row-start, 3);
+ --internal-or-asset-viewer-history-row-end: var(--or-asset-viewer-history-row-end, 4);
+ --internal-or-asset-viewer-history-height: var(--or-asset-viewer-history-height, unset);
+ --internal-or-asset-viewer-history-min-height: var(--or-asset-viewer-history-min-height, unset);
+
+ height: 100%;
+ width: 100%;
+ background-color: var(--internal-or-asset-viewer-background-color);
+ }
+
+ *[hidden] {
+ display: none;
+ }
+
+ #container {
+ box-sizing: border-box;
+ padding: var(--internal-or-asset-viewer-panel-margin);
+ height: 100%;
+ display: grid;
+ grid-template-columns: var(--internal-or-asset-viewer-grid-template-columns);
+ grid-template-rows: var(--internal-or-asset-viewer-grid-template-rows);
+ grid-auto-rows: var(--internal-or-asset-viewer-grid-template-auto-rows);
+ }
+
+ .panel {
+ display: flex;
+ flex-direction: column;
+ background-color: var(--internal-or-asset-viewer-panel-color);
+ padding: var(--internal-or-asset-viewer-panel-padding);
+ margin: var(--internal-or-asset-viewer-panel-margin);
+ box-shadow: ${unsafeCSS(DefaultBoxShadow)};
+ }
+
+ .panel-content-wrapper {
+ height: 100%;
+ min-height: 0;
+ }
+
+ .panel-content {
+ display: flex;
+ flex-wrap: wrap;
+ height: 100%;
+ }
+
+ .panel-title {
+ text-transform: uppercase;
+ font-weight: bolder;
+ color: var(--internal-or-asset-viewer-title-text-color);
+ margin-bottom: 15px;
+ flex: 0 0 auto;
+ }
+
+ .field {
+ margin: 10px 0;
+ width: 100%;
+ flex: 0 0 auto;
+ min-height: 50px;
+ }
+
+ .field > * {
+ width: 100%;
+ box-sizing: border-box;
+ }
+
+ #info-panel {
+ grid-column-start: var(--internal-or-asset-viewer-info-columm-start);
+ grid-column-end: var(--internal-or-asset-viewer-info-columm-end);
+ grid-row-start: var(--internal-or-asset-viewer-info-row-start);
+ grid-row-end: var(--internal-or-asset-viewer-info-row-end);
+ height: var(--internal-or-asset-viewer-info-height);
+ min-height: var(--internal-or-asset-viewer-info-min-height);
+ }
+
+ #location-panel {
+ grid-column-start: var(--internal-or-asset-viewer-location-columm-start);
+ grid-column-end: var(--internal-or-asset-viewer-location-columm-end);
+ grid-row-start: var(--internal-or-asset-viewer-location-row-start);
+ grid-row-end: var(--internal-or-asset-viewer-location-row-end);
+ height: var(--internal-or-asset-viewer-location-height);
+ min-height: var(--internal-or-asset-viewer-location-min-height);
+ }
+
+ #attributes-panel {
+ grid-column-start: var(--internal-or-asset-viewer-attributes-columm-start);
+ grid-column-end: var(--internal-or-asset-viewer-attributes-columm-end);
+ grid-row-start: var(--internal-or-asset-viewer-attributes-row-start);
+ grid-row-end: var(--internal-or-asset-viewer-attributes-row-end);
+ height: var(--internal-or-asset-viewer-attributes-height);
+ min-height: var(--internal-or-asset-viewer-attributes-min-height);
+ }
+
+ #history-panel {
+ grid-column-start: var(--internal-or-asset-viewer-history-columm-start);
+ grid-column-end: var(--internal-or-asset-viewer-history-columm-end);
+ grid-row-start: var(--internal-or-asset-viewer-history-row-start);
+ grid-row-end: var(--internal-or-asset-viewer-history-row-end);
+ height: var(--internal-or-asset-viewer-history-height);
+ min-height: var(--internal-or-asset-viewer-history-min-height);
+ }
+
+
+
+
+ button {
+ background-color: var(--internal-or-asset-tree-button-color);
+ color: var(--internal-or-asset-tree-background-color);
+ --or-icon-width: 26px;
+ --or-icon-height: 26px;
+ --or-icon-fill: var(--internal-or-asset-tree-background-color);
+ margin: 0 8px;
+ border: none;
+ padding: 0;
+ display: inline-block;
+ cursor: pointer;
+ }
+
+ button:focus {
+ outline: 0;
+ }
+
+ #header {
+ background-color: var(--internal-or-asset-tree-header-color);
+ display: flex;
+ width: 100%;
+ height: var(--internal-or-asset-tree-header-height);
+ border-bottom: 1px solid ${unsafeCSS(DefaultColor5)};
+ -webkit-box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
+ -moz-box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
+ box-shadow: ${unsafeCSS(DefaultBoxShadowBottom)};
+ z-index: 1000;
+ }
+
+ #header > * {
+ line-height: var(--internal-or-asset-tree-header-height);
+ }
+
+ #title-container {
+ flex: 1 0 auto;
+ flex-direction: row;
+ text-transform: capitalize;
+ padding-left: 30px;
+
+ --or-select-text-color: var(--internal-or-asset-tree-header-text-color);
+ --or-select-option-text-color: var(--internal-or-asset-tree-header-menu-text-color);
+ --or-select-option-background-color: var(--internal-or-asset-tree-header-menu-background-color);
+ --or-select-background-color: none;
+ --or-select-border-color: none;
+ --or-select-padding: 5px 20px 5px 5px;
+ }
+
+ #title {
+ font-weight: bold;
+ font-size: 20px;
+ color: var(--internal-or-asset-tree-header-text-color);
+ }
+
+ #realm-picker {
+ outline: none;
+ margin-left: 5px;
+ text-transform: none;
+ font-size: 14px;
+ }
+
+ #header-btns {
+ display: flex;
+ flex-direction: row;
+ padding-right: 10px;
+ }
+
+ .modal-container {
+ position: relative;
+ line-height: normal;
+ }
+
+ .modal {
+ position: absolute;
+ height: 0;
+ overflow: hidden;
+ }
+
+ .modal[data-visible] {
+ transition: all 0.5s ease-in;
+ height: auto;
+ overflow: visible;
+ }
+
+ .modal-content {
+ border: 1px solid var(--internal-or-asset-tree-line-color);
+ box-shadow: ${unsafeCSS(DefaultBoxShadow)};
+ -moz-box-shadow: ${unsafeCSS(DefaultBoxShadow)};
+ -webkit-box-shadow: ${unsafeCSS(DefaultBoxShadow)};
+ color: var(--internal-or-asset-tree-header-menu-text-color);
+ background-color: var(--internal-or-asset-tree-header-menu-background-color);
+ padding: 20px 25px 10px 25px;
+ }
+
+ .modal-content > ul {
+ list-style-type: none;
+ padding: 0;
+ margin-bottom: 0;
+ white-space: nowrap;
+ }
+
+ .modal-content > ul > li {
+ font-weight: bolder;
+ line-height: 40px;
+ cursor: pointer;
+ }
+
+ .modal-content > ul > li > or-icon {
+ visibility: hidden;
+ width: 18px;
+ height: 18px;
+ margin-right: 10px;
+ --or-icon-fill: var(--internal-or-asset-tree-header-color);
+ --or-icon-stroke: var(--internal-or-asset-tree-header-color);
+ --or-icon-stroke-width: 2px;
+ }
+
+ .modal-content > ul > li[data-selected] > or-icon {
+ visibility: visible;
+ }
+
+ .modal-content > h2 {
+ opacity: 0.6;
+ font-size: 0.9em;
+ margin: 0;
+ }
+
+ .modal-btns {
+ text-align: right;
+ }
+
+ .modal-btns .btn {
+ font-weight: bolder;
+ cursor: pointer;
+ text-transform: uppercase;
+ }
+
+ .modal-btns .btn + .btn {
+ margin-left: 15px;
+ }
+
+ #sort-menu {
+ left: -173px;
+ top: var(--internal-or-asset-tree-header-height);
+ }
+
+ #delete-not-allowed-modal {
+ left: -400px;
+ top: var(--internal-or-asset-tree-header-height);
+ }
+
+ #delete-confirm-modal {
+ left: -300px;
+ top: var(--internal-or-asset-tree-header-height);
+ }
+
+ #list-container {
+ flex: 1 0 auto;
+ overflow: auto;
+ }
+
+ #list {
+ margin: 0;
+ color: var(--internal-or-asset-tree-text-color);
+ padding: 15px 0;
+ font-weight: bolder;
+ }
+
+ #list, ol {
+ list-style-type: none;
+ }
+
+ li ol {
+ padding: 0;
+ }
+
+ #list li:not([data-expanded]) > ol {
+ display: none;
+ }
+
+ #list li[data-selected] > .node-container, #list li > .node-container:hover {
+ background-color: var(--internal-or-asset-tree-selected-background-color);
+ }
+
+ #list li[data-selected] > .node-container {
+ border-left-color: var(--internal-or-asset-tree-selected-color);
+ }
+
+ .node-container {
+ display: flex;
+ flex-direction: row;
+ border-left: 6px solid transparent;
+ user-select: none;
+ cursor: pointer;
+ height: var(--internal-or-asset-tree-item-height);
+ line-height: var(--internal-or-asset-tree-item-height);
+ padding-top: var(--internal-or-asset-tree-item-padding);
+ padding-bottom: var(--internal-or-asset-tree-item-padding);
+ }
+
+ .node-container > * {
+ flex: 0 0 auto;
+ }
+
+ .expander {
+ width: 26px;
+ height: 100%;
+ display: inline-block;
+ background-repeat: no-repeat;
+ background-size: 100%;
+ background-position: center;
+ }
+
+ .expander[data-expandable] {
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='${unsafeCSS(mdi.icons["chevron-right"])}'/%3E%3C/svg%3E");
+ }
+
+ li[data-expanded] > .node-container .expander {
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='${unsafeCSS(mdi.icons["chevron-down"])}'/%3E%3C/svg%3E") !important;
+ }
+
+ .node-name {
+ margin: -4px 0;
+ flex: 1 0 auto;
+ display: flex;
+ align-items: center;
+ }
+
+ .node-name > span {
+ vertical-align: middle;
+ }
+
+ .node-name > or-icon {
+ --or-icon-width: var(--internal-or-asset-tree-item-height);
+ --or-icon-height: var(--internal-or-asset-tree-item-height);
+ margin-right: 10px;
+ }
+
+ #loading {
+ flex: 1 0 auto;
+ display: inline-flex;
+ align-items: center;
+ text-align: center;
+ margin: 0 auto;
+ }
+
+`;
\ No newline at end of file
diff --git a/ui/component/or-asset-viewer/tsconfig.json b/ui/component/or-asset-viewer/tsconfig.json
new file mode 100644
index 000000000..227b51dc4
--- /dev/null
+++ b/ui/component/or-asset-viewer/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "./dist",
+ "tsBuildInfoFile": "./dist/.tsbuildinfo",
+ "rootDir": "src"
+ },
+ "include": [
+ "./src",
+ "../or-map/@types"
+ ],
+ "references": [
+ { "path": "../core" },
+ { "path": "../rest" },
+ { "path": "../or-select" },
+ { "path": "../or-translate" },
+ { "path": "../or-icon" },
+ { "path": "../or-map" },
+ { "path": "../or-input" },
+ { "path": "../or-attribute-input" }
+ ]
+}
\ No newline at end of file
diff --git a/ui/component/or-attribute-input/.npmignore b/ui/component/or-attribute-input/.npmignore
new file mode 100644
index 000000000..ca658009d
--- /dev/null
+++ b/ui/component/or-attribute-input/.npmignore
@@ -0,0 +1,3 @@
+build/
+build.gradle
+test/
\ No newline at end of file
diff --git a/ui/component/or-attribute-input/README.md b/ui/component/or-attribute-input/README.md
new file mode 100644
index 000000000..70db9a9a0
--- /dev/null
+++ b/ui/component/or-attribute-input/README.md
@@ -0,0 +1,31 @@
+# @openremote/or-input \<or-input\>
+[![NPM Version][npm-image]][npm-url]
+[![Linux Build][travis-image]][travis-url]
+[![Test Coverage][coveralls-image]][coveralls-url]
+
+Web Component for displaying an input control.
+
+## Install
+```bash
+npm i @openremote/or-input
+yarn add @openremote/or-input
+```
+
+## Usage
+For a full list of properties, methods and options refer to the TypeDoc generated [documentation]().
+
+
+## Supported Browsers
+The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition,
+Internet Explorer 11 is also supported.
+
+
+## License
+[GNU AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
+
+[npm-image]: https://img.shields.io/npm/v/live-xxx.svg
+[npm-url]: https://npmjs.org/package/@openremote/or-input
+[travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
+[travis-url]: https://travis-ci.org/live-js/live-xxx
+[coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
+[coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master
diff --git a/ui/component/or-attribute-input/build.gradle b/ui/component/or-attribute-input/build.gradle
new file mode 100644
index 000000000..c08de8a80
--- /dev/null
+++ b/ui/component/or-attribute-input/build.gradle
@@ -0,0 +1,11 @@
+buildDir = "dist"
+
+task clean() {
+ doLast {
+ delete "dist"
+ }
+}
+
+task build() {
+ dependsOn npmBuild
+}
\ No newline at end of file
diff --git a/ui/component/or-attribute-input/package.json b/ui/component/or-attribute-input/package.json
new file mode 100644
index 000000000..9d26467d3
--- /dev/null
+++ b/ui/component/or-attribute-input/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@openremote/or-attribute-input",
+ "version": "1.0.0",
+ "description": "OpenRemote attribute input",
+ "main": "dist/index.js",
+ "types": "src/index.ts",
+ "scripts": {
+ "build": "npx tsc",
+ "test": "echo \"No tests\" && exit 0"
+ },
+ "author": "OpenRemote",
+ "license": "AGPL-3.0-or-later",
+ "dependencies": {
+ "@openremote/core": "^1.0.0",
+ "@openremote/or-input": "^1.0.0",
+ "lit-element": "^2.2.1"
+ },
+ "devDependencies": {
+ "tslint": "^5.11.0",
+ "typescript": "^3.4.5"
+ }
+}
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
new file mode 100644
index 000000000..f0f53463a
--- /dev/null
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -0,0 +1,297 @@
+import {css, customElement, html, LitElement, property, PropertyValues, query, TemplateResult} from "lit-element";
+import i18next from "i18next";
+import {translate} from "@openremote/or-translate/dist/translate-mixin";
+import {
+ AssetAttribute,
+ AttributeDescriptor,
+ AttributeEvent,
+ AttributeRef,
+ AttributeValueDescriptor,
+ AttributeValueType,
+ MetaItemType,
+ ValueType
+} from "@openremote/model";
+import openremote, {AssetModelUtil} from "@openremote/core";
+import {subscribe} from "@openremote/core/dist/asset-mixin";
+import "@openremote/or-select";
+import "@openremote/or-input";
+import {InputType, OrInput, OrInputChangedEvent} from "@openremote/or-input";
+
+// Allows consuming applications to provide custom UI for certain attributes; if the value is changed the custom control
+// must call the valueChangeNotifier.
+class AttributeInputProviders {
+ public _providers: Array<(assetType: string, attribute: AssetAttribute, attributeDescriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean, disabled: boolean) => TemplateResult | undefined> = [];
+
+ public addInputProvider(callback: (assetType: string, attribute: AssetAttribute, attributeDescriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean, disabled: boolean) => TemplateResult | undefined) {
+ this._providers.push(callback);
+ }
+
+ public removeInputProvider(callback: (assetType: string, attribute: AssetAttribute, attributeDescriptor: AttributeDescriptor | undefined, valueDescriptor: AttributeValueDescriptor | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean, disabled: boolean) => TemplateResult | undefined) {
+ const i = this._providers.indexOf(callback);
+ if (i <= 0) {
+ this._providers.splice(i, 1);
+ }
+ }
+}
+
+const inputProviders = new AttributeInputProviders();
+export default inputProviders;
+
+@customElement("or-attribute-input")
+export class OrAttributeInput extends subscribe(openremote)(translate(i18next)(LitElement)) {
+
+ static get styles() {
+ return css`
+ :host {
+ display: inline-block;
+ }
+
+ or-input {
+ width: 100%;
+ }
+ `;
+ }
+
+ @property({type: Object, reflect: false})
+ public attribute?: AssetAttribute;
+
+ @property({type: Object})
+ public attributeRef?: AttributeRef;
+
+ @property({type: String})
+ public assetType?: string;
+
+ @property({type: String})
+ public label?: string;
+
+ @property({type: Boolean})
+ public disabled: boolean = false;
+
+ @property({type: Boolean})
+ public preventWrite: boolean = false;
+
+ @property({type: Boolean})
+ public dense: boolean = false;
+
+ @property({type: Boolean})
+ public readonly: boolean = false;
+
+ @property()
+ protected _loading: boolean = false;
+
+ protected _inputType?: InputType;
+ protected _valueOutboundConverter?: (value: any) => any;
+ protected _valueInboundConverter?: (value: any) => any;
+ protected _min?: number;
+ protected _max?: number;
+ protected _step?: number;
+ protected _label?: string;
+ protected _readonly?: boolean;
+ protected _allowedValues?: string[] | [string, string][];
+ protected _template?: TemplateResult;
+
+ @query("#or-input")
+ protected _input!: OrInput;
+
+ shouldUpdate(_changedProperties: PropertyValues): boolean {
+
+ if (_changedProperties.has("attribute")) {
+ this._inputType = undefined;
+ this._valueInboundConverter = undefined;
+ this._valueOutboundConverter = undefined;
+ this._min = undefined;
+ this._max = undefined;
+ this._step = undefined;
+ this._label = undefined;
+ this._readonly = undefined;
+ this._allowedValues = undefined;
+
+ if (this.assetType && this.attribute) {
+ // Type is actually the name of the type descriptor not the type descriptor itself
+ const type = this.attribute.type as string;
+ const attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(this.attribute.name!, this.assetType);
+ const valueDescriptor = AssetModelUtil.getAttributeValueDescriptorFromAsset(type, this.assetType, this.attribute.name);
+
+ for (const inputProvider of inputProviders._providers) {
+ this._template = inputProvider(this.assetType, this.attribute, attributeDescriptor, valueDescriptor, (newValue: any) => this.onValueChange(newValue), this.readonly, this.disabled);
+ if (this._template) {
+ break;
+ }
+ }
+
+ if (!this._template) {
+ if (valueDescriptor) {
+
+ switch (valueDescriptor.name) {
+ case AttributeValueType.GEO_JSON_POINT.name:
+ break;
+ case AttributeValueType.BOOLEAN.name:
+ case AttributeValueType.SWITCH_TOGGLE.name:
+ this._inputType = InputType.SWITCH;
+ break;
+ case AttributeValueType.NUMBER.name:
+ this._inputType = InputType.NUMBER;
+ break;
+ case AttributeValueType.STRING.name:
+ this._inputType = InputType.TEXT;
+ break;
+ case AttributeValueType.OBJECT.name:
+ case AttributeValueType.ARRAY.name:
+ this._inputType = InputType.JSON;
+ break;
+ case AttributeValueType.BRIGHTNESS_LUX.name:
+ this._inputType = InputType.NUMBER;
+ this._step = 1;
+ this._min = 0;
+ break;
+ default:
+ // Use value type
+ switch (valueDescriptor.valueType) {
+ case ValueType.STRING:
+ this._inputType = InputType.TEXT;
+ break;
+ case ValueType.NUMBER:
+ this._inputType = InputType.NUMBER;
+ break;
+ case ValueType.BOOLEAN:
+ this._inputType = InputType.SWITCH;
+ break;
+ default:
+ this._inputType = InputType.JSON;
+ break;
+ }
+ break;
+ }
+ }
+
+ if (!this._inputType) {
+ const value = this.attribute.value;
+
+ if (value) {
+ if (typeof value === "number") {
+ this._inputType = InputType.NUMBER;
+ } else if (typeof value === "string") {
+ this._inputType = InputType.TEXT;
+ } else if (typeof value === "boolean") {
+ this._inputType = InputType.SWITCH;
+ } else {
+ this._inputType = InputType.JSON;
+ }
+ }
+ }
+
+ if (this._inputType) {
+ // TODO: Update to use 'effective' meta so not dependent on meta items being defined on the asset itself
+ this._min = AssetModelUtil.getMetaValue(MetaItemType.RANGE_MIN, this.attribute.meta);
+ this._max = AssetModelUtil.getMetaValue(MetaItemType.RANGE_MAX, this.attribute.meta);
+ this._label = AssetModelUtil.getMetaValue(MetaItemType.LABEL, this.attribute.meta);
+ this._readonly = AssetModelUtil.getMetaValue(MetaItemType.READ_ONLY, this.attribute.meta);
+ this._allowedValues = AssetModelUtil.getMetaValue(MetaItemType.ALLOWED_VALUES, this.attribute.meta);
+
+ if (this._inputType === InputType.JSON) {
+ const outConverter = this._valueOutboundConverter;
+ const inConverter = this._valueInboundConverter;
+
+ this._valueOutboundConverter = (value) => {
+ if (outConverter) {
+ // @ts-ignore
+ value = outConverter(value);
+ }
+ if (value !== null && typeof(value) !== "string") {
+ value = JSON.stringify(value, null, 2);
+ this._valueInboundConverter = (value) => {
+ if (inConverter) {
+ // @ts-ignore
+ value = inConverter(value);
+ }
+ if (typeof(value) === "string") {
+ value = JSON.parse(value);
+ }
+ return value;
+ }
+ }
+
+ return value;
+ };
+ }
+ }
+ }
+ }
+ }
+
+ return super.shouldUpdate(_changedProperties);
+ }
+
+ updated(_changedProperties: PropertyValues): void {
+ super.updated(_changedProperties);
+
+ if (_changedProperties.has("attributeRef")) {
+ this.attribute = undefined;
+
+ if (this.attributeRef) {
+ this._loading = true;
+ super.attributeRefs = [this.attributeRef];
+ } else {
+ super.attributeRefs = undefined;
+ }
+ }
+ }
+
+ render() {
+
+ if (this._loading) {
+ return html`
+ <div>LOADING</div>
+ `;
+ }
+
+ if ((!this.attribute && !this.attributeRef) || !this.assetType) {
+ return html``;
+ }
+
+ if (!this.attribute) {
+ return html`
+ <div><or-translate value="notFound"></or-translate></div>
+ `;
+ }
+
+ if (this._template) {
+ return html`${this._template}`;
+ }
+
+ if (this._inputType) {
+ let value: any = this.attribute.value;
+
+ if (this._valueOutboundConverter) {
+ // Convert the value before setting it on the input
+ value = this._valueOutboundConverter(this.attribute.value);
+ }
+
+ return html`<or-input .type="${this._inputType}" .label="${i18next.t([this.attribute!.name!, this._label || this.attribute!.name!])}" .value="${value}" .allowedValues="${this._allowedValues}" .min="${this._min}" .max="${this._max}" .readonly="${this.readonly || this._readonly}" .disabled="${this.disabled}" .dense="${this.dense}" @or-input-changed="${(e: OrInputChangedEvent) => this.onValueChange(e.detail.value)}"></or-input>`;
+ }
+
+ return html`<span>INPUT TYPE NOT IMPLEMENTED</span>`;
+ }
+
+ protected onValueChange(newValue: any) {
+ if (this.attribute) {
+ if (this._valueInboundConverter) {
+ newValue = this._valueInboundConverter(newValue);
+ }
+
+ if (!this.preventWrite && !this.disabled && !this.readonly) {
+ super._sendEvent({
+ eventType: "attribute",
+ attributeState: {
+ attributeRef: {
+ entityId: this.attribute.assetId,
+ attributeName: this.attribute.name
+ },
+ value: newValue
+ }
+ } as AttributeEvent);
+ this.dispatchEvent(new OrInputChangedEvent(newValue, this.attribute.value));
+ }
+ }
+ }
+}
diff --git a/ui/component/or-attribute-input/tsconfig.json b/ui/component/or-attribute-input/tsconfig.json
new file mode 100644
index 000000000..acb1a2837
--- /dev/null
+++ b/ui/component/or-attribute-input/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "extends": "../../tsconfig",
+ "compilerOptions": {
+ "outDir": "./dist",
+ "tsBuildInfoFile": "./dist/.tsbuildinfo",
+ "rootDir": "src"
+ },
+ "include": [
+ "./src"
+ ],
+ "references": [
+ { "path": "../core" },
+ { "path": "../or-select" }
+ ]
+}
\ No newline at end of file
diff --git a/ui/component/or-bottom-navigation/package.json b/ui/component/or-bottom-navigation/package.json
index ebe6e355a..f2c523838 100644
--- a/ui/component/or-bottom-navigation/package.json
+++ b/ui/component/or-bottom-navigation/package.json
@@ -10,9 +10,6 @@
},
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
- "dependencies": {
-
- },
"devDependencies": {
"tslint": "^5.11.0",
"typescript": "^3.4.5"
diff --git a/ui/component/or-header/package.json b/ui/component/or-header/package.json
index 6742d21c5..ff0c02f46 100644
--- a/ui/component/or-header/package.json
+++ b/ui/component/or-header/package.json
@@ -11,7 +11,7 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "lit-element": "^2.1.0"
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"tslint": "^5.11.0",
diff --git a/ui/component/or-icon/package.json b/ui/component/or-icon/package.json
index 9d1813bd4..5c1f683bd 100644
--- a/ui/component/or-icon/package.json
+++ b/ui/component/or-icon/package.json
@@ -15,7 +15,7 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "lit-element": "^2.1.0"
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"@mdi/svg": "^4.2.95",
diff --git a/ui/component/or-input/package.json b/ui/component/or-input/package.json
index fa294f9bf..e1a604aa0 100644
--- a/ui/component/or-input/package.json
+++ b/ui/component/or-input/package.json
@@ -11,9 +11,18 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
+ "@material/button": "^3.2.0",
+ "@material/checkbox": "^3.2.0",
+ "@material/floating-label": "^3.2.0",
+ "@material/form-field": "^3.2.0",
+ "@material/icon-button": "^3.2.0",
+ "@material/line-ripple": "^3.1.0",
+ "@material/ripple": "^3.2.0",
+ "@material/switch": "^3.2.0",
+ "@material/textfield": "^3.2.0",
"@openremote/core": "^1.0.0",
"@openremote/or-select": "^1.0.0",
- "lit-element": "^2.1.0"
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"tslint": "^5.11.0",
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index 7580b9d99..8c89b745b 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -1,35 +1,26 @@
-import {customElement, html, LitElement, property, query, TemplateResult} from "lit-element";
+import {css, customElement, html, LitElement, property, PropertyValues, TemplateResult, unsafeCSS} from "lit-element";
+import {classMap} from "lit-html/directives/class-map";
+import {ifDefined} from "lit-html/directives/if-defined";
import {orInputStyle} from "./style";
-import {
- AttributeDescriptor,
- AttributeValueDescriptor,
- AttributeValueType,
- MetaItemType,
- ValueType
-} from "@openremote/model";
-import {AssetModelUtil} from "@openremote/core";
import "@openremote/or-select";
+import {MDCTextField} from "@material/textfield";
+import {MDCComponent} from "@material/base";
+import {MDCRipple} from "@material/ripple";
+import {MDCCheckbox} from "@material/checkbox";
+import {MDCSwitch} from "@material/switch";
+import {MDCFormField, MDCFormFieldInput} from "@material/form-field";
import {OrSelectChangedEvent} from "@openremote/or-select";
-// Allows consumers of the or-input component to provide custom input controls; if the value is changed the custom control
-// must call the valueChangeNotifier.
-class InputProviders {
- public _providers: Array<(assetType: string, attributeName: string, attributeDescriptor: AttributeDescriptor | undefined, value: any | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean) => TemplateResult | undefined> = [];
-
- public addInputProvider(callback: (assetType: string, attributeName: string, attributeDescriptor: AttributeDescriptor | undefined, value: any | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean) => TemplateResult | undefined) {
- this._providers.push(callback);
- }
-
- public removeInputProvider(callback: (assetType: string, attributeName: string, attributeDescriptor: AttributeDescriptor | undefined, value: any | undefined, valueChangeNotifier: (value: any | undefined) => void, readonly: boolean) => TemplateResult | undefined) {
- const i = this._providers.indexOf(callback);
- if (i <= 0) {
- this._providers.splice(i, 1);
- }
- }
-}
-
-const inputProviders = new InputProviders();
-export default inputProviders;
+// TODO: Add webpack/rollup to build so consumers aren't forced to use the same tooling
+const buttonStyle = require("@material/button/dist/mdc.button.css");
+const iconButtonStyle = require("!!raw-loader!@material/icon-button/dist/mdc.icon-button.css");
+const textfieldStyle = require("!!raw-loader!@material/textfield/dist/mdc.textfield.css");
+const rippleStyle = require("!!raw-loader!@material/ripple/dist/mdc.ripple.css");
+const lineRippleStyle = require("!!raw-loader!@material/line-ripple/dist/mdc.line-ripple.css");
+const floatingLabelStyle = require("!!raw-loader!@material/floating-label/dist/mdc.floating-label.css");
+const formFieldStyle = require("!!raw-loader!@material/form-field/dist/mdc.form-field.css");
+const checkboxStyle = require("!!raw-loader!@material/checkbox/dist/mdc.checkbox.css");
+const switchStyle = require("!!raw-loader!@material/switch/dist/mdc.switch.css");
export class OrInputChangedEvent extends CustomEvent<OrInputChangedEventDetail> {
@@ -60,242 +51,456 @@ declare global {
export enum InputType {
BUTTON = "button",
+ BUTTON_MOMENTARY = "button-momentary",
CHECKBOX = "checkbox",
COLOUR = "color",
DATE = "date",
- DATETIME = "datetime",
- DECIMAL = "decimal",
+ DATETIME = "datetime-local",
EMAIL = "email",
- GEO_JSON_POINT = "geoPos",
- INTEGER = "integer",
JSON = "json",
+ MONTH = "month",
NUMBER = "number",
PASSWORD = "password",
RADIO = "radio",
- SWITCH_MOMENTARY = "switchMomentary",
- SWITCH_TOGGLE = "checkbox",
- SELECT = "select",
- SLIDER = "range",
- TELEPHONE = "telephone",
+ SWITCH = "switch",
+ RANGE = "range",
+ TELEPHONE = "tel",
TEXT = "text",
TEXTAREA = "textarea",
TIME = "time",
- URL = "url"
+ URL = "url",
+ WEEK = "week",
+ SELECT = "select"
}
@customElement("or-input")
export class OrInput extends LitElement {
- @property({type: String})
- public assetType?: string;
-
- @property({type: String})
- public attributeName?: string;
+ static get styles() {
+ return [
+ css`${unsafeCSS(iconButtonStyle)}`,
+ css`${unsafeCSS(buttonStyle)}`,
+ css`${unsafeCSS(textfieldStyle)}`,
+ css`${unsafeCSS(rippleStyle)}`,
+ css`${unsafeCSS(lineRippleStyle)}`,
+ css`${unsafeCSS(floatingLabelStyle)}`,
+ css`${unsafeCSS(formFieldStyle)}`,
+ css`${unsafeCSS(checkboxStyle)}`,
+ css`${unsafeCSS(switchStyle)}`,
+ orInputStyle
+ ];
+ }
- @property({type: Object})
+ @property()
public value?: any;
@property({type: String})
public type?: InputType;
@property({type: Boolean})
- public allowNull: boolean = true;
+ public readonly: boolean = false;
@property({type: Boolean})
- public readonly: boolean = false;
+ public disabled: boolean = false;
@property({type: Boolean})
public required: boolean = false;
- @property({type: Object})
- public attributeDescriptor?: AttributeDescriptor;
+ @property()
+ public max?: any;
- @property({type: Object})
- public attributeValueDescriptor?: AttributeValueDescriptor;
+ @property()
+ public min?: HTMLInputElement;
+
+ @property({type: Number})
+ public step?: number;
+
+ @property({type: Boolean})
+ public checked: boolean = false;
+
+ @property({type: Number})
+ public maxLength?: number;
+
+ @property({type: Number})
+ public minLength?: number;
+
+ @property({type: Number})
+ public rows?: number;
+
+ @property({type: Number})
+ public cols?: number;
+
+ @property({type: Boolean})
+ public multiple: boolean = false;
@property({type: String})
- public valueType?: ValueType;
+ public pattern?: string;
- @query("#or-input")
- protected _input!: HTMLInputElement;
+ @property({type: String})
+ public placeHolder?: string;
- static get styles() {
- return [
- orInputStyle
- ];
- }
+ @property({type: Array})
+ public options?: string[] | [string, string][];
- protected render() {
+ /* STYLING PROPERTIES BELOW */
- if (!this.assetType || !this.attributeName) {
- return;
- }
+ @property({type: String})
+ public icon?: string;
- if (!this.attributeDescriptor) {
- this.attributeDescriptor = AssetModelUtil.getAttributeDescriptorFromAsset(this.assetType, this.attributeName);
- }
+ @property({type: Boolean})
+ public dense: boolean = false;
- for (const inputProvider of inputProviders._providers) {
- const template = inputProvider(this.assetType, this.attributeName, this.attributeDescriptor, this.value, (newValue: any) => this.onValueChange(newValue), this.readonly);
- if (template) {
- return template;
- }
- }
+ /* BUTTON STYLES START */
- const valueType = this.getValueType();
-
- if (!this.type) {
- const valueDescriptor = this.getValueDescriptor();
- if (valueDescriptor && valueDescriptor.name) {
- // @ts-ignore
- this.type = InputType[valueDescriptor.name];
-
- if (!this.type) {
- switch (valueDescriptor.name) {
- case AttributeValueType.BOOLEAN.name:
- this.type = InputType.CHECKBOX;
- break;
- case AttributeValueType.STRING.name:
- this.type = InputType.TEXT;
- break;
- case AttributeValueType.ARRAY.name:
- case AttributeValueType.OBJECT.name:
- this.type = InputType.JSON;
- break;
- }
- }
- }
+ @property({type: Boolean})
+ public iconTrailing: boolean = false;
+
+ @property({type: Boolean})
+ public raised: boolean = false;
+
+ @property({type: Boolean})
+ public unElevated: boolean = false;
+
+ @property({type: Boolean})
+ public outlined: boolean = false;
+
+ @property({type: Boolean})
+ public rounded: boolean = false;
+
+ /* BUTTON STYLES END */
+
+ /* TEXT INPUT STYLES START */
+
+ @property({type: Boolean})
+ public fullWidth: boolean = false;
+
+ @property({type: String})
+ public helperText?: string;
+
+ @property({type: Boolean})
+ public helperPersistent: boolean = false;
+
+ @property({type: String})
+ public validationMessage = '';
+
+ @property({type: Boolean})
+ public charCounter: boolean = false;
+
+ @property({type: String})
+ public label?: string;
+
+ /* TEXT INPUT STYLES END */
+
+ protected _mdcComponent?: MDCComponent<any>;
+ protected _mdcField?: MDCComponent<any>;
+ protected _processedValue?: any;
+
+ disconnectedCallback(): void {
+ super.disconnectedCallback();
+ if (this._mdcComponent) {
+ this._mdcComponent.destroy();
+ this._mdcComponent = undefined;
}
+ if (this._mdcField) {
+ this._mdcField.destroy();
+ this._mdcField = undefined;
+ }
+ }
+
+ protected render() {
if (this.type) {
switch (this.type) {
+ case InputType.RADIO:
+ return html`<span>RADIO</span>`;
+ case InputType.SWITCH:
+ return html`
+ <div id="field" class="mdc-form-field ${this.dense ? "mdc-form-field--dense" : ""}">
+ <div id="component" class="mdc-switch ${this.disabled || this.readonly ? "mdc-switch--disabled" : ""} ${this.value ? "mdc-switch--checked" : ""}">
+ <div class="mdc-switch__track"></div>
+ <div class="mdc-switch__thumb-underlay">
+ <div class="mdc-switch__thumb">
+ <input type="checkbox" id="elem" class="mdc-switch__native-control"
+ ?checked="${this._processedValue}"
+ ?required="${this.required}"
+ ?disabled="${this.disabled || this.readonly}"
+ @change="${(e: Event) => this.onValueChange((e.target as HTMLInputElement).checked)}"
+ role="switch">
+ </div>
+ </div>
+ </div>
+ <label for="elem">${this.label}</label>
+ </div>
+ `;
+ case InputType.SELECT:
+ return html`
+ <or-select .required="${this.required}" .options="${this.options}" .value="${this._processedValue}" .readonly="${this.readonly}" @or-select-changed="${(e: OrSelectChangedEvent) => this.onValueChange(e.detail.value)}"></or-select>
+ `;
case InputType.BUTTON:
- const isExecutable = this.attributeDescriptor && this.attributeDescriptor.metaItemDescriptors && this.attributeDescriptor.metaItemDescriptors.find((mid) => mid.urn === MetaItemType.EXECUTABLE.urn);
- if (isExecutable) {
- return html`<span>EXECUTABLE BUTTON NOT IMPLEMENTED</span>`;
+ case InputType.BUTTON_MOMENTARY: {
+ const rounded = !!(!this._processedValue && this.rounded && this.icon);
+ const classes = {
+ "mdc-button--raised": this.raised,
+ "mdc-button--unelevated": this.unElevated,
+ "mdc-button--outlined": !rounded && this.outlined,
+ "mdc-button--dense": !rounded && this.dense,
+ "or-input--rounded": this.rounded,
+ "mdc-button": !rounded,
+ "mdc-icon-button": rounded
+ };
+ const iconClasses = {
+ "mdc-icon-button__icon": rounded,
+ "mdc-button__icon": !rounded,
+ };
+ if (this.type === InputType.BUTTON_MOMENTARY) {
+ return html`
+ <button id="component" class="${classMap(classes)}"
+ ?required="${this.required}"
+ ?readonly="${this.readonly}"
+ ?disabled="${this.disabled}"
+ @onmousedown="${() => this.onValueChange(true)}" @onmouseup="${() => this.onValueChange(false)}">
+ ${this.icon ? html`<or-icon class="${classMap(iconClasses)}" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
+ ${this.label ? html`<span class="mdc-button__label">${this.label}</span>` : ``}
+ ${this.iconTrailing ? html`<or-icon class="${classMap(iconClasses)}" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>` : ``}
+ </button>
+ `;
}
- case InputType.SWITCH_MOMENTARY:
- if (!valueType || valueType === ValueType.BOOLEAN) {
- return html`<input type="button" @onmousedown="${() => this.onValueChange(true)}" @onmouseup="${() => this.onValueChange(false)}" value="" ?readonly="${this.readonly}" />`;
- }
- break;
- case InputType.DECIMAL:
- case InputType.INTEGER:
+ return html`
+ <button id="component" class="${classMap(classes)}"
+ ?required="${this.required}"
+ ?readonly="${this.readonly}"
+ ?disabled="${this.disabled}"
+ @onmouseup="${() => this.onValueChange(true)}">
+ ${this.icon ? html`<or-icon class="${classMap(iconClasses)}" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
+ ${this.label ? html`<span class="mdc-button__label">${this.label}</span>` : ``}
+ ${this.iconTrailing ? html`<or-icon class="${classMap(iconClasses)}" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>` : ``}
+ </button>
+ `;
+ }
+ case InputType.CHECKBOX:
+ return html`
+ <div id="field" class="mdc-form-field ${this.dense ? "mdc-form-field--dense" : ""}">
+ <div id="component" class="mdc-checkbox ${this.dense ? "mdc-checkbox--dense" : ""}">
+ <input type="checkbox"
+ ?checked="${this._processedValue}"
+ ?required="${this.required}"
+ ?disabled="${this.disabled || this.readonly}"
+ @change="${(e: Event) => this.onValueChange((e.target as HTMLInputElement).checked)}"
+ class="mdc-checkbox__native-control" id="elem"/>
+ <div class="mdc-checkbox__background">
+ <svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
+ <path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
+ </svg>
+ <div class="mdc-checkbox__mixedmark"></div>
+ </div>
+ </div>
+ <label for="elem">${this.label}</label>
+ </div>
+ `;
case InputType.NUMBER:
- case InputType.SLIDER:
- if (valueType && valueType !== ValueType.NUMBER) {
- break;
- }
+ case InputType.RANGE:
case InputType.DATE:
case InputType.DATETIME:
case InputType.TIME:
- if (valueType && valueType !== ValueType.NUMBER && valueType !== ValueType.STRING) {
- break;
- }
- case InputType.SWITCH_TOGGLE:
- case InputType.CHECKBOX:
+ case InputType.MONTH:
+ case InputType.WEEK:
case InputType.COLOUR:
case InputType.EMAIL:
case InputType.PASSWORD:
case InputType.TELEPHONE:
- case InputType.TEXT:
case InputType.URL:
- case InputType.SELECT:
- if (this.type === InputType.TEXT || this.type === InputType.SELECT) {
- const options = this.getAllowedValues();
- if (options || this.type === InputType.SELECT) {
- return html`
- <or-select ?required="${this.required}" .options="${options}" .value="${this.value}" ?readonly="${this.readonly}" @or-select-changed="${(e: OrSelectChangedEvent) => this.onValueChange(e.detail.value)}"></or-select>
- `;
- }
- }
-
- const step = this.type === InputType.INTEGER ? "1" : undefined;
- const min = this.getMinValue();
- const max = this.getMaxValue();
-
- return html`<input ?required="${this.required}" type="${this.type}" step="${step}" min="${min}" max="${max}" value="${this.value}" @change="${(e: Event) => this.onValueChange((e.target as HTMLInputElement).value)}" />`;
- case InputType.GEO_JSON_POINT:
- break;
+ case InputType.TEXT:
+ case InputType.TEXTAREA:
+ case InputType.JSON: {
+ const showLabel = !this.fullWidth && this.label;
+ const outlined = !this.fullWidth && this.outlined;
+ const hasHelper = !!this.helperText;
+ const showValidationMessage = this.validationMessage;
+ const classes = {
+ "mdc-text-field--outlined": outlined,
+ "mdc-text-field--textarea": this.type === InputType.TEXTAREA || this.type === InputType.JSON,
+ "mdc-text-field--disabled": this.disabled,
+ "mdc-text-field--fullwidth": this.fullWidth,
+ "mdc-text-field--dense": this.type !== InputType.TEXTAREA && this.type !== InputType.JSON && this.dense,
+ "mdc-text-field--no-label": !this.label,
+ "mdc-text-field--with-leading-icon": !!this.icon,
+ "mdc-text-field--with-trailing-icon": this.iconTrailing
+ };
+ const helperClasses = {
+ "mdc-text-field-helper-text--persistent": this.helperPersistent,
+ "mdc-text-field-helper-text--validation-msg": showValidationMessage,
+ };
+
+ const labelTemplate = showLabel ? html`<label class="mdc-floating-label ${this._processedValue || this._processedValue === false ? "mdc-floating-label--float-above" : ""}" for="elem">${this.label}</label>` : ``;
+
+ return html`
+ <div id="component" class="mdc-text-field ${classMap(classes)}">
+ ${this.icon ? html`<or-icon class="mdc-text-field__icon" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
+ ${this.type === InputType.TEXTAREA || this.type === InputType.JSON ? html`
+ <textarea id="elem" class="mdc-text-field__input"
+ ?required="${this.required}"
+ ?readonly="${this.readonly}"
+ ?disabled="${this.disabled}"
+ @change="${(e: Event) => this.onValueChange((e.target as HTMLTextAreaElement).value)}"
+ minlength="${ifDefined(this.minLength)}"
+ maxlength="${ifDefined(this.maxLength)}"
+ rows="${this.rows ? this.rows : 5}"
+ cols="${ifDefined(this.cols)}"
+ aria-label="${ifDefined(this.label)}">${this._processedValue}</textarea>
+ ${this.renderOutlined(labelTemplate)}
+ ` :
+ html`<input type="${this.type}" id="elem" class="mdc-text-field__input"
+ ?required="${this.required}"
+ ?readonly="${this.readonly}"
+ ?disabled="${this.disabled}"
+ @change="${(e: Event) => this.onValueChange((e.target as HTMLInputElement).value)}"
+ value="${this._processedValue}"
+ min="${ifDefined(this.min)}"
+ max="${ifDefined(this.max)}"
+ step="${ifDefined(this.step)}"
+ aria-label="${ifDefined(this.label)}"
+ minlength="${ifDefined(this.minLength)}"
+ maxlength="${ifDefined(this.maxLength)}"
+ placeholder="${ifDefined(this.placeHolder)}" />
+ ${outlined ? this.renderOutlined(labelTemplate) : labelTemplate}
+ ${!outlined ? html`<div class="mdc-line-ripple"></div>` : ``}
+ ${this.iconTrailing ? html`<or-icon class="mdc-text-field__icon" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>` : ``}
+ `}
+ </div>
+ ${hasHelper ? html`
+ <div class="mdc-text-field-helper-line">
+ <div class="mdc-text-field-helper-text ${classMap(helperClasses)}">${showValidationMessage ? this.validationMessage : this.helperText}</div>
+ ${this.charCounter && !this.readonly ? html`<div class="mdc-text-field-character-counter"></div>` : ``}
+ </div>
+ ` : ``}
+ `;
+ }
}
}
return html`<span>INPUT TYPE NOT IMPLEMENTED</span>`;
}
- protected onValueChange(newValue: any | undefined) {
- const previousValue = this.value;
- this.value = newValue;
- this.dispatchEvent(new OrInputChangedEvent(this.value, previousValue));
- }
-
- protected getValueDescriptor() {
- if (this.attributeValueDescriptor) {
- return this.attributeValueDescriptor;
- }
-
- if (this.attributeDescriptor) {
- return this.attributeDescriptor.valueDescriptor;
+ protected shouldUpdate(_changedProperties: PropertyValues): boolean {
+ if (_changedProperties.has("value") || _changedProperties.has("type")) {
+ let val = this.value;
+
+ if (typeof(val) !== "string") {
+ switch (this.type) {
+ case InputType.DATETIME:
+ // Date time conversion for UNIX timestamps in millis
+ if (typeof(val) === "number") {
+ const offset = (new Date()).getTimezoneOffset() * 60000;
+ const str = (new Date(val - offset)).toISOString();
+ val = str.slice(0, str.lastIndexOf(":"));
+ }
+ break;
+ case InputType.JSON:
+ val = val !== undefined && val !== null ? JSON.stringify(val, null, 2) : "";
+ break;
+ }
+ }
+ this._processedValue = val;
}
+ return super.shouldUpdate(_changedProperties);
}
- protected getValueType() {
- if (this.valueType) {
- return this.valueType;
- }
-
- const descriptor = this.getValueDescriptor();
- if (descriptor) {
- return descriptor.valueType;
- }
+ protected updated(_changedProperties: PropertyValues): void {
+ super.updated(_changedProperties);
- if (this.value) {
- if (typeof this.value === "number") {
- return ValueType.NUMBER;
+ if (_changedProperties.has("type")) {
+ const component = this.shadowRoot!.getElementById("component");
+ if (this._mdcComponent) {
+ this._mdcComponent.destroy();
+ this._mdcComponent = undefined;
}
- if (typeof this.value === "string") {
- return ValueType.STRING;
+ if (this._mdcField) {
+ this._mdcField.destroy();
+ this._mdcField = undefined;
}
- if (typeof this.value === "boolean") {
- return ValueType.BOOLEAN;
- }
- if (Array.isArray(this.value)) {
- return ValueType.ARRAY;
+
+ if (component && this.type) {
+ switch(this.type) {
+ case InputType.SELECT:
+ break;
+ case InputType.RADIO:
+ break;
+ case InputType.BUTTON:
+ this._mdcComponent = new MDCRipple(component);
+ break;
+ case InputType.CHECKBOX:
+ this._mdcComponent = new MDCCheckbox(component);
+ const field = this.shadowRoot!.getElementById("field");
+ if (field) {
+ const mdcField = new MDCFormField(field);
+ mdcField.input = this._mdcComponent as unknown as MDCFormFieldInput;
+ this._mdcField = mdcField;
+ }
+ break;
+ case InputType.SWITCH:
+ this._mdcComponent = new MDCSwitch(component);
+ break;
+ default:
+ this._mdcComponent = new MDCTextField(component);
+ break;
+ }
}
- return ValueType.OBJECT;
}
- }
- protected getMinValue() {
- if (!this.attributeDescriptor) {
- return;
+ if (!this.type && this.value) {
+ if (this.value instanceof Date) {
+ this.type = InputType.DATETIME;
+ } else if (typeof(this.value) === "boolean") {
+ this.type = InputType.CHECKBOX;
+ } else if (typeof(this.value) === "number") {
+ this.type = InputType.NUMBER;
+ } else if (typeof(this.value) === "string") {
+ this.type = InputType.TEXT;
+ } else {
+ this.type = InputType.JSON;
+ }
}
+ }
- const descriptor = AssetModelUtil.getMetaInitialValueFromMetaDescriptors(MetaItemType.RANGE_MIN, this.attributeDescriptor.metaItemDescriptors);
- if (descriptor) {
- return descriptor.initialValue;
- }
+ protected renderOutlined(labelTemplate: TemplateResult | "") {
+ return html`
+ <div class="mdc-notched-outline">
+ <div class="mdc-notched-outline__leading"></div>
+ <div class="mdc-notched-outline__notch">
+ ${labelTemplate}
+ </div>
+ <div class="mdc-notched-outline__trailing"></div>
+ </div>
+ `;
}
- protected getMaxValue() {
- if (!this.attributeDescriptor) {
- return;
- }
+ protected onValueChange(newValue: any | undefined) {
+ const previousValue = this.value;
- const descriptor = AssetModelUtil.getMetaInitialValueFromMetaDescriptors(MetaItemType.RANGE_MAX, this.attributeDescriptor.metaItemDescriptors);
- if (descriptor) {
- return descriptor.initialValue;
+ if (newValue === "null") {
+ newValue = null;
}
- }
- protected getAllowedValues() {
- if (!this.attributeDescriptor) {
- return;
+ if (typeof(newValue) === "string" && typeof(previousValue) !== "string") {
+ switch (this.type) {
+ case InputType.CHECKBOX:
+ case InputType.SWITCH:
+ newValue = newValue === "on";
+ break;
+ case InputType.JSON:
+ case InputType.NUMBER:
+ case InputType.RANGE:
+ newValue = JSON.parse(newValue);
+ break;
+ case InputType.DATETIME:
+ const date = Date.parse(newValue);
+ const offset = (new Date()).getTimezoneOffset() * 60000;
+ newValue = date + offset;
+ break;
+ }
}
- const allowedValues = AssetModelUtil.getMetaInitialValueFromMetaDescriptors(MetaItemType.ALLOWED_VALUES, this.attributeDescriptor.metaItemDescriptors);
- if (allowedValues && Array.isArray(allowedValues) && allowedValues.length > 0) {
- return [...allowedValues];
- }
+ this.value = newValue;
+ this.dispatchEvent(new OrInputChangedEvent(this.value, previousValue));
}
}
diff --git a/ui/component/or-input/src/style.ts b/ui/component/or-input/src/style.ts
index 5aa0ee6ac..9acf21506 100644
--- a/ui/component/or-input/src/style.ts
+++ b/ui/component/or-input/src/style.ts
@@ -1,19 +1,45 @@
- import {css} from "lit-element";
+import {css, unsafeCSS} from "lit-element";
+import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultColor4, DefaultBoxShadow, DefaultDisabledOpacity,
+ DefaultBoxShadowBottom} from "@openremote/core";
// TODO this is temp work, should be replaced with material design components / styling
// language=CSS
export const orInputStyle = css`
- input {
- position: relative;
- font-family: inherit;
- padding: 10px;
- border-radius: 0;
- border: none;
- font-size: 14px;
-
- border-bottom: 2px solid #d5d5d5;
- background-color: var(--or-input-background, #f2f2f2);
+
+ :host {
+ --internal-or-input-color: var(--or-input-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
+ --internal-or-input-text-color: var(--or-input-text-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
+
+ --mdc-theme-primary: var(--internal-or-input-color);
+ --mdc-theme-on-primary: var(--internal-or-input-text-color);
+ }
+
+ .or-input--rounded {
+ border-radius: 50% !important;
+ }
+
+ /* MDC TEXT FIELD DOESN'T USE THEME VARS */
+ .mdc-text-field--focused:not(.mdc-text-field--disabled) .mdc-floating-label {
+ color: var(--mdc-theme-primary);
+ }
+ .mdc-text-field--focused .mdc-text-field__input:required ~ .mdc-floating-label::after,
+ .mdc-text-field--focused .mdc-text-field__input:required ~ .mdc-notched-outline .mdc-floating-label::after {
+ color: var(--mdc-theme-primary);
+ }
+
+ .mdc-text-field, .mdc-text-field-helper-line {
+ width: inherit;
+ }
+
+ .mdc-text-field--dense:not(.mdc-text-field--no-label):not(.mdc-text-field--outlined) {
+ height: 52px;
+ }
+
+ .mdc-text-field--dense.mdc-text-field--no-label {
+ height: 40px;
+ }
+
+ .mdc-switch {
+ margin: 18px;
}
-
- input.invalid { border-bottom: 2px solid red;}
`;
diff --git a/ui/component/or-map/src/util.ts b/ui/component/or-map/src/util.ts
index 9c27ae389..29ee4685c 100644
--- a/ui/component/or-map/src/util.ts
+++ b/ui/component/or-map/src/util.ts
@@ -1,28 +1,48 @@
import {LngLat, LngLatBounds, LngLatBoundsLike, LngLatLike} from "mapbox-gl";
import L, {LatLng, LatLngBounds} from "mapbox.js";
+import {Asset, AttributeType, AssetAttribute, GeoJSONPoint, AttributeValueType} from "@openremote/model";
+import {getAssetAttribute} from "@openremote/core/dist/util";
-export function getLngLat(lngLatLike?: LngLatLike): LngLat | undefined {
+export function getLngLat(lngLatLike?: LngLatLike | Asset | AssetAttribute | GeoJSONPoint | object): LngLat | undefined {
if (lngLatLike) {
if (lngLatLike instanceof LngLat) {
return lngLatLike as LngLat;
}
- const obj = lngLatLike as object;
+ let obj = lngLatLike as any;
- if (obj.hasOwnProperty("lng")) {
- const lngLatObj = obj as { lng: number; lat: number; };
- return new LngLat(lngLatObj.lng, lngLatObj.lat);
+ if (obj.hasOwnProperty("attributes")) {
+ // This is an asset
+ const locationAttribute = getAssetAttribute(obj as Asset, AttributeType.LOCATION.attributeName!);
+ if (!locationAttribute) {
+ return;
+ }
+ obj = locationAttribute;
}
- if (obj.hasOwnProperty("lon")) {
- const lonLatObj = obj as { lon: number; lat: number; };
- return new LngLat(lonLatObj.lon, lonLatObj.lat);
+ if (obj.hasOwnProperty("name") && obj.hasOwnProperty("type")) {
+ const attr = obj as AssetAttribute;
+ if (attr.type !== AttributeValueType.GEO_JSON_POINT.name || !attr.value) {
+ return;
+ }
+ obj = attr.value;
}
- const lonLatArr = obj as number[];
- if (lonLatArr.length === 2) {
- return new LngLat(lonLatArr[0], lonLatArr[1]);
+ if (obj.type === "Point" && Array.isArray(obj.coordinates)) {
+ return new LngLat(obj.coordinates[0], obj.coordinates[1]);
+ }
+
+ if (obj.lng && obj.lat) {
+ return new LngLat(obj.lng, obj.lat);
+ }
+
+ if (obj.lon && obj.lat) {
+ return new LngLat(obj.lon, obj.lat);
+ }
+
+ if (Array.isArray(obj) && obj.length === 2) {
+ return new LngLat(obj[0], obj[1]);
}
}
}
@@ -61,4 +81,4 @@ export function getLatLngBounds(lngLatBoundsLike?: LngLatBoundsLike): LatLngBoun
if (lngLatBounds) {
return L.latLngBounds(getLatLng(lngLatBounds.getNorthEast())!, getLatLng(lngLatBounds.getSouthWest())!);
}
-}
\ No newline at end of file
+}
diff --git a/ui/component/or-rules-editor/package.json b/ui/component/or-rules-editor/package.json
index bf5606a8b..259f62be2 100644
--- a/ui/component/or-rules-editor/package.json
+++ b/ui/component/or-rules-editor/package.json
@@ -17,7 +17,7 @@
"@openremote/or-select": "^1.0.0",
"@openremote/or-translate": "^1.0.0",
"@openremote/rest": "^1.0.2",
- "lit-element": "^2.1.0",
+ "lit-element": "^2.2.1",
"moment": "^2.24.0"
},
"devDependencies": {
diff --git a/ui/component/or-rules-editor/src/index.ts b/ui/component/or-rules-editor/src/index.ts
index 6f50d4e77..b5dcdadf8 100644
--- a/ui/component/or-rules-editor/src/index.ts
+++ b/ui/component/or-rules-editor/src/index.ts
@@ -1,4 +1,4 @@
-import {customElement, html, LitElement, property} from "lit-element";
+import {customElement, html, LitElement, property, TemplateResult} from "lit-element";
import i18next from "i18next";
import "@openremote/or-select";
import "@openremote/or-icon";
@@ -109,6 +109,7 @@ export interface RulesConfig {
hideWhenAddGroup?: boolean;
hideWhenGroupOutline?: boolean;
};
+ inputProvider?: (assetType: string, attributeName: string, attributeDescriptor: AttributeDescriptor | undefined, value: any | undefined, valueChangeNotifier: (value: any) => void, readonly: boolean) => TemplateResult | undefined;
descriptors?: {
all?: RulesDescriptorSection;
when?: RulesDescriptorSection;
diff --git a/ui/component/or-rules-editor/src/or-rule-actions.ts b/ui/component/or-rules-editor/src/or-rule-actions.ts
index 6faeda772..08128913e 100644
--- a/ui/component/or-rules-editor/src/or-rule-actions.ts
+++ b/ui/component/or-rules-editor/src/or-rule-actions.ts
@@ -12,7 +12,8 @@ import {
} from "@openremote/model";
import i18next from "i18next";
import {OrSelectChangedEvent} from "@openremote/or-select";
-import {OrInputChangedEvent} from "@openremote/or-input";
+import {OrAttributeInput} from "@openremote/or-attribute-input";
+import {OrInputChangedEvent} from "@openremote/or-input/dist";
@customElement("or-rule-actions")
class OrRuleActions extends LitElement {
@@ -121,9 +122,11 @@ class OrRuleActions extends LitElement {
const attributeNames = attributeDescriptors.map((ad) => [ad.attributeName, i18next.t(ad.attributeName!)]);
const assetType = assetTypes.length > 0 ? assetTypes[0][0] : undefined;
+ const attributeInput = this.config && this.config.inputProvider && action.attributeName ? this.config.inputProvider(assetType!, action.attributeName, attributeDescriptors.find((ad) => ad.attributeName === action.attributeName)!, action.value, (value: any) => this.setActionAttributeValue(action, value), this.readonly || false) : undefined;
+
actionTemplate = html`
<or-select @or-select-changed="${(e: OrSelectChangedEvent) => this.setActionAttributeName(action, e.detail.value)}" ?readonly="${this.readonly}" .options="${attributeNames}" .value="${action.attributeName}"></or-select>
- ${action.attributeName ? html`<or-input @or-input-changed="${(e: OrInputChangedEvent) => this.setActionAttributeValue(action, e.detail.value)}" ?readonly="${this.readonly}" .assetType="${assetType}" .attributeName="${action.attributeName}" .value="${action.value}"></or-input>` : ``}
+ ${action.attributeName ? attributeInput ? attributeInput : html`<or-attribute-input @or-input-changed="${(e: OrInputChangedEvent) => this.setActionAttributeValue(action, e.detail.value)}" ?readonly="${this.readonly}" .assetType="${assetType}" .attributeName="${action.attributeName}" .value="${action.value}"></or-attribute-input>` : ``}
`;
if (action.action === "update-attribute" && !hideUpdateOptions) {
diff --git a/ui/component/or-rules-editor/src/or-rule-asset-query.ts b/ui/component/or-rules-editor/src/or-rule-asset-query.ts
index dd0b711cd..7c906c7a2 100644
--- a/ui/component/or-rules-editor/src/or-rule-asset-query.ts
+++ b/ui/component/or-rules-editor/src/or-rule-asset-query.ts
@@ -21,7 +21,7 @@ import {
RulesConfigAttribute
} from "./index";
import {OrSelectChangedEvent} from "@openremote/or-select";
-import "@openremote/or-input";
+import "@openremote/or-attribute-input";
import {InputType, OrInputChangedEvent} from "@openremote/or-input";
import {getEnumKeyAsString} from "@openremote/core/dist/util";
import {assetQueryEditorStyle} from "./style";
@@ -68,18 +68,27 @@ class OrRuleAssetQuery extends LitElement {
protected attributePredicateValueEditorTemplate(assetDescriptor: AssetDescriptor, attributePredicate: AttributePredicate) {
+ if (!attributePredicate.value) {
+ return ``;
+ }
+
const valuePredicate = attributePredicate.value;
+ const assetType = getAssetTypeFromQuery(this.query);
const attributeName = this.getAttributeName(attributePredicate);
+ const descriptor = assetDescriptor.attributeDescriptors ? assetDescriptor.attributeDescriptors.find((ad) => ad.attributeName === attributeName) : undefined;
+ // @ts-ignore
+ const value = valuePredicate.value ? valuePredicate.value : null;
- if (!assetDescriptor || !valuePredicate) {
- return ``;
+ const attributeInput = this.config && this.config.inputProvider ? this.config.inputProvider(assetType!, attributeName!, descriptor, value, (value: any) => this.setValuePredicateProperty(valuePredicate, "value", value), this.readonly || false) : undefined;
+
+ if (attributeInput) {
+ return attributeInput;
}
switch (valuePredicate.predicateType) {
case "string":
- const descriptor = assetDescriptor && assetDescriptor.attributeDescriptors ? assetDescriptor.attributeDescriptors.find((ad) => ad.attributeName === attributeName) : undefined;
return html`
- <or-input required type="${InputType.TEXT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${getAssetTypeFromQuery(this.query)}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.value ? valuePredicate.value : null}" ?readonly="${this.readonly}"></or-input>
+ <or-attribute-input required type="${InputType.TEXT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${assetType}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${value}" ?readonly="${this.readonly}"></or-attribute-input>
`;
break;
case "boolean":
@@ -89,13 +98,13 @@ class OrRuleAssetQuery extends LitElement {
case "number":
if (valuePredicate.operator === AQO.BETWEEN) {
return html`
- <or-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${getAssetTypeFromQuery(this.query)}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.value ? valuePredicate.value : null}" ?readonly="${this.readonly}"></or-input>
+ <or-attribute-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${assetType}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${value}" ?readonly="${this.readonly}"></or-attribute-input>
<span style="display: inline-flex; align-items: center;">&</span>
- <or-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "rangeValue", e.detail.value)}" .assetType="${getAssetTypeFromQuery(this.query)}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.rangeValue ? valuePredicate.rangeValue : null}" ?readonly="${this.readonly}"></or-input>
+ <or-attribute-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "rangeValue", e.detail.value)}" .assetType="${assetType}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.rangeValue ? valuePredicate.rangeValue : null}" ?readonly="${this.readonly}"></or-attribute-input>
`;
}
return html`
- <or-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${getAssetTypeFromQuery(this.query)}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.value ? valuePredicate.value : null}" ?readonly="${this.readonly}"></or-input>
+ <or-attribute-input required type="${InputType.NUMBER}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${assetType}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${value}" ?readonly="${this.readonly}"></or-attribute-input>
`;
case "string-array":
return html `<span>NOT IMPLEMENTED</span>`;
@@ -112,7 +121,7 @@ class OrRuleAssetQuery extends LitElement {
case "array":
// TODO: Update once we can determine inner type of array
// Assume string array
- return html`<or-input required type="${InputType.TEXT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${getAssetTypeFromQuery(this.query)}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${valuePredicate.value ? valuePredicate.value : null}" ?readonly="${this.readonly}"></or-input>`;
+ return html`<or-attribute-input required type="${InputType.TEXT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValuePredicateProperty(valuePredicate, "value", e.detail.value)}" .assetType="${assetType}" .attributeName="${attributeName}" .attributeDescriptor="${descriptor}" .value="${value}" ?readonly="${this.readonly}"></or-attribute-input>`;
default:
return html `<span>NOT IMPLEMENTED</span>`;
}
diff --git a/ui/component/or-rules-editor/src/or-rule-header.ts b/ui/component/or-rules-editor/src/or-rule-header.ts
index ce25e273a..5c7a5ed69 100644
--- a/ui/component/or-rules-editor/src/or-rule-header.ts
+++ b/ui/component/or-rules-editor/src/or-rule-header.ts
@@ -1,6 +1,6 @@
import {customElement, html, LitElement, property} from "lit-element";
import "@openremote/or-translate";
-import "@openremote/or-input";
+import "@openremote/or-attribute-input";
import "@openremote/or-select";
import "@openremote/or-icon";
import {TenantRuleset} from "@openremote/model";
diff --git a/ui/component/or-rules-editor/src/style.ts b/ui/component/or-rules-editor/src/style.ts
index cb0c91725..17393d2b4 100644
--- a/ui/component/or-rules-editor/src/style.ts
+++ b/ui/component/or-rules-editor/src/style.ts
@@ -1,5 +1,5 @@
import {css, unsafeCSS} from "lit-element";
-import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultBoxShadow, DefaultColor4, DefaultColor6, DefaultColor7, DefaultDisabledOpacity} from "@openremote/core";
+import {DefaultColor1, DefaultColor2, DefaultColor5, DefaultColor3, DefaultBoxShadow, DefaultColor4, DefaultColor6, DefaultDisabledOpacity} from "@openremote/core";
// language=CSS
export const rulesEditorStyle = css`
@@ -13,7 +13,7 @@ export const rulesEditorStyle = css`
--internal-or-rules-editor-text-color: var(--or-rules-editor-text-color, inherit);
--internal-or-rules-editor-button-color: var(--or-rules-editor-button-color, var(--or-app-color4, ${unsafeCSS(DefaultColor4)}));
--internal-or-rules-editor-invalid-color: var(--or-rules-editor-invalid-color, var(--or-app-color6, ${unsafeCSS(DefaultColor6)}));
- --internal-or-rules-editor-panel-color: var(--or-rules-editor-panel-color, var(--or-app-color7, ${unsafeCSS(DefaultColor7)}));
+ --internal-or-rules-editor-panel-color: var(--or-rules-editor-panel-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
--internal-or-rules-editor-line-color: var(--or-rules-editor-line-color, var(--or-app-color5, ${unsafeCSS(DefaultColor5)}));
--internal-or-rules-editor-list-selected-color: var(--or-rules-editor-list-selected-color, var(--or-app-color2, ${unsafeCSS(DefaultColor2)}));
diff --git a/ui/component/or-select/package.json b/ui/component/or-select/package.json
index 6078f90c0..d59976195 100644
--- a/ui/component/or-select/package.json
+++ b/ui/component/or-select/package.json
@@ -11,14 +11,14 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "@openremote/core": "^1.0.0",
- "@openremote/rest": "^1.0.0",
- "@openremote/or-icon": "^1.0.0",
"@material/list": "^1.0.1",
"@material/menu": "^1.0.1",
"@material/menu-surface": "^1.0.1",
"@material/select": "^1.0.1",
- "lit-element": "^2.1.0"
+ "@openremote/core": "^1.0.0",
+ "@openremote/or-icon": "^1.0.0",
+ "@openremote/rest": "^1.0.0",
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"tslint": "^5.11.0",
diff --git a/ui/component/or-select/src/style.ts b/ui/component/or-select/src/style.ts
index 2c83254e1..e86189fa4 100644
--- a/ui/component/or-select/src/style.ts
+++ b/ui/component/or-select/src/style.ts
@@ -1,5 +1,5 @@
import {css, unsafeCSS} from "lit-element";
-import {DefaultColor2, DefaultColor5, DefaultColor7} from "@openremote/core";
+import {DefaultColor1, DefaultColor2, DefaultColor5} from "@openremote/core";
// TODO this is temp work, should be replaced with material design components / styling
@@ -16,7 +16,7 @@ export const selectStyle = css`
--internal-or-select-text-color: var(--or-select-text-color, inherit);
--internal-or-select-padding: var(--or-select-padding, 10px 40px 10px 10px);
--internal-or-select-option-text-color: var(--or-select-option-text-color, inherit);
- --internal-or-select-option-background-color: var(--or-select-option-background-color, var(--or-app-color7, ${unsafeCSS(DefaultColor7)}));
+ --internal-or-select-option-background-color: var(--or-select-option-background-color, var(--or-app-color1, ${unsafeCSS(DefaultColor1)}));
}
select:invalid {
diff --git a/ui/component/or-smart-notify/package.json b/ui/component/or-smart-notify/package.json
index 80a452c78..d22db7544 100644
--- a/ui/component/or-smart-notify/package.json
+++ b/ui/component/or-smart-notify/package.json
@@ -16,7 +16,7 @@
"@fortawesome/free-solid-svg-icons": "^5.6.3",
"@openremote/model": "^1.0.0",
"@openremote/rest": "^1.0.0",
- "lit-element": "^2.1.0",
+ "lit-element": "^2.2.1",
"moment": "^2.24.0"
},
"devDependencies": {
diff --git a/ui/component/or-thermostat/package.json b/ui/component/or-thermostat/package.json
index 9279877ed..87f843656 100644
--- a/ui/component/or-thermostat/package.json
+++ b/ui/component/or-thermostat/package.json
@@ -11,7 +11,7 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "lit-element": "^2.1.0"
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"tslint": "^5.11.0",
diff --git a/ui/component/or-timeline/package.json b/ui/component/or-timeline/package.json
index 880d43fa0..7c1360ba4 100644
--- a/ui/component/or-timeline/package.json
+++ b/ui/component/or-timeline/package.json
@@ -11,7 +11,7 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "lit-element": "^2.1.0",
+ "lit-element": "^2.2.1",
"moment": "^2.24.0"
},
"devDependencies": {
diff --git a/ui/component/or-translate/package.json b/ui/component/or-translate/package.json
index ff7a40909..2c176fd67 100644
--- a/ui/component/or-translate/package.json
+++ b/ui/component/or-translate/package.json
@@ -11,12 +11,11 @@
"author": "OpenRemote",
"license": "AGPL-3.0-or-later",
"dependencies": {
- "lit-element": "^2.1.0",
- "i18next": "^15.0.9"
+ "i18next": "^15.0.9",
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"tslint": "^5.11.0",
"typescript": "^3.4.5"
}
}
-
diff --git a/ui/component/or-translate/src/index.ts b/ui/component/or-translate/src/index.ts
index 42a211d9e..c89ece7b1 100644
--- a/ui/component/or-translate/src/index.ts
+++ b/ui/component/or-translate/src/index.ts
@@ -7,7 +7,7 @@ export class OrTranslate extends translate(i18next)(LitElement) {
public static styles = css`
:host {
- display: inline-block;
+ display: inline;
}
:host([hidden]) {
diff --git a/ui/component/or-translate/src/translate-mixin.ts b/ui/component/or-translate/src/translate-mixin.ts
index df6077ef9..9a34da0f8 100644
--- a/ui/component/or-translate/src/translate-mixin.ts
+++ b/ui/component/or-translate/src/translate-mixin.ts
@@ -10,54 +10,56 @@ interface CustomElement {
}
// TODO: Can't currently export declaration files with explicit LitElement type (see https://github.com/Microsoft/TypeScript/issues/17293)
-export const translate = (i18next: i18n.i18n) => <T extends Constructor<CustomElement>>(litElement: T) => {
+export const translate = (i18next: i18n.i18n) => <T extends Constructor<CustomElement>>(base: T) =>
+ class extends base {
- return class extends litElement {
+ _i18nextJustInitialized = false;
- public _i18nextJustInitialized = false;
+ connectedCallback() {
+ if (!i18next.language) {
+ i18next.on("initialized", this.initCallback);
+ }
- public connectedCallback() {
- if (!i18next.language) {
- i18next.on("initialized", this.initCallback);
- }
-
- i18next.on("languageChanged", this.langChangedCallback);
+ i18next.on("languageChanged", this.langChangedCallback);
- if (super.connectedCallback) {
- super.connectedCallback();
+ if (super.connectedCallback) {
+ super.connectedCallback();
+ }
}
- }
- public disconnectedCallback() {
- i18next.off("initialized", this.initCallback);
- i18next.off("languageChanged", this.langChangedCallback);
- }
+ disconnectedCallback() {
+ i18next.off("initialized", this.initCallback);
+ i18next.off("languageChanged", this.langChangedCallback);
- public shouldUpdate(changedProps: PropertyValues) {
- if (this._i18nextJustInitialized) {
- this._i18nextJustInitialized = false;
- return true;
+ if (super.disconnectedCallback) {
+ super.disconnectedCallback();
+ }
}
- // @ts-ignore
- return super.shouldUpdate && super.shouldUpdate(changedProps);
- }
+ shouldUpdate(changedProps: PropertyValues) {
+ if (this._i18nextJustInitialized) {
+ this._i18nextJustInitialized = false;
+ return true;
+ }
- public initCallback = (options: i18n.InitOptions) => {
- this._i18nextJustInitialized = true;
- // @ts-ignore
- if (this.requestUpdate) {
// @ts-ignore
- this.requestUpdate();
+ return super.shouldUpdate && super.shouldUpdate(changedProps);
}
- }
- public langChangedCallback = () => {
- // @ts-ignore
- if (this.requestUpdate) {
+ public initCallback = (options: i18n.InitOptions) => {
+ this._i18nextJustInitialized = true;
+ // @ts-ignore
+ if (this.requestUpdate) {
+ // @ts-ignore
+ this.requestUpdate();
+ }
+ };
+
+ public langChangedCallback = () => {
// @ts-ignore
- this.requestUpdate();
+ if (this.requestUpdate) {
+ // @ts-ignore
+ this.requestUpdate();
+ }
}
- }
- };
-};
+ };
diff --git a/ui/demo/demo-core/package.json b/ui/demo/demo-core/package.json
index 545bed0e9..75dd2ee39 100644
--- a/ui/demo/demo-core/package.json
+++ b/ui/demo/demo-core/package.json
@@ -18,8 +18,8 @@
"@openremote/core": "^1.0.1",
"@openremote/or-icon": "^1.0.0",
"@openremote/or-translate": "^1.0.0",
- "lit-html": "^0.12.0",
- "i18next": "^15.0.9"
+ "i18next": "^15.0.9",
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"@babel/core": "^7.2.2",
@@ -31,15 +31,15 @@
"@babel/runtime": "^7.2.0",
"babel-loader": "^8.0.4",
"copy-webpack-plugin": "^4.6.0",
- "html-webpack-plugin": "^3.2.0",
- "source-map-loader": "^0.2.4",
- "style-loader": "^0.23.1",
+ "cross-env": "^5.2.0",
"css-loader": "^2.0.0",
"fast-async": "^6.3.8",
"file-loader": "^2.0.0",
+ "html-webpack-plugin": "^3.2.0",
"raw-loader": "^0.5.1",
- "cross-env": "^5.2.0",
"shx": "^0.3.2",
+ "source-map-loader": "^0.2.4",
+ "style-loader": "^0.23.1",
"tslint": "^5.11.0",
"typescript": "^3.4.5",
"url-loader": "^1.1.2",
diff --git a/ui/demo/demo-or-thermostat/package.json b/ui/demo/demo-or-thermostat/package.json
index 201ce1c9d..383f0e85c 100644
--- a/ui/demo/demo-or-thermostat/package.json
+++ b/ui/demo/demo-or-thermostat/package.json
@@ -25,23 +25,23 @@
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/runtime": "^7.2.0",
+ "@polymer/iron-demo-helpers": "^3.0.0-pre.19",
"babel-loader": "^8.0.4",
"copy-webpack-plugin": "^4.6.0",
- "html-webpack-plugin": "^3.2.0",
- "source-map-loader": "^0.2.4",
- "style-loader": "^0.23.1",
+ "cross-env": "^5.2.0",
"css-loader": "^2.0.0",
"fast-async": "^6.3.8",
"file-loader": "^2.0.0",
+ "html-webpack-plugin": "^3.2.0",
"raw-loader": "^0.5.1",
- "cross-env": "^5.2.0",
"shx": "^0.3.2",
+ "source-map-loader": "^0.2.4",
+ "style-loader": "^0.23.1",
"tslint": "^5.11.0",
"typescript": "^3.4.5",
"url-loader": "^1.1.2",
"webpack": "^4.24.0",
"webpack-cli": "^3.1.2",
- "webpack-dev-server": "^3.1.10",
- "@polymer/iron-demo-helpers": "^3.0.0-pre.19"
+ "webpack-dev-server": "^3.1.10"
}
}
diff --git a/ui/demo/demo-rest/package.json b/ui/demo/demo-rest/package.json
index 86d66d4c4..6f8efbed7 100644
--- a/ui/demo/demo-rest/package.json
+++ b/ui/demo/demo-rest/package.json
@@ -16,7 +16,7 @@
"license": "AGPL-3.0-or-later",
"dependencies": {
"@openremote/rest": "^1.0.1",
- "lit-html": "^0.12.0"
+ "lit-element": "^2.2.1"
},
"devDependencies": {
"@babel/core": "^7.2.2",
@@ -28,15 +28,15 @@
"@babel/runtime": "^7.2.0",
"babel-loader": "^8.0.4",
"copy-webpack-plugin": "^4.6.0",
- "html-webpack-plugin": "^3.2.0",
- "source-map-loader": "^0.2.4",
- "style-loader": "^0.23.1",
+ "cross-env": "^5.2.0",
"css-loader": "^2.0.0",
"fast-async": "^6.3.8",
"file-loader": "^2.0.0",
+ "html-webpack-plugin": "^3.2.0",
"raw-loader": "^0.5.1",
- "cross-env": "^5.2.0",
"shx": "^0.3.2",
+ "source-map-loader": "^0.2.4",
+ "style-loader": "^0.23.1",
"tslint": "^5.11.0",
"typescript": "^3.4.5",
"url-loader": "^1.1.2",
diff --git a/yarn.lock b/yarn.lock
index 79cb2eb5f..416bc93b0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -747,6 +747,13 @@
dependencies:
tslib "^1.9.3"
+"@material/animation@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/animation/-/animation-3.1.0.tgz#ab04e7c2e92ab370a2b28d12af1b88538d23014f"
+ integrity sha512-ZfP95awrPBLhpaCTPNx+xKYPp2D88fzf5p5YNVp6diUAGRpq3g12Aq7qJfIHDXAFo5CtrYhgOKRqIKxUVcFisQ==
+ dependencies:
+ tslib "^1.9.3"
+
"@material/base@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@material/base/-/base-1.0.0.tgz#e4ef0b22c54aa887af94f5988fb1c0cb3245beba"
@@ -754,6 +761,40 @@
dependencies:
tslib "^1.9.3"
+"@material/base@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/base/-/base-3.1.0.tgz#ab933896ab6390d4e1d2f9797b74a90f47db272a"
+ integrity sha512-pWEBHyPrMV3rdnjqWWH96h5t3MxQI6V1J9jOor+UBG7bXQtr6InTabTqhz5CLY7r+qZU8YvNh2OKIy8heP0cyQ==
+ dependencies:
+ tslib "^1.9.3"
+
+"@material/button@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/button/-/button-3.2.0.tgz#859d9ce164d6ee5925ac0fb04af57ea7d9295c6e"
+ integrity sha512-VEASy3Dtc7BCo8/cuUIp6w0+/l4U1myGZffK5GeFVInP/erStSQOmYXT7jGXkZpUglRzWOpVvEpc6nsvhMqGbw==
+ dependencies:
+ "@material/elevation" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/ripple" "^3.2.0"
+ "@material/rtl" "^3.2.0"
+ "@material/shape" "^3.1.0"
+ "@material/theme" "^3.1.0"
+ "@material/typography" "^3.1.0"
+
+"@material/checkbox@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/checkbox/-/checkbox-3.2.0.tgz#168d4e16e160bec17948d06416935250fa10fac5"
+ integrity sha512-4XgQ4sM40j60n4RN43BxXtkFVvyFQgo/vc0W5hf9Qz2uwEah46Shg1nHMYZNvcNW+FXRm96gH8zz3qFgEf1ytA==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/dom" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/ripple" "^3.2.0"
+ "@material/rtl" "^3.2.0"
+ "@material/theme" "^3.1.0"
+ tslib "^1.9.3"
+
"@material/dom@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@material/dom/-/dom-1.1.0.tgz#3bd3d1a3415b4181118fecb182d93beda56a6f8c"
@@ -761,6 +802,13 @@
dependencies:
tslib "^1.9.3"
+"@material/dom@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/dom/-/dom-3.1.0.tgz#1e58cad0cd5e1d9d6f6cb07422e327ad34a9d405"
+ integrity sha512-RtBLSkrBjMfHwknaGBifAIC8cBWF9pXjz2IYqfI2braB6SfQI4vhdJviwyiA5BmA/psn3cKpBUZbHI0ym0O0SQ==
+ dependencies:
+ tslib "^1.9.3"
+
"@material/elevation@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@material/elevation/-/elevation-1.1.0.tgz#def23c360ae067b43c1632a331b9883b9f679cc5"
@@ -770,11 +818,25 @@
"@material/feature-targeting" "^0.44.1"
"@material/theme" "^1.1.0"
+"@material/elevation@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/elevation/-/elevation-3.1.0.tgz#2fcbde47653cc115519a39acc2d04b34e4cff12b"
+ integrity sha512-e45LqiG6LfbR1M52YkSLA7pQPeYJOuOVzLp27xy2072TnLuJexMxhEaG4O1novEIjsTtMjqfrfJ/koODU5vEew==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/theme" "^3.1.0"
+
"@material/feature-targeting@^0.44.1":
version "0.44.1"
resolved "https://registry.yarnpkg.com/@material/feature-targeting/-/feature-targeting-0.44.1.tgz#afafc80294e5efab94bee31a187273d43d34979a"
integrity sha512-90cc7njn4aHbH9UxY8qgZth1W5JgOgcEdWdubH1t7sFkwqFxS5g3zgxSBt46TygFBVIXNZNq35Xmg80wgqO7Pg==
+"@material/feature-targeting@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/feature-targeting/-/feature-targeting-3.1.0.tgz#a6f6cacd1e0c9b60dc82f2f3bb2de8cfd472252b"
+ integrity sha512-aXAa1Pv6w32URacE9LfMsl9zI6hFwx1K0Lp3Xpyf4rAkmaAB6z0gOkhicOrVFc0f64YheJgHjE7hJFieVenQdw==
+
"@material/floating-label@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@material/floating-label/-/floating-label-1.1.0.tgz#505b9f8c7628d0498a18b165c387d4c34840ca60"
@@ -787,6 +849,42 @@
"@material/typography" "^1.0.0"
tslib "^1.9.3"
+"@material/floating-label@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/floating-label/-/floating-label-3.2.0.tgz#6de47528d1534b7d87f42286ed952fe63153c4d9"
+ integrity sha512-szzsSou+xXj3E6InEuOCr8E28IE5EdcBfKRaHoR5EBkzgcRxLuZkFSqD19zsUgVErdTCcRSbeU9mYa6cP8+Nzw==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/rtl" "^3.2.0"
+ "@material/theme" "^3.1.0"
+ "@material/typography" "^3.1.0"
+ tslib "^1.9.3"
+
+"@material/form-field@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/form-field/-/form-field-3.2.0.tgz#be35298526d7436922636ec8b163733814cfafa7"
+ integrity sha512-4XjZGy1S966IOUxFaRAKcZOvr5qqvx8r1RMvfCsEzTB45y9Lo2puilNyCtatVAULRxCwszZb7Kbd++cpmMpzZA==
+ dependencies:
+ "@material/base" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/ripple" "^3.2.0"
+ "@material/rtl" "^3.2.0"
+ "@material/theme" "^3.1.0"
+ "@material/typography" "^3.1.0"
+ tslib "^1.9.3"
+
+"@material/icon-button@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/icon-button/-/icon-button-3.2.0.tgz#7a132fffe5be347db77281d63e7e4c5ffe0881ca"
+ integrity sha512-UTX1q4x5FxntBeb5TxBsXIjbhwFjQxJxovaUGo8+eUL9V9tU6rJ3NnlrFirx9gZnFIU1Xpssm91NCItVZy/Dpg==
+ dependencies:
+ "@material/base" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/ripple" "^3.2.0"
+ "@material/theme" "^3.1.0"
+ tslib "^1.9.3"
+
"@material/line-ripple@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@material/line-ripple/-/line-ripple-1.1.0.tgz#0fef69c14ddf42877f10eed05c1a2489808f1cf4"
@@ -797,6 +895,16 @@
"@material/theme" "^1.1.0"
tslib "^1.9.3"
+"@material/line-ripple@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/line-ripple/-/line-ripple-3.1.0.tgz#63a4f41f2a2a5df01c2e229a76fc2b0735cd62c0"
+ integrity sha512-o6E6wrDqoOK4esCnM1MQ9t7DC/JQrzSrwYsYdqtOpGnr3G5Jx7WWVt6GEVh2eNXy8OnVYkJdQbMjyPVEVJb/Dg==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/theme" "^3.1.0"
+ tslib "^1.9.3"
+
"@material/list@^1.0.1", "@material/list@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@material/list/-/list-1.1.1.tgz#296ed85ae3585af1749462e5bafd617d5675e85e"
@@ -852,6 +960,19 @@
"@material/theme" "^1.1.0"
tslib "^1.9.3"
+"@material/notched-outline@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/notched-outline/-/notched-outline-3.2.0.tgz#3b7e79e6282e747a18e97b0d0c79f06eab924aa0"
+ integrity sha512-IFuxVoQqlOy/WSSawI2Fglh/U1hS0QtVUiGsc8GUoVUd1pifn7RXidHP3vQrMDEo8M/RwA9p6uveQKjPwW41RA==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/floating-label" "^3.2.0"
+ "@material/rtl" "^3.2.0"
+ "@material/shape" "^3.1.0"
+ "@material/theme" "^3.1.0"
+ tslib "^1.9.3"
+
"@material/ripple@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@material/ripple/-/ripple-1.1.0.tgz#236016fb30c8366faf143297df2c38166d84ffbc"
@@ -864,11 +985,28 @@
"@material/theme" "^1.1.0"
tslib "^1.9.3"
+"@material/ripple@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/ripple/-/ripple-3.2.0.tgz#f4b714834b73b793b280024d4ebcca01018df3bd"
+ integrity sha512-GtwkfNakALmfGLs6TpdFIVeAWjRqbyT7WfEw9aU7elUokABfHES+O0KoSKQSMQiSQ8Vjl90MONzNsN1Evi/1YQ==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/dom" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/theme" "^3.1.0"
+ tslib "^1.9.3"
+
"@material/rtl@^0.42.0":
version "0.42.0"
resolved "https://registry.yarnpkg.com/@material/rtl/-/rtl-0.42.0.tgz#1836e78186c2d8b996f6fbf97adab203535335bc"
integrity sha512-VrnrKJzhmspsN8WXHuxxBZ69yM5IwhCUqWr1t1eNfw3ZEvEj7i1g3P31HGowKThIN1dc1Wh4LE14rCISWCtv5w==
+"@material/rtl@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/rtl/-/rtl-3.2.0.tgz#0b2f7321463100674dfbf4507b54ccd052f05378"
+ integrity sha512-L/w9m9Yx1ceOw/VjEfeJoqD4rW9QP3IBb9MamXAg3qUi/zsztoXD/FUw179pxkLn4huFFNlVYZ4Y1y6BpM0PMA==
+
"@material/select@^1.0.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@material/select/-/select-1.1.1.tgz#c4a646de35590407d5effeb25b1d08fad012aa70"
@@ -895,6 +1033,46 @@
dependencies:
"@material/feature-targeting" "^0.44.1"
+"@material/shape@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/shape/-/shape-3.1.0.tgz#7ccac6606d0ae45b779b3e52b8921c09c2b2f429"
+ integrity sha512-Oyvs7YjHfByA0e9IVVp7ojAlPwgSu3Bl0cioiE0OdkidkAaNu0izM2ryRzMBDH5o8+lRD0kpZoT+9CVVCdaYIg==
+ dependencies:
+ "@material/feature-targeting" "^3.1.0"
+
+"@material/switch@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/switch/-/switch-3.2.0.tgz#003409a8eecfd2f9c9600bfb23e152bf12b7e518"
+ integrity sha512-gECImbvf3HGpmc/Sj2Meq+z7/ri5jmD5rKOeUUeC6nZ77/HiGCRhmSD66rlS0SH5qUUj0mWSbE8ZVOJmVWySEQ==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/dom" "^3.1.0"
+ "@material/elevation" "^3.1.0"
+ "@material/feature-targeting" "^3.1.0"
+ "@material/ripple" "^3.2.0"
+ "@material/rtl" "^3.2.0"
+ "@material/theme" "^3.1.0"
+ tslib "^1.9.3"
+
+"@material/textfield@^3.2.0":
+ version "3.2.0"
+ resolved "https://registry.yarnpkg.com/@material/textfield/-/textfield-3.2.0.tgz#c4272601f9a57f26fd7fce8b3089a5d5d6595ad1"
+ integrity sha512-xPWDkTzurMOxvH0+DsenzboF7dFoUeLcbqX/9vyhWe3aPlO6ZWFNn3lAmYN24ElqR5FEr5zXNYfeIQ4JLT5mYw==
+ dependencies:
+ "@material/animation" "^3.1.0"
+ "@material/base" "^3.1.0"
+ "@material/dom" "^3.1.0"
+ "@material/floating-label" "^3.2.0"
+ "@material/line-ripple" "^3.1.0"
+ "@material/notched-outline" "^3.2.0"
+ "@material/ripple" "^3.2.0"
+ "@material/rtl" "^3.2.0"
+ "@material/shape" "^3.1.0"
+ "@material/theme" "^3.1.0"
+ "@material/typography" "^3.1.0"
+ tslib "^1.9.3"
+
"@material/theme@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@material/theme/-/theme-1.1.0.tgz#9c95dd804168c23c30589fcf09ecc5af5b3d1adc"
@@ -902,6 +1080,13 @@
dependencies:
"@material/feature-targeting" "^0.44.1"
+"@material/theme@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/theme/-/theme-3.1.0.tgz#d31147bbc9e20bdaa3e322c9e898e4fc98807d8c"
+ integrity sha512-N4JX+akOwg1faAvFvIEhDcwW4cZfUpwEn8lct6Vs3WczjLF6/KdIoLVaYh+eVl1bzfsoIuWvx56j0B1PjXZw9g==
+ dependencies:
+ "@material/feature-targeting" "^3.1.0"
+
"@material/typography@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@material/typography/-/typography-1.0.0.tgz#327ecfcac5ee3af8a3a102f3f125a761202f4189"
@@ -909,6 +1094,13 @@
dependencies:
"@material/feature-targeting" "^0.44.1"
+"@material/typography@^3.1.0":
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/@material/typography/-/typography-3.1.0.tgz#5a3aee31f49f6b8c87ebc91b77c5b896b280c492"
+ integrity sha512-aSNBQvVxIH1kORSYdLGuSTivx6oJ1MSOSTUAsUwhXPQLQlvbdFeZaqUp7xgn+EvRsHGRFhWk5YGuiBds9+7zQg==
+ dependencies:
+ "@material/feature-targeting" "^3.1.0"
+
"@mdi/svg@^4.2.95":
version "4.2.95"
resolved "https://registry.yarnpkg.com/@mdi/svg/-/svg-4.2.95.tgz#05d45a4391da211da3de2e0e25acad8272c23d67"
@@ -1092,6 +1284,11 @@
resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.5.3.tgz#1c3b71b091eaeaf5924538006b7f70603ce63d38"
integrity sha512-Jugo5V/1bS0fRhy2z8+cUAHEyWOATaz4rbyLVvcFs7+dXp5HfwpEwzF1Q11bB10ApUqHf+yTauxI0UXQDwGrbA==
+"@types/simplebar@^2.4.2":
+ version "2.4.2"
+ resolved "https://registry.yarnpkg.com/@types/simplebar/-/simplebar-2.4.2.tgz#f45e3268b7153bfe8da50658a929be5cd098c4cb"
+ integrity sha512-omSnWgcQ5hGANK8MijABHDNtj7bM2GH80g8wVqeRmaePJ2lPN4RmbrVihEbYtnovW2aS51a0joITsb6+Q1HnnA==
+
"@webassemblyjs/[email protected]":
version "1.8.5"
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.8.5.tgz#51b1c5fe6576a34953bf4b253df9f0d490d9e359"
@@ -1807,6 +2004,11 @@ camelcase@^5.0.0, camelcase@^5.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320"
integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
+can-use-dom@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/can-use-dom/-/can-use-dom-0.1.0.tgz#22cc4a34a0abc43950f42c6411024a3f6366b45a"
+ integrity sha1-IsxKNKCrxDlQ9CxkEQJKP2NmtFo=
+
caniuse-lite@^1.0.30000984:
version "1.0.30000989"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000989.tgz#b9193e293ccf7e4426c5245134b8f2a56c0ac4b9"
@@ -2120,6 +2322,11 @@ core-js-compat@^3.1.1:
browserslist "^4.6.6"
semver "^6.3.0"
+core-js@^3.0.1:
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.2.1.tgz#cd41f38534da6cc59f7db050fe67307de9868b09"
+ integrity sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw==
+
core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
@@ -3910,18 +4117,13 @@ levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"
-lit-element@^2.0.1, lit-element@^2.1.0:
+lit-element@^2.0.1, lit-element@^2.1.0, lit-element@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/lit-element/-/lit-element-2.2.1.tgz#79c94d8cfdc2d73b245656e37991bd1e4811d96f"
integrity sha512-ipDcgQ1EpW6Va2Z6dWm79jYdimVepO5GL0eYkZrFvdr0OD/1N260Q9DH+K5HXHFrRoC7dOg+ZpED2XE0TgGdXw==
dependencies:
lit-html "^1.0.0"
-lit-html@^0.12.0:
- version "0.12.0"
- resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-0.12.0.tgz#d994420fda74744f9d4a79401b086de929643e6a"
- integrity sha512-NyFgq8yTlGEjUFQOmNnK/kj+ZdDVJzTwsLunNSewGiOns7SjuJi6ymCCqzZZ81uW2VwEmliMbOlFZc9QmOJPLA==
-
lit-html@^1.0.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/lit-html/-/lit-html-1.1.2.tgz#2e3560a7075210243649c888ad738eaf0daa8374"
@@ -3967,6 +4169,21 @@ locate-path@^3.0.0:
p-locate "^3.0.0"
path-exists "^3.0.0"
+lodash.debounce@^4.0.8:
+ version "4.0.8"
+ resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
+ integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
+
+lodash.memoize@^4.1.2:
+ version "4.1.2"
+ resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
+ integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
+
+lodash.throttle@^4.1.1:
+ version "4.1.1"
+ resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
+ integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ=
+
lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.3:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@@ -5396,6 +5613,11 @@ reselect@^3.0.1:
resolved "https://registry.yarnpkg.com/reselect/-/reselect-3.0.1.tgz#efdaa98ea7451324d092b2b2163a6a1d7a9a2147"
integrity sha1-79qpjqdFEyTQkrKyFjpqHXqaIUc=
+resize-observer-polyfill@^1.5.1:
+ version "1.5.1"
+ resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
+ integrity sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg==
+
resolve-cwd@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
@@ -5674,6 +5896,18 @@ signal-exit@^3.0.0:
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=
+simplebar@^4.2.3:
+ version "4.2.3"
+ resolved "https://registry.yarnpkg.com/simplebar/-/simplebar-4.2.3.tgz#dac40aced299c17928329eab3d5e6e795fafc10c"
+ integrity sha512-9no0pK7/1y+8/oTF3sy/+kx0PjQ3uk4cYwld5F1CJGk2gx+prRyUq8GRfvcVLq5niYWSozZdX73a2wIr1o9l/g==
+ dependencies:
+ can-use-dom "^0.1.0"
+ core-js "^3.0.1"
+ lodash.debounce "^4.0.8"
+ lodash.memoize "^4.1.2"
+ lodash.throttle "^4.1.1"
+ resize-observer-polyfill "^1.5.1"
+
slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"