100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Add realm based settings in map, update languages
Robin Dekkers77b0489debbb
diff --git a/deployment/manager/shared/locales/de/or.json b/deployment/manager/shared/locales/de/or.jsonindex d572b28fc..7616fee72 100644--- a/deployment/manager/shared/locales/de/or.json+++ b/deployment/manager/shared/locales/de/or.json@@ -114,6 +114,13 @@"attributeValueType": {"PERCENTAGE": "%.2f","NUMBER": "%.0f",- "TEMPERATURE": "%.1f"+ "TEMPERATURE": "%.1f",+ "POWER": "%.1f",+ "CURRENCY": "%.1f",+ "SPEED": "%.1f",+ "CHARGE": "%.1f",+ "ENERGY": "%.1f",+ "CO2": "%.1f",+ "HUMIDITY": "%.1f"}}diff --git a/deployment/manager/shared/locales/en/or.json b/deployment/manager/shared/locales/en/or.jsonindex 19595b0a2..0904c06a1 100644--- a/deployment/manager/shared/locales/en/or.json+++ b/deployment/manager/shared/locales/en/or.json@@ -180,6 +180,13 @@"attributeValueType": {"PERCENTAGE": "%.2f","NUMBER": "%.0f",- "TEMPERATURE": "%.1f"+ "TEMPERATURE": "%.1f",+ "POWER": "%.1f",+ "CURRENCY": "%.1f",+ "SPEED": "%.1f",+ "CHARGE": "%.1f",+ "ENERGY": "%.1f",+ "CO2": "%.1f",+ "HUMIDITY": "%.1f"}}diff --git a/deployment/manager/shared/locales/es/or.json b/deployment/manager/shared/locales/es/or.jsonindex 4ea8f23df..c2c4a96df 100644--- a/deployment/manager/shared/locales/es/or.json+++ b/deployment/manager/shared/locales/es/or.json@@ -112,6 +112,13 @@"attributeValueType": {"PERCENTAGE": "%.2f","NUMBER": "%.0f",- "TEMPERATURE": "%.1f"+ "TEMPERATURE": "%.1f",+ "POWER": "%.1f",+ "CURRENCY": "%.1f",+ "SPEED": "%.1f",+ "CHARGE": "%.1f",+ "ENERGY": "%.1f",+ "CO2": "%.1f",+ "HUMIDITY": "%.1f"}}diff --git a/deployment/manager/shared/locales/fr/or.json b/deployment/manager/shared/locales/fr/or.jsonindex e9cd51527..64e4f8386 100644--- a/deployment/manager/shared/locales/fr/or.json+++ b/deployment/manager/shared/locales/fr/or.json@@ -113,6 +113,13 @@"attributeValueType": {"PERCENTAGE": "%.2f","NUMBER": "%.0f",- "TEMPERATURE": "%.1f"+ "TEMPERATURE": "%.1f",+ "POWER": "%.1f",+ "CURRENCY": "%.1f",+ "SPEED": "%.1f",+ "CHARGE": "%.1f",+ "ENERGY": "%.1f",+ "CO2": "%.1f",+ "HUMIDITY": "%.1f"}}diff --git a/deployment/manager/shared/locales/nl/or.json b/deployment/manager/shared/locales/nl/or.jsonindex 20b6d1d9c..37133022a 100644--- a/deployment/manager/shared/locales/nl/or.json+++ b/deployment/manager/shared/locales/nl/or.json@@ -178,6 +178,13 @@"attributeValueType": {"PERCENTAGE": "%.2f","NUMBER": "%.0f",- "TEMPERATURE": "%.1f"+ "TEMPERATURE": "%.1f",+ "POWER": "%.1f",+ "CURRENCY": "%.1f",+ "SPEED": "%.1f",+ "CHARGE": "%.1f",+ "ENERGY": "%.1f",+ "CO2": "%.1f",+ "HUMIDITY": "%.1f"}}diff --git a/ui/app/main/src/components/my-app.ts b/ui/app/main/src/components/my-app.tsindex 168f4e95c..6fa0d689c 100644--- a/ui/app/main/src/components/my-app.ts+++ b/ui/app/main/src/components/my-app.ts@@ -8,6 +8,7 @@ import {RootState, store} from "../store";import "../components/pages/page-map";import "../components/pages/page-assets";import "../components/pages/page-rules";+import "../components/pages/page-insights";import i18next from "i18next";import {connect} from "pwa-helpers/connect-mixin";@@ -85,6 +86,7 @@ class MyApp extends connect(store)(LitElement) {${this.page === "map" ? html`<page-map class="page"></page-map>` : ``}${this.page === "assets" ? html`<page-assets class="page"></page-assets>` : ``}${this.page === "rules" ? html`<page-rules class="page"></page-rules>` : ``}+ ${this.page === "insights" ? html`<page-insights class="page"></page-insights>` : ``}</main>`;}@@ -109,4 +111,4 @@ class MyApp extends connect(store)(LitElement) {});}}-}+}\ No newline at end of filediff --git a/ui/app/main/src/components/pages/page-insights.ts b/ui/app/main/src/components/pages/page-insights.tsnew file mode 100644index 000000000..8953312a0--- /dev/null+++ b/ui/app/main/src/components/pages/page-insights.ts@@ -0,0 +1,79 @@+import {customElement, html, LitElement, property, TemplateResult, css, unsafeCSS} from "lit-element";+import {store} from "../../store";+import {connect} from "pwa-helpers/connect-mixin";+import "@openremote/or-data-viewer";+import {DataViewerConfig} from "@openremote/or-data-viewer";+import {DefaultBoxShadow} from "@openremote/core";++// language=CSS+const style = css`++ or-asset-tree {+ align-items: stretch;+ z-index: 1;+ }++ .hideMobile {+ display: none;+ }++ or-asset-viewer {+ align-items: stretch;+ z-index: 0;+ }++ @media only screen and (min-width: 768px){+ or-asset-tree {+ width: 300px;+ min-width: 300px;+ box-shadow: ${unsafeCSS(DefaultBoxShadow)}+ }++ .hideMobile {+ display: flex;+ }++ or-asset-viewer,+ or-asset-viewer.hideMobile {+ display: initial;+ }++++ }+`;++const viewerConfig: DataViewerConfig = {+ panels: {+ "chart": {+ type: "chart",+ hideOnMobile: true,+ panelStyles: {+ gridColumn: "1 / -1",+ gridRowStart: "1"+ },+ defaults: [{+ assetId:"5442Ite2XVp3Ky9X2y647a",+ attributes: ["UVIndex"]+ }]+ }+ }+};++@customElement("page-insights")+class PageInsights extends connect(store)(LitElement) {++ static get styles() {+ return style;+ }++ @property()+ protected _assetId;++ protected render(): TemplateResult | void {+ return html`+ <or-data-viewer .config="${viewerConfig}"></or-data-viewer>+ `;+ }++}diff --git a/ui/app/main/src/index.ts b/ui/app/main/src/index.tsindex 887327c25..09e9e6b32 100644--- a/ui/app/main/src/index.ts+++ b/ui/app/main/src/index.ts@@ -27,6 +27,14 @@ router.on({store.dispatch(setActiveAsset(params.id));store.dispatch(updatePage("assets", params.id));},+ "insights": (params, query) => {+ store.dispatch(setActiveAsset(null));+ store.dispatch(updatePage("insights"));+ },+ "insights/:id": (params, query) => {+ store.dispatch(setActiveAsset(params.id));+ store.dispatch(updatePage("insights", params.id));+ },"rules": (params, query) => {store.dispatch(updatePage("rules"));},diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex 4232f76b6..abb88bffa 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -447,7 +447,7 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem}</style><div id="history-controls">- <or-input id="history-attribute-picker" value="${historyAttrs[0].name}" .label="${i18next.t("attribute")}" @or-input-changed="${(evt: OrInputChangedEvent) => attributeChanged(evt.detail.value)}" .type="${InputType.SELECT}" .options="${options}"></or-input>+ <or-input id="history-attribute-picker" .checkAssetWrite="${false}" value="${historyAttrs[0].name}" .label="${i18next.t("attribute")}" @or-input-changed="${(evt: OrInputChangedEvent) => attributeChanged(evt.detail.value)}" .type="${InputType.SELECT}" .options="${options}"></or-input></div><or-attribute-history id="attribute-history" .config="${viewerConfig.historyConfig}" .assetType="${asset.type}"></or-attribute-history>diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.tsindex 31d44e65a..8f2a8064d 100644--- a/ui/component/or-attribute-history/src/index.ts+++ b/ui/component/or-attribute-history/src/index.ts@@ -311,9 +311,9 @@ export class OrAttributeHistory extends translate(i18next)(LitElement) {return html`<div id="container"><div id="controls">- <or-input .type="${InputType.SELECT}" ?disabled="${disabled}" .label="${i18next.t("timeframe")}" @or-input-changed="${(evt: OrInputChangedEvent) => this.period = evt.detail.value}" .value="${this.period}" .options="${this._getPeriodOptions().map(item => item.value)}"></or-input>+ <or-input .checkAssetWrite="${false}" .type="${InputType.SELECT}" ?disabled="${disabled}" .label="${i18next.t("timeframe")}" @or-input-changed="${(evt: OrInputChangedEvent) => this.period = evt.detail.value}" .value="${this.period}" .options="${this._getPeriodOptions().map(item => item.value)}"></or-input><div id="ending-controls">- <or-input id="ending-date" .type="${InputType.DATETIME}" ?disabled="${disabled}" label="${i18next.t("ending")}" .value="${this.fromTimestamp}" @or-input-changed="${(evt: OrInputChangedEvent) => this._updateTimestamp(moment(evt.detail.value as string).toDate())}"></or-input>+ <or-input id="ending-date" .checkAssetWrite="${false}" .type="${InputType.DATETIME}" ?disabled="${disabled}" label="${i18next.t("ending")}" .value="${this.fromTimestamp}" @or-input-changed="${(evt: OrInputChangedEvent) => this._updateTimestamp(moment(evt.detail.value as string).toDate())}"></or-input><or-icon class="button button-icon" ?disabled="${disabled}" icon="chevron-left" @click="${() => this.fromTimestamp = this._updateTimestamp(this.fromTimestamp!, false)}"></or-icon><or-icon class="button button-icon" ?disabled="${disabled}" icon="chevron-right" @click="${() => this.fromTimestamp = this._updateTimestamp(this.fromTimestamp!, true)}"></or-icon><or-icon class="button button-icon" ?disabled="${disabled}" icon="chevron-double-right" @click="${() => this.fromTimestamp = this._updateTimestamp(new Date())}"></or-icon>diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex 348871003..7c4698354 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -462,6 +462,7 @@ export class OrChart extends translate(i18next)(LitElement) {<span class="line-label solid"></span>`: ``}<or-input id="ending-date"+ .checkAssetWrite="${false}".type="${endDateInputType}"?disabled="${disabled}".value="${this.timestamp}"@@ -473,6 +474,7 @@ export class OrChart extends translate(i18next)(LitElement) {<div class="period-controls"><span class="line-label dashed"></span><or-input id="ending-date"+ .checkAssetWrite="${false}".type="${endDateInputType}"?disabled="${disabled}".value="${this.compareTimestamp}"diff --git a/ui/component/or-input/src/index.ts b/ui/component/or-input/src/index.tsindex 9059733da..ddcdcb2e8 100644--- a/ui/component/or-input/src/index.ts+++ b/ui/component/or-input/src/index.ts@@ -279,6 +279,10 @@ export class OrInput extends LitElement {@property({type: Boolean})public autoSelect?: boolean;++ @property({type: Boolean})+ public checkAssetWrite: boolean = true;+/* STYLING PROPERTIES BELOW */@property({type: String})@@ -351,7 +355,7 @@ export class OrInput extends LitElement {}protected render() {- const readonly = this.readonly || !manager.hasRole(ClientRole.WRITE_ASSETS)+ const readonly = this.readonly || this.checkAssetWrite ? !manager.hasRole(ClientRole.WRITE_ASSETS) : false;if (this.type) {diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.tsindex 442f77ff2..16d92b704 100644--- a/ui/component/or-map/src/index.ts+++ b/ui/component/or-map/src/index.ts@@ -134,6 +134,7 @@ export class OrMap extends LitElement {}}+protected onManagerEvent = (event: OREvent) => {switch (event) {case OREvent.READY:@@ -142,6 +143,13 @@ export class OrMap extends LitElement {}break;case OREvent.DISPLAY_REALM_CHANGED:+ if(this._map){+ this._map.loadViewSettings().then(()=> {+ if(!this._map) return+ this._map.setCenter()+ this._map.flyTo();+ });+ }break;}}@@ -157,6 +165,11 @@ export class OrMap extends LitElement {manager.removeListener(this.onManagerEvent);}+ public reloadMap() {+ this._loaded = false;+ this.loadMap();+ }+public loadMap() {if (this._loaded) {diff --git a/ui/component/or-map/src/mapwidget.ts b/ui/component/or-map/src/mapwidget.tsindex 59a38a86f..ec301aa18 100644--- a/ui/component/or-map/src/mapwidget.ts+++ b/ui/component/or-map/src/mapwidget.ts@@ -112,6 +112,17 @@ export class MapWidget {return this;}+ public async loadViewSettings() {+ const settingsResponse = await manager.rest.api.MapResource.getSettingsJs();+ const settings = settingsResponse.data as any;++ // Load options for current realm or fallback to default if exist+ const realmName = manager.displayRealm || "default";+ this._viewSettings = settings.options ? settings.options[realmName] ? settings.options[realmName] : settings.options.default : null;+ return settings++ }+public async load(): Promise<void> {if (this._loaded) {return;@@ -124,11 +135,8 @@ export class MapWidget {style.id = "mapboxJsStyle";style.textContent = mapboxJsStyles;this._styleParent.appendChild(style);- const settingsResponse = await manager.rest.api.MapResource.getSettingsJs();- const settings = settingsResponse.data as any;+ const settings = await this.loadViewSettings();- // Load options for current realm or fallback to default if exist- this._viewSettings = settings.options ? settings.options[manager.getRealm() || "default"] ? settings.options[manager.getRealm() || "default"] : settings.options.default : null;let options: OptionsJS | undefined;if (this._viewSettings) {options = {};diff --git a/ui/component/or-rules/src/json-viewer/or-rule-condition.ts b/ui/component/or-rules/src/json-viewer/or-rule-condition.tsindex c8412f793..fbe547247 100644--- a/ui/component/or-rules/src/json-viewer/or-rule-condition.ts+++ b/ui/component/or-rules/src/json-viewer/or-rule-condition.ts@@ -158,8 +158,12 @@ class OrRuleCondition extends translate(i18next)(LitElement) {break;}}-- typeTemplate = html`+ if(this.readonly) {+ typeTemplate = html`+ <or-input readonly type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>+ `;+ } else {+ typeTemplate = html`<div id="type" style="color: #${buttonColor}">${getContentWithMenuTemplate(html`<or-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>`,@@ -168,6 +172,8 @@ class OrRuleCondition extends translate(i18next)(LitElement) {(values: string[] | string) => this.type = values as ConditionType)}</div>`;+ }+}if (type) {diff --git a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.tsindex 3b991efdb..358453aec 100644--- a/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts+++ b/ui/component/or-rules/src/json-viewer/or-rule-then-otherwise.ts@@ -233,7 +233,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {`;}- protected ruleActionTemplate(actions: RuleActionUnion[], action: RuleActionUnion) {+ protected ruleActionTemplate(actions: RuleActionUnion[], action: RuleActionUnion, readonly?: boolean) {const showTypeSelect = !this.config || !this.config.controls || this.config.controls.hideActionTypeOptions !== true;const type = this.getActionType(action);@@ -269,15 +269,21 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {}}- typeTemplate = html`- <div id="type" style="color: #${buttonColor}">- ${getContentWithMenuTemplate(- html`<or-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>`,- getActionTypesMenu(this.config, this.assetDescriptors),- action.action,- (values: string[] | string) => this.setActionType(actions, action, values as string))}- </div>- `;+ if(readonly) {+ typeTemplate = html`+ <or-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>+ `;+ } else {+ typeTemplate = html`+ <div id="type" style="color: #${buttonColor}">+ ${getContentWithMenuTemplate(+ html`<or-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-input>`,+ getActionTypesMenu(this.config, this.assetDescriptors),+ action.action,+ (values: string[] | string) => this.setActionType(actions, action, values as string))}+ </div>+ `;+ }}if (type) {@@ -314,7 +320,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {<or-panel .heading="${i18next.t("then")}...">${this.ruleRecurrenceTemplate(this.rule.recurrence)}- ${!this.rule.then ? `` : this.rule.then.map((action: RuleActionUnion) => this.ruleActionTemplate(this.rule.then!, action))}+ ${!this.rule.then ? `` : this.rule.then.map((action: RuleActionUnion) => this.ruleActionTemplate(this.rule.then!, action, this.readonly))}${thenAllowAdd ? html`<span class="add-button-wrapper">${getContentWithMenuTemplate(