@openremote/or-rules 1.8.0-snapshot.20250725074716 → 1.8.0-snapshot.20250725120001
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 +30 -30
- package/custom-elements.json +13 -13
- package/dist/umd/index.bundle.js +4744 -4744
- package/dist/umd/index.bundle.js.map +1 -1
- package/lib/flow-viewer/components/confirmation-dialog.js +61 -24
- package/lib/flow-viewer/components/connection-container.js +35 -1
- package/lib/flow-viewer/components/connection-line.js +117 -28
- package/lib/flow-viewer/components/context-menu.js +140 -45
- package/lib/flow-viewer/components/editor-workspace.js +282 -20
- package/lib/flow-viewer/components/flow-editor.js +160 -47
- package/lib/flow-viewer/components/flow-node-socket.js +146 -31
- package/lib/flow-viewer/components/flow-node.js +192 -29
- package/lib/flow-viewer/components/internal-picker.js +271 -54
- package/lib/flow-viewer/components/node-menu-item.js +132 -32
- package/lib/flow-viewer/components/node-panel.js +104 -60
- package/lib/flow-viewer/components/notification-dialog.js +55 -23
- package/lib/flow-viewer/components/popup-modal.js +113 -54
- package/lib/flow-viewer/components/rule-browser.js +119 -30
- package/lib/flow-viewer/components/selectable-element.js +71 -1
- package/lib/flow-viewer/components/selection-box.js +119 -15
- package/lib/flow-viewer/components/top-bar.js +116 -49
- package/lib/flow-viewer/components/workspace-contextmenu-options.js +128 -5
- package/lib/flow-viewer/components/writable-dropdown.js +51 -5
- package/lib/flow-viewer/converters/node-converter.js +10 -1
- package/lib/flow-viewer/flow-viewer.js +19 -1
- package/lib/flow-viewer/models/camera.js +2 -1
- package/lib/flow-viewer/models/context-menu-button.js +2 -1
- package/lib/flow-viewer/models/light-node-collection.js +2 -1
- package/lib/flow-viewer/models/status.js +8 -1
- package/lib/flow-viewer/node-structure/copy.machine.js +34 -1
- package/lib/flow-viewer/node-structure/identity.assigner.js +10 -1
- package/lib/flow-viewer/node-structure/identity.dom.link.js +4 -1
- package/lib/flow-viewer/node-structure/index.js +5 -1
- package/lib/flow-viewer/node-structure/socket.type.matcher.js +50 -1
- package/lib/flow-viewer/node-structure/utils.js +109 -1
- package/lib/flow-viewer/services/copy-paste-manager.js +59 -1
- package/lib/flow-viewer/services/exporter.js +67 -1
- package/lib/flow-viewer/services/input.js +80 -1
- package/lib/flow-viewer/services/integration.js +27 -1
- package/lib/flow-viewer/services/modal.js +29 -8
- package/lib/flow-viewer/services/project.js +222 -1
- package/lib/flow-viewer/services/shortcuts.js +63 -1
- package/lib/flow-viewer/styles/editor-workspace-style.js +55 -53
- package/lib/flow-viewer/styles/flow-node-style.js +95 -93
- package/lib/flow-viewer/styles/picker-styles.js +31 -29
- package/lib/flow-viewer/utils.js +49 -1
- package/lib/index.js +953 -56
- package/lib/json-viewer/forms/or-rule-form-alarm.js +91 -18
- package/lib/json-viewer/forms/or-rule-form-email-message.js +51 -12
- package/lib/json-viewer/forms/or-rule-form-localized.js +269 -43
- package/lib/json-viewer/forms/or-rule-form-push-notification.js +152 -63
- package/lib/json-viewer/forms/or-rule-form-webhook.js +296 -101
- package/lib/json-viewer/modals/or-rule-alarm-modal.js +173 -17
- package/lib/json-viewer/modals/or-rule-notification-modal.js +196 -11
- package/lib/json-viewer/modals/or-rule-radial-modal.js +142 -17
- package/lib/json-viewer/modals/or-rule-webhook-modal.js +78 -8
- package/lib/json-viewer/or-rule-action-alarm.js +97 -5
- package/lib/json-viewer/or-rule-action-attribute.js +235 -33
- package/lib/json-viewer/or-rule-action-notification.js +465 -56
- package/lib/json-viewer/or-rule-action-webhook.js +49 -18
- package/lib/json-viewer/or-rule-asset-query.js +849 -126
- package/lib/json-viewer/or-rule-condition.js +216 -29
- package/lib/json-viewer/or-rule-json-viewer.js +393 -34
- package/lib/json-viewer/or-rule-then-otherwise.js +609 -113
- package/lib/json-viewer/or-rule-trigger-query.js +227 -57
- package/lib/json-viewer/or-rule-when.js +343 -126
- package/lib/or-rule-group-viewer.js +106 -12
- package/lib/or-rule-text-viewer.js +133 -22
- package/lib/or-rule-tree.js +601 -57
- package/lib/or-rule-validity.js +373 -62
- package/lib/or-rule-viewer.js +361 -81
- package/lib/style.js +89 -64
- package/package.json +11 -11
|
@@ -1,102 +1,297 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
.
|
|
3
|
-
|
|
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 { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
8
|
+
import { i18next } from "@openremote/or-translate";
|
|
9
|
+
import { css, html, LitElement } from "lit";
|
|
10
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
11
|
+
import { when } from 'lit/directives/when.js';
|
|
12
|
+
import { OrRulesJsonRuleChangedEvent } from "../or-rule-json-viewer";
|
|
13
|
+
//language=css
|
|
14
|
+
const styling = css `
|
|
15
|
+
.divider {
|
|
16
|
+
border-bottom: 1px solid rgba(0, 0, 0, 12%);
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
let OrRuleFormWebhook = class OrRuleFormWebhook extends LitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.loading = false;
|
|
23
|
+
this.httpMethodOptions = ["GET" /* HTTPMethod.GET */, "POST" /* HTTPMethod.POST */, "PUT" /* HTTPMethod.PUT */, "DELETE" /* HTTPMethod.DELETE */];
|
|
24
|
+
this.authMethodOptions = new Map([
|
|
25
|
+
["username_password", (i18next.t('username') + " & " + i18next.t('password'))],
|
|
26
|
+
["client_credentials", "oauth Client Credentials Grant"],
|
|
27
|
+
["password", "oauth Password Grant"]
|
|
28
|
+
]);
|
|
4
29
|
}
|
|
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
|
-
<div style="display: flex; flex-direction: column; gap:
|
|
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
|
-
|
|
30
|
+
static get styles() {
|
|
31
|
+
return [styling];
|
|
32
|
+
}
|
|
33
|
+
/* --------------------------- */
|
|
34
|
+
// Lifecycle methods
|
|
35
|
+
shouldUpdate(changedProperties) {
|
|
36
|
+
if (changedProperties.has('webhook')) {
|
|
37
|
+
if (this.webhook.headers == undefined) {
|
|
38
|
+
this.webhook.headers = {};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return super.shouldUpdate(changedProperties);
|
|
42
|
+
}
|
|
43
|
+
/* --------------- */
|
|
44
|
+
// Util
|
|
45
|
+
getAuthMethod(webhook) {
|
|
46
|
+
if (webhook.oAuthGrant != undefined) {
|
|
47
|
+
return this.authMethodOptions.get(webhook.oAuthGrant.grant_type);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return this.authMethodOptions.get("username_password");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getOAuthGrant(authMethodKey) {
|
|
54
|
+
if (authMethodKey == 'client_credentials' || authMethodKey == 'password') {
|
|
55
|
+
return { grant_type: authMethodKey };
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
reloadHeaders() {
|
|
62
|
+
this.loading = true;
|
|
63
|
+
this.updateComplete.then(() => this.loading = false);
|
|
64
|
+
this.notifyWebhookUpdate(false);
|
|
65
|
+
}
|
|
66
|
+
notifyWebhookUpdate(requestUpdate = true) {
|
|
67
|
+
if (requestUpdate) {
|
|
68
|
+
this.requestUpdate("webhook");
|
|
69
|
+
}
|
|
70
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
71
|
+
}
|
|
72
|
+
/* ---------------- */
|
|
73
|
+
// Template rendering
|
|
74
|
+
render() {
|
|
75
|
+
return when(!this.webhook, () => html `
|
|
76
|
+
${i18next.t('errorOccurred')}
|
|
77
|
+
`, () => html `
|
|
78
|
+
<form style="display: flex; flex-direction: column; min-width: 520px;">
|
|
79
|
+
<!-- HTTP Method & URL -->
|
|
80
|
+
<div style="display: flex; flex-direction: row; align-items: center; gap: 5px; margin-bottom: 28px;">
|
|
81
|
+
<or-mwc-input style="flex: 0;" type="${InputType.SELECT}" .value="${this.webhook.httpMethod}"
|
|
82
|
+
.options="${this.httpMethodOptions}"
|
|
83
|
+
@or-mwc-input-changed="${(ev) => {
|
|
84
|
+
this.webhook.httpMethod = ev.detail.value;
|
|
85
|
+
this.notifyWebhookUpdate();
|
|
86
|
+
}}"
|
|
87
|
+
></or-mwc-input>
|
|
88
|
+
<or-mwc-input style="flex: 1;" type="${InputType.URL}" required label="${i18next.t('webUrl')}"
|
|
89
|
+
.value="${this.webhook.url}" helperPersistent
|
|
90
|
+
@or-mwc-input-changed="${(e) => {
|
|
91
|
+
this.webhook.url = e.detail.value;
|
|
92
|
+
this.notifyWebhookUpdate();
|
|
93
|
+
}}"></or-mwc-input>
|
|
94
|
+
</div>
|
|
95
|
+
<!-- Headers -->
|
|
96
|
+
<div style="display: flex; flex-direction: column; gap: 5px; margin-bottom: 28px;">
|
|
97
|
+
<span>Headers</span>
|
|
98
|
+
${when(this.loading, () => html `
|
|
99
|
+
${this.getHeadersTemplate(this.webhook.headers, true)}
|
|
100
|
+
`, () => html `
|
|
101
|
+
${this.getHeadersTemplate(this.webhook.headers, false)}
|
|
102
|
+
`)}
|
|
103
|
+
<or-mwc-input type="${InputType.BUTTON}" icon="plus" label="addRequestHeader"
|
|
104
|
+
@or-mwc-input-changed="${(ev) => {
|
|
105
|
+
if ((this.webhook.headers ? this.webhook.headers[''] : undefined) != undefined) {
|
|
106
|
+
this.webhook.headers[''].push('');
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.webhook.headers[''] = [''];
|
|
110
|
+
}
|
|
111
|
+
this.reloadHeaders();
|
|
112
|
+
}}"></or-mwc-input>
|
|
113
|
+
</div>
|
|
114
|
+
<!-- Authorization -->
|
|
115
|
+
<div style="display: flex; flex-direction: column; gap: 10px; margin-bottom: ${this.webhook.oAuthGrant || this.webhook.usernamePassword ? '28px' : '0'};">
|
|
116
|
+
<or-mwc-input type="${InputType.SWITCH}" fullwidth label="${i18next.t('requiresAuthorization')}"
|
|
117
|
+
.value="${this.webhook.oAuthGrant || this.webhook.usernamePassword}"
|
|
118
|
+
@or-mwc-input-changed="${(ev) => {
|
|
119
|
+
this.webhook.usernamePassword = ev.detail.value ? {
|
|
120
|
+
username: 'admin',
|
|
121
|
+
password: 'secret'
|
|
122
|
+
} : undefined;
|
|
123
|
+
this.notifyWebhookUpdate();
|
|
124
|
+
}}"></or-mwc-input>
|
|
125
|
+
${when(this.webhook.oAuthGrant || this.webhook.usernamePassword, () => {
|
|
126
|
+
const values = Array.from(this.authMethodOptions.values());
|
|
127
|
+
return html `
|
|
128
|
+
<or-mwc-input type="${InputType.SELECT}" label="${i18next.t('method')}"
|
|
129
|
+
.value="${this.getAuthMethod(this.webhook)}"
|
|
130
|
+
.options="${values}"
|
|
131
|
+
@or-mwc-input-changed="${(ev) => {
|
|
132
|
+
const entry = [...this.authMethodOptions.entries()].find((entry) => entry[1] == ev.detail.value);
|
|
133
|
+
this.webhook.oAuthGrant = this.getOAuthGrant(entry[0]);
|
|
134
|
+
this.notifyWebhookUpdate();
|
|
135
|
+
}}"></or-mwc-input>
|
|
136
|
+
${this.getAuthSettingsTemplate(this.webhook)}
|
|
137
|
+
`;
|
|
138
|
+
})}
|
|
139
|
+
</div>
|
|
140
|
+
<!-- Payload -->
|
|
141
|
+
<div style="display: flex; flex-direction: column; gap: 5px;">
|
|
142
|
+
${when(this.webhook.httpMethod != "GET" /* HTTPMethod.GET */ && this.webhook.httpMethod != "DELETE" /* HTTPMethod.DELETE */, () => html `
|
|
143
|
+
<or-mwc-input type="${InputType.SWITCH}" fullwidth label="${i18next.t('includeBodyInRequest')}"
|
|
144
|
+
.value="${this.webhook.payload != undefined}"
|
|
145
|
+
@or-mwc-input-changed="${(ev) => {
|
|
146
|
+
this.webhook.payload = ev.detail.value ? JSON.stringify({
|
|
147
|
+
rule: "%RULESET_NAME%",
|
|
148
|
+
assets: "%TRIGGER_ASSETS%"
|
|
149
|
+
}, null, 4) : undefined;
|
|
150
|
+
this.notifyWebhookUpdate();
|
|
151
|
+
}}"
|
|
152
|
+
></or-mwc-input>
|
|
153
|
+
${when(this.webhook.payload != undefined, () => {
|
|
154
|
+
return html `
|
|
155
|
+
<or-mwc-input type="${InputType.TEXTAREA}" .value="${this.webhook.payload}"
|
|
156
|
+
@or-mwc-input-changed="${(ev) => {
|
|
157
|
+
this.webhook.payload = ev.detail.value;
|
|
158
|
+
this.notifyWebhookUpdate();
|
|
159
|
+
}}"></or-mwc-input>
|
|
160
|
+
`;
|
|
161
|
+
})}
|
|
162
|
+
`)}
|
|
163
|
+
</div>
|
|
164
|
+
</form>
|
|
165
|
+
`);
|
|
166
|
+
}
|
|
167
|
+
getHeadersTemplate(headers, loading) {
|
|
168
|
+
return Object.keys(this.webhook.headers)
|
|
169
|
+
.sort((a, b) => -(a.localeCompare(b)))
|
|
170
|
+
.map((key, keyIndex, keys) => {
|
|
171
|
+
const values = this.webhook.headers[key];
|
|
172
|
+
return values.map((value, valueIndex) => html `
|
|
173
|
+
<div style="display: flex; gap: 5px;">
|
|
174
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('header')}" value="${key}"
|
|
175
|
+
style="flex: 1;" .disabled="${loading}"
|
|
176
|
+
@or-mwc-input-changed="${(ev) => {
|
|
177
|
+
values.length > 0 ? values.splice(valueIndex, 1) : delete this.webhook.headers[key];
|
|
178
|
+
const newValues = this.webhook.headers[ev.detail.value];
|
|
179
|
+
if (newValues && newValues.length > 0) {
|
|
180
|
+
newValues.push(value);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.webhook.headers[ev.detail.value] = [value];
|
|
184
|
+
}
|
|
185
|
+
this.reloadHeaders();
|
|
186
|
+
}}"
|
|
187
|
+
></or-mwc-input>
|
|
188
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('value')}" value="${value}"
|
|
189
|
+
style="flex: 1;" .disabled="${loading}"
|
|
190
|
+
@or-mwc-input-changed="${(ev) => {
|
|
191
|
+
this.webhook.headers[key][valueIndex] = ev.detail.value;
|
|
192
|
+
this.notifyWebhookUpdate();
|
|
193
|
+
}}"
|
|
194
|
+
></or-mwc-input>
|
|
195
|
+
<or-mwc-input type="${InputType.BUTTON}" icon="delete" .disabled="${loading}"
|
|
196
|
+
@or-mwc-input-changed="${() => {
|
|
197
|
+
values.splice(valueIndex, 1);
|
|
198
|
+
this.reloadHeaders();
|
|
199
|
+
}}"></or-mwc-input>
|
|
200
|
+
</div>
|
|
201
|
+
`);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
getAuthSettingsTemplate(webhook) {
|
|
205
|
+
var _a, _b;
|
|
206
|
+
const authGrant = webhook.oAuthGrant;
|
|
207
|
+
if (authGrant == undefined) {
|
|
208
|
+
return html `
|
|
209
|
+
<div style="display: flex; flex-direction: column; gap: 10px;">
|
|
210
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('username')}"
|
|
211
|
+
.value="${(_a = webhook.usernamePassword) === null || _a === void 0 ? void 0 : _a.username}"
|
|
212
|
+
@or-mwc-input-changed="${(ev) => {
|
|
213
|
+
if (!this.webhook.usernamePassword) {
|
|
214
|
+
this.webhook.usernamePassword = {};
|
|
215
|
+
}
|
|
216
|
+
this.webhook.usernamePassword.username = ev.detail.value;
|
|
217
|
+
this.notifyWebhookUpdate();
|
|
218
|
+
}}"></or-mwc-input>
|
|
219
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('password')}"
|
|
220
|
+
.value="${(_b = this.webhook.usernamePassword) === null || _b === void 0 ? void 0 : _b.password}"
|
|
221
|
+
@or-mwc-input-changed="${(ev) => {
|
|
222
|
+
if (!this.webhook.usernamePassword) {
|
|
223
|
+
this.webhook.usernamePassword = {};
|
|
224
|
+
}
|
|
225
|
+
this.webhook.usernamePassword.password = ev.detail.value;
|
|
226
|
+
this.notifyWebhookUpdate();
|
|
227
|
+
}}"></or-mwc-input>
|
|
228
|
+
</div>
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return html `
|
|
233
|
+
<div style="display: flex; flex-direction: column; gap: 10px;">
|
|
234
|
+
<div style="display: flex; flex-direction: row; align-items: center; gap: 5px;">
|
|
235
|
+
<or-mwc-input style="flex: 1;" type="${InputType.URL}" required
|
|
236
|
+
label="${i18next.t('tokenUrl')}" .value="${authGrant.tokenEndpointUri}"
|
|
237
|
+
@or-mwc-input-changed="${(ev) => {
|
|
238
|
+
authGrant.tokenEndpointUri = ev.detail.value;
|
|
239
|
+
this.notifyWebhookUpdate();
|
|
240
|
+
}}"></or-mwc-input>
|
|
241
|
+
</div>
|
|
242
|
+
${when(authGrant.grant_type != undefined, () => {
|
|
243
|
+
switch (authGrant.grant_type) {
|
|
244
|
+
case "client_credentials": {
|
|
245
|
+
const grant = authGrant;
|
|
246
|
+
return html `
|
|
247
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('clientId')}"
|
|
248
|
+
.value="${grant.client_id}"
|
|
249
|
+
@or-mwc-input-changed="${(ev) => {
|
|
250
|
+
grant.client_id = ev.detail.value;
|
|
251
|
+
this.notifyWebhookUpdate();
|
|
252
|
+
}}"></or-mwc-input>
|
|
253
|
+
<or-mwc-input type="${InputType.PASSWORD}" label="${i18next.t('clientSecret')}"
|
|
254
|
+
.value="${grant.client_secret}"
|
|
255
|
+
@or-mwc-input-changed="${(ev) => {
|
|
256
|
+
grant.client_secret = ev.detail.value;
|
|
257
|
+
this.notifyWebhookUpdate();
|
|
258
|
+
}}"></or-mwc-input>
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
case "password": {
|
|
262
|
+
const grant = authGrant;
|
|
263
|
+
return html `
|
|
264
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('username')}"
|
|
265
|
+
.value="${grant.username}"
|
|
266
|
+
@or-mwc-input-changed="${(ev) => {
|
|
267
|
+
grant.username = ev.detail.value;
|
|
268
|
+
this.notifyWebhookUpdate();
|
|
269
|
+
}}"></or-mwc-input>
|
|
270
|
+
<or-mwc-input type="${InputType.TEXT}" label="${i18next.t('password')}"
|
|
271
|
+
.value="${grant.password}"
|
|
272
|
+
@or-mwc-input-changed="${(ev) => {
|
|
273
|
+
grant.password = ev.detail.value;
|
|
274
|
+
this.notifyWebhookUpdate();
|
|
275
|
+
}}"></or-mwc-input>
|
|
276
|
+
`;
|
|
277
|
+
}
|
|
278
|
+
default:
|
|
279
|
+
return html `${i18next.t('errorOccurred')}`;
|
|
280
|
+
}
|
|
281
|
+
})}
|
|
282
|
+
</div>
|
|
283
|
+
`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
__decorate([
|
|
288
|
+
property({ type: Object })
|
|
289
|
+
], OrRuleFormWebhook.prototype, "webhook", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
state()
|
|
292
|
+
], OrRuleFormWebhook.prototype, "loading", void 0);
|
|
293
|
+
OrRuleFormWebhook = __decorate([
|
|
294
|
+
customElement("or-rule-form-webhook")
|
|
295
|
+
], OrRuleFormWebhook);
|
|
296
|
+
export { OrRuleFormWebhook };
|
|
297
|
+
//# sourceMappingURL=or-rule-form-webhook.js.map
|
|
@@ -1,17 +1,173 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
/*
|
|
8
|
+
* Copyright 2024, OpenRemote Inc.
|
|
9
|
+
*
|
|
10
|
+
* See the CONTRIBUTORS.txt file in the distribution for a
|
|
11
|
+
* full listing of individual contributors.
|
|
12
|
+
*
|
|
13
|
+
* This program is free software: you can redistribute it and/or modify
|
|
14
|
+
* it under the terms of the GNU Affero General Public License as
|
|
15
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
16
|
+
* License, or (at your option) any later version.
|
|
17
|
+
*
|
|
18
|
+
* This program is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
* GNU Affero General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
24
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
25
|
+
*/
|
|
26
|
+
import { css, html, LitElement } from "lit";
|
|
27
|
+
import { customElement, property } from "lit/decorators.js";
|
|
28
|
+
import "@openremote/or-mwc-components/or-mwc-input";
|
|
29
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
30
|
+
import i18next from "i18next";
|
|
31
|
+
import { translate } from "@openremote/or-translate";
|
|
32
|
+
import { OrMwcDialogOpenedEvent } from "@openremote/or-mwc-components/or-mwc-dialog";
|
|
33
|
+
import { OrRulesJsonRuleChangedEvent } from "../or-rule-json-viewer";
|
|
34
|
+
const checkValidity = (form, dialog) => {
|
|
35
|
+
if (form) {
|
|
36
|
+
const inputs = form.querySelectorAll('or-mwc-input');
|
|
37
|
+
const elements = Array.prototype.slice.call(inputs);
|
|
38
|
+
const valid = elements.every((element) => {
|
|
39
|
+
if (element.shadowRoot) {
|
|
40
|
+
const input = element.shadowRoot.querySelector('input, textarea');
|
|
41
|
+
if (element.type === InputType.SELECT) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (input && input.checkValidity()) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
element._mdcComponent.valid = false;
|
|
49
|
+
element._mdcComponent.helperTextContent = 'required';
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
if (valid) {
|
|
58
|
+
dialog.close();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// language=CSS
|
|
63
|
+
const style = css `
|
|
64
|
+
:host {
|
|
65
|
+
display: flex;
|
|
66
|
+
align-items: center;
|
|
67
|
+
}
|
|
68
|
+
:host > * {
|
|
69
|
+
margin: 0 3px 6px;
|
|
70
|
+
}
|
|
71
|
+
.min-width {
|
|
72
|
+
min-width: 200px;
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
let OrRuleAlarmModal = class OrRuleAlarmModal extends translate(i18next)(LitElement) {
|
|
76
|
+
static get styles() {
|
|
77
|
+
return style;
|
|
78
|
+
}
|
|
79
|
+
constructor() {
|
|
80
|
+
super();
|
|
81
|
+
this.title = "settings";
|
|
82
|
+
this.addEventListener(OrMwcDialogOpenedEvent.NAME, this.initDialog);
|
|
83
|
+
}
|
|
84
|
+
initDialog() {
|
|
85
|
+
const modal = this.shadowRoot.getElementById('alarm-modal');
|
|
86
|
+
if (!modal)
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
renderDialogHTML(action) {
|
|
90
|
+
const dialog = this.shadowRoot.getElementById("alarm-modal");
|
|
91
|
+
if (!this.shadowRoot)
|
|
92
|
+
return;
|
|
93
|
+
const slot = this.shadowRoot.querySelector('.alarm-form-slot');
|
|
94
|
+
if (dialog && slot) {
|
|
95
|
+
let container = document.createElement("div");
|
|
96
|
+
slot.assignedNodes({ flatten: true }).forEach((child) => {
|
|
97
|
+
if (child instanceof HTMLElement) {
|
|
98
|
+
container.appendChild(child);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
dialog.content = html `${container}`;
|
|
102
|
+
dialog.dismissAction = null;
|
|
103
|
+
this.requestUpdate();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
firstUpdated(changedProperties) {
|
|
107
|
+
if (changedProperties.has("action")) {
|
|
108
|
+
this.renderDialogHTML(this.action);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
checkForm() {
|
|
112
|
+
const dialog = this.shadowRoot.host;
|
|
113
|
+
if (this.shadowRoot) {
|
|
114
|
+
const alarmConfig = this.shadowRoot.querySelector('or-rule-form-alarm');
|
|
115
|
+
if (alarmConfig && alarmConfig.shadowRoot) {
|
|
116
|
+
const form = alarmConfig.shadowRoot.querySelector('form');
|
|
117
|
+
return checkValidity(form, dialog);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
render() {
|
|
122
|
+
var _a;
|
|
123
|
+
if (!this.action)
|
|
124
|
+
return html ``;
|
|
125
|
+
const alarmPickerModalActions = [
|
|
126
|
+
{
|
|
127
|
+
actionName: "cancel",
|
|
128
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("cancel")}"></or-mwc-input>`,
|
|
129
|
+
action: (dialog) => {
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
actionName: "",
|
|
134
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" .label="${i18next.t("ok")}" @or-mwc-input-changed="${this.checkForm}"></or-mwc-input>`
|
|
135
|
+
}
|
|
136
|
+
];
|
|
137
|
+
const alarmPickerModalOpen = () => {
|
|
138
|
+
const dialog = this.shadowRoot.getElementById("alarm-modal");
|
|
139
|
+
if (dialog) {
|
|
140
|
+
dialog.open();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return html `
|
|
144
|
+
<or-mwc-input style="width: 200px" .type="${InputType.SELECT}" .value="${(_a = this.action.alarm) === null || _a === void 0 ? void 0 : _a.severity}" .label="${i18next.t("alarm.severity")}" .options="${[["LOW" /* AlarmSeverity.LOW */, i18next.t("alarm.severity_LOW")], ["MEDIUM" /* AlarmSeverity.MEDIUM */, i18next.t("alarm.severity_MEDIUM")], ["HIGH" /* AlarmSeverity.HIGH */, i18next.t("alarm.severity_HIGH")]]}" @or-mwc-input-changed="${(e) => this.setActionAlarmSeverity(e.detail.value)}"></or-mwc-input>
|
|
145
|
+
<or-mwc-input .type="${InputType.BUTTON}" .label="${i18next.t("settings")}" @or-mwc-input-changed="${alarmPickerModalOpen}"></or-mwc-input>
|
|
146
|
+
<or-mwc-dialog id="alarm-modal" heading="${this.title}" .actions="${alarmPickerModalActions}"></or-mwc-dialog>
|
|
147
|
+
<slot class="alarm-form-slot"></slot>
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
setActionAlarmSeverity(value) {
|
|
151
|
+
if (value && this.action.alarm) {
|
|
152
|
+
const alarm = this.action.alarm;
|
|
153
|
+
alarm.severity = value;
|
|
154
|
+
this.action.alarm = Object.assign({}, alarm);
|
|
155
|
+
}
|
|
156
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
157
|
+
this.requestUpdate();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
__decorate([
|
|
161
|
+
property({ type: Object, attribute: false })
|
|
162
|
+
], OrRuleAlarmModal.prototype, "action", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
property({ type: String })
|
|
165
|
+
], OrRuleAlarmModal.prototype, "title", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
property({ type: Object })
|
|
168
|
+
], OrRuleAlarmModal.prototype, "query", void 0);
|
|
169
|
+
OrRuleAlarmModal = __decorate([
|
|
170
|
+
customElement("or-rule-alarm-modal")
|
|
171
|
+
], OrRuleAlarmModal);
|
|
172
|
+
export { OrRuleAlarmModal };
|
|
173
|
+
//# sourceMappingURL=or-rule-alarm-modal.js.map
|