@openremote/or-smart-notify 1.0.0 → 1.2.0-snapshot.20240512154942

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,21 +1,31 @@
1
- # \<or-header\>
1
+ # @openremote/or-smart-notify \<or-smart-notify\>
2
+ [![NPM Version][npm-image]][npm-url]
3
+ [![Linux Build][travis-image]][travis-url]
4
+ [![Test Coverage][coveralls-image]][coveralls-url]
2
5
 
3
- Displays header with menu based on slots.
6
+ Web Component for displaying a smart notify control.
4
7
 
5
- ## Install the Polymer-CLI
8
+ ## Install
9
+ ```bash
10
+ npm i @openremote/or-smart-notify
11
+ yarn add @openremote/or-smart-notify
12
+ ```
6
13
 
7
- First, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) and npm (packaged with [Node.js](https://nodejs.org)) installed. Run `npm install` to install your element's dependencies, then run `polymer serve` to serve your element locally.
14
+ ## Usage
15
+ For a full list of properties, methods and options refer to the TypeDoc generated [documentation]().
8
16
 
9
- ## Viewing Your Element
10
17
 
11
- ```
12
- $ polymer serve
13
- ```
18
+ ## Supported Browsers
19
+ The last 2 versions of all modern browsers are supported, including Chrome, Safari, Opera, Firefox, Edge. In addition,
20
+ Internet Explorer 11 is also supported.
14
21
 
15
- ## Running Tests
16
22
 
17
- ```
18
- $ polymer test
19
- ```
23
+ ## License
24
+ [GNU AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)
20
25
 
21
- Your application is already set up to be tested via [web-component-tester](https://github.com/Polymer/web-component-tester). Run `polymer test` to run your application's test suite locally.
26
+ [npm-image]: https://img.shields.io/npm/v/live-xxx.svg
27
+ [npm-url]: https://npmjs.org/package/@openremote/or-smart-notify
28
+ [travis-image]: https://img.shields.io/travis/live-js/live-xxx/master.svg
29
+ [travis-url]: https://travis-ci.org/live-js/live-xxx
30
+ [coveralls-image]: https://img.shields.io/coveralls/live-js/live-xxx/master.svg
31
+ [coveralls-url]: https://coveralls.io/r/live-js/live-xxx?branch=master
package/package.json CHANGED
@@ -1,31 +1,34 @@
1
1
  {
2
2
  "name": "@openremote/or-smart-notify",
3
- "version": "1.0.0",
3
+ "version": "1.2.0-snapshot.20240512154942",
4
4
  "description": "OpenRemote Smarty Notify element",
5
- "main": "dist/index.js",
6
- "types": "src/index.ts",
5
+ "main": "dist/umd/index.bundle.js",
6
+ "module": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./*": "./lib/*.js"
10
+ },
11
+ "types": "lib/index.d.ts",
7
12
  "scripts": {
8
- "build": "npx tsc",
9
- "test": "echo \"No tests\" && exit 0"
13
+ "test": "echo \"No tests\" && exit 0",
14
+ "prepublishOnly": "npx webpack"
10
15
  },
11
16
  "author": "OpenRemote",
12
17
  "license": "AGPL-3.0-or-later",
13
18
  "dependencies": {
14
- "@openremote/rest": "^1.0.0",
15
- "@openremote/model": "^1.0.0",
16
- "lit-element": "^2.0.1",
17
19
  "@fortawesome/fontawesome-svg-core": "^1.2.12",
18
- "@fortawesome/free-solid-svg-icons": "^5.6.3",
19
20
  "@fortawesome/free-regular-svg-icons": "^5.6.3",
20
- "moment": "^2.24.0"
21
+ "@fortawesome/free-solid-svg-icons": "^5.6.3",
22
+ "@openremote/core": "1.2.0-snapshot.20240512154942",
23
+ "@openremote/model": "1.2.0-snapshot.20240512154942",
24
+ "@openremote/rest": "1.2.0-snapshot.20240512154942",
25
+ "lit": "^2.0.2",
26
+ "moment": "^2.29.4"
21
27
  },
22
28
  "devDependencies": {
23
- "@polymer/decorators": "^3.0.0",
24
- "@polymer/iron-demo-helpers": "^3.0.0-pre.19",
25
- "@webcomponents/webcomponentsjs": "^2.0.0",
26
- "style-loader": "^0.23.1",
27
- "tslint": "^5.11.0",
28
- "typescript": "^3.2.2",
29
- "wct-browser-legacy": "^1.0.0"
29
+ "@openremote/util": "1.2.0-snapshot.20240512154942"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
30
33
  }
31
- }
34
+ }
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/index.js DELETED
@@ -1,331 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { html, LitElement, property, customElement } from 'lit-element';
8
- import moment from 'moment';
9
- import { icon } from '@fortawesome/fontawesome-svg-core';
10
- import { faClock } from '@fortawesome/free-regular-svg-icons';
11
- import { faTimes } from '@fortawesome/free-solid-svg-icons';
12
- import REST from "@openremote/rest";
13
- let OrSmartNotify = class OrSmartNotify extends LitElement {
14
- constructor() {
15
- super();
16
- // if smart notify popup is visible
17
- this.isVisible = false;
18
- // If smart notify is active
19
- this.isActive = false;
20
- // If smart notify is active
21
- this.isDisabled = false;
22
- // If smart notify is active
23
- this.smartNotify = {};
24
- // default function on smartyNotify
25
- this.currentTime = '-';
26
- const self = this;
27
- this.currentTime = moment().format('HH:mm');
28
- setInterval(function () {
29
- self.currentTime = moment().format('HH:mm');
30
- }, 500);
31
- }
32
- render() {
33
- // language=HTML
34
- return html `
35
- <style>
36
- #smartNotifyControlPanel {
37
- position: fixed;
38
- left: 20px;
39
- bottom: 146px;
40
- width: 315px;
41
- z-index: 2;
42
- background-color: #FFFFFF;
43
-
44
- -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
45
- -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
46
- box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
47
- }
48
- .layout.horizontal {
49
- display: -ms-flexbox;
50
- display: -webkit-flex;
51
- display: flex;
52
-
53
- -ms-flex-direction: row;
54
- -webkit-flex-direction: row;
55
- flex-direction: row;
56
-
57
-
58
- -ms-flex-align: center;
59
- -webkit-align-items: center;
60
- align-items: center;
61
-
62
- -ms-flex-pack: center;
63
- -webkit-justify-content: center;
64
- justify-content: center;
65
- }
66
-
67
- .t-center {
68
- text-align: center;
69
- }
70
-
71
- .controller-timeline{
72
- padding: 5px 20px;
73
- height: 32px;
74
- line-height: 32px;
75
- border-bottom: solid 1px #dedede;
76
- }
77
-
78
- .flex {
79
- -ms-flex: 1 1 0.000000001px;
80
- -webkit-flex: 1;
81
- flex: 1;
82
- -webkit-flex-basis: 0.000000001px;
83
- flex-basis: 0.000000001px;
84
- }
85
-
86
- .padding-2-5 {
87
- padding: 2px 5px;
88
- }
89
- .padding-10 {
90
- padding: 10px;
91
- }
92
- #smart-notify-toggle {
93
- margin-top: 29px;
94
- }
95
-
96
- .smart-notify-toggle-label {
97
- color: #FFFFFF;
98
- background-color: #00477c;
99
- border-top-left-radius: 5px;
100
- border-top-right-radius: 5px;
101
- padding: 2px 8px;
102
- font-size: 12px;
103
- height: 19px;
104
- }
105
-
106
- .smart-notify-toggle-icon {
107
- background-color: #555753;
108
- border-bottom-left-radius: 5px;
109
- border-bottom-right-radius: 5px;
110
- margin-top: 2px;
111
- height: 48px;
112
- }
113
-
114
- .smart-notify-toggle-icon[active] {
115
- background-color: #00477c;
116
- }
117
-
118
- icon {
119
- height: 20px;
120
- width: 20px;
121
- }
122
-
123
- icon .svg-inline--fa {
124
- height: 20px;
125
- width: 20px;
126
- }
127
-
128
- icon[large] {
129
- height: 28px;
130
- width: 28px;
131
- }
132
-
133
- icon[large] .svg-inline--fa {
134
- height: 28px;
135
- width: 28px;
136
- margin: 10px;
137
- }
138
-
139
- icon[large] svg path {
140
- fill: #FFFFFF;
141
- color: #FFFFFF;
142
- }
143
-
144
- /* The switch - the box around the slider */
145
- .switch {
146
- position: relative;
147
- display: inline-block;
148
- width: 36px;
149
- height: 14px;
150
- margin: 10px 0;
151
- }
152
-
153
- /* Hide default HTML checkbox */
154
- .switch input {
155
- opacity: 0;
156
- width: 0;
157
- height: 0;
158
- }
159
-
160
- /* The slider */
161
- .slider {
162
- position: absolute;
163
- cursor: pointer;
164
- top: 0;
165
- left: 0;
166
- right: 0;
167
- bottom: 0;
168
- background-color: #ccc;
169
- -webkit-transition: .4s;
170
- transition: .4s;
171
- }
172
-
173
- .slider:before {
174
- position: absolute;
175
- content: "";
176
- height: 20px;
177
- width: 20px;
178
- left: 0;
179
- top: -3px;
180
- background-color: white;
181
- -webkit-transition: .4s;
182
- transition: .4s;
183
- box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);
184
- }
185
-
186
- input:checked + .slider:before {
187
- background-color: var(--app-primary-color);
188
- }
189
-
190
- input:focus + .slider {
191
- }
192
-
193
- input:checked + .slider:before {
194
- -webkit-transform: translateX(20px);
195
- -ms-transform: translateX(20px);
196
- transform: translateX(20px);
197
- }
198
-
199
- /* Rounded sliders */
200
- .slider.round {
201
- border-radius: 34px;
202
- }
203
-
204
- .slider.round:before {
205
- border-radius: 50%;
206
- }
207
- </style>
208
-
209
- ${this.isVisible ? html `
210
- <div id="smartNotifyControlPanel">
211
- <div class="layout horizontal controller-timeline t-center">
212
- <icon>${icon(faClock).node.item(0)}</icon>
213
- <div class="flex padding-2-5" style="font-weight: 600;">Smart Notify</div>
214
-
215
- <a style="height: 22px;" @click="${this.close}">
216
- <icon>${icon(faTimes).node.item(0)}</icon>
217
- </a>
218
- </div>
219
- <div class="layout horizontal">
220
- <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Wachttijd berekenen</div>
221
- <div class="flex t-center">
222
- <label class="switch">
223
- <input @change="${this.setSmartNotify}" ?disabled="${this.isDisabled}" ?checked="${this.isActive}" type="checkbox">
224
- <span class="slider round"></span>
225
- </label>
226
- </div>
227
- </div>
228
- ${this.isActive ? html `
229
- <div class="layout horizontal">
230
- <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Starttijd</div>
231
- <div class="flex t-center">${this.isActive ? moment(this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp).format('HH:mm') : "-"}</div>
232
- </div>
233
- ` : ``}
234
- </div>
235
- ` : ``}
236
- <div id="smart-notify-toggle" @click="${this.toggleVisibility}">
237
- <div class="smart-notify-toggle-label">${this.currentTime}</div>
238
- <div class="smart-notify-toggle-icon" ?active="${this.isActive}">
239
- <icon large>${icon(faClock).node.item(0)}</icon>
240
- </div>
241
- </div>
242
-
243
- `;
244
- }
245
- getSmartNotify() {
246
- const self = this;
247
- return new Promise(function (resolve, reject) {
248
- const smartNotifyQuery = {
249
- name: { predicateType: "string", value: "SMART_NOTIFY_ASSET" },
250
- select: { include: "ALL_EXCEPT_PATH" /* ALL_EXCEPT_PATH */ }
251
- };
252
- REST.api.AssetResource.queryAssets(smartNotifyQuery).then(response => {
253
- console.log("Setting Smart Notify");
254
- if (response.data) {
255
- self.smartNotify = response.data[0];
256
- self.isActive = self.smartNotify.attributes.SMART_NOTIFY_ENABLED.value ? true : false;
257
- self.onChange();
258
- resolve(response);
259
- }
260
- }).catch(reason => {
261
- reject(Error("Error:" + reason));
262
- console.log("Error:" + reason);
263
- });
264
- });
265
- }
266
- checkSmartNotifyMarkers() {
267
- const self = this;
268
- if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length > 0) {
269
- }
270
- else if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length === 0) {
271
- this.getSmartNotify().then(() => {
272
- setTimeout(function () {
273
- self.checkSmartNotifyMarkers();
274
- }.bind(this), 3000);
275
- });
276
- }
277
- }
278
- setSmartNotify(e) {
279
- const isChecked = e.target.checked;
280
- if (isChecked == true) {
281
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = moment();
282
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp = moment();
283
- this.isActive = true;
284
- }
285
- else {
286
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = null;
287
- this.isActive = false;
288
- }
289
- REST.api.AssetResource.update(this.smartNotify.id, this.smartNotify).then(response => {
290
- console.log("Setting Smart Notify");
291
- this.smartNotify.version = this.smartNotify.version + 1;
292
- if (isChecked == true) {
293
- this.checkSmartNotifyMarkers();
294
- }
295
- else {
296
- // Clear the smartnotify markers and smart notify in frontend
297
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = false;
298
- this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers = [];
299
- this.onChange();
300
- }
301
- }).catch(reason => console.log("Error:" + reason));
302
- }
303
- close() {
304
- this.isVisible = false;
305
- }
306
- toggleVisibility() {
307
- this.isVisible = !this.isVisible;
308
- }
309
- };
310
- __decorate([
311
- property({ type: Function })
312
- ], OrSmartNotify.prototype, "onChange", void 0);
313
- __decorate([
314
- property({ type: Boolean })
315
- ], OrSmartNotify.prototype, "isVisible", void 0);
316
- __decorate([
317
- property({ type: Boolean })
318
- ], OrSmartNotify.prototype, "isActive", void 0);
319
- __decorate([
320
- property({ type: Boolean })
321
- ], OrSmartNotify.prototype, "isDisabled", void 0);
322
- __decorate([
323
- property({ type: Object })
324
- ], OrSmartNotify.prototype, "smartNotify", void 0);
325
- __decorate([
326
- property({ type: String })
327
- ], OrSmartNotify.prototype, "currentTime", void 0);
328
- OrSmartNotify = __decorate([
329
- customElement('or-smart-notify')
330
- ], OrSmartNotify);
331
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAEtE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAC,IAAI,EAAC,MAAM,mC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AI,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;AA5OhC,aAAa;IADlB,aAAa,CAAC,iBAAiB,CAAC;GAC3B,aAAa,CA+TlB"}
package/src/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/src/index.js DELETED
@@ -1,326 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { html, LitElement, property } from 'lit-element';
8
- import moment from 'moment';
9
- import { icon } from '@fortawesome/fontawesome-svg-core';
10
- import { faClock } from '@fortawesome/free-regular-svg-icons';
11
- import { faTimes } from '@fortawesome/free-solid-svg-icons';
12
- import REST from "@openremote/rest";
13
- class OrSmartNotify extends LitElement {
14
- constructor() {
15
- super();
16
- // if smart notify popup is visible
17
- this.isVisible = false;
18
- // If smart notify is active
19
- this.isActive = false;
20
- // If smart notify is active
21
- this.isDisabled = false;
22
- // If smart notify is active
23
- this.smartNotify = {};
24
- // default function on smartyNotify
25
- this.currentTime = '-';
26
- this.currentTime = moment().format('HH:mm');
27
- setInterval(function () {
28
- this.currentTime = moment().format('HH:mm');
29
- }.bind(this), 500);
30
- }
31
- render() {
32
- // language=HTML
33
- return html `
34
- <style>
35
- #smartNotifyControlPanel {
36
- position: fixed;
37
- left: 20px;
38
- bottom: 146px;
39
- width: 315px;
40
- z-index: 2;
41
- background-color: #FFFFFF;
42
-
43
- -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
44
- -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
45
- box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
46
- }
47
- .layout.horizontal {
48
- display: -ms-flexbox;
49
- display: -webkit-flex;
50
- display: flex;
51
-
52
- -ms-flex-direction: row;
53
- -webkit-flex-direction: row;
54
- flex-direction: row;
55
-
56
-
57
- -ms-flex-align: center;
58
- -webkit-align-items: center;
59
- align-items: center;
60
-
61
- -ms-flex-pack: center;
62
- -webkit-justify-content: center;
63
- justify-content: center;
64
- }
65
-
66
- .t-center {
67
- text-align: center;
68
- }
69
-
70
- .controller-timeline{
71
- padding: 5px 20px;
72
- height: 32px;
73
- line-height: 32px;
74
- border-bottom: solid 1px #dedede;
75
- }
76
-
77
- .flex {
78
- -ms-flex: 1 1 0.000000001px;
79
- -webkit-flex: 1;
80
- flex: 1;
81
- -webkit-flex-basis: 0.000000001px;
82
- flex-basis: 0.000000001px;
83
- }
84
-
85
- .padding-2-5 {
86
- padding: 2px 5px;
87
- }
88
- .padding-10 {
89
- padding: 10px;
90
- }
91
- #smart-notify-toggle {
92
- margin-top: 29px;
93
- }
94
-
95
- .smart-notify-toggle-label {
96
- color: #FFFFFF;
97
- background-color: #00477c;
98
- border-top-left-radius: 5px;
99
- border-top-right-radius: 5px;
100
- padding: 2px 8px;
101
- font-size: 12px;
102
- height: 19px;
103
- }
104
-
105
- .smart-notify-toggle-icon {
106
- background-color: #555753;
107
- border-bottom-left-radius: 5px;
108
- border-bottom-right-radius: 5px;
109
- margin-top: 2px;
110
- height: 48px;
111
- }
112
-
113
- .smart-notify-toggle-icon[active] {
114
- background-color: #00477c;
115
- }
116
-
117
- icon {
118
- height: 20px;
119
- width: 20px;
120
- }
121
-
122
- icon .svg-inline--fa {
123
- height: 20px;
124
- width: 20px;
125
- }
126
-
127
- icon[large] {
128
- height: 28px;
129
- width: 28px;
130
- }
131
-
132
- icon[large] .svg-inline--fa {
133
- height: 28px;
134
- width: 28px;
135
- margin: 10px;
136
- }
137
-
138
- icon[large] svg path {
139
- fill: #FFFFFF;
140
- color: #FFFFFF;
141
- }
142
-
143
- /* The switch - the box around the slider */
144
- .switch {
145
- position: relative;
146
- display: inline-block;
147
- width: 36px;
148
- height: 14px;
149
- margin: 10px 0;
150
- }
151
-
152
- /* Hide default HTML checkbox */
153
- .switch input {
154
- opacity: 0;
155
- width: 0;
156
- height: 0;
157
- }
158
-
159
- /* The slider */
160
- .slider {
161
- position: absolute;
162
- cursor: pointer;
163
- top: 0;
164
- left: 0;
165
- right: 0;
166
- bottom: 0;
167
- background-color: #ccc;
168
- -webkit-transition: .4s;
169
- transition: .4s;
170
- }
171
-
172
- .slider:before {
173
- position: absolute;
174
- content: "";
175
- height: 20px;
176
- width: 20px;
177
- left: 0;
178
- top: -3px;
179
- background-color: white;
180
- -webkit-transition: .4s;
181
- transition: .4s;
182
- box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);
183
- }
184
-
185
- input:checked + .slider:before {
186
- background-color: var(--app-primary-color);
187
- }
188
-
189
- input:focus + .slider {
190
- }
191
-
192
- input:checked + .slider:before {
193
- -webkit-transform: translateX(20px);
194
- -ms-transform: translateX(20px);
195
- transform: translateX(20px);
196
- }
197
-
198
- /* Rounded sliders */
199
- .slider.round {
200
- border-radius: 34px;
201
- }
202
-
203
- .slider.round:before {
204
- border-radius: 50%;
205
- }
206
- </style>
207
-
208
- ${this.isVisible ? html `
209
- <div id="smartNotifyControlPanel">
210
- <div class="layout horizontal controller-timeline t-center">
211
- <icon>${icon(faClock).node.item(0)}</icon>
212
- <div class="flex padding-2-5" style="font-weight: 600;">Smart Notify</div>
213
-
214
- <a style="height: 22px;" @click="${this.close}">
215
- <icon>${icon(faTimes).node.item(0)}</icon>
216
- </a>
217
- </div>
218
- <div class="layout horizontal">
219
- <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Wachttijd berekenen</div>
220
- <div class="flex t-center">
221
- <label class="switch">
222
- <input @change="${this.setSmartNotify}" ?disabled="${this.isDisabled}" ?checked="${this.isActive}" type="checkbox">
223
- <span class="slider round"></span>
224
- </label>
225
- </div>
226
- </div>
227
- ${this.isActive ? html `
228
- <div class="layout horizontal">
229
- <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Starttijd</div>
230
- <div class="flex t-center">${this.isActive ? moment(this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp).format('HH:mm') : "-"}</div>
231
- </div>
232
- ` : ``}
233
- </div>
234
- ` : ``}
235
- <div id="smart-notify-toggle" @click="${this.toggleVisibility}">
236
- <div class="smart-notify-toggle-label">${this.currentTime}</div>
237
- <div class="smart-notify-toggle-icon" ?active="${this.isActive}">
238
- <icon large>${icon(faClock).node.item(0)}</icon>
239
- </div>
240
- </div>
241
-
242
- `;
243
- }
244
- getSmartNotify() {
245
- return new Promise(function (resolve, reject) {
246
- const smartNotifyQuery = {
247
- name: { predicateType: "string", value: "SMART_NOTIFY_ASSET" },
248
- select: { include: "ALL_EXCEPT_PATH" /* ALL_EXCEPT_PATH */ }
249
- };
250
- REST.api.AssetResource.queryAssets(smartNotifyQuery).then(response => {
251
- console.log("Setting Smart Notify");
252
- if (response.data) {
253
- this.smartNotify = response.data[0];
254
- this.isActive = this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value ? true : false;
255
- this.onChange();
256
- resolve(response);
257
- }
258
- }).catch(reason => {
259
- reject(Error("Error:" + reason));
260
- console.log("Error:" + reason);
261
- });
262
- }.bind(this));
263
- }
264
- checkSmartNotifyMarkers() {
265
- if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length > 0) {
266
- }
267
- else if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length === 0) {
268
- this.getSmartNotify().then(() => {
269
- setTimeout(function () {
270
- this.checkSmartNotifyMarkers();
271
- }.bind(this), 3000);
272
- });
273
- }
274
- }
275
- setSmartNotify(e) {
276
- const isChecked = e.target.checked;
277
- if (isChecked == true) {
278
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = moment();
279
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp = moment();
280
- this.isActive = true;
281
- }
282
- else {
283
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = null;
284
- this.isActive = false;
285
- }
286
- REST.api.AssetResource.update(this.smartNotify.id, this.smartNotify).then(response => {
287
- console.log("Setting Smart Notify");
288
- this.smartNotify.version = this.smartNotify.version + 1;
289
- if (isChecked == true) {
290
- this.checkSmartNotifyMarkers();
291
- }
292
- else {
293
- // Clear the smartnotify markers and smart notify in frontend
294
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = false;
295
- this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers = [];
296
- this.onChange();
297
- }
298
- }).catch(reason => console.log("Error:" + reason));
299
- }
300
- close() {
301
- this.isVisible = false;
302
- }
303
- toggleVisibility() {
304
- this.isVisible = !this.isVisible;
305
- }
306
- }
307
- __decorate([
308
- property({ type: Function })
309
- ], OrSmartNotify.prototype, "onChange", void 0);
310
- __decorate([
311
- property({ type: Boolean })
312
- ], OrSmartNotify.prototype, "isVisible", void 0);
313
- __decorate([
314
- property({ type: Boolean })
315
- ], OrSmartNotify.prototype, "isActive", void 0);
316
- __decorate([
317
- property({ type: Boolean })
318
- ], OrSmartNotify.prototype, "isDisabled", void 0);
319
- __decorate([
320
- property({ type: Object })
321
- ], OrSmartNotify.prototype, "smartNotify", void 0);
322
- __decorate([
323
- property({ type: String })
324
- ], OrSmartNotify.prototype, "currentTime", void 0);
325
- window.customElements.define('or-smart-notify', OrSmartNotify);
326
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +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,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAE5C,WAAW,CAAC;YACR,IAAI,CAAC,WAAW,GAAG,MAAM,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACvB,CAAC;IA1TS,MAAM;QACZ,gBAAgB;QAChB,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AK,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"}
package/src/index.ts DELETED
@@ -1,333 +0,0 @@
1
- import {html, LitElement, property, customElement} from 'lit-element';
2
-
3
- import moment from 'moment';
4
-
5
- import {icon} from '@fortawesome/fontawesome-svg-core'
6
- import {faClock} from '@fortawesome/free-regular-svg-icons';
7
- import {faTimes} from '@fortawesome/free-solid-svg-icons';
8
-
9
- import REST from "@openremote/rest";
10
- import {AssetQuery, BaseAssetQueryInclude} from "@openremote/model";
11
-
12
- @customElement('or-smart-notify')
13
- class OrSmartNotify extends LitElement {
14
- protected render() {
15
- // language=HTML
16
- return html`
17
- <style>
18
- #smartNotifyControlPanel {
19
- position: fixed;
20
- left: 20px;
21
- bottom: 146px;
22
- width: 315px;
23
- z-index: 2;
24
- background-color: #FFFFFF;
25
-
26
- -webkit-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
27
- -moz-box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
28
- box-shadow: 1px 1px 2px 0px rgba(0,0,0,0.28);
29
- }
30
- .layout.horizontal {
31
- display: -ms-flexbox;
32
- display: -webkit-flex;
33
- display: flex;
34
-
35
- -ms-flex-direction: row;
36
- -webkit-flex-direction: row;
37
- flex-direction: row;
38
-
39
-
40
- -ms-flex-align: center;
41
- -webkit-align-items: center;
42
- align-items: center;
43
-
44
- -ms-flex-pack: center;
45
- -webkit-justify-content: center;
46
- justify-content: center;
47
- }
48
-
49
- .t-center {
50
- text-align: center;
51
- }
52
-
53
- .controller-timeline{
54
- padding: 5px 20px;
55
- height: 32px;
56
- line-height: 32px;
57
- border-bottom: solid 1px #dedede;
58
- }
59
-
60
- .flex {
61
- -ms-flex: 1 1 0.000000001px;
62
- -webkit-flex: 1;
63
- flex: 1;
64
- -webkit-flex-basis: 0.000000001px;
65
- flex-basis: 0.000000001px;
66
- }
67
-
68
- .padding-2-5 {
69
- padding: 2px 5px;
70
- }
71
- .padding-10 {
72
- padding: 10px;
73
- }
74
- #smart-notify-toggle {
75
- margin-top: 29px;
76
- }
77
-
78
- .smart-notify-toggle-label {
79
- color: #FFFFFF;
80
- background-color: #00477c;
81
- border-top-left-radius: 5px;
82
- border-top-right-radius: 5px;
83
- padding: 2px 8px;
84
- font-size: 12px;
85
- height: 19px;
86
- }
87
-
88
- .smart-notify-toggle-icon {
89
- background-color: #555753;
90
- border-bottom-left-radius: 5px;
91
- border-bottom-right-radius: 5px;
92
- margin-top: 2px;
93
- height: 48px;
94
- }
95
-
96
- .smart-notify-toggle-icon[active] {
97
- background-color: #00477c;
98
- }
99
-
100
- icon {
101
- height: 20px;
102
- width: 20px;
103
- }
104
-
105
- icon .svg-inline--fa {
106
- height: 20px;
107
- width: 20px;
108
- }
109
-
110
- icon[large] {
111
- height: 28px;
112
- width: 28px;
113
- }
114
-
115
- icon[large] .svg-inline--fa {
116
- height: 28px;
117
- width: 28px;
118
- margin: 10px;
119
- }
120
-
121
- icon[large] svg path {
122
- fill: #FFFFFF;
123
- color: #FFFFFF;
124
- }
125
-
126
- /* The switch - the box around the slider */
127
- .switch {
128
- position: relative;
129
- display: inline-block;
130
- width: 36px;
131
- height: 14px;
132
- margin: 10px 0;
133
- }
134
-
135
- /* Hide default HTML checkbox */
136
- .switch input {
137
- opacity: 0;
138
- width: 0;
139
- height: 0;
140
- }
141
-
142
- /* The slider */
143
- .slider {
144
- position: absolute;
145
- cursor: pointer;
146
- top: 0;
147
- left: 0;
148
- right: 0;
149
- bottom: 0;
150
- background-color: #ccc;
151
- -webkit-transition: .4s;
152
- transition: .4s;
153
- }
154
-
155
- .slider:before {
156
- position: absolute;
157
- content: "";
158
- height: 20px;
159
- width: 20px;
160
- left: 0;
161
- top: -3px;
162
- background-color: white;
163
- -webkit-transition: .4s;
164
- transition: .4s;
165
- box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.6);
166
- }
167
-
168
- input:checked + .slider:before {
169
- background-color: var(--app-primary-color);
170
- }
171
-
172
- input:focus + .slider {
173
- }
174
-
175
- input:checked + .slider:before {
176
- -webkit-transform: translateX(20px);
177
- -ms-transform: translateX(20px);
178
- transform: translateX(20px);
179
- }
180
-
181
- /* Rounded sliders */
182
- .slider.round {
183
- border-radius: 34px;
184
- }
185
-
186
- .slider.round:before {
187
- border-radius: 50%;
188
- }
189
- </style>
190
-
191
- ${this.isVisible ? html`
192
- <div id="smartNotifyControlPanel">
193
- <div class="layout horizontal controller-timeline t-center">
194
- <icon>${icon(faClock).node.item(0)}</icon>
195
- <div class="flex padding-2-5" style="font-weight: 600;">Smart Notify</div>
196
-
197
- <a style="height: 22px;" @click="${this.close}">
198
- <icon>${icon(faTimes).node.item(0)}</icon>
199
- </a>
200
- </div>
201
- <div class="layout horizontal">
202
- <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Wachttijd berekenen</div>
203
- <div class="flex t-center">
204
- <label class="switch">
205
- <input @change="${this.setSmartNotify}" ?disabled="${this.isDisabled}" ?checked="${this.isActive}" type="checkbox">
206
- <span class="slider round"></span>
207
- </label>
208
- </div>
209
- </div>
210
- ${this.isActive ? html`
211
- <div class="layout horizontal">
212
- <div style="background-color: var(--app-lightgrey-color, #dedede);" class="flex padding-10">Starttijd</div>
213
- <div class="flex t-center">${this.isActive ? moment(this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp).format('HH:mm') : "-"}</div>
214
- </div>
215
- ` : ``}
216
- </div>
217
- ` : ``}
218
- <div id="smart-notify-toggle" @click="${this.toggleVisibility}">
219
- <div class="smart-notify-toggle-label">${this.currentTime}</div>
220
- <div class="smart-notify-toggle-icon" ?active="${this.isActive}">
221
- <icon large>${icon(faClock).node.item(0)}</icon>
222
- </div>
223
- </div>
224
-
225
- `;
226
- }
227
- // default function on smartyNotify
228
- @property({type: Function})
229
- private onChange: any;
230
-
231
- // if smart notify popup is visible
232
- @property({type: Boolean})
233
- private isVisible: boolean = false;
234
-
235
- // If smart notify is active
236
- @property({type: Boolean})
237
- private isActive: boolean = false;
238
-
239
- // If smart notify is active
240
- @property({type: Boolean})
241
- private isDisabled: boolean = false;
242
-
243
- // If smart notify is active
244
- @property({type: Object})
245
- private smartNotify: any = {};
246
-
247
- // default function on smartyNotify
248
- @property({type: String})
249
- private currentTime: string = '-';
250
-
251
- getSmartNotify() {
252
- const self:any = this;
253
- return new Promise(function(resolve: any, reject: any) {
254
- const smartNotifyQuery: AssetQuery = {
255
- name: {predicateType: "string", value: "SMART_NOTIFY_ASSET"},
256
- select: {include: BaseAssetQueryInclude.ALL_EXCEPT_PATH}
257
- };
258
- REST.api.AssetResource.queryAssets(smartNotifyQuery).then((response: any) => {
259
- console.log("Setting Smart Notify");
260
- if (response.data) {
261
- self.smartNotify = response.data[0];
262
- self.isActive = self.smartNotify.attributes.SMART_NOTIFY_ENABLED.value ? true : false;
263
- self.onChange();
264
- resolve(response);
265
- }
266
-
267
- }).catch((reason:any) => {
268
- reject(Error("Error:" + reason));
269
- console.log("Error:" + reason)
270
- });
271
-
272
- });
273
- }
274
-
275
- checkSmartNotifyMarkers() {
276
- const self:any = this;
277
- if(this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length > 0) {
278
- } else if (this.isActive && this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers.length === 0) {
279
- this.getSmartNotify().then(()=> {
280
- setTimeout(function(){
281
- self.checkSmartNotifyMarkers();
282
- }.bind(this), 3000);
283
- });
284
- }
285
- }
286
-
287
- setSmartNotify(e:any) {
288
- const isChecked = e.target.checked;
289
- if (isChecked == true) {
290
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = moment();
291
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.valueTimestamp = moment();
292
- this.isActive = true;
293
- } else {
294
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = null;
295
- this.isActive = false;
296
- }
297
- REST.api.AssetResource.update(this.smartNotify.id, this.smartNotify).then((response:any) => {
298
- console.log("Setting Smart Notify");
299
- this.smartNotify.version = this.smartNotify.version+1;
300
- if(isChecked == true){
301
- this.checkSmartNotifyMarkers();
302
- } else {
303
-
304
- // Clear the smartnotify markers and smart notify in frontend
305
- this.smartNotify.attributes.SMART_NOTIFY_ENABLED.value = false;
306
- this.smartNotify.attributes.SMART_NOTIFY_RESULT.value.markers = [];
307
- this.onChange();
308
- }
309
-
310
- }).catch((reason:any) => console.log("Error:" + reason));
311
- }
312
-
313
- close() {
314
- this.isVisible = false;
315
- }
316
-
317
- toggleVisibility() {
318
- this.isVisible = !this.isVisible;
319
- }
320
-
321
- constructor() {
322
- super();
323
- const self:any = this;
324
- this.currentTime = moment().format('HH:mm');
325
-
326
- setInterval(function(){
327
- self.currentTime = moment().format('HH:mm');
328
- }, 500);
329
- }
330
-
331
-
332
- }
333
-
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "../../tsconfig",
3
- "compilerOptions": {
4
- "outDir": "./dist/",
5
- "rootDir": "src"
6
- },
7
- "include": [
8
- "./src"
9
- ],
10
- "references": [
11
- { "path": "../core" },
12
- { "path": "../rest" }
13
- ]
14
- }