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
Webcomponents smart notify, timeline
robindekkers822139eb67b3
diff --git a/ui/component/or-smart-notify/.npmignore b/ui/component/or-smart-notify/.npmignorenew file mode 100644index 000000000..ca658009d--- /dev/null+++ b/ui/component/or-smart-notify/.npmignore@@ -0,0 +1,3 @@+build/+build.gradle+test/\ No newline at end of filediff --git a/ui/component/or-smart-notify/README.md b/ui/component/or-smart-notify/README.mdnew file mode 100644index 000000000..1492f67af--- /dev/null+++ b/ui/component/or-smart-notify/README.md@@ -0,0 +1,3 @@+# \<or-smart-notify\>++OpenRemote SmartNotify\ No newline at end of filediff --git a/ui/component/or-smart-notify/build.gradle b/ui/component/or-smart-notify/build.gradlenew file mode 100644index 000000000..56d41d45d--- /dev/null+++ b/ui/component/or-smart-notify/build.gradle@@ -0,0 +1,9 @@+task clean() {+ doLast {+ delete "dist"+ }+}++task build() {+ dependsOn npmBuild+}diff --git a/ui/component/or-smart-notify/package.json b/ui/component/or-smart-notify/package.jsonnew file mode 100644index 000000000..0589a81b5--- /dev/null+++ b/ui/component/or-smart-notify/package.json@@ -0,0 +1,31 @@+{+ "name": "@openremote/or-smart-notify",+ "version": "1.0.0",+ "description": "OpenRemote Smarty Notify element",+ "main": "dist/index.js",+ "types": "src/index.ts",+ "scripts": {+ "build": "npx tsc",+ "test": "echo \"No tests\" && exit 0"+ },+ "author": "OpenRemote",+ "license": "AGPL-3.0-or-later",+ "dependencies": {+ "@openremote/rest": "^1.0.0",+ "@openremote/model": "^1.0.0",+ "lit-element": "^2.0.1",+ "@fortawesome/fontawesome-svg-core": "^1.2.12",+ "@fortawesome/free-solid-svg-icons": "^5.6.3",+ "@fortawesome/free-regular-svg-icons": "^5.6.3",+ "moment": "^2.24.0"+ },+ "devDependencies": {+ "@polymer/decorators": "^3.0.0",+ "@polymer/iron-demo-helpers": "^3.0.0-pre.19",+ "@webcomponents/webcomponentsjs": "^2.0.0",+ "style-loader": "^0.23.1",+ "tslint": "^5.11.0",+ "typescript": "^3.2.2",+ "wct-browser-legacy": "^1.0.0"+ }+}diff --git a/ui/component/or-smart-notify/src/index.d.ts b/ui/component/or-smart-notify/src/index.d.tsnew file mode 100644index 000000000..cb0ff5c3b--- /dev/null+++ b/ui/component/or-smart-notify/src/index.d.ts@@ -0,0 +1 @@+export {};diff --git a/ui/component/or-smart-notify/src/index.js b/ui/component/or-smart-notify/src/index.jsnew file mode 100644index 000000000..1d5550f9b--- /dev/null+++ b/ui/component/or-smart-notify/src/index.js@@ -0,0 +1,326 @@+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;+ return c > 3 && r && Object.defineProperty(target, key, r), r;+};+import { html, LitElement, property } from 'lit-element';+import moment from 'moment';+import { icon } from '@fortawesome/fontawesome-svg-core';+import { faClock } from '@fortawesome/free-regular-svg-icons';+import { faTimes } from '@fortawesome/free-solid-svg-icons';+import REST from "@openremote/rest";+class OrSmartNotify extends LitElement {+ constructor() {+ super();+ // if smart notify popup is visible+ this.isVisible = false;+ // If smart notify is active+ this.isActive = false;+ // If smart notify is active+ this.isDisabled = false;+ // If smart notify is active+ this.smartNotify = {};+ // default function on smartyNotify+ this.currentTime = '-';+ this.currentTime = moment().format('HH:mm');+ setInterval(function () {+ this.currentTime = moment().format('HH:mm');+ }.bind(this), 500);+ }+ render() {+ // language=HTML+ return html `+ <style>+ #smartNotifyControlPanel {+ position: fixed;+ left: 20px;+ bottom: 146px;+ width: 315px;+ z-index: 2;+ background-color: #FFFFFF;++ -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ }+ .layout.horizontal {+ display: -ms-flexbox;+ display: -webkit-flex;+ display: flex;++ -ms-flex-direction: row;+ -webkit-flex-direction: row;+ flex-direction: row;+++ -ms-flex-align: center;+ -webkit-align-items: center;+ align-items: center;++ -ms-flex-pack: center;+ -webkit-justify-content: center;+ justify-content: center;+ }++ .t-center {+ text-align: center;+ }++ .controller-timeline{+ padding: 5px 20px;+ height: 32px;+ line-height: 32px;+ border-bottom: solid 1px #dedede;+ }++ .flex {+ -ms-flex: 1 1 0.000000001px;+ -webkit-flex: 1;+ flex: 1;+ -webkit-flex-basis: 0.000000001px;+ flex-basis: 0.000000001px;+ }++ .padding-2-5 {+ padding: 2px 5px;+ }+ .padding-10 {+ padding: 10px;+ }+ #smart-notify-toggle {+ margin-top: 29px;+ }++ .smart-notify-toggle-label {+ color: #FFFFFF;+ background-color: #00477c;+ border-top-left-radius: 5px;+ border-top-right-radius: 5px;+ padding: 2px 8px;+ font-size: 12px;+ height: 19px;+ }++ .smart-notify-toggle-icon {+ background-color: #555753;+ border-bottom-left-radius: 5px;+ border-bottom-right-radius: 5px;+ margin-top: 2px;+ height: 48px;+ }++ .smart-notify-toggle-icon[active] {+ background-color: #00477c;+ }++ icon {+ height: 20px;+ width: 20px;+ }++ icon .svg-inline--fa {+ height: 20px;+ width: 20px;+ }++ icon[large] {+ height: 28px;+ width: 28px;+ }++ icon[large] .svg-inline--fa {+ height: 28px;+ width: 28px;+ margin: 10px;+ }++ icon[large] svg path {+ fill: #FFFFFF;+ color: #FFFFFF;+ }++ /* The switch - the box around the slider */+ .switch {+ position: relative;+ display: inline-block;+ width: 36px;+ height: 14px;+ margin: 10px 0;+ }++ /* Hide default HTML checkbox */+ .switch input {+ opacity: 0;+ width: 0;+ height: 0;+ }++ /* The slider */+ .slider {+ position: absolute;+ cursor: pointer;+ top: 0;+ left: 0;+ right: 0;+ bottom: 0;+ background-color: #ccc;+ -webkit-transition: .4s;+ transition: .4s;+ }++ .slider:before {+ position: absolute;+ content: "";+ height: 20px;+ width: 20px;+ left: 0;+ top: -3px;+ background-color: white;+ -webkit-transition: .4s;+ transition: .4s;+ box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);+ }++ input:checked + .slider:before {+ background-color: var(--app-primary-color);+ }++ input:focus + .slider {+ }++ input:checked + .slider:before {+ -webkit-transform: translateX(20px);+ -ms-transform: translateX(20px);+ transform: translateX(20px);+ }++ /* Rounded sliders */+ .slider.round {+ border-radius: 34px;+ }++ .slider.round:before {+ border-radius: 50%;+ }+ </style>++ ${this.isVisible ? html `+ <div id="smartNotifyControlPanel">+ <div class="layout horizontal controller-timeline t-center">+ <icon>${icon(faClock).node.item(0)}</icon>+ <div class="flex padding-2-5" style="font-weight: 600;">Smart Notify</div>++ <a style="height: 22px;" @click="${this.close}">+ <icon>${icon(faTimes).node.item(0)}</icon>+ </a>+ </div>+ <div class="layout horizontal">+ <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Wachttijd berekenen</div>+ <div class="flex t-center">+ <label class="switch">+ <input @change="${this.setSmartNotify}" ?disabled="${this.isDisabled}" ?checked="${this.isActive}" type="checkbox">+ <span class="slider round"></span>+ </label>+ </div>+ </div>+ ${this.isActive ? html `+ <div class="layout horizontal">+ <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Starttijd</div>+ <div class="flex t-center">${this.isActive ? moment(this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp).format('HH:mm') : "-"}</div>+ </div>+ ` : ``}+ </div>+ ` : ``}+ <div id="smart-notify-toggle" @click="${this.toggleVisibility}">+ <div class="smart-notify-toggle-label">${this.currentTime}</div>+ <div class="smart-notify-toggle-icon" ?active="${this.isActive}">+ <icon large>${icon(faClock).node.item(0)}</icon>+ </div>+ </div>++ `;+ }+ getSmartNotify() {+ return new Promise(function (resolve, reject) {+ const smartNotifyQuery = {+ name: { predicateType: "string", value: "SMART_NOTIFY_ASSET" },+ select: { include: "ALL_EXCEPT_PATH" /* ALL_EXCEPT_PATH */ }+ };+ REST.api.AssetResource.queryAssets(smartNotifyQuery).then(response => {+ console.log("Setting Smart Notify");+ if (response.data) {+ this.smartNotify = response.data[0];+ this.isActive = this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value ? true : false;+ this.onChange();+ resolve(response);+ }+ }).catch(reason => {+ reject(Error("Error:" + reason));+ console.log("Error:" + reason);+ });+ }.bind(this));+ }+ checkSmartNotifyMarkers() {+ if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length > 0) {+ }+ else if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length === 0) {+ this.getSmartNotify().then(() => {+ setTimeout(function () {+ this.checkSmartNotifyMarkers();+ }.bind(this), 3000);+ });+ }+ }+ setSmartNotify(e) {+ const isChecked = e.target.checked;+ if (isChecked == true) {+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = moment();+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp = moment();+ this.isActive = true;+ }+ else {+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = null;+ this.isActive = false;+ }+ REST.api.AssetResource.update(this.smartNotify.id, this.smartNotify).then(response => {+ console.log("Setting Smart Notify");+ this.smartNotify.version = this.smartNotify.version + 1;+ if (isChecked == true) {+ this.checkSmartNotifyMarkers();+ }+ else {+ // Clear the smartnotify markers and smart notify in frontend+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = false;+ this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers = [];+ this.onChange();+ }+ }).catch(reason => console.log("Error:" + reason));+ }+ close() {+ this.isVisible = false;+ }+ toggleVisibility() {+ this.isVisible = !this.isVisible;+ }+}+__decorate([+ property({ type: Function })+], OrSmartNotify.prototype, "onChange", void 0);+__decorate([+ property({ type: Boolean })+], OrSmartNotify.prototype, "isVisible", void 0);+__decorate([+ property({ type: Boolean })+], OrSmartNotify.prototype, "isActive", void 0);+__decorate([+ property({ type: Boolean })+], OrSmartNotify.prototype, "isDisabled", void 0);+__decorate([+ property({ type: Object })+], OrSmartNotify.prototype, "smartNotify", void 0);+__decorate([+ property({ type: String })+], OrSmartNotify.prototype, "currentTime", void 0);+window.customElements.define('or-smart-notify', OrSmartNotify);+//# sourceMappingURL=index.js.map\ No newline at end of filediff --git a/ui/component/or-smart-notify/src/index.js.map b/ui/component/or-smart-notify/src/index.js.mapnew file mode 100644index 000000000..48aa8f329--- /dev/null+++ b/ui/component/or-smart-notify/src/index.js.map@@ -0,0 +1 @@+{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAEvD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,IAAI,EAAC,MAAM,mCAAmC,CAAA;AACtD,OAAO,EAAC,OAAO,EAAC,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAC,MAAM,mCAAmC,CAAC;AAE1D,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAGpC,MAAM,aAAc,SAAQ,UAAU;IAmTlC;QACI,KAAK,EAAE,CAAC;QA1FZ,mCAAmC;QAE3B,cAAS,GAAY,KAAK,CAAC;QAEnC,4BAA4B;QAEpB,aAAQ,GAAY,KAAK,CAAC;QAElC,4BAA4B;QAEpB,eAAU,GAAY,KAAK,CAAC;QAEpC,4BAA4B;QAEpB,gBAAW,GAAQ,EAAE,CAAC;QAE9B,mCAAmC;QAE3B,gBAAW,GAAW,GAAG,CAAC;QA0E9B,IAAI,CAAC,WAAW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B,IAAI,CAAC,uBAAuB,EAAE,CAAC;aAClC;iBAAM;gBAEH,6DAA6D;gBAC7D,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,oBAAoB,CAAC,KAAK,GAAG,KAAK,CAAC;gBAC/D,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;gBACnE,IAAI,CAAC,QAAQ,EAAE,CAAC;aACnB;QAEL,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK;QACD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,gBAAgB;QACZ,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;IACrC,CAAC;CAaJ;AAtGG;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;+CACV;AAIjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;gDACS;AAInC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;+CACQ;AAIlC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;iDACU;AAIpC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACK;AAI9B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;kDACS;AAoFtC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC"}\ No newline at end of filediff --git a/ui/component/or-smart-notify/src/index.ts b/ui/component/or-smart-notify/src/index.tsnew file mode 100644index 000000000..10dee0b49--- /dev/null+++ b/ui/component/or-smart-notify/src/index.ts@@ -0,0 +1,333 @@+import {html, LitElement, property, customElement} from 'lit-element';++import moment from 'moment';++import {icon} from '@fortawesome/fontawesome-svg-core'+import {faClock} from '@fortawesome/free-regular-svg-icons';+import {faTimes} from '@fortawesome/free-solid-svg-icons';++import REST from "@openremote/rest";+import {AssetQuery, BaseAssetQueryInclude} from "@openremote/model";++@customElement('or-smart-notify')+class OrSmartNotify extends LitElement {+ protected render() {+ // language=HTML+ return html`+ <style>+ #smartNotifyControlPanel {+ position: fixed;+ left: 20px;+ bottom: 146px;+ width: 315px;+ z-index: 2;+ background-color: #FFFFFF;++ -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ }+ .layout.horizontal {+ display: -ms-flexbox;+ display: -webkit-flex;+ display: flex;++ -ms-flex-direction: row;+ -webkit-flex-direction: row;+ flex-direction: row;+++ -ms-flex-align: center;+ -webkit-align-items: center;+ align-items: center;++ -ms-flex-pack: center;+ -webkit-justify-content: center;+ justify-content: center;+ }++ .t-center {+ text-align: center;+ }++ .controller-timeline{+ padding: 5px 20px;+ height: 32px;+ line-height: 32px;+ border-bottom: solid 1px #dedede;+ }++ .flex {+ -ms-flex: 1 1 0.000000001px;+ -webkit-flex: 1;+ flex: 1;+ -webkit-flex-basis: 0.000000001px;+ flex-basis: 0.000000001px;+ }++ .padding-2-5 {+ padding: 2px 5px;+ }+ .padding-10 {+ padding: 10px;+ }+ #smart-notify-toggle {+ margin-top: 29px;+ }++ .smart-notify-toggle-label {+ color: #FFFFFF;+ background-color: #00477c;+ border-top-left-radius: 5px;+ border-top-right-radius: 5px;+ padding: 2px 8px;+ font-size: 12px;+ height: 19px;+ }++ .smart-notify-toggle-icon {+ background-color: #555753;+ border-bottom-left-radius: 5px;+ border-bottom-right-radius: 5px;+ margin-top: 2px;+ height: 48px;+ }++ .smart-notify-toggle-icon[active] {+ background-color: #00477c;+ }++ icon {+ height: 20px;+ width: 20px;+ }++ icon .svg-inline--fa {+ height: 20px;+ width: 20px;+ }++ icon[large] {+ height: 28px;+ width: 28px;+ }++ icon[large] .svg-inline--fa {+ height: 28px;+ width: 28px;+ margin: 10px;+ }++ icon[large] svg path {+ fill: #FFFFFF;+ color: #FFFFFF;+ }++ /* The switch - the box around the slider */+ .switch {+ position: relative;+ display: inline-block;+ width: 36px;+ height: 14px;+ margin: 10px 0;+ }++ /* Hide default HTML checkbox */+ .switch input {+ opacity: 0;+ width: 0;+ height: 0;+ }++ /* The slider */+ .slider {+ position: absolute;+ cursor: pointer;+ top: 0;+ left: 0;+ right: 0;+ bottom: 0;+ background-color: #ccc;+ -webkit-transition: .4s;+ transition: .4s;+ }++ .slider:before {+ position: absolute;+ content: "";+ height: 20px;+ width: 20px;+ left: 0;+ top: -3px;+ background-color: white;+ -webkit-transition: .4s;+ transition: .4s;+ box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);+ }++ input:checked + .slider:before {+ background-color: var(--app-primary-color);+ }++ input:focus + .slider {+ }++ input:checked + .slider:before {+ -webkit-transform: translateX(20px);+ -ms-transform: translateX(20px);+ transform: translateX(20px);+ }++ /* Rounded sliders */+ .slider.round {+ border-radius: 34px;+ }++ .slider.round:before {+ border-radius: 50%;+ }+ </style>++ ${this.isVisible ? html`+ <div id="smartNotifyControlPanel">+ <div class="layout horizontal controller-timeline t-center">+ <icon>${icon(faClock).node.item(0)}</icon>+ <div class="flex padding-2-5" style="font-weight: 600;">Smart Notify</div>++ <a style="height: 22px;" @click="${this.close}">+ <icon>${icon(faTimes).node.item(0)}</icon>+ </a>+ </div>+ <div class="layout horizontal">+ <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Wachttijd berekenen</div>+ <div class="flex t-center">+ <label class="switch">+ <input @change="${this.setSmartNotify}" ?disabled="${this.isDisabled}" ?checked="${this.isActive}" type="checkbox">+ <span class="slider round"></span>+ </label>+ </div>+ </div>+ ${this.isActive ? html`+ <div class="layout horizontal">+ <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Starttijd</div>+ <div class="flex t-center">${this.isActive ? moment(this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp).format('HH:mm') : "-"}</div>+ </div>+ ` : ``}+ </div>+ ` : ``}+ <div id="smart-notify-toggle" @click="${this.toggleVisibility}">+ <div class="smart-notify-toggle-label">${this.currentTime}</div>+ <div class="smart-notify-toggle-icon" ?active="${this.isActive}">+ <icon large>${icon(faClock).node.item(0)}</icon>+ </div>+ </div>++ `;+ }+ // default function on smartyNotify+ @property({type: Function})+ private onChange: any;++ // if smart notify popup is visible+ @property({type: Boolean})+ private isVisible: boolean = false;++ // If smart notify is active+ @property({type: Boolean})+ private isActive: boolean = false;++ // If smart notify is active+ @property({type: Boolean})+ private isDisabled: boolean = false;++ // If smart notify is active+ @property({type: Object})+ private smartNotify: any = {};++ // default function on smartyNotify+ @property({type: String})+ private currentTime: string = '-';++ getSmartNotify() {+ const self:any = this;+ return new Promise(function(resolve: any, reject: any) {+ const smartNotifyQuery: AssetQuery = {+ name: {predicateType: "string", value: "SMART_NOTIFY_ASSET"},+ select: {include: BaseAssetQueryInclude.ALL_EXCEPT_PATH}+ };+ REST.api.AssetResource.queryAssets(smartNotifyQuery).then((response: any) => {+ console.log("Setting Smart Notify");+ if (response.data) {+ self.smartNotify = response.data[0];+ self.isActive = self.smartNotify.attributes.SMART_NOTIFY_ENABLED.value ? true : false;+ self.onChange();+ resolve(response);+ }++ }).catch((reason:any) => {+ reject(Error("Error:" + reason));+ console.log("Error:" + reason)+ });++ });+ }++ checkSmartNotifyMarkers() {+ const self:any = this;+ if(this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length > 0) {+ } else if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length === 0) {+ this.getSmartNotify().then(()=> {+ setTimeout(function(){+ self.checkSmartNotifyMarkers();+ }.bind(this), 3000);+ });+ }+ }++ setSmartNotify(e:any) {+ const isChecked = e.target.checked;+ if (isChecked == true) {+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = moment();+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp = moment();+ this.isActive = true;+ } else {+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = null;+ this.isActive = false;+ }+ REST.api.AssetResource.update(this.smartNotify.id, this.smartNotify).then((response:any) => {+ console.log("Setting Smart Notify");+ this.smartNotify.version = this.smartNotify.version+1;+ if(isChecked == true){+ this.checkSmartNotifyMarkers();+ } else {++ // Clear the smartnotify markers and smart notify in frontend+ this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = false;+ this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers = [];+ this.onChange();+ }++ }).catch((reason:any) => console.log("Error:" + reason));+ }++ close() {+ this.isVisible = false;+ }++ toggleVisibility() {+ this.isVisible = !this.isVisible;+ }++ constructor() {+ super();+ const self:any = this;+ this.currentTime = moment().format('HH:mm');++ setInterval(function(){+ self.currentTime = moment().format('HH:mm');+ }, 500);+ }+++}+diff --git a/ui/component/or-smart-notify/tsconfig.json b/ui/component/or-smart-notify/tsconfig.jsonnew file mode 100644index 000000000..aa12a532d--- /dev/null+++ b/ui/component/or-smart-notify/tsconfig.json@@ -0,0 +1,14 @@+{+ "extends": "../../tsconfig",+ "compilerOptions": {+ "outDir": "./dist/",+ "rootDir": "src"+ },+ "include": [+ "./src"+ ],+ "references": [+ { "path": "../core" },+ { "path": "../rest" }+ ]+}\ No newline at end of filediff --git a/ui/component/or-timeline/.npmignore b/ui/component/or-timeline/.npmignorenew file mode 100644index 000000000..ca658009d--- /dev/null+++ b/ui/component/or-timeline/.npmignore@@ -0,0 +1,3 @@+build/+build.gradle+test/\ No newline at end of filediff --git a/ui/component/or-timeline/README.md b/ui/component/or-timeline/README.mdnew file mode 100644index 000000000..f443ae029--- /dev/null+++ b/ui/component/or-timeline/README.md@@ -0,0 +1,3 @@+# \<or-timeline\>++OpenRemote Timlinediff --git a/ui/component/or-timeline/build.gradle b/ui/component/or-timeline/build.gradlenew file mode 100644index 000000000..56d41d45d--- /dev/null+++ b/ui/component/or-timeline/build.gradle@@ -0,0 +1,9 @@+task clean() {+ doLast {+ delete "dist"+ }+}++task build() {+ dependsOn npmBuild+}diff --git a/ui/component/or-timeline/package.json b/ui/component/or-timeline/package.jsonnew file mode 100644index 000000000..7ccba7d32--- /dev/null+++ b/ui/component/or-timeline/package.json@@ -0,0 +1,26 @@+{+ "name": "@openremote/or-timeline",+ "version": "1.0.0",+ "description": "OpenRemote Timeline",+ "main": "dist/index.js",+ "types": "src/index.ts",+ "scripts": {+ "build": "npx tsc",+ "test": "echo \"No tests\" && exit 0"+ },+ "author": "OpenRemote",+ "license": "AGPL-3.0-or-later",+ "dependencies": {+ "lit-element": "^2.0.1",+ "moment": "^2.24.0"+ },+ "devDependencies": {+ "@polymer/decorators": "^3.0.0",+ "@polymer/iron-demo-helpers": "^3.0.0-pre.19",+ "@webcomponents/webcomponentsjs": "^2.0.0",+ "style-loader": "^0.23.1",+ "tslint": "^5.11.0",+ "typescript": "^3.2.2",+ "wct-browser-legacy": "^1.0.0"+ }+}diff --git a/ui/component/or-timeline/src/index.d.ts b/ui/component/or-timeline/src/index.d.tsnew file mode 100644index 000000000..cb0ff5c3b--- /dev/null+++ b/ui/component/or-timeline/src/index.d.ts@@ -0,0 +1 @@+export {};diff --git a/ui/component/or-timeline/src/index.js b/ui/component/or-timeline/src/index.jsnew file mode 100644index 000000000..216555fc5--- /dev/null+++ b/ui/component/or-timeline/src/index.js@@ -0,0 +1,242 @@+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;+ return c > 3 && r && Object.defineProperty(target, key, r), r;+};+import { html, LitElement, property } from 'lit-element';+import moment from 'moment';+class OrTimeline extends LitElement {+ constructor() {+ super();+ // default value in minutes+ this.value = 0;+ // default value in minutes+ this.current = 0;+ // maxRange in minutes+ this.maxRange = 360;+ // minRange in minutes+ this.minRange = 0;+ // Steps in minutes+ this.step = 5;+ }+ render() {+ const range = this.shadowRoot.getElementById('or-timeline-slider');+ if (range) {+ range.value = Math.round(this.current);+ this.moveBubble(range);+ }+ return html `+ <style>+ :host {+ position: relative;+ }+ .timeline-container {+ display: block;+ height: 52px;+ background-color: var(--app-white, #FFFFFF);++ -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);++ padding-top: 20px;+ }+ .slidecontainer {+ position: relative;+ margin: -5px 50px 0 30px;+ }++ /* The slider itself */+ .slider {+ box-sizing: border-box;+ -webkit-appearance: none; /* Override default CSS styles */+ appearance: none;+ width: calc(100% + 20px);+ margin-left: -10px;+ height: 12px;+ background: #bdbdbd; /* Grey background */+ outline: none; /* Remove outline */+ opacity: 1; /* Set transparency (for mouse-over effects on hover) */+ -webkit-transition: .2s; /* 0.2 seconds transition on hover */+ transition: opacity .2s;++ border-radius: 6px;+ }++ /* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */+ .slider::-webkit-slider-thumb {+ -webkit-appearance: none;+ appearance: none;+ width: 18px;+ height: 18px;+ margin: 0;+ border-radius: 50%;+ cursor: pointer;+ border: 0 !important;+ background-color: var(--timeline-accent, blue); /* Green background */+ }++ .slider::-ms-thumb,+ .slider::-moz-range-thumb,+ .slider::-webkit-slider-thumb {+ width: 18px;+ height: 18px;+ margin: 0;+ border-radius: 50%;+ cursor: pointer;+ border: 0 !important;+ background-color: var(--timeline-accent, blue); /* Green background */+ }++ #timelineHourMarkers {+ position: relative;+ display: -webkit-box;+ display: -moz-box;+ display: -ms-flexbox;+ display: -webkit-flex;+ display: flex;+ -webkit-box-orient: horizontal;+ -moz-box-orient: horizontal;+ -webkit-box-direction: normal;+ -moz-box-direction: normal;+ -webkit-flex-direction: row;+ -ms-flex-direction: row;+ flex-direction: row;++ margin: 0 50px 0 30px;+ }++ #timelineHourMarkers > .timelineHourMark{+ display: flex;+ flex: 1 100%;+ flex-grow: 1;+ flex-shrink: 1;+ flex-basis: 100%;++ overflow: visible;+ color: #dcdcdc;+ border-left: 1px solid #dcdcdc;+ font-size: 12px;+ -webkit-user-select: none;+ -moz-user-select: none;+ -ms-user-select: none;+ user-select: none;+ padding-left: 4px;+ padding-bottom: 4px;+ }+ #timelineHourMarkers .timelineHourMark:last-child {+ position: absolute;+ right: -25px;+ }++ #range-value {+ position: absolute;+ background-color: var(--timeline-accent, blue);+ height: 30px;+ width: 60px;+ text-align: center;+ color: white;+ display: inline-block;+ left: 0;+ font-size: 12px;+ font-weight: bold;+ line-height: 30px;+ }++ .time-value-container {+ width: 100%;+ display: block;+ position: relative;+ height: 30px;+ }+ </style>+++ <div class="time-value-container">+ <div id="range-value">${this.current === 0 ? 'LIVE' : moment().add(this.current, 'minutes').format('HH:mm')}</div>+ </div>+ <div class="timeline-container">+ <div id="timelineHourMarkers" class="layout horizontal justified style-scope controller-timeline">+ ${new Array((this.maxRange / 60) + 1).fill(0).map((_, idx) => {+ return html `+ ${idx === 0 ? html `+ <div class="timelineHourMark style-scope controller-timeline">Nu</div>+ ` : html `+ <div class="timelineHourMark style-scope controller-timeline">+${idx}u</div>+ `}+ `;+ })}+ </div>++ <div class="slidecontainer">+ <input id="or-timeline-slider" class="slider" type="range" @input="${this.moveBubble}" @change="${this.valueChange}" value="${this.current}" min="${this.minRange}" max="${this.maxRange}" step="${this.step}">+ </div>+ </div>++ `;+ }+ moveBubble(e = null, value = null) {+ let el;+ if (e) {+ el = e.target;+ }+ else {+ el = this.shadowRoot.getElementById('or-timeline-slider');+ }+ if (el) {+ if (value) {+ this.current = parseInt(value);+ }+ else {+ this.current = parseInt(el.value);+ }+ // Measure width of range input+ const width = el.offsetWidth;+ const v = this.current;+ // Figure out placement percentage between left and right of input+ const newPoint = v / this.maxRange;+ // Janky value to get pointer to line up better+ let offset = 0;+ let newPlace;+ // Prevent bubble from going beyond left or right (unsupported browsers)+ if (newPoint < 0) {+ newPlace = 0;+ }+ else if (newPoint > 1) {+ newPlace = width;+ }+ else {+ newPlace = width * newPoint + offset;+ offset -= newPoint;+ }+ // Move bubble+ const range = this.shadowRoot.getElementById('range-value');+ range.style.left = newPlace + "px";+ }+ }+ valueChange(e) {+ this.moveBubble(e);+ this.onChange();+ }+}+__decorate([+ property({ type: Function })+], OrTimeline.prototype, "onChange", void 0);+__decorate([+ property({ type: Number })+], OrTimeline.prototype, "value", void 0);+__decorate([+ property({ type: Number })+], OrTimeline.prototype, "current", void 0);+__decorate([+ property({ type: Number })+], OrTimeline.prototype, "maxRange", void 0);+__decorate([+ property({ type: Number })+], OrTimeline.prototype, "minRange", void 0);+__decorate([+ property({ type: Number })+], OrTimeline.prototype, "step", void 0);+window.customElements.define('or-timeline', OrTimeline);+//# sourceMappingURL=index.js.map\ No newline at end of filediff --git a/ui/component/or-timeline/src/index.js.map b/ui/component/or-timeline/src/index.js.mapnew file mode 100644index 000000000..1db5746d6--- /dev/null+++ b/ui/component/or-timeline/src/index.js.map@@ -0,0 +1 @@+{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAEvD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,MAAM,UAAW,SAAQ,UAAU;IAoO/B;QACI,KAAK,EAAE,CAAC;QAnEZ,2BAA2B;QAEnB,UAAK,GAAW,CAAC,CAAC;QAE1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;SACtC;IAEL,CAAC;IAED,WAAW,CAAE,CAAC;QACV,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,QAAQ,EAAE,CAAC;IACpB,CAAC;CAOJ;AAzEG;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;4CACV;AAIjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yCACC;AAI1B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACE;AAI3B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACM;AAI/B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACI;AAI7B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;wCACA;AAuD7B,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC"}\ No newline at end of filediff --git a/ui/component/or-timeline/src/index.ts b/ui/component/or-timeline/src/index.tsnew file mode 100644index 000000000..64907b48a--- /dev/null+++ b/ui/component/or-timeline/src/index.ts@@ -0,0 +1,247 @@+import {html, LitElement, property} from 'lit-element';++import moment from 'moment';++class OrTimeline extends LitElement {+ protected render() {+ if(this.shadowRoot){+ const range:any = this.shadowRoot.getElementById('or-timeline-slider');+ if(range) {+ range.value = Math.round(this.current);+ this.moveBubble(range);+ }+ }++ return html`+ <style>+ :host {+ position: relative;+ }+ .timeline-container {+ display: block;+ height: 52px;+ background-color: var(--app-white, #FFFFFF);++ -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);+ box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);++ padding-top: 20px;+ }+ .slidecontainer {+ position: relative;+ margin: -5px 50px 0 30px;+ }++ /* The slider itself */+ .slider {+ box-sizing: border-box;+ -webkit-appearance: none; /* Override default CSS styles */+ appearance: none;+ width: calc(100% + 20px);+ margin-left: -10px;+ height: 12px;+ background: #bdbdbd; /* Grey background */+ outline: none; /* Remove outline */+ opacity: 1; /* Set transparency (for mouse-over effects on hover) */+ -webkit-transition: .2s; /* 0.2 seconds transition on hover */+ transition: opacity .2s;++ border-radius: 6px;+ }++ /* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */+ .slider::-webkit-slider-thumb {+ -webkit-appearance: none;+ appearance: none;+ width: 18px;+ height: 18px;+ margin: 0;+ border-radius: 50%;+ cursor: pointer;+ border: 0 !important;+ background-color: var(--timeline-accent, blue); /* Green background */+ }++ .slider::-ms-thumb,+ .slider::-moz-range-thumb,+ .slider::-webkit-slider-thumb {+ width: 18px;+ height: 18px;+ margin: 0;+ border-radius: 50%;+ cursor: pointer;+ border: 0 !important;+ background-color: var(--timeline-accent, blue); /* Green background */+ }++ #timelineHourMarkers {+ position: relative;+ display: -webkit-box;+ display: -moz-box;+ display: -ms-flexbox;+ display: -webkit-flex;+ display: flex;+ -webkit-box-orient: horizontal;+ -moz-box-orient: horizontal;+ -webkit-box-direction: normal;+ -moz-box-direction: normal;+ -webkit-flex-direction: row;+ -ms-flex-direction: row;+ flex-direction: row;++ margin: 0 50px 0 30px;+ }++ #timelineHourMarkers > .timelineHourMark{+ display: flex;+ flex: 1 100%;+ flex-grow: 1;+ flex-shrink: 1;+ flex-basis: 100%;++ overflow: visible;+ color: #dcdcdc;+ border-left: 1px solid #dcdcdc;+ font-size: 12px;+ -webkit-user-select: none;+ -moz-user-select: none;+ -ms-user-select: none;+ user-select: none;+ padding-left: 4px;+ padding-bottom: 4px;+ }+ #timelineHourMarkers .timelineHourMark:last-child {+ position: absolute;+ right: -25px;+ }++ #range-value {+ position: absolute;+ background-color: var(--timeline-accent, blue);+ height: 30px;+ width: 60px;+ text-align: center;+ color: white;+ display: inline-block;+ left: 0;+ font-size: 12px;+ font-weight: bold;+ line-height: 30px;+ }++ .time-value-container {+ width: 100%;+ display: block;+ position: relative;+ height: 30px;+ }+ </style>+++ <div class="time-value-container">+ <div id="range-value">${this.current === 0 ? 'LIVE' : moment().add(this.current, 'minutes').format('HH:mm')}</div>+ </div>+ <div class="timeline-container">+ <div id="timelineHourMarkers" class="layout horizontal justified style-scope controller-timeline">+ ${new Array((this.maxRange/60)+1).fill(0).map((_, idx) => {+ return html`+ ${idx === 0 ? html`+ <div class="timelineHourMark style-scope controller-timeline">Nu</div>+ ` : html`+ <div class="timelineHourMark style-scope controller-timeline">+${idx}u</div>+ `}+ `})}+ </div>++ <div class="slidecontainer">+ <input id="or-timeline-slider" class="slider" type="range" @input="${this.moveBubble}" @change="${this.valueChange}" value="${this.current}" min="${this.minRange}" max="${this.maxRange}" step="${this.step}">+ </div>+ </div>++ `;+ }+ // default value in minutes+ @property({type: Function})+ private onChange: any;++ // default value in minutes+ @property({type: Number})+ private value: number = 0;++ // default value in minutes+ @property({type: Number})+ public current: number = 0;++ // maxRange in minutes+ @property({type: Number})+ private maxRange: number = 360;++ // minRange in minutes+ @property({type: Number})+ private minRange: number = 0;++ // Steps in minutes+ @property({type: Number})+ private step: number = 5;++ moveBubble(e:any=null, value:string|null=null) {+ let el;+ if(e){+ el = e.target;+ } else {+ if(this.shadowRoot){+ el = this.shadowRoot.getElementById('or-timeline-slider');+ }+ }++ if(el) {+ if(value){+ this.current = parseInt(value);+ } else {+ this.current = parseInt(el.value);+ }+ // Measure width of range input+ const width = el.offsetWidth;+ const v = this.current;++ // Figure out placement percentage between left and right of input+ const newPoint = v / this.maxRange;+ // Janky value to get pointer to line up better+ let offset = 0;+ let newPlace;++ // Prevent bubble from going beyond left or right (unsupported browsers)+ if (newPoint < 0) {+ newPlace = 0;+ } else if (newPoint > 1) {+ newPlace = width;+ } else {+ newPlace = width * newPoint + offset;+ offset -= newPoint;+ }++ // Move bubble+ if(this.shadowRoot) {+ const range:HTMLElement | null = this.shadowRoot.getElementById('range-value');+ if(range){+ range.style.left = newPlace + "px";+ }+ }+ }++ }++ valueChange (e:any) {+ this.moveBubble(e);+ this.onChange();+ }++ constructor() {+ super();+ }+++}++window.customElements.define('or-timeline', OrTimeline);diff --git a/ui/component/or-timeline/tsconfig.json b/ui/component/or-timeline/tsconfig.jsonnew file mode 100644index 000000000..aa12a532d--- /dev/null+++ b/ui/component/or-timeline/tsconfig.json@@ -0,0 +1,14 @@+{+ "extends": "../../tsconfig",+ "compilerOptions": {+ "outDir": "./dist/",+ "rootDir": "src"+ },+ "include": [+ "./src"+ ],+ "references": [+ { "path": "../core" },+ { "path": "../rest" }+ ]+}\ No newline at end of file