Skip to content

armgit / core

Public Imported from GitHub
0

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

Fix data-viewer grid, rules recipients, or-chart

Robin Dekkers0eb335ea0927
diff --git a/ui/component/or-chart/package.json b/ui/component/or-chart/package.json
index 7554d9cd0..24b7dad76 100644
--- a/ui/component/or-chart/package.json
+++ b/ui/component/or-chart/package.json
@@ -20,7 +20,7 @@
"@openremote/or-panel": "^1.1.0",
"@openremote/or-translate": "^1.1.0",
"@openremote/or-mwc-components": "^1.1.0",
- "chart.js": "^2.8.0",
+ "chart.js": "2.9.3",
"chartjs-plugin-annotation": "0.5.7",
"jsonpath-plus": "^1.1.0",
"lit-element": "^2.2.1",
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index 8c7e7b56b..b9c7860b4 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -659,8 +659,12 @@ export class OrChart extends translate(i18next)(LitElement) {
display: false
},
tooltips: {
- mode: 'index',
- intersect: true
+ mode: 'x',
+ intersect: false
+ },
+ hover: {
+ mode: 'x',
+ intersect: false
},
scales: {
yAxes: [{
@@ -727,7 +731,6 @@ export class OrChart extends translate(i18next)(LitElement) {
if(assets.length > 0) {
this.assets = view.assetIds.map((assetId: string) => assets.find(x => x.id === assetId));
this.assetAttributes = view.attributes.map((attr: string, index: number) => Util.getAssetAttribute(this.assets[index], attr));
- console.log(this.assets, this.assetAttributes);
this.period = view.period;
this._loading = false;
}
@@ -952,10 +955,10 @@ export class OrChart extends translate(i18next)(LitElement) {
});
data = data.concat(cPredictedData);
-
data = data.concat(cData);
}
+
Promise.all(data).then((completed=> {
this._data = completed;
}))
@@ -1080,7 +1083,7 @@ export class OrChart extends translate(i18next)(LitElement) {
if (typeof datapoint['y'] !== 'undefined') {
datapoint['y'] = Math.round(datapoint['y'] * 100) / 100
} else {
- delete datapoint['y']
+ delete datapoint['y'];
}
});
return data;
diff --git a/ui/component/or-data-viewer/src/index.ts b/ui/component/or-data-viewer/src/index.ts
index 207a21740..38d13f365 100644
--- a/ui/component/or-data-viewer/src/index.ts
+++ b/ui/component/or-data-viewer/src/index.ts
@@ -182,7 +182,19 @@ export class OrDataViewer extends subscribe(manager)(translate(i18next)(LitEleme
return html`
- ${content}
+ <div class=${classMap({"panel": true, mobileHidden: panelConfig.hideOnMobile === true})} id="${name}-panel" style="${panelConfig && panelConfig.panelStyles ? styleMap(panelConfig.panelStyles) : ""}">
+ <div class="panel-content-wrapper">
+ ${(panelConfig && panelConfig.type === "chart") ? html`
+ <div class="panel-title">
+ <or-translate value="${name}"></or-translate>
+ </div>
+ ` : ``}
+
+ <div class="panel-content">
+ ${content}
+ </div>
+ </div>
+ </div>
`;
}
@@ -194,18 +206,7 @@ export class OrDataViewer extends subscribe(manager)(translate(i18next)(LitEleme
let content: TemplateResult | undefined;
if (panelConfig && panelConfig.type === "chart") {
- content = html`
- <div class=${classMap({"panel": true, mobileHidden: panelConfig.hideOnMobile === true})} id="${name}-panel" style="${panelConfig && panelConfig.panelStyles ? styleMap(panelConfig.panelStyles) : ""}">
- <div class="panel-content-wrapper">
- <div class="panel-title">
- <or-translate value="${name}"></or-translate>
- </div>
- <div class="panel-content">
- <or-chart id="chart" panelName="${panelName}" .config="${this.config.chartConfig}"></or-chart>
- </div>
- </div>
- </div>
- `;
+ content = html`<or-chart id="chart" panelName="${panelName}" .config="${this.config.chartConfig}"></or-chart>`;
}
if (panelConfig && panelConfig.type === "kpi") {
diff --git a/ui/component/or-data-viewer/src/style.ts b/ui/component/or-data-viewer/src/style.ts
index ab2df8956..44fb1b2d6 100644
--- a/ui/component/or-data-viewer/src/style.ts
+++ b/ui/component/or-data-viewer/src/style.ts
@@ -32,8 +32,10 @@ export const style = css`
}
#container {
+ max-width: 1400px;
box-sizing: border-box;
display: grid;
+ margin: auto;
padding: 20px 20px;
grid-gap: 10px;
grid-template-columns: repeat(auto-fill, minmax(calc(25% - 8px), 1fr));
@@ -124,7 +126,13 @@ export const style = css`
display: none;
cursor: pointer;
}
-
+
+ @media screen and (max-width: 1024px) {
+ #container {
+ grid-template-columns: repeat(auto-fill, minmax(calc(50% - 8px), 1fr));
+ }
+ }
+
@media screen and (max-width: 769px) {
.back-navigation {
display: block;
diff --git a/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts b/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
index ff769674a..47f8b9988 100644
--- a/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
+++ b/ui/component/or-rules/src/json-viewer/modals/or-rule-notification-modal.ts
@@ -50,7 +50,7 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
}
}
- updated(changedProperties: PropertyValues){
+ firstUpdated(changedProperties: PropertyValues){
if(changedProperties.has("action")){
this.renderDialogHTML(this.action);
}
@@ -58,8 +58,7 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
protected render() {
if(!this.action) return html``;
-
-
+
const notificationPickerModalActions: DialogAction[] = [
{
actionName: "cancel",
@@ -86,7 +85,7 @@ export class OrRuleNotificationModal extends translate(i18next)(LitElement) {
return html`
<or-input .type="${InputType.BUTTON}" .label="${i18next.t("message")}" @click="${notificationPickerModalOpen}"></or-input>
- <or-mwc-dialog id="notification-modal" dialogTitle="${this.title}" .dialogActions="${notificationPickerModalActions}"> </or-mwc-dialog>
+ <or-mwc-dialog id="notification-modal" dialogTitle="${this.title}" .dialogActions="${notificationPickerModalActions}"></or-mwc-dialog>
<slot class="notification-form-slot"></slot>
`
}
diff --git a/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts b/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
index 103a36a01..30c6abb67 100644
--- a/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
+++ b/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
@@ -128,7 +128,7 @@ export class OrRuleActionNotification extends LitElement {
valueTemplate = html`<or-input .type="${InputType.TEXT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setActionNotificationName(e.detail.value)}" ?readonly="${this.readonly}" .value="${value}" ></or-input>`
}
- let modalTemplate;
+ let modalTemplate = html``;
if(message) {
if(messageType === "push") {
modalTemplate = html`
@@ -163,10 +163,15 @@ export class OrRuleActionNotification extends LitElement {
}
getNotificationTargetType() {
- if(!this.action.target) return;
+ if(this.action.target) {
+ if(this.action.target.assets || this.action.target.matchedAssets) return NotificationTargetType.ASSET;
+ if(this.action.target.users) return NotificationTargetType.USER;
+ } else if(this.action.notification) {
+ if(this.action.notification.message && this.action.notification.message.type === "email") return NotificationTargetType.CUSTOM;
+ } else {
+ return;
+ }
- if(this.action.target.assets || this.action.target.matchedAssets) return NotificationTargetType.ASSET;
- if(this.action.target.users) return NotificationTargetType.USER;
}
@@ -239,7 +244,6 @@ export class OrRuleActionNotification extends LitElement {
case NotificationTargetType.TENANT:
break;
case NotificationTargetType.CUSTOM:
- delete this.action.target;
break;
}
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());