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: - properly type tablerows in data export page and get rid of mirror vars (tablerows and attr refs) - no longer change timerange values based on selected attributes - colour management/defaults correctly set

Vincent2f9da0035f7c
diff --git a/ui/app/manager/src/pages/page-export.ts b/ui/app/manager/src/pages/page-export.ts
index 41ae691b0..682398bdd 100644
--- a/ui/app/manager/src/pages/page-export.ts
+++ b/ui/app/manager/src/pages/page-export.ts
@@ -28,6 +28,14 @@ export interface OrExportConfig {
selectedAttributes: AttributeRef[];
}
+interface tableRow {
+ assetName: string,
+ assetId: string,
+ attributeName: string,
+ oldestTimestamp: number,
+ latestTimestamp: number
+}
+
@customElement("page-export")
class PageExport<S extends AppStateKeyed> extends Page<S> {
@@ -189,9 +197,8 @@ class PageExport<S extends AppStateKeyed> extends Page<S> {
};
private isClearExportBtnDisabled: boolean = true;
private isExportBtnDisabled: boolean = true;
- private attrRefs: any[];
- private tableRows: any[] = []; //todo type this so it can be put in table
+ private tableRows: tableRow[] = [];
get name(): string {
return "export";
@@ -274,28 +281,18 @@ class PageExport<S extends AppStateKeyed> extends Page<S> {
const allAssets = assetInfos.map(attr => attr.data),
allDatapoints = datapointPeriod.map(datapoints => datapoints.data);
- this.tableRows = allDatapoints.map(dataInfo => {
- const relevantAssetInfo = allAssets.find(asset => asset.id === dataInfo.assetId);
- return {
- assetName: relevantAssetInfo.name,
- assetId: relevantAssetInfo.id,
- attributeName: dataInfo.attributeName,
- oldestTimestamp: dataInfo.oldestTimestamp,
- latestTimestamp: dataInfo.latestTimestamp
- };
- });
- this.renderTableRows();
-
if (allDatapoints.length > 0) {
- this.attrRefs = allDatapoints.map(dataInfo => {
+ this.tableRows = allDatapoints.map(dataInfo => {
const relevantAssetInfo = allAssets.find(asset => asset.id === dataInfo.assetId);
return {
- id: relevantAssetInfo.id,
- name: dataInfo.attributeName
- }
+ assetName: relevantAssetInfo.name,
+ assetId: relevantAssetInfo.id,
+ attributeName: dataInfo.attributeName,
+ oldestTimestamp: dataInfo.oldestTimestamp,
+ latestTimestamp: dataInfo.latestTimestamp
+ };
});
- this.oldestTimestamp = allDatapoints[0].oldestTimestamp;
- this.latestTimestamp = allDatapoints[0].oldestTimestamp;
+ this.renderTableRows();
this.isClearExportBtnDisabled = false;
this.isExportBtnDisabled = false;
} else {
@@ -358,7 +355,7 @@ class PageExport<S extends AppStateKeyed> extends Page<S> {
protected export = () => {
manager.rest.api.AssetDatapointResource.getDatapointExport({
- attributeRefs: JSON.stringify(this.attrRefs),
+ attributeRefs: JSON.stringify(this.tableRows.map(attr => ({id: attr.assetId, name: attr.attributeName}))),
fromTimestamp: this.oldestTimestamp,
toTimestamp: this.latestTimestamp
}, {
@@ -400,7 +397,6 @@ class PageExport<S extends AppStateKeyed> extends Page<S> {
this.saveConfig();
this.tableRows = [];
this.renderTableRows();
- this.attrRefs = [];
this.isClearExportBtnDisabled = true;
this.isExportBtnDisabled = true;
}
diff --git a/ui/component/core/src/defaults.ts b/ui/component/core/src/defaults.ts
index 6158d8635..ad835cebd 100644
--- a/ui/component/core/src/defaults.ts
+++ b/ui/component/core/src/defaults.ts
@@ -1,4 +1,4 @@
-export const DefaultColor4: string = "#1b5630"; // Primary
+export const DefaultColor4: string = "#4d9d2a"; // Primary
export const DefaultColor7: string = "#FFF"; // Secondary
export const DefaultColor1: string = "#FFF"; // Surface
export const DefaultColor2: string = "#F9F9F9"; // Background
diff --git a/ui/component/or-app/src/index.ts b/ui/component/or-app/src/index.ts
index a9b113c63..414e3bec7 100644
--- a/ui/component/or-app/src/index.ts
+++ b/ui/component/or-app/src/index.ts
@@ -18,7 +18,7 @@ import "./or-header";
import "@openremote/or-icon";
import {updateMetadata} from "pwa-helpers/metadata";
import i18next from "i18next";
-import manager, {Auth, DefaultColor2, DefaultColor3, ManagerConfig, Util, BasicLoginResult, OREvent, normaliseConfig, Manager} from "@openremote/core";
+import manager, {Auth, DefaultColor2, DefaultColor3, DefaultColor4, ManagerConfig, Util, BasicLoginResult, OREvent, normaliseConfig, Manager} from "@openremote/core";
import {DEFAULT_LANGUAGES, HeaderConfig, HeaderItem, Languages} from "./or-header";
import {DialogConfig, OrMwcDialog, showErrorDialog, showDialog} from "@openremote/or-mwc-components/or-mwc-dialog";
import {OrMwcSnackbar} from "@openremote/or-mwc-components/or-mwc-snackbar";
@@ -100,8 +100,8 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {
return css`
:host {
--or-app-color2: ${unsafeCSS(DefaultColor2)};
- --or-app-color3: #4C4C4C;
- --or-app-color4: #4D9D2A;
+ --or-app-color3: ${unsafeCSS(DefaultColor3)};
+ --or-app-color4: ${unsafeCSS(DefaultColor4)};
--or-console-primary-color: #4D9D2A;
color: ${unsafeCSS(DefaultColor3)};
fill: ${unsafeCSS(DefaultColor3)};
diff --git a/ui/component/or-mwc-components/src/or-mwc-dialog.ts b/ui/component/or-mwc-components/src/or-mwc-dialog.ts
index 4f7fabbea..2b59f0956 100644
--- a/ui/component/or-mwc-components/src/or-mwc-dialog.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-dialog.ts
@@ -4,7 +4,7 @@ import "@openremote/or-translate";
import "./or-mwc-input";
import {InputType} from "./or-mwc-input";
import { i18next } from "@openremote/or-translate";
-import {DefaultColor2, DefaultColor5, Util } from "@openremote/core";
+import {DefaultColor2, DefaultColor4, DefaultColor5, Util } from "@openremote/core";
import { Asset, AssetEvent, Attribute, AttributeRef } from "@openremote/model";
import manager from "@openremote/core";
import {ListItem, ListType, OrMwcListChangedEvent} from "./or-mwc-list";
@@ -384,6 +384,9 @@ export class OrMwcAttributeSelector extends OrMwcDialog {
footer.mdc-dialog__actions {
border-top: 1px solid ${unsafeCSS(DefaultColor5)};
}
+ #header {
+ background-color: ${unsafeCSS(DefaultColor4)} !important;
+ }
`;
this.reRenderDialog();