@openremote/or-rules 1.8.0-snapshot.20250725120001 → 1.8.0-snapshot.20250725123024
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 +24 -61
- package/lib/flow-viewer/components/connection-container.js +1 -35
- package/lib/flow-viewer/components/connection-line.js +28 -117
- package/lib/flow-viewer/components/context-menu.js +45 -140
- package/lib/flow-viewer/components/editor-workspace.js +20 -282
- package/lib/flow-viewer/components/flow-editor.js +47 -160
- package/lib/flow-viewer/components/flow-node-socket.js +31 -146
- package/lib/flow-viewer/components/flow-node.js +29 -192
- package/lib/flow-viewer/components/internal-picker.js +54 -271
- package/lib/flow-viewer/components/node-menu-item.js +32 -132
- package/lib/flow-viewer/components/node-panel.js +60 -104
- package/lib/flow-viewer/components/notification-dialog.js +23 -55
- package/lib/flow-viewer/components/popup-modal.js +54 -113
- package/lib/flow-viewer/components/rule-browser.js +30 -119
- package/lib/flow-viewer/components/selectable-element.js +1 -71
- package/lib/flow-viewer/components/selection-box.js +15 -119
- package/lib/flow-viewer/components/top-bar.js +49 -116
- package/lib/flow-viewer/components/workspace-contextmenu-options.js +5 -128
- package/lib/flow-viewer/components/writable-dropdown.js +5 -51
- package/lib/flow-viewer/converters/node-converter.js +1 -10
- package/lib/flow-viewer/flow-viewer.js +1 -19
- package/lib/flow-viewer/models/camera.js +1 -2
- package/lib/flow-viewer/models/context-menu-button.js +1 -2
- package/lib/flow-viewer/models/light-node-collection.js +1 -2
- package/lib/flow-viewer/models/status.js +1 -8
- package/lib/flow-viewer/node-structure/copy.machine.js +1 -34
- package/lib/flow-viewer/node-structure/identity.assigner.js +1 -10
- package/lib/flow-viewer/node-structure/identity.dom.link.js +1 -4
- package/lib/flow-viewer/node-structure/index.js +1 -5
- package/lib/flow-viewer/node-structure/socket.type.matcher.js +1 -50
- package/lib/flow-viewer/node-structure/utils.js +1 -109
- package/lib/flow-viewer/services/copy-paste-manager.js +1 -59
- package/lib/flow-viewer/services/exporter.js +1 -67
- package/lib/flow-viewer/services/input.js +1 -80
- package/lib/flow-viewer/services/integration.js +1 -27
- package/lib/flow-viewer/services/modal.js +8 -29
- package/lib/flow-viewer/services/project.js +1 -222
- package/lib/flow-viewer/services/shortcuts.js +1 -63
- package/lib/flow-viewer/styles/editor-workspace-style.js +53 -55
- package/lib/flow-viewer/styles/flow-node-style.js +93 -95
- package/lib/flow-viewer/styles/picker-styles.js +29 -31
- package/lib/flow-viewer/utils.js +1 -49
- package/lib/index.js +56 -953
- package/lib/json-viewer/forms/or-rule-form-alarm.js +18 -91
- package/lib/json-viewer/forms/or-rule-form-email-message.js +12 -51
- package/lib/json-viewer/forms/or-rule-form-localized.js +43 -269
- package/lib/json-viewer/forms/or-rule-form-push-notification.js +63 -152
- package/lib/json-viewer/forms/or-rule-form-webhook.js +101 -296
- package/lib/json-viewer/modals/or-rule-alarm-modal.js +17 -173
- package/lib/json-viewer/modals/or-rule-notification-modal.js +11 -196
- package/lib/json-viewer/modals/or-rule-radial-modal.js +17 -142
- package/lib/json-viewer/modals/or-rule-webhook-modal.js +8 -78
- package/lib/json-viewer/or-rule-action-alarm.js +5 -97
- package/lib/json-viewer/or-rule-action-attribute.js +33 -235
- package/lib/json-viewer/or-rule-action-notification.js +56 -465
- package/lib/json-viewer/or-rule-action-webhook.js +18 -49
- package/lib/json-viewer/or-rule-asset-query.js +126 -849
- package/lib/json-viewer/or-rule-condition.js +29 -216
- package/lib/json-viewer/or-rule-json-viewer.js +34 -393
- package/lib/json-viewer/or-rule-then-otherwise.js +113 -609
- package/lib/json-viewer/or-rule-trigger-query.js +57 -227
- package/lib/json-viewer/or-rule-when.js +126 -343
- package/lib/or-rule-group-viewer.js +12 -106
- package/lib/or-rule-text-viewer.js +22 -133
- package/lib/or-rule-tree.js +57 -601
- package/lib/or-rule-validity.js +62 -373
- package/lib/or-rule-viewer.js +81 -361
- package/lib/style.js +64 -89
- package/package.json +11 -11
|
@@ -1,297 +1,102 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
]);
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,i){var r,a=arguments.length,s=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var h=e.length-1;h>=0;h--)(r=e[h])&&(s=(a<3?r(s):a>3?r(t,o,s):r(t,o))||s);return a>3&&s&&Object.defineProperty(t,o,s),s};import{InputType as e}from"@openremote/or-mwc-components/or-mwc-input";import{i18next as t}from"@openremote/or-translate";import{css as o,html as i,LitElement as r}from"lit";import{customElement as a,property as s,state as h}from"lit/decorators.js";import{when as n}from"lit/directives/when.js";import{OrRulesJsonRuleChangedEvent as d}from"../or-rule-json-viewer";let styling=o`
|
|
2
|
+
.divider {
|
|
3
|
+
border-bottom: 1px solid rgba(0, 0, 0, 12%);
|
|
29
4
|
}
|
|
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
|
-
<div style="display: flex; flex-direction: column; gap:
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
|
5
|
+
`,OrRuleFormWebhook=class extends r{constructor(){super(...arguments),this.loading=!1,this.httpMethodOptions=["GET","POST","PUT","DELETE"],this.authMethodOptions=new Map([["username_password",t.t("username")+" & "+t.t("password")],["client_credentials","oauth Client Credentials Grant"],["password","oauth Password Grant"]])}static get styles(){return[styling]}shouldUpdate(e){return e.has("webhook")&&void 0==this.webhook.headers&&(this.webhook.headers={}),super.shouldUpdate(e)}getAuthMethod(e){return void 0!=e.oAuthGrant?this.authMethodOptions.get(e.oAuthGrant.grant_type):this.authMethodOptions.get("username_password")}getOAuthGrant(e){return"client_credentials"==e||"password"==e?{grant_type:e}:void 0}reloadHeaders(){this.loading=!0,this.updateComplete.then(()=>this.loading=!1),this.notifyWebhookUpdate(!1)}notifyWebhookUpdate(e=!0){e&&this.requestUpdate("webhook"),this.dispatchEvent(new d)}render(){return n(!this.webhook,()=>i`
|
|
6
|
+
${t.t("errorOccurred")}
|
|
7
|
+
`,()=>i`
|
|
8
|
+
<form style="display: flex; flex-direction: column; min-width: 520px;">
|
|
9
|
+
<!-- HTTP Method & URL -->
|
|
10
|
+
<div style="display: flex; flex-direction: row; align-items: center; gap: 5px; margin-bottom: 28px;">
|
|
11
|
+
<or-mwc-input style="flex: 0;" type="${e.SELECT}" .value="${this.webhook.httpMethod}"
|
|
12
|
+
.options="${this.httpMethodOptions}"
|
|
13
|
+
@or-mwc-input-changed="${e=>{this.webhook.httpMethod=e.detail.value,this.notifyWebhookUpdate()}}"
|
|
14
|
+
></or-mwc-input>
|
|
15
|
+
<or-mwc-input style="flex: 1;" type="${e.URL}" required label="${t.t("webUrl")}"
|
|
16
|
+
.value="${this.webhook.url}" helperPersistent
|
|
17
|
+
@or-mwc-input-changed="${e=>{this.webhook.url=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
18
|
+
</div>
|
|
19
|
+
<!-- Headers -->
|
|
20
|
+
<div style="display: flex; flex-direction: column; gap: 5px; margin-bottom: 28px;">
|
|
21
|
+
<span>Headers</span>
|
|
22
|
+
${n(this.loading,()=>i`
|
|
23
|
+
${this.getHeadersTemplate(this.webhook.headers,!0)}
|
|
24
|
+
`,()=>i`
|
|
25
|
+
${this.getHeadersTemplate(this.webhook.headers,!1)}
|
|
26
|
+
`)}
|
|
27
|
+
<or-mwc-input type="${e.BUTTON}" icon="plus" label="addRequestHeader"
|
|
28
|
+
@or-mwc-input-changed="${e=>{(this.webhook.headers?this.webhook.headers[""]:void 0)!=void 0?this.webhook.headers[""].push(""):this.webhook.headers[""]=[""],this.reloadHeaders()}}"></or-mwc-input>
|
|
29
|
+
</div>
|
|
30
|
+
<!-- Authorization -->
|
|
31
|
+
<div style="display: flex; flex-direction: column; gap: 10px; margin-bottom: ${this.webhook.oAuthGrant||this.webhook.usernamePassword?"28px":"0"};">
|
|
32
|
+
<or-mwc-input type="${e.SWITCH}" fullwidth label="${t.t("requiresAuthorization")}"
|
|
33
|
+
.value="${this.webhook.oAuthGrant||this.webhook.usernamePassword}"
|
|
34
|
+
@or-mwc-input-changed="${e=>{this.webhook.usernamePassword=e.detail.value?{username:"admin",password:"secret"}:void 0,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
35
|
+
${n(this.webhook.oAuthGrant||this.webhook.usernamePassword,()=>{let o=Array.from(this.authMethodOptions.values());return i`
|
|
36
|
+
<or-mwc-input type="${e.SELECT}" label="${t.t("method")}"
|
|
37
|
+
.value="${this.getAuthMethod(this.webhook)}"
|
|
38
|
+
.options="${o}"
|
|
39
|
+
@or-mwc-input-changed="${e=>{let t=[...this.authMethodOptions.entries()].find(t=>t[1]==e.detail.value);this.webhook.oAuthGrant=this.getOAuthGrant(t[0]),this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
40
|
+
${this.getAuthSettingsTemplate(this.webhook)}
|
|
41
|
+
`})}
|
|
42
|
+
</div>
|
|
43
|
+
<!-- Payload -->
|
|
44
|
+
<div style="display: flex; flex-direction: column; gap: 5px;">
|
|
45
|
+
${n("GET"!=this.webhook.httpMethod&&"DELETE"!=this.webhook.httpMethod,()=>i`
|
|
46
|
+
<or-mwc-input type="${e.SWITCH}" fullwidth label="${t.t("includeBodyInRequest")}"
|
|
47
|
+
.value="${void 0!=this.webhook.payload}"
|
|
48
|
+
@or-mwc-input-changed="${e=>{this.webhook.payload=e.detail.value?JSON.stringify({rule:"%RULESET_NAME%",assets:"%TRIGGER_ASSETS%"},null,4):void 0,this.notifyWebhookUpdate()}}"
|
|
49
|
+
></or-mwc-input>
|
|
50
|
+
${n(void 0!=this.webhook.payload,()=>i`
|
|
51
|
+
<or-mwc-input type="${e.TEXTAREA}" .value="${this.webhook.payload}"
|
|
52
|
+
@or-mwc-input-changed="${e=>{this.webhook.payload=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
53
|
+
`)}
|
|
54
|
+
`)}
|
|
55
|
+
</div>
|
|
56
|
+
</form>
|
|
57
|
+
`)}getHeadersTemplate(o,r){return Object.keys(this.webhook.headers).sort((e,t)=>-e.localeCompare(t)).map((o,a,s)=>{let h=this.webhook.headers[o];return h.map((a,s)=>i`
|
|
58
|
+
<div style="display: flex; gap: 5px;">
|
|
59
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("header")}" value="${o}"
|
|
60
|
+
style="flex: 1;" .disabled="${r}"
|
|
61
|
+
@or-mwc-input-changed="${e=>{h.length>0?h.splice(s,1):delete this.webhook.headers[o];let t=this.webhook.headers[e.detail.value];t&&t.length>0?t.push(a):this.webhook.headers[e.detail.value]=[a],this.reloadHeaders()}}"
|
|
62
|
+
></or-mwc-input>
|
|
63
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("value")}" value="${a}"
|
|
64
|
+
style="flex: 1;" .disabled="${r}"
|
|
65
|
+
@or-mwc-input-changed="${e=>{this.webhook.headers[o][s]=e.detail.value,this.notifyWebhookUpdate()}}"
|
|
66
|
+
></or-mwc-input>
|
|
67
|
+
<or-mwc-input type="${e.BUTTON}" icon="delete" .disabled="${r}"
|
|
68
|
+
@or-mwc-input-changed="${()=>{h.splice(s,1),this.reloadHeaders()}}"></or-mwc-input>
|
|
69
|
+
</div>
|
|
70
|
+
`)})}getAuthSettingsTemplate(o){var r,a;let s=o.oAuthGrant;return void 0==s?i`
|
|
71
|
+
<div style="display: flex; flex-direction: column; gap: 10px;">
|
|
72
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("username")}"
|
|
73
|
+
.value="${null==(r=o.usernamePassword)?void 0:r.username}"
|
|
74
|
+
@or-mwc-input-changed="${e=>{this.webhook.usernamePassword||(this.webhook.usernamePassword={}),this.webhook.usernamePassword.username=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
75
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("password")}"
|
|
76
|
+
.value="${null==(a=this.webhook.usernamePassword)?void 0:a.password}"
|
|
77
|
+
@or-mwc-input-changed="${e=>{this.webhook.usernamePassword||(this.webhook.usernamePassword={}),this.webhook.usernamePassword.password=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
78
|
+
</div>
|
|
79
|
+
`:i`
|
|
80
|
+
<div style="display: flex; flex-direction: column; gap: 10px;">
|
|
81
|
+
<div style="display: flex; flex-direction: row; align-items: center; gap: 5px;">
|
|
82
|
+
<or-mwc-input style="flex: 1;" type="${e.URL}" required
|
|
83
|
+
label="${t.t("tokenUrl")}" .value="${s.tokenEndpointUri}"
|
|
84
|
+
@or-mwc-input-changed="${e=>{s.tokenEndpointUri=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
85
|
+
</div>
|
|
86
|
+
${n(void 0!=s.grant_type,()=>{switch(s.grant_type){case"client_credentials":return i`
|
|
87
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("clientId")}"
|
|
88
|
+
.value="${s.client_id}"
|
|
89
|
+
@or-mwc-input-changed="${e=>{s.client_id=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
90
|
+
<or-mwc-input type="${e.PASSWORD}" label="${t.t("clientSecret")}"
|
|
91
|
+
.value="${s.client_secret}"
|
|
92
|
+
@or-mwc-input-changed="${e=>{s.client_secret=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
93
|
+
`;case"password":return i`
|
|
94
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("username")}"
|
|
95
|
+
.value="${s.username}"
|
|
96
|
+
@or-mwc-input-changed="${e=>{s.username=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
97
|
+
<or-mwc-input type="${e.TEXT}" label="${t.t("password")}"
|
|
98
|
+
.value="${s.password}"
|
|
99
|
+
@or-mwc-input-changed="${e=>{s.password=e.detail.value,this.notifyWebhookUpdate()}}"></or-mwc-input>
|
|
100
|
+
`;default:return i`${t.t("errorOccurred")}`}})}
|
|
101
|
+
</div>
|
|
102
|
+
`}};__decorate([s({type:Object})],OrRuleFormWebhook.prototype,"webhook",void 0),__decorate([h()],OrRuleFormWebhook.prototype,"loading",void 0),OrRuleFormWebhook=__decorate([a("or-rule-form-webhook")],OrRuleFormWebhook);export{OrRuleFormWebhook};
|
|
@@ -1,173 +1,17 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
1
|
+
var __decorate=this&&this.__decorate||function(t,e,o,r){var i,a=arguments.length,l=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,o,r);else for(var n=t.length-1;n>=0;n--)(i=t[n])&&(l=(a<3?i(l):a>3?i(e,o,l):i(e,o))||l);return a>3&&l&&Object.defineProperty(e,o,l),l};import{css as t,html as e,LitElement as o}from"lit";import{customElement as r,property as i}from"lit/decorators.js";import"@openremote/or-mwc-components/or-mwc-input";import{InputType as a}from"@openremote/or-mwc-components/or-mwc-input";import l from"i18next";import{translate as n}from"@openremote/or-translate";import{OrMwcDialogOpenedEvent as s}from"@openremote/or-mwc-components/or-mwc-dialog";import{OrRulesJsonRuleChangedEvent as c}from"../or-rule-json-viewer";let checkValidity=(t,e)=>{if(t){let o=t.querySelectorAll("or-mwc-input");Array.prototype.slice.call(o).every(t=>{if(!t.shadowRoot)return!1;{let e=t.shadowRoot.querySelector("input, textarea");return t.type===a.SELECT||!!(e&&e.checkValidity())||(t._mdcComponent.valid=!1,t._mdcComponent.helperTextContent="required",!1)}})&&e.close()}},style=t`
|
|
2
|
+
:host {
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
:host > * {
|
|
7
|
+
margin: 0 3px 6px;
|
|
8
|
+
}
|
|
9
|
+
.min-width {
|
|
10
|
+
min-width: 200px;
|
|
11
|
+
}
|
|
12
|
+
`,OrRuleAlarmModal=class extends n(l)(o){static get styles(){return style}constructor(){super(),this.title="settings",this.addEventListener(s.NAME,this.initDialog)}initDialog(){if(!this.shadowRoot.getElementById("alarm-modal"))return}renderDialogHTML(t){let o=this.shadowRoot.getElementById("alarm-modal");if(!this.shadowRoot)return;let r=this.shadowRoot.querySelector(".alarm-form-slot");if(o&&r){let t=document.createElement("div");r.assignedNodes({flatten:!0}).forEach(e=>{e instanceof HTMLElement&&t.appendChild(e)}),o.content=e`${t}`,o.dismissAction=null,this.requestUpdate()}}firstUpdated(t){t.has("action")&&this.renderDialogHTML(this.action)}checkForm(){let t=this.shadowRoot.host;if(this.shadowRoot){let e=this.shadowRoot.querySelector("or-rule-form-alarm");if(e&&e.shadowRoot)return checkValidity(e.shadowRoot.querySelector("form"),t)}}render(){var t;if(!this.action)return e``;let o=[{actionName:"cancel",content:e`<or-mwc-input class="button" .type="${a.BUTTON}" .label="${l.t("cancel")}"></or-mwc-input>`,action:t=>{}},{actionName:"",content:e`<or-mwc-input class="button" .type="${a.BUTTON}" .label="${l.t("ok")}" @or-mwc-input-changed="${this.checkForm}"></or-mwc-input>`}];return e`
|
|
13
|
+
<or-mwc-input style="width: 200px" .type="${a.SELECT}" .value="${null==(t=this.action.alarm)?void 0:t.severity}" .label="${l.t("alarm.severity")}" .options="${[["LOW",l.t("alarm.severity_LOW")],["MEDIUM",l.t("alarm.severity_MEDIUM")],["HIGH",l.t("alarm.severity_HIGH")]]}" @or-mwc-input-changed="${t=>this.setActionAlarmSeverity(t.detail.value)}"></or-mwc-input>
|
|
14
|
+
<or-mwc-input .type="${a.BUTTON}" .label="${l.t("settings")}" @or-mwc-input-changed="${()=>{let t=this.shadowRoot.getElementById("alarm-modal");t&&t.open()}}"></or-mwc-input>
|
|
15
|
+
<or-mwc-dialog id="alarm-modal" heading="${this.title}" .actions="${o}"></or-mwc-dialog>
|
|
16
|
+
<slot class="alarm-form-slot"></slot>
|
|
17
|
+
`}setActionAlarmSeverity(t){if(t&&this.action.alarm){let e=this.action.alarm;e.severity=t,this.action.alarm=Object.assign({},e)}this.dispatchEvent(new c),this.requestUpdate()}};__decorate([i({type:Object,attribute:!1})],OrRuleAlarmModal.prototype,"action",void 0),__decorate([i({type:String})],OrRuleAlarmModal.prototype,"title",void 0),__decorate([i({type:Object})],OrRuleAlarmModal.prototype,"query",void 0),OrRuleAlarmModal=__decorate([r("or-rule-alarm-modal")],OrRuleAlarmModal);export{OrRuleAlarmModal};
|