-
Notifications
You must be signed in to change notification settings - Fork 0
/
strolch-wc-plc-behavior.html
103 lines (94 loc) · 2.76 KB
/
strolch-wc-plc-behavior.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<link rel="import" href="../polymer/polymer.html">
<script>
StrolchPlcBehavior = {
properties: {
localesPath: {
type: String,
value: './locales.json'
},
warningConfirmed: {
type: Boolean,
value: false
}
},
arrayFilled: function (array) {
return !!(array && array.length && array.length > 0);
},
isTelegram: function (addressType) {
return addressType === "Telegram";
},
isNotification: function (addressType) {
return addressType === "Notification";
},
isBoolean: function (type) {
return type === 'Boolean';
},
isNumber: function (type) {
switch (type) {
case 'Short':
case 'Integer':
case 'Long':
case 'Float':
case 'Double':
return true;
default:
return false;
}
},
isInteger: function (type) {
switch (type) {
case 'Short':
case 'Integer':
case 'Long':
return true;
default:
return false;
}
},
isFloat: function (type) {
switch (type) {
case 'Float':
case 'Double':
return true;
default:
return false;
}
},
isString: function (type) {
switch (type) {
case 'String':
case 'ByteArray':
return true;
default:
return false;
}
},
isPlcError: function (plc) {
return plc.state === "Failed";
},
isError: function (device) {
return device.state === "Error" || device.stateMsg !== "";
},
isOn: function (device) {
return device.state === "On";
},
onRequestError: function (e) {
this.fire("strolch-ajax-request-error", e.detail);
},
confirmActionWarning: function (callback) {
var bound = callback.bind(this);
if (this.warningConfirmed) {
bound();
return;
}
this.fire("strolch-show-info", {
title: this.localize('confirmActionWarning'),
line1: this.localize('confirmActionWarningMsg'),
callback: function () {
this.warningConfirmed = true;
bound();
}.bind(this)
});
}
}
</script>