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: various bug fixes

Rich Turnerfec884285a52
diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.json
index 4a0fadef3..7ea1435b1 100644
--- a/deployment/manager/shared/locales/en/or.json
+++ b/deployment/manager/shared/locales/en/or.json
@@ -388,5 +388,6 @@
"never": "Never",
"repetitionEnds": "Repetition ends",
"repeatOccurrenceEvery": "Repeat occurrence every",
- "daysOfTheWeek": "days of the week"
+ "daysOfTheWeek": "days of the week",
+ "logCategory": {}
}
diff --git a/ui/app/or-app/src/or-header.ts b/ui/app/or-app/src/or-header.ts
index 4b851963f..6d0d8752d 100644
--- a/ui/app/or-app/src/or-header.ts
+++ b/ui/app/or-app/src/or-header.ts
@@ -1,4 +1,4 @@
-import {css, customElement, html, LitElement, property, query, TemplateResult, unsafeCSS} from "lit-element";
+import {css, customElement, html, LitElement, property, PropertyValues, query, TemplateResult, unsafeCSS} from "lit-element";
import {until} from "lit-html/directives/until";
import manager, {
DefaultBoxShadowBottom,
@@ -335,7 +335,7 @@ class OrHeader extends LitElement {
private _drawerOpened = false;
@property({ type: String })
- private activeMenu: string | undefined = getCurrentMenuItemRef();
+ private activeMenu: string | undefined;
public connectedCallback(): void {
super.connectedCallback();
@@ -361,6 +361,13 @@ class OrHeader extends LitElement {
this._onHashChanged(e);
}
+ protected shouldUpdate(changedProperties: PropertyValues): boolean {
+ if (changedProperties.has("config")) {
+ this.activeMenu = getCurrentMenuItemRef(this.config && this.config.mainMenu && this.config.mainMenu.length > 0 ? this.config.mainMenu[0].href : undefined);
+ }
+ return super.shouldUpdate(changedProperties);
+ }
+
protected render() {
const mainItems = this.config ? this.config.mainMenu : undefined;
@@ -441,7 +448,7 @@ class OrHeader extends LitElement {
${getContentWithMenuTemplate(
html`
<div id="realm-picker">
- <span>${tenants.find((t) => t.realm === manager.displayRealm).displayName}</span>
+ <span>${tenants.find((t) => t.realm === manager.displayRealm)?.displayName}</span>
<or-icon icon="chevron-down"></or-icon>
</div>
`,
diff --git a/ui/app/or-app/src/pages/page-map.ts b/ui/app/or-app/src/pages/page-map.ts
index 894837f24..093ba9d77 100644
--- a/ui/app/or-app/src/pages/page-map.ts
+++ b/ui/app/or-app/src/pages/page-map.ts
@@ -9,9 +9,9 @@ import {
OrMapMarkerAsset,
OrMapMarkerClickedEvent
} from "@openremote/or-map";
-import manager, {Util} from "@openremote/core";
+import manager, {OREvent, Util} from "@openremote/core";
import {createSelector} from "reselect";
-import {Asset, AssetEvent, AssetEventCause, AttributeEvent, GeoJSONPoint, Attribute, WellknownMetaItems, WellknownAttributes} from "@openremote/model";
+import {Asset, AssetEvent, AssetEventCause, AttributeEvent, GeoJSONPoint, Attribute, WellknownMetaItems, WellknownAttributes, AssetQueryOperator, LogicGroupOperator} from "@openremote/model";
import {getAssetsRoute} from "./page-assets";
import {Page, router} from "../types";
import {AppStateKeyed} from "../app";
@@ -69,6 +69,12 @@ const pageMapSlice = createSlice({
]
};
},
+ setAssets(state, action: PayloadAction<Asset[]>) {
+ return {
+ ...state,
+ assets: action.payload
+ };
+ },
setAssetSubscriptionId(state, action: PayloadAction<string>) {
return {
...state,
@@ -84,7 +90,7 @@ const pageMapSlice = createSlice({
}
});
-const {assetEventReceived, attributeEventReceived, setAssetSubscriptionId, setAttributeSubscriptionId} = pageMapSlice.actions;
+const {assetEventReceived, attributeEventReceived, setAssets, setAssetSubscriptionId, setAttributeSubscriptionId} = pageMapSlice.actions;
export const pageMapReducer = pageMapSlice.reducer;
export function pageMapProvider<S extends MapStateKeyed>(store: EnhancedStore<S>, config?:MapAssetCardConfig) {
@@ -166,19 +172,64 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
try {
const result = await manager.rest.api.AssetResource.queryAssets({
+ tenant: {
+ realm: manager.displayRealm
+ },
select: {
- excludeAttributes: true,
+ attributes: [WellknownAttributes.LOCATION],
excludeParentInfo: true,
excludePath: true
+ },
+ attributes: {
+ items: [
+ {
+ name: {
+ predicateType: "string",
+ value: WellknownAttributes.LOCATION
+ }
+ }
+ ],
+ groups: [
+ {
+ operator: LogicGroupOperator.OR,
+ items: [
+ {
+ meta: [
+ {
+ name: {
+ predicateType: "string",
+ value: WellknownMetaItems.SHOWONDASHBOARD
+ },
+ negated: true
+ },
+ {
+ name: {
+ predicateType: "string",
+ value: WellknownMetaItems.SHOWONDASHBOARD
+ },
+ value: {
+ predicateType: "boolean",
+ value: true
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
}
});
if (result.data) {
+ const assets = result.data;
+
+ dispatch(setAssets(assets))
+
const ids = result.data.map(
asset => asset.id
);
- const assetSubscriptionId = await manager.events.subscribeAssetEvents(ids, true, (event) => {
+ const assetSubscriptionId = await manager.events.subscribeAssetEvents(ids, false, {filterType: "asset", attributeNames: [WellknownAttributes.LOCATION]}, (event) => {
dispatch(assetEventReceived(event));
});
@@ -219,12 +270,9 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
protected mapCardConfig: MapAssetCardConfig = {
default: {
- exclude: ["userNotes"]
+ exclude: ["notes"]
},
assetTypes: {
- "urn:openremote:asset:iems:weather": {
- exclude: ["location"]
- }
}
};
@@ -259,13 +307,13 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
return html`
- ${this._currentAsset ? html `<or-map-asset-card .config="${this.config ? this.config : this.mapCardConfig}" .asset="${this._currentAsset}"></or-map-asset-card>` : ``}
+ ${this._currentAsset ? html `<or-map-asset-card .config="${this.config ? this.config : this.mapCardConfig}" .assetId="${this._currentAsset.id}"></or-map-asset-card>` : ``}
<or-map id="map" class="or-map">
${
this._assets.filter((asset) => {
const attr = asset.attributes[WellknownAttributes.LOCATION] as Attribute<GeoJSONPoint>;
- const showOnMap = !!Util.getMetaValue(WellknownMetaItems.SHOWONDASHBOARD, attr);
+ const showOnMap = !attr.meta || !attr.meta.hasOwnProperty(WellknownMetaItems.SHOWONDASHBOARD) || !!Util.getMetaValue(WellknownMetaItems.SHOWONDASHBOARD, attr);
return showOnMap;
}).map((asset) => {
return html`
@@ -281,6 +329,7 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
super.connectedCallback();
this.addEventListener(OrMapMarkerClickedEvent.NAME, this.onMapMarkerClick);
this.addEventListener(OrMapClickedEvent.NAME, this.onMapClick);
+ manager.addListener(this.onManagerEvent);
this._store.dispatch(this.subscribeAssets());
}
@@ -288,9 +337,19 @@ export class PageMap<S extends MapStateKeyed> extends Page<S> {
super.disconnectedCallback();
this.removeEventListener(OrMapMarkerClickedEvent.NAME, this.onMapMarkerClick);
this.removeEventListener(OrMapClickedEvent.NAME, this.onMapClick);
+ manager.removeListener(this.onManagerEvent);
this._store.dispatch(this.unsubscribeAssets());
}
+ protected onManagerEvent = (event: OREvent) => {
+ switch (event) {
+ case OREvent.DISPLAY_REALM_CHANGED:
+ this._store.dispatch(this.unsubscribeAssets());
+ this._store.dispatch(this.subscribeAssets());
+ break;
+ }
+ }
+
stateChanged(state: S) {
this._assets = this._getMapAssets(state);
this._currentAsset = this._getCurrentAsset(state);
diff --git a/ui/component/core/src/asset-mixin.ts b/ui/component/core/src/asset-mixin.ts
index 2411ea21d..e704aab17 100644
--- a/ui/component/core/src/asset-mixin.ts
+++ b/ui/component/core/src/asset-mixin.ts
@@ -109,7 +109,7 @@ export const subscribe = (eventProviderFactory: EventProviderFactory) => <T exte
this._subscriptionIds = [];
if (!isAttributes) {
- const assetSubscriptionId = await eventProviderFactory.getEventProvider()!.subscribeAssetEvents(ids, true, (event) => this._onEvent(event));
+ const assetSubscriptionId = await eventProviderFactory.getEventProvider()!.subscribeAssetEvents(ids, true, undefined, (event) => this._onEvent(event));
// Check if the same IDs are in place
const currentIds: string[] | AttributeRef[] | undefined = this._attributeRefs ? this._attributeRefs : this._assetIds;
if (!this._subscriptionIds || !Util.objectsEqual(ids, currentIds)) {
diff --git a/ui/component/core/src/event.ts b/ui/component/core/src/event.ts
index 8e517c8f6..e880305c8 100644
--- a/ui/component/core/src/event.ts
+++ b/ui/component/core/src/event.ts
@@ -4,6 +4,7 @@ import {
Asset,
AssetEvent,
AssetEventCause,
+ AssetFilter,
AssetsEvent,
AttributeEvent,
AttributeRef,
@@ -36,7 +37,7 @@ export interface EventProvider {
unsubscribe<T extends SharedEvent>(subscriptionId: string): void;
- subscribeAssetEvents(ids: string[] | AttributeRef[] | null, requestCurrentValues: boolean, callback: (event: AssetEvent) => void): Promise<string>;
+ subscribeAssetEvents(ids: string[] | AttributeRef[] | null, requestCurrentValues: boolean, filter: AssetFilter | undefined, callback: (event: AssetEvent) => void): Promise<string>;
subscribeAttributeEvents(ids: string[] | AttributeRef[], requestCurrentValues: boolean, callback: (event: AttributeEvent) => void): Promise<string>;
@@ -251,7 +252,7 @@ abstract class EventProviderImpl implements EventProvider {
return this._doSendWithReply(event);
}
- public async subscribeAssetEvents(ids: string[] | AttributeRef[] | null, requestCurrentValues: boolean, callback: (event: AssetEvent) => void): Promise<string> {
+ public async subscribeAssetEvents(ids: string[] | AttributeRef[] | null, requestCurrentValues: boolean, filter: AssetFilter | undefined, callback: (event: AssetEvent) => void): Promise<string> {
const subscription: EventSubscription<AssetEvent> = {
eventType: "asset"
@@ -260,11 +261,19 @@ abstract class EventProviderImpl implements EventProvider {
const isAttributeRef = ids && typeof ids[0] !== "string";
const assetIds = isAttributeRef ? (ids as AttributeRef[]).map((ref) => ref.id!) : ids as string[] | null;
- if (assetIds && assetIds.length > 0) {
- subscription.filter = {
- filterType: "asset",
- assetIds: ids
- };
+ if (filter || assetIds && assetIds.length > 0) {
+
+ if (!filter) {
+ filter = {
+ filterType: "asset"
+ };
+ }
+
+ if (assetIds && assetIds.length > 0) {
+ filter.assetIds = assetIds;
+ }
+
+ subscription.filter = filter;
}
let subscriptionId: string | null = null;
diff --git a/ui/component/core/src/index.ts b/ui/component/core/src/index.ts
index 87fd19565..4ee176759 100644
--- a/ui/component/core/src/index.ts
+++ b/ui/component/core/src/index.ts
@@ -210,17 +210,11 @@ export class ORIconSets {
export class AssetModelUtil {
static _assetTypeInfos: AssetTypeInfo[] = [];
- static _assetDescriptors: AssetDescriptor[] = [];
- static _agentDescriptors: AgentDescriptor[] = [];
static _metaItemDescriptors: MetaItemDescriptor[] = [];
static _valueDescriptors: ValueDescriptor[] = [];
- public static getAgentDescriptors(): AgentDescriptor[] {
- return [...this._agentDescriptors];
- }
-
public static getAssetDescriptors(): AssetDescriptor[] {
- return [...this._assetDescriptors];
+ return AssetModelUtil._assetTypeInfos.map(info => info.assetDescriptor as AgentDescriptor);
}
public static getMetaItemDescriptors(): MetaItemDescriptor[] {
@@ -266,9 +260,10 @@ export class AssetModelUtil {
return type as AssetDescriptor;
}
- return this._assetDescriptors.find((assetDescriptor) => {
- return assetDescriptor.name === type;
+ const match = this._assetTypeInfos.find((assetTypeInfo) => {
+ return assetTypeInfo.assetDescriptor!.name === type;
});
+ return match ? match.assetDescriptor : undefined;
}
public static getAttributeDescriptor(attributeName?: string, assetTypeOrDescriptor?: string | AssetDescriptor | AssetTypeInfo): AttributeDescriptor | undefined {
@@ -783,8 +778,6 @@ export class Manager implements EventProviderFactory {
const valueDescriptorResponse = await rest.api.AssetModelResource.getValueDescriptors();
AssetModelUtil._assetTypeInfos = assetInfosResponse.data;
- AssetModelUtil._agentDescriptors = AssetModelUtil._assetTypeInfos.filter(info => info.assetDescriptor!.descriptorType === "agent").map(info => info.assetDescriptor as AgentDescriptor);
- AssetModelUtil._assetDescriptors = AssetModelUtil._assetTypeInfos.filter(info => info.assetDescriptor!.descriptorType === "asset").map(info => info.assetDescriptor!);
AssetModelUtil._metaItemDescriptors = metaItemDescriptorResponse.data;
AssetModelUtil._valueDescriptors = valueDescriptorResponse.data;
} catch (e) {
diff --git a/ui/component/core/src/util.ts b/ui/component/core/src/util.ts
index 4d1395dc8..24624d424 100644
--- a/ui/component/core/src/util.ts
+++ b/ui/component/core/src/util.ts
@@ -479,7 +479,7 @@ function getValueHolderValueAsString(nameValueHolder: NameValueHolder<any> | und
return valueStr;
}
-export function getValueAsString(value: any, formatProvider: () => ValueFormat | undefined, fallback?: string): string {
+export function getValueAsString(value: any, formatProvider: () => ValueFormat | undefined, language?: string, fallback?: string): string {
let valueStr = "";
if (value === null || typeof(value) === "undefined") {
@@ -506,7 +506,7 @@ export function getValueAsString(value: any, formatProvider: () => ValueFormat |
switch (typeof(value)) {
case "number":
- valueStr = new Intl.NumberFormat(i18next.language, format).format(value);
+ valueStr = new Intl.NumberFormat(language || i18next.language, format).format(value);
break;
case "boolean":
if (format.asOnOff) {
@@ -529,7 +529,7 @@ export function getValueAsString(value: any, formatProvider: () => ValueFormat |
const weekNo = getWeekNumber(value);
valueStr = format.week === ValueFormatStyleRepresentation.DIGIT_2 ? String(weekNo).padStart(2,"0") : Number(weekNo).toString(10);
} else {
- valueStr = new Intl.DateTimeFormat(i18next.language, format).format(value);
+ valueStr = new Intl.DateTimeFormat(language || i18next.language, format).format(value);
}
break;
}
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index 2fa7125fa..a5f11e0e6 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -2,7 +2,6 @@ import {customElement, html, LitElement, property, PropertyValues, TemplateResul
import "@openremote/or-input";
import "@openremote/or-icon";
import {
- AgentDescriptor,
Asset,
AssetDescriptor,
AssetEvent,
@@ -10,9 +9,9 @@ import {
AssetQuery,
AssetsEvent,
AssetTreeNode,
+ AssetTypeInfo,
ClientRole,
- SharedEvent,
- AssetTypeInfo
+ SharedEvent
} from "@openremote/model";
import "@openremote/or-translate";
import {style} from "./style";
@@ -25,7 +24,12 @@ import {getContentWithMenuTemplate, MenuItem} from "@openremote/or-mwc-component
import "@openremote/or-mwc-components/dist/or-mwc-list";
import {i18next} from "@openremote/or-translate";
import "@openremote/or-mwc-components/dist/or-mwc-dialog";
-import {OrMwcDialog, showDialog, showErrorDialog, showOkCancelDialog} from "@openremote/or-mwc-components/dist/or-mwc-dialog";
+import {
+ OrMwcDialog,
+ showDialog,
+ showErrorDialog,
+ showOkCancelDialog
+} from "@openremote/or-mwc-components/dist/or-mwc-dialog";
import {OrAddAssetDialog, OrAddChangedEvent} from "./or-add-asset-dialog";
import "./or-add-asset-dialog";
@@ -40,7 +44,7 @@ export interface AssetTreeConfig {
types?: string[];
};
add?: {
- typesProvider?: (parent: UiAssetTreeNode | undefined) => [AgentDescriptor[], AssetDescriptor[]] | undefined;
+ typesProvider?: (parent: UiAssetTreeNode | undefined) => AssetDescriptor[] | undefined;
typesParent?: {
default?: AssetTreeTypeConfig;
none?: AssetTreeTypeConfig;
@@ -182,8 +186,8 @@ export const getAssetTypes = async () => {
}
}
-export function getDefaultAllowedAddAssetTypes(): [AgentDescriptor[], AssetDescriptor[]] {
- return [AssetModelUtil.getAgentDescriptors(), AssetModelUtil.getAssetDescriptors().filter((descriptor) => descriptor.descriptorType !== "agent")];
+export function getDefaultAllowedAddAssetTypes(): AssetDescriptor[] {
+ return AssetModelUtil.getAssetDescriptors();
}
@customElement("or-asset-tree")
@@ -642,7 +646,7 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
return this._getAllowedChildTypes(selectedNode).length > 0;
}
- protected _getAllowedChildTypes(selectedNode: UiAssetTreeNode | undefined): [AgentDescriptor[], AssetDescriptor[]] {
+ protected _getAllowedChildTypes(selectedNode: UiAssetTreeNode | undefined): AssetDescriptor[] {
let includedAssetTypes: string[] | undefined;
let excludedAssetTypes: string[];
@@ -674,15 +678,9 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
}
}
- const descriptors = getDefaultAllowedAddAssetTypes();
- descriptors[0] = descriptors[0]
- .filter((descriptor) => (!includedAssetTypes || includedAssetTypes.some((inc) => Util.stringMatch(inc, descriptor.name!)))
- && (!excludedAssetTypes || !excludedAssetTypes.some((exc) => Util.stringMatch(exc, descriptor.name!))));
- descriptors[1] = descriptors[1]
+ return getDefaultAllowedAddAssetTypes()
.filter((descriptor) => (!includedAssetTypes || includedAssetTypes.some((inc) => Util.stringMatch(inc, descriptor.name!)))
&& (!excludedAssetTypes || !excludedAssetTypes.some((exc) => Util.stringMatch(exc, descriptor.name!))));
-
- return descriptors;
}
protected _getSortFunction(): (a: UiAssetTreeNode, b: UiAssetTreeNode) => number {
@@ -743,7 +741,7 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
public async _addEventSubscriptions(): Promise<void> {
if (!this.disableSubscribe) {
// Subscribe to asset events for all assets in the realm
- this._subscriptionIds = [await manager.getEventProvider()!.subscribeAssetEvents(null, false, (event) => this._onEvent(event))];
+ this._subscriptionIds = [await manager.getEventProvider()!.subscribeAssetEvents(null, false, undefined, (event) => this._onEvent(event))];
}
}
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 8c8d54fc5..694123bab 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -759,7 +759,7 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
include:[]
},
attributes: {
- include: ["userNotes", "manufacturer", "model"]
+ include: ["notes", "manufacturer", "model"]
}
},
location: {
@@ -783,7 +783,7 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
include:[]
},
attributes: {
- exclude: ["location", "userNotes", "manufacturer", "model", "status"]
+ exclude: ["location", "notes", "manufacturer", "model", "status"]
}
},
history: {
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 1c897abc1..d896e9135 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -482,11 +482,11 @@ export class OrAttributeCard extends LitElement {
elm.value = "";
}
- let attributes = Object.values(this.assetAttributes);
+ let attributes = this.assetAttributes;
if (attributes && attributes.length > 0) {
return attributes
- .filter((attr) => !!Util.getMetaValue(attr, undefined, WellknownMetaItems.STOREDATAPOINTS))
+ .filter((attr) => !attr.meta || !attr.meta.hasOwnProperty(WellknownMetaItems.STOREDATAPOINTS) || !!Util.getMetaValue(attr, undefined, WellknownMetaItems.STOREDATAPOINTS))
.map((attr: Attribute<any>) => {
const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.asset!.type, attr.name, attr);
return [attr.name!, Util.getAttributeLabel(attr, descriptors[0], this.asset!.type, false)];
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 4bb805fe3..cfa45e55f 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -23,7 +23,7 @@ import {
} from "@openremote/model";
import manager, {AssetModelUtil, DefaultColor4, subscribe, Util} from "@openremote/core";
import "@openremote/or-input";
-import {InputType, OrInput, OrInputChangedEvent, ValueInputProviderOptions, ValueInputTemplateFunction, ValueInputProviderGenerator, getValueHolderInputTemplateProvider, ValueInputProvider} from "@openremote/or-input";
+import {InputType, OrInput, OrInputChangedEvent, ValueInputProviderOptions, ValueInputProviderGenerator, getValueHolderInputTemplateProvider, ValueInputProvider} from "@openremote/or-input";
import "@openremote/or-map";
import { geoJsonPointInputTemplateProvider } from "@openremote/or-map";
@@ -491,7 +491,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
}
const options: ValueInputProviderOptions = {
- readonly: this.readonly,
+ readonly: this.isReadonly(),
disabled: this.disabled,
compact: this.compact,
label: this.getLabel()
@@ -551,7 +551,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
content = html`<or-translate .value="attributeUnsupported"></or-translate>`;
}
- content = getAttributeInputWrapper(content, value, loading, !!this.disabled, this._templateProvider.supportsHelperText ? undefined : helperText, this._templateProvider.supportsLabel ? undefined : this.getLabel(), buttonIcon, () => this._updateValue());
+ content = getAttributeInputWrapper(content, value, loading, !!this.disabled, this._templateProvider.supportsHelperText ? undefined : helperText, this._templateProvider.supportsLabel ? undefined : this.getLabel(), this._templateProvider.supportsSendButton ? buttonIcon : undefined, () => this._updateValue());
return content;
}
@@ -605,10 +605,7 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
protected _onInputValueChanged(value: any) {
this._newValue = value;
-
- if (!this.showButton) {
- this._updateValue();
- }
+ this._updateValue();
}
protected _updateValue() {
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index 793140c48..d276ee394 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -712,13 +712,13 @@ export class OrChart extends translate(i18next)(LitElement) {
this._loading = true;
manager.rest.api.AssetResource.queryAssets(query).then((response) => {
+ this._loading = false;
const assets = response.data;
if (!view || !view.assetIds || !view.attributes || assets.length !== view.assetIds.length || assets.length !== view.attributes.length) return;
this.assets = view.assetIds.map((assetId: string) => assets.find(x => x.id === assetId)!);
this.assetAttributes = view.attributes.map((attr: string, index: number) => assets[index] && assets[index].attributes ? assets[index].attributes![attr] : undefined).filter(attr => !!attr) as Attribute<any>[];
this.period = view.period;
- this._loading = false;
});
}
@@ -832,7 +832,7 @@ export class OrChart extends translate(i18next)(LitElement) {
let attributes = Object.values(this.activeAsset.attributes);
if (attributes && attributes.length > 0) {
return attributes
- .filter((attr) => !!Util.getMetaValue(attr, undefined, WellknownMetaItems.STOREDATAPOINTS))
+ .filter((attr) => !attr.meta || !attr.meta.hasOwnProperty(WellknownMetaItems.STOREDATAPOINTS) || !!Util.getMetaValue(attr, undefined, WellknownMetaItems.STOREDATAPOINTS))
.filter((attr) => (this.assetAttributes && !this.assetAttributes.some((assetAttr, index) => (assetAttr.name === attr.name) && this.assets[index].id === this.activeAsset!.id)))
.map((attr) => {
const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(this.activeAsset!.type, attr.name, attr);
diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.ts
index be673fbf6..66eaf58c2 100644
--- a/ui/component/or-input/src/index.ts
+++ b/ui/component/or-input/src/index.ts
@@ -12,7 +12,7 @@ import {MDCList, MDCListActionEvent} from "@material/list";
import {MDCFormField, MDCFormFieldInput} from "@material/form-field";
import {MDCIconButtonToggle, MDCIconButtonToggleEventDetail} from "@material/icon-button";
-import {DefaultColor4, DefaultColor8, Util, AssetModelUtil} from "@openremote/core";
+import {DefaultColor4, DefaultColor8, Util} from "@openremote/core";
import i18next from "i18next";
import { ValueFormat, ValueFormatStyleRepresentation, AssetDescriptor, ValueDescriptorHolder, ValueDescriptor, WellknownValueTypes, MetaHolder, WellknownMetaItems, ValueHolder, NameHolder, Attribute, ValueConstraint, AttributeDescriptor, ValueConstraintSize, ValueConstraintPattern, ValueConstraintMax, ValueConstraintMin, ValueConstraintAllowedValues, ValueConstraintPastOrPresent, ValueConstraintPast, ValueConstraintFuture, ValueConstraintFutureOrPresent, ValueConstraintNotNull, ValueConstraintNotBlank, ValueConstraintNotEmpty, NameValueHolder } from "@openremote/model";
@@ -929,7 +929,7 @@ export class OrInput extends LitElement {
case InputType.TEXTAREA:
case InputType.JSON: {
// The following HTML input types require the values as specially formatted strings
- let valMinMax: [any, any, any] = [this.value === undefined || this.value === null ? "" : this.value, this.min, this.max];
+ let valMinMax: [any, any, any] = [this.value === undefined || this.value === null ? undefined : this.value, this.min, this.max];
if (valMinMax.some((v) => typeof (v) !== "string")) {
@@ -963,7 +963,8 @@ export class OrInput extends LitElement {
break;
}
- valMinMax = valMinMax.map((val) => Util.getValueAsString(val, () => format)) as [any,any,any];
+ // Numbers/dates must be in english locale
+ valMinMax = valMinMax.map((val) => val !== undefined ? Util.getValueAsString(val, () => format, "en-GB") : undefined) as [any,any,any];
}
}
@@ -1009,7 +1010,7 @@ export class OrInput extends LitElement {
<input type="${type}" id="elem" aria-labelledby="${ifDefined(label ? "label" : undefined)}"
class="mdc-text-field__input" ?required="${this.required}" ?readonly="${this.readonly}"
?disabled="${this.disabled}" min="${ifDefined(valMinMax[1])}" max="${ifDefined(valMinMax[2])}"
- step="${ifDefined(this.step)}" minlength="${ifDefined(this.minLength)}" pattern="${ifDefined(this.pattern)}"
+ step="${this.step ? this.step : "any"}" minlength="${ifDefined(this.minLength)}" pattern="${ifDefined(this.pattern)}"
maxlength="${ifDefined(this.maxLength)}" placeholder="${ifDefined(this.placeHolder)}"
.value="${valMinMax[0] !== null && valMinMax[0] !== undefined ? valMinMax[0] : ""}"
@keyup="${(e: KeyboardEvent) => {
diff --git a/ui/component/or-log-viewer/src/index.ts b/ui/component/or-log-viewer/src/index.ts
index 325dec8ea..045acd977 100644
--- a/ui/component/or-log-viewer/src/index.ts
+++ b/ui/component/or-log-viewer/src/index.ts
@@ -12,7 +12,7 @@ import {
import i18next from "i18next";
import {translate} from "@openremote/or-translate";
import * as Model from "@openremote/model";
-import manager, {DefaultColor2, DefaultColor3} from "@openremote/core";
+import manager, {DefaultColor2, DefaultColor3, Util} from "@openremote/core";
import "@openremote/or-input";
import "@openremote/or-panel";
import "@openremote/or-translate";
@@ -340,7 +340,7 @@ export class OrLogViewer extends translate(i18next)(LitElement) {
const categories = this.config && this.config.allowedCategories ? this.config.allowedCategories : Object.keys((Model as any)["SyslogCategory"]) as Model.SyslogCategory[];
return categories.map((cat) => {
return {
- text: cat,
+ text: i18next.t("logCategory." + cat, {defaultValue: Util.capitaliseFirstLetter(cat.toLowerCase().replace(/_/g, " "))}),
value: cat
} as MenuItem;
});
diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.ts
index 87a4a2d8c..ec5bd979f 100644
--- a/ui/component/or-map/src/index.ts
+++ b/ui/component/or-map/src/index.ts
@@ -80,11 +80,14 @@ export class CenterControl {
control.classList.add("mapboxgl-ctrl");
control.classList.add("mapboxgl-ctrl-group");
const button = document.createElement("button");
- button.className = "mapboxgl-ctrl-icon mapboxgl-ctrl-geolocate";
+ button.className = "mapboxgl-ctrl-geolocate";
button.addEventListener("click", (ev) => map.flyTo({
center: this.pos,
zoom: map.getZoom()
}));
+ const buttonIcon = document.createElement("span");
+ buttonIcon.className = "mapboxgl-ctrl-icon";
+ button.appendChild(buttonIcon);
control.appendChild(button);
this.elem = control;
return control;
diff --git a/ui/component/or-map/src/style.ts b/ui/component/or-map/src/style.ts
index 7ce12a4f4..19d0dd07c 100644
--- a/ui/component/or-map/src/style.ts
+++ b/ui/component/or-map/src/style.ts
@@ -219,7 +219,6 @@ export const mapAssetCardStyle = css`
height: var(--internal-or-map-asset-card-header-height);
border-top: 1px solid var(--internal-or-map-asset-card-separator-color);
text-align: right;
- --or-input-color: var(--internal-or-map-asset-card-background-text-color);
padding: 5px 12px;
}
diff --git a/ui/component/or-rules/src/or-rule-validity.ts b/ui/component/or-rules/src/or-rule-validity.ts
index fc7f08100..5d59f8803 100644
--- a/ui/component/or-rules/src/or-rule-validity.ts
+++ b/ui/component/or-rules/src/or-rule-validity.ts
@@ -1,4 +1,4 @@
-import {css, customElement, html, LitElement, property, PropertyValues} from "lit-element";
+import {css, customElement, html, LitElement, property, PropertyValues, query} from "lit-element";
import {CalendarEvent, RulesetUnion, WellknownRulesetMetaItems} from "@openremote/model";
import {OrRulesRuleChangedEvent} from "./index";
import "@openremote/or-input";
@@ -19,6 +19,9 @@ export class OrRuleValidity extends translate(i18next)(LitElement) {
@property({type: Object})
public ruleset?: RulesetUnion;
+ @query("#radial-modal")
+ protected dialog?: OrMwcDialog;
+
@property({type: Object})
public rrule: RRule = new RRule({
freq: RRule.DAILY,
@@ -178,7 +181,9 @@ export class OrRuleValidity extends translate(i18next)(LitElement) {
}
setValidityType(value: any) {
- if(!this.ruleset || !this.ruleset.meta) return;
+ if(!this.ruleset) return;
+
+ if (!this.ruleset.meta) this.ruleset.meta = {};
switch (value) {
case "validityAlways":
@@ -215,58 +220,61 @@ export class OrRuleValidity extends translate(i18next)(LitElement) {
}
renderDialogHTML() {
- const dialog: OrMwcDialog = this.shadowRoot!.getElementById("radial-modal") as OrMwcDialog;
+
+ if (!this.ruleset) {
+ return;
+ }
+
+ if (!this.dialog) {
+ return;
+ }
+
const options = [RRule.MO.toString(), RRule.TU.toString(), RRule.WE.toString(), RRule.TH.toString(), RRule.FR.toString(), RRule.SA.toString(), RRule.SU.toString()];
const validityTypes = ["validityAlways", "validityPeriod", "validityRecurrence"];
- const validityType = this.getValidityType()
+ const validityType = this.getValidityType();
const selectedOptions = this.rrule.options && this.rrule.options.byweekday ? this.rrule.options.byweekday.map(day => new Weekday(day).toString()) : [];
-
- if (dialog && this.ruleset && this.ruleset.meta) {
- const validity = this.ruleset.meta[WellknownRulesetMetaItems.VALIDITY] as CalendarEvent;
+ const validity = this.ruleset.meta ? this.ruleset.meta[WellknownRulesetMetaItems.VALIDITY] as CalendarEvent : undefined;
- dialog.dialogContent = html`
- <div style="min-height: 200px; min-width: 635px; display:grid; flex-direction: row;">
- <div class="layout horizontal">
- <or-input .value="${validityType}" .type="${InputType.SELECT}" .options="${validityTypes}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValidityType(e.detail.value)}" ></or-input>
- </div>
+ this.dialog.dialogContent = html`
+ <div style="min-height: 200px; min-width: 635px; display:grid; flex-direction: row;">
+ <div class="layout horizontal">
+ <or-input .value="${validityType}" .type="${InputType.SELECT}" .options="${validityTypes}" @or-input-changed="${(e: OrInputChangedEvent) => this.setValidityType(e.detail.value)}" ></or-input>
+ </div>
- ${(validityType === "validityPeriod" || validityType === "validityRecurrence") ? html`
- <label style="display:block; margin-top: 20px;"><or-translate value="period"></or-translate></label>
- <div style="display: flex; justify-content: space-between;" class="layout horizontal">
- <div>
- <or-input value="${moment(validity.start).format("YYYY-MM-DD")}" .type="${InputType.DATE}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "start")}" .label="${i18next.t("from")}"></or-input>
- <or-input .disabled=${this.isAllDay()} .value="${moment(validity.start).format("HH:mm")}" .type="${InputType.TIME}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "dtstart-time")}" .label="${i18next.t("from")}"></or-input>
- </div>
- <div>
- <or-input .value="${moment(validity.end).format("YYYY-MM-DD")}" .type="${InputType.DATE}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "end")}" .label="${i18next.t("to")}"></or-input>
- <or-input .disabled=${this.isAllDay()} .value="${moment(validity.end).format("HH:mm")}" .type="${InputType.TIME}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "until-time")}" .label="${i18next.t("to")}"></or-input>
- </div>
- </div>
-
- <div class="layout horizontal">
- <or-input .value=${this.isAllDay()} @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "all-day")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("allDay")}"></or-input>
+ ${validity && (validityType === "validityPeriod" || validityType === "validityRecurrence") ? html`
+ <label style="display:block; margin-top: 20px;"><or-translate value="period"></or-translate></label>
+ <div style="display: flex; justify-content: space-between;" class="layout horizontal">
+ <div>
+ <or-input value="${moment(validity.start).format("YYYY-MM-DD")}" .type="${InputType.DATE}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "start")}" .label="${i18next.t("from")}"></or-input>
+ <or-input .disabled=${this.isAllDay()} .value="${moment(validity.start).format("HH:mm")}" .type="${InputType.TIME}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "dtstart-time")}" .label="${i18next.t("from")}"></or-input>
</div>
- ` : ``}
-
- ${validityType === "validityRecurrence" ? html`
- <label style="display:block; margin-top: 20px;"><or-translate value="repeatOccurrenceEvery"></or-translate></label>
- <div class="layout horizontal">
- <or-input .value="${selectedOptions}" .type="${InputType.CHECKBOX_LIST}" .options="${options}" .label="${i18next.t("daysOfTheWeek")}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "byweekday")}" ></or-input>
+ <div>
+ <or-input .value="${moment(validity.end).format("YYYY-MM-DD")}" .type="${InputType.DATE}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "end")}" .label="${i18next.t("to")}"></or-input>
+ <or-input .disabled=${this.isAllDay()} .value="${moment(validity.end).format("HH:mm")}" .type="${InputType.TIME}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "until-time")}" .label="${i18next.t("to")}"></or-input>
</div>
-
- <label style="display:block; margin-top: 20px;"><or-translate value="repetitionEnds"></or-translate></label>
- <div class="layout horizontal">
- <or-input .value="${!this.rrule.options.until}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "never-ends")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("never")}"></or-input>
- </div>
- <div class="layout horizontal">
- <or-input ?disabled="${!this.rrule.options.until}" .value="${this.rrule.options.until ? moment(this.rrule.options.until).format("YYYY-MM-DD") : moment().add(1, 'year').format('YYYY-MM-DD')}" .type="${InputType.DATE}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "until")}" .label="${i18next.t("to")}"></or-input>
- </div>
- ` : ``}
-
+ </div>
+ <div class="layout horizontal">
+ <or-input .value=${this.isAllDay()} @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "all-day")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("allDay")}"></or-input>
+ </div>
+ ` : ``}
+
+ ${validityType === "validityRecurrence" ? html`
+ <label style="display:block; margin-top: 20px;"><or-translate value="repeatOccurrenceEvery"></or-translate></label>
+ <div class="layout horizontal">
+ <or-input .value="${selectedOptions}" .type="${InputType.CHECKBOX_LIST}" .options="${options}" .label="${i18next.t("daysOfTheWeek")}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "byweekday")}" ></or-input>
+ </div>
- </div>`;
- }
+ <label style="display:block; margin-top: 20px;"><or-translate value="repetitionEnds"></or-translate></label>
+ <div class="layout horizontal">
+ <or-input .value="${!this.rrule.options.until}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "never-ends")}" .type="${InputType.CHECKBOX}" .label="${i18next.t("never")}"></or-input>
+ </div>
+ <div class="layout horizontal">
+ <or-input ?disabled="${!this.rrule.options.until}" .value="${this.rrule.options.until ? moment(this.rrule.options.until).format("YYYY-MM-DD") : moment().add(1, 'year').format('YYYY-MM-DD')}" .type="${InputType.DATE}" @or-input-changed="${(e: OrInputChangedEvent) => this.setRRuleValue(e.detail.value, "until")}" .label="${i18next.t("to")}"></or-input>
+ </div>
+ ` : ``}
+
+ </div>`;
}
protected render() {