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
Merge or-attribute-card to master
Robin Dekkersdc56c94863aa
diff --cc deployment/manager/shared/locales/en/or.jsonindex 3621c9e1d,dbaac26ec..62a24d001--- a/deployment/manager/shared/locales/en/or.json+++ b/deployment/manager/shared/locales/en/or.json@@@ -205,20 -191,5 +205,21 @@@"CO2": "%.1f","HUMIDITY": "%.1f"},+ "gatewayConnection": "Manager interconnect",+ "secured": "Secured",+ "clientSecret": "Client secret",+ "clientId": "Client ID",+ "realm": "Realm",+ "port": "Port",+ "host": "Hostname",+ "errorOccurred": "An error has occurred",+ "managerError": {+ "MANAGER_FAILED_TO_LOAD": "Manager failed to load (see console logs)",+ "KEYCLOAK_FAILED_TO_LOAD": "Keycloak failed to load (see console logs)",+ "AUTH_TYPE_UNSUPPORTED": "Requested auth type not supported",+ "CONSOLE_ERROR": "Console error (see console logs)",+ "EVENTS_CONNECTION_ERROR": "Event bus connection error (see console logs)",+ "TRANSLATION_ERROR": "Translations error (see console logs)"- }++ },+ "couldNotRetrieveAttribute": "Could not retrieve attribute information"}diff --cc deployment/manager/shared/locales/nl/or.jsonindex f40a6a69b,cc52fb47d..56eb8f94b--- a/deployment/manager/shared/locales/nl/or.json+++ b/deployment/manager/shared/locales/nl/or.json@@@ -205,11 -189,5 +205,12 @@@"CO2": "%.1f","HUMIDITY": "%.1f"},+ "gatewayConnection": "Manager interconnect",+ "secured": "Beveiligd",+ "clientSecret": "Client secret",+ "clientId": "Client ID",+ "realm": "Realm",+ "port": "Poort",- "host": "Hostname"++ "host": "Hostname",+ "couldNotRetrieveAttribute": "Kan de gegevens voor dit attribuut niet ophalen"}diff --cc ui/app/or-app/src/pages/page-insights.tsindex 036a36ae3,000000000..9b25bd29emode 100644,000000..100644--- a/ui/app/or-app/src/pages/page-insights.ts+++ b/ui/app/or-app/src/pages/page-insights.ts@@@ -1,108 -1,0 +1,96 @@@+import {css, customElement, html, property, TemplateResult, unsafeCSS} from "lit-element";+import "@openremote/or-data-viewer";+import {DataViewerConfig} from "@openremote/or-data-viewer";+import {DefaultBoxShadow} from "@openremote/core";+import {AppStateKeyed, Page} from "../index";+import {EnhancedStore} from "@reduxjs/toolkit";++export function pageInsightsProvider<S extends AppStateKeyed>(store: EnhancedStore<S>, config?:DataViewerConfig) {+ return {+ routes: [+ "insights",+ "insights/:id"+ ],+ pageCreator: () => {+ const page = new PageInsights(store);+ if(config) page.config = config;+ return page;+ }+ };+}++const viewerConfig: DataViewerConfig = {+ panels: {+ "chart": {+ type: "chart",+ hideOnMobile: true,+ panelStyles: {+ gridColumn: "1 / -1",+ gridRowStart: "1"+ },+ defaults: [{+ assetId:"5442Ite2XVp3Ky9X2y647a",+ attributes: ["UVIndex"]+ }]- },- "chart2": {- type: "chart",- hideOnMobile: true,- panelStyles: {- gridColumn: "1 / -1",- gridRowStart: "1"- },- defaults: [{- assetId:"5442Ite2XVp3Ky9X2y647a",- attributes: ["UVIndex"]- }]+ }+ }+};++@customElement("page-insights")+class PageInsights<S extends AppStateKeyed> extends Page<S> {++ static get styles() {+ // language=CSS+ return 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;+ }+ }+ `;+ }++ @property()+ public config?: DataViewerConfig;++ @property()+ protected _assetId;++ constructor(store: EnhancedStore<S>) {+ super(store);+ }++ protected render(): TemplateResult | void {+ return html`+ <or-data-viewer .config="${this.config ? this.config : viewerConfig}"></or-data-viewer>+ `;+ }++ public stateChanged(state: S) {+ }+}diff --cc ui/component/core/src/util.tsindex 3decc3da4,bc602b348..c0fb84142--- a/ui/component/core/src/util.ts+++ b/ui/component/core/src/util.ts@@@ -212,9 -203,18 +212,9 @@@ export function getEnumKeyAsString(enmreturn key!;}-export function getQueryParameter(name: string): string {- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");- const regex = new RegExp("[\\?&]" + name + "=([^&#]*)");- const results = regex.exec(location.search);- return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));-}-export function getAssetAttribute(asset: Asset, attributeName: string): AssetAttribute | undefined {-- if (asset.attributes && asset.attributes.hasOwnProperty(attributeName)) {- const attr = asset.attributes[attributeName] as AssetAttribute;- attr.name = attributeName;- attr.assetId = asset.id;++ if (asset && asset.attributes && asset.attributes.hasOwnProperty(attributeName)) {+ const attr = {...asset.attributes[attributeName], name: attributeName, assetId: asset.id} as AssetAttribute;return attr;}}diff --cc ui/component/or-data-viewer/package.jsonindex bd4164092,bd4164092..488a0b8a4--- a/ui/component/or-data-viewer/package.json+++ b/ui/component/or-data-viewer/package.json@@@ -16,6 -16,6 +16,7 @@@"@openremote/model": "^1.1.0","@openremote/or-icon": "^1.1.0","@openremote/or-input": "^1.1.0",++ "@openremote/or-attribute-card": "^1.1.0","@openremote/or-attribute-input": "^1.1.0","@openremote/or-attribute-history": "^1.1.0","@openremote/or-translate": "^1.1.0",diff --cc ui/component/or-data-viewer/src/index.tsindex 5499b4b87,96447fbf7..cfd2544c5--- a/ui/component/or-data-viewer/src/index.ts+++ b/ui/component/or-data-viewer/src/index.ts@@@ -20,8 -20,8 +20,9 @@@ import {style} from "./style"import i18next from "i18next";import {styleMap} from "lit-html/directives/style-map";import {classMap} from "lit-html/directives/class-map";++import "@openremote/or-attribute-card";-export type PanelType = "chart";+export type PanelType = "chart" | "kpi";export interface DefaultAssets {assetId?: string;@@@ -205,13 -205,10 +206,13 @@@ export class OrDataViewer extends subsccontent = html`<or-chart id="chart" .config="${this.config.chartConfig}"></or-chart>`;-}+ if (panelConfig && panelConfig.type === "kpi") {+ content = html`- <or-chart id="chart" .config="${this.config.chartConfig}"></or-chart>++ <or-attribute-card .config="${this.config.chartConfig}"></or-attribute-card>+ `;+ }return content;-}}diff --cc ui/component/or-data-viewer/src/style.tsindex 83c050cd2,83c050cd2..ab2df8956--- a/ui/component/or-data-viewer/src/style.ts+++ b/ui/component/or-data-viewer/src/style.ts@@@ -36,7 -36,7 +36,7 @@@ export const style = cssdisplay: grid;padding: 20px 20px;grid-gap: 10px;-- grid-template-columns: repeat(auto-fill, minmax(calc(50% - 5px),1fr));++ grid-template-columns: repeat(auto-fill, minmax(calc(25% - 8px), 1fr));grid-auto-rows: 5px;-webkit-animation: fadein 0.3s; /* Safari, Chrome and Opera > 12.1 */diff --cc ui/component/or-data-viewer/tsconfig.jsonindex 2e82f9066,2e82f9066..71b5d1067--- a/ui/component/or-data-viewer/tsconfig.json+++ b/ui/component/or-data-viewer/tsconfig.json@@@ -14,6 -14,6 +14,7 @@@{ "path": "../model" },{ "path": "../or-chart" },{ "path": "../or-panel" },-- { "path": "../or-translate" }++ { "path": "../or-translate" },++ { "path": "../or-attribute-card" }]}