Skip to content

armgit / core

Public Imported from GitHub
0

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

Add notification for rule, resize for or-history, map settings

robindekkersc95e1763b476
diff --git a/deployment/map/mapsettings.json b/deployment/map/mapsettings.json
index ccce473c7..6f65c55d3 100644
--- a/deployment/map/mapsettings.json
+++ b/deployment/map/mapsettings.json
@@ -3,14 +3,14 @@
"default": {
"center": [5.4774, 51.4370],
"bounds": [5.343, 51.378, 5.591, 51.509],
- "zoom": 13,
+ "zoom": 14,
"maxZoom": 19,
"boxZoom": false
},
"building": {
- "center": [5.4774, 51.4370],
+ "center": [5.4561596, 51.446795],
"bounds": [5.343, 51.378, 5.591, 51.509],
- "zoom": 13,
+ "zoom": 15,
"minZoom": 14,
"maxZoom": 19,
"boxZoom": false
diff --git a/ui/app/main/index.html b/ui/app/main/index.html
index 8ebec0a87..a9d1d11fc 100644
--- a/ui/app/main/index.html
+++ b/ui/app/main/index.html
@@ -8,11 +8,11 @@
<meta name="apple-mobile-web-app-title" content="OpenRemote Demo">
<meta name="msapplication-TileImage" content="images/Icon-144.png">
- <meta name="msapplication-TileColor" content="#222120">
+ <meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-tap-highlight" content="no">
<link rel="icon" href="images/favicon.ico">
- <meta name="theme-color" content="#222120">
+ <meta name="theme-color" content="#ffffff">
<!-- Add to homescreen for Chrome on Android. Fallback for manifest.json -->
<meta name="mobile-web-app-capable" content="yes">
@@ -28,7 +28,7 @@
<!-- Tile icon for Windows 8 (144x144 + tile color) -->
<meta name="msapplication-TileImage" content="images/Icon-144.png">
- <meta name="msapplication-TileColor" content="#222120">
+ <meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-tap-highlight" content="no">
<!-- Default twitter cards -->
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 7176d9e34..bf1d1cefc 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -9,7 +9,7 @@ import {InputType, OrInput, OrInputChangedEvent} from "@openremote/or-input";
import "@openremote/or-map";
import manager, {subscribe, Util, AssetModelUtil} from "@openremote/core";
import "@openremote/or-panel";
-import {HistoryConfig, OrAttributeHistory} from "@openremote/or-attribute-history";
+import {HistoryConfig, OrAttributeHistory, OrAttributeHistoryEvent} from "@openremote/or-attribute-history";
import {Type as MapType, Util as MapUtil} from "@openremote/or-map";
import {
Asset,
@@ -60,6 +60,29 @@ export interface ViewerConfig {
historyConfig?: HistoryConfig;
}
+class EventHandler{
+ _callbacks: Function[];
+
+ constructor() {
+ this._callbacks = [];
+ }
+
+ startCallbacks() {
+ return new Promise((resolve, reject)=> {
+ if(this._callbacks && this._callbacks.length > 0){
+ this._callbacks.forEach(cb => cb());
+ }
+ resolve();
+ })
+
+ }
+
+ addCallback(callback:Function) {
+ this._callbacks.push(callback);
+ }
+}
+const onRenderComplete = new EventHandler();
+
@customElement("or-asset-viewer")
export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElement)) {
@@ -73,6 +96,7 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
panels: {
"info": {
type: "property",
+ hideOnMobile: true,
panelStyles: {
},
fieldStyles: {
@@ -141,7 +165,9 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
constructor() {
super();
- window.addEventListener('resize', this.generateGrid.bind(this));
+ window.addEventListener('resize', () => OrAssetViewer.generateGrid(this.shadowRoot));
+
+ this.addEventListener(OrAttributeHistoryEvent.NAME,() => OrAssetViewer.generateGrid(this.shadowRoot));
}
shouldUpdate(changedProperties: PropertyValues): boolean {
@@ -221,7 +247,9 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
}
this.onCompleted().then(() => {
- this.generateGrid();
+ onRenderComplete.startCallbacks().then(()=> {
+ OrAssetViewer.generateGrid(this.shadowRoot);
+ });
});
}
@@ -230,13 +258,13 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
await this.updateComplete;
}
- generateGrid(){
- if(this.shadowRoot) {
- const grid = this.shadowRoot.querySelector('#container');
+ public static generateGrid(shadowRoot: ShadowRoot | null){
+ if(shadowRoot) {
+ const grid = shadowRoot.querySelector('#container');
if(grid){
const rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));
const rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));
- const items = this.shadowRoot.querySelectorAll('.panel');
+ const items = shadowRoot.querySelectorAll('.panel');
if(items){
items.forEach((item) => {
const content = item.querySelector('.panel-content-wrapper');
@@ -339,12 +367,21 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
}
}
};
-
+ const options = historyAttrs.map((attr) => [attr.name, Util.getAttributeLabel(attr, undefined)]);
+ const attrName:string = historyAttrs[0].name!;
+ onRenderComplete.addCallback(() => attributeChanged(attrName));
content = html`
+ <style>
+ or-attribute-history{
+ min-height: 70px;
+ width: 100%;
+ }
+ </style>
<div id="history-controls">
- <or-input id="history-attribute-picker" .label="${i18next.t("attribute")}" @or-input-changed="${(evt: OrInputChangedEvent) => attributeChanged(evt.detail.value)}" .type="${InputType.SELECT}" .options="${historyAttrs.map((attr) => [attr.name, Util.getAttributeLabel(attr, undefined)])}"></or-input>
+ <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>
</div>
<or-attribute-history id="attribute-history" .config="${viewerConfig.historyConfig}" .assetType="${asset.type}"></or-attribute-history>
+
`;
}
} else if (panelConfig && panelConfig.type === "location") {
diff --git a/ui/component/or-asset-viewer/src/style.ts b/ui/component/or-asset-viewer/src/style.ts
index 5d87bce66..c7c6c3397 100644
--- a/ui/component/or-asset-viewer/src/style.ts
+++ b/ui/component/or-asset-viewer/src/style.ts
@@ -38,7 +38,7 @@ export const style = css`
grid-gap: 10px;
grid-template-columns: repeat(auto-fill, minmax(calc(50% - 5px),1fr));
grid-auto-rows: 5px;
-
+
-webkit-animation: fadein 0.3s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 0.3s; /* Firefox < 16 */
-ms-animation: fadein 0.3s; /* Internet Explorer */
@@ -169,12 +169,29 @@ export const style = css`
padding: 20px 15px 0;
}
+ #container {
+ grid-auto-rows: auto;
+ }
+
.panel {
border-radius: 0;
border-right: none;
border-left: none;
}
+
+ #attributes-panel {
+ grid-row-start: 1;
+ }
+
+ #location-panel {
+ grid-row-start: 2;
+ }
+
+ #history-panel {
+ grid-row-start: 3;
+ }
+
#container {
grid-template-columns: 1fr!important;
padding: 20px 0;
diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.ts
index ce2f83037..e81936306 100644
--- a/ui/component/or-attribute-history/src/index.ts
+++ b/ui/component/or-attribute-history/src/index.ts
@@ -30,6 +30,35 @@ import {JSONPath} from "jsonpath-plus";
import moment from "moment";
import {styleMap} from "lit-html/directives/style-map";
+
+export class OrAttributeHistoryEvent extends CustomEvent<OrAttributeHistoryEventDetail> {
+
+ public static readonly NAME = "or-attribute-history-event";
+
+ constructor(value?: any, previousValue?: any) {
+ super(OrAttributeHistoryEvent.NAME, {
+ detail: {
+ value: value,
+ previousValue: previousValue
+ },
+ bubbles: true,
+ composed: true
+ });
+ }
+}
+
+export interface OrAttributeHistoryEventDetail {
+ value?: any;
+ previousValue?: any;
+}
+
+declare global {
+ export interface HTMLElementEventMap {
+ [OrAttributeHistoryEvent.NAME]: OrAttributeHistoryEvent;
+ }
+}
+
+
export type TableColumnType = "timestamp" | "prop";
export interface TableColumnConfig {
@@ -104,6 +133,7 @@ const style = css`
#container {
display: flex;
+ min-width: 0;
width: 100%;
height: 100%;
flex-direction: column;
@@ -141,8 +171,6 @@ const style = css`
}
#chart-container {
- height: 100%;
- flex: 1 1 auto;
position: relative;
}
@@ -339,6 +367,8 @@ export class OrAttributeHistory extends translate(i18next)(LitElement) {
options: {
// maintainAspectRatio: false,
// REMOVED AS DOESN'T SIZE CORRECTLY responsive: true,
+ maintainAspectRatio: false,
+ onResize: () => this.dispatchEvent(new OrAttributeHistoryEvent('resize')),
legend: {
display: false
},
diff --git a/ui/component/or-map/src/index.ts b/ui/component/or-map/src/index.ts
index 5b9d2b9f0..ddf0046e7 100644
--- a/ui/component/or-map/src/index.ts
+++ b/ui/component/or-map/src/index.ts
@@ -252,7 +252,7 @@ export class OrMap extends LitElement {
<div id="container">
<div id="map"></div>
<slot></slot>
- <a id="openremote" href="https://manager.io/" target="_blank">
+ <a id="openremote" href="https://openremote.io/" target="_blank">
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAQAAADZc7J/AAAABGdBTUEAAYagMeiWXwAAAAJiS0dEAP+Hj8y/AAAESUlEQVRIx5XVbWzdZRnH8c//f07POe36sK7SrYXZjYGzbBokOqd4QtKATdnMDFFSkoFzmWGRQOAFSoYnsBSzxBdmGsN4Y7LEFwZkUdHpDoja/AnJjBvp1sm2upW5PtAV+zBS+7Tz//tiLe0emPF+d9/39fvmunJf9+8K3HBF1drFzurVn5+5XkTwPwBNOt1s0pCjDnnT+Xzy/wOa5jaXnLLfLwzlF0WENwaYckyvUTHS1tnjl+6JFqk+JoMOqqy2JqjPVpXP1k7U1+Ty8paBPk97NX/pYwEdgZUetNkdlirDrHGnyv6y5r3lm4M2WVzwpJfz8XUBHTntnrJO6qqLWE9u/125zBNq0WebN/PXAjqq/cBOVWDasCEsd5MsmEzt/3xP+S6fwNsezPdfBejI6fCEDMa95oAT/t31pVxDQ6p6oy2WYSb18w0D2V3Klez2w3y8CNAR2G6vShxXUCxMkXLvS7Y6E/5+3emaJ92JqezzG+8M2nHW/flTi59xladU4phtfluYgnsDWUt8Nv7+8UfO73UUuenvDLxuCKu0RQt90BFo14wxzzpamD8uExtHSsu5HSP7XMCtZ5uTPyO0SdVCBlXahHjNG4WFrGY9Y4tXzODL7zb7NYJS64eHzWK92xYAa9yBKa8Wphf0xaQ4XOz0qF9JhMnXh//mIm4dnDSMOusWALepwQUnrm2t4pi9hrGyP+ccloxV6kOZFemoWi2mOpclaQycqGlt9R8XHS/GixinnVWvbDpjDEEpNpdnWrtd+HvZWzMQT9xjj1iXzUau6MPS9X9NKOeTmqzPpZWwfMkEKnza2ivimqxCKZjQa9BMmFI2D+gxibql4z7EiobYOSy1o7V6Xt1aYacGvD/7lse1+GZ9t0Zc8kHaGcOa1K6o+FePL1iy7K7wYHy70FZa9+qVWOm7tgslfpecKcy46GS0xXKM6g6d14VU+RfTnRJ8Y223w8j4tkMOOeR1j6nAMT8tzkCUcvlbn3ImbJn0RyWC+1af1Iv6ukcbf+aIRKDR3b5ipVCiy+PenaupWRsSfzCWim0ftUmdiqrJwWLpbmk3196UfXG0X6NKIWKDXva0I0UQZT2nRaDfc/mhgCj0PS9ImZzefbg5fliIvuTA++/0ZaYDTDqqpzhn6lHoW36iSuLHnslfCiBqdMBGDI6/0LUhfkgGiWFbC29c+epRaJMX3YJuD+R75l15wG4DaKh5dsPJsj0GXLaawavkWY/MyUcU/JOPHCkK7fAjNZiIf/PeX/vWx1814muF0Y/EKWs95mFVuKhgX352EYAoY5vnNSDRF/9p/MgHfQ2dldNIqbPeJm2aBBix20vzg26RpUUpLfb43FxZU4YMmEJGoxXKQeIfCg4uzMkrTDVitZ0ecst1B05i0Cv26Vk8H68JjFKabXa/Zkul5w5Lxp120EHdlyu/AQCiQI1P+YxaGcwY1+20kasnM/wXCa5/Ik1hKTEAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTktMDgtMjBUMTU6MTc6NTUrMDA6MDCwJSdSAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE5LTA4LTIwVDE1OjE3OjU1KzAwOjAwwXif7gAAAABJRU5ErkJggg==" />
</a>
</div>
diff --git a/ui/component/or-map/src/style.ts b/ui/component/or-map/src/style.ts
index 8e63cbd8a..59650a91c 100644
--- a/ui/component/or-map/src/style.ts
+++ b/ui/component/or-map/src/style.ts
@@ -65,7 +65,11 @@ export const style = css`
.or-map-marker {
position: absolute; /* This makes mapboxJS behave like mapboxGL */
}
-
+
+ .or-map-marker.active {
+ z-index: 1;
+ }
+
.marker-container {
position: relative;
cursor: pointer;
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
new file mode 100644
index 000000000..4ba68475c
--- /dev/null
+++ b/ui/component/or-rules/src/json-viewer/or-rule-action-notification.ts
@@ -0,0 +1,86 @@
+import {customElement, html, LitElement, property, css} from "lit-element";
+import {RulesConfig} from "../index";
+import {
+ RuleActionNotification,
+ EmailNotificationMessageRecipient,
+ EmailNotificationMessage
+} from "@openremote/model";
+import {InputType, OrInputChangedEvent} from "@openremote/or-input";
+import {OrRulesJsonRuleChangedEvent} from "./or-rule-json-viewer";
+
+// language=CSS
+const style = css`
+ :host {
+ display: flex;
+ align-items: center;
+ }
+
+ :host > * {
+ margin-right: 10px;
+ }
+`;
+
+@customElement("or-rule-action-notification")
+export class OrRuleActionNotification extends LitElement {
+
+ static get styles() {
+ return style;
+ }
+
+ @property({type: Object, attribute: false})
+ public action!: RuleActionNotification;
+
+ public readonly?: boolean;
+
+ public config?: RulesConfig;
+
+
+ protected render() {
+ let value: string = "";
+ if(this.action.notification && this.action.notification.message ){
+ const message:EmailNotificationMessage = this.action.notification.message;
+ if(message.to) {
+ value = message.to.map(t => t.address).join(';');
+ }
+ }
+
+ return html`
+ <or-input .type="${InputType.TEXT}" @or-input-changed="${(e: OrInputChangedEvent) => this.setActionNotificationName(e.detail.value)}" ?readonly="${this.readonly}" .value="${value}" ></or-input>
+ `;
+
+
+ }
+
+ protected setActionNotificationName(emails: string | undefined) {
+ this.action.notification = {
+ message: {
+ type: "email",
+ subject: "%RULESET_NAME%",
+ html: "TEST",
+ from: {address:"[email protected]"},
+ to: []
+ }
+ };
+
+ if(emails && this.action.notification && this.action.notification.message){
+
+ const arrayOfEmails = emails.split(';');
+ const message:EmailNotificationMessage = this.action.notification.message;
+
+ arrayOfEmails.forEach(email => {
+ const messageRecipient:EmailNotificationMessageRecipient = {
+ address: email,
+ name: email
+ };
+ if(message && message.to){
+ message.to.push(messageRecipient);
+ }
+ });
+
+ this.action.notification.message = message;
+ }
+ this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
+ this.requestUpdate();
+ }
+
+}
\ No newline at end of file
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.ts
index b7f44aaa7..d7b15a66a 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
@@ -16,6 +16,7 @@ import {MenuItem} from "@openremote/or-mwc-components/dist/or-mwc-menu";
import {getAssetDescriptorIconTemplate} from "@openremote/or-icon";
import {AssetModelUtil} from "@openremote/core";
import "./or-rule-action-attribute";
+import "./or-rule-action-notification";
import {getContentWithMenuTemplate} from "@openremote/or-mwc-components/dist/or-mwc-menu";
import { translate } from "@openremote/or-translate";
@@ -185,7 +186,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
template = html`<span>WAIT NOT IMPLEMENTED</span>`;
break;
case ActionType.NOTIFICATION:
- template = html`<span>NOTIFICATION NOT IMPLEMENTED</span>`;
+ template = html`<or-rule-action-notification id="rule-notification" .action="${action}" .config="${this.config}" .readonly="${this.readonly}"></or-rule-action-notification>`;
break;
default:
template = html`<or-rule-action-attribute .action="${action}" .config="${this.config}" .assetDescriptors="${this.assetDescriptors}" .readonly="${this.readonly}"></or-rule-action-attribute>`;
@@ -232,6 +233,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
case "wait":
break;
case "notification":
+ return action.action;
break;
case "write-attribute":
case "update-attribute":
@@ -261,7 +263,7 @@ class OrRuleThenOtherwise extends translate(i18next)(LitElement) {
action.attributeName = undefined;
break;
case "notification":
- action.notification = undefined;
+ action.notification = undefined;
break;
case "update-attribute":
action.value = undefined;