@openremote/or-rules 1.8.0-snapshot.20250725074716 → 1.8.0-snapshot.20250725120000
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,11 +1,196 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 } from "lit";
|
|
8
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
9
|
+
import "@openremote/or-mwc-components/or-mwc-input";
|
|
10
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
11
|
+
import i18next from "i18next";
|
|
12
|
+
import { translate } from "@openremote/or-translate";
|
|
13
|
+
import { OrMwcDialogOpenedEvent } from "@openremote/or-mwc-components/or-mwc-dialog";
|
|
14
|
+
import { OrRulesJsonRuleChangedEvent } from "../or-rule-json-viewer";
|
|
15
|
+
const checkValidity = (form) => {
|
|
16
|
+
if (form) {
|
|
17
|
+
const inputs = form.querySelectorAll('or-mwc-input');
|
|
18
|
+
const elements = Array.prototype.slice.call(inputs);
|
|
19
|
+
return elements.every((element) => {
|
|
20
|
+
if (element.shadowRoot) {
|
|
21
|
+
const input = element.shadowRoot.querySelector('input, textarea, select');
|
|
22
|
+
if (input && input.checkValidity()) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (element._mdcComponent) {
|
|
27
|
+
element._mdcComponent.valid = false;
|
|
28
|
+
element._mdcComponent.helperTextContent = 'required';
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export class OrRulesNotificationModalCancelEvent extends CustomEvent {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(OrRulesNotificationModalCancelEvent.NAME, {
|
|
42
|
+
bubbles: true,
|
|
43
|
+
composed: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
OrRulesNotificationModalCancelEvent.NAME = "or-rules-notification-modal-cancel";
|
|
48
|
+
export class OrRulesNotificationModalOkEvent extends CustomEvent {
|
|
49
|
+
constructor() {
|
|
50
|
+
super(OrRulesNotificationModalOkEvent.NAME, {
|
|
51
|
+
bubbles: true,
|
|
52
|
+
composed: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
OrRulesNotificationModalOkEvent.NAME = "or-rules-notification-modal-ok";
|
|
57
|
+
let OrRuleNotificationModal = class OrRuleNotificationModal extends translate(i18next)(LitElement) {
|
|
58
|
+
constructor() {
|
|
59
|
+
super();
|
|
60
|
+
this.title = "message";
|
|
61
|
+
this.addEventListener(OrMwcDialogOpenedEvent.NAME, this.initDialog);
|
|
62
|
+
}
|
|
63
|
+
connectedCallback() {
|
|
64
|
+
this.addEventListener(OrRulesJsonRuleChangedEvent.NAME, this._onJsonRuleChanged);
|
|
65
|
+
return super.connectedCallback();
|
|
66
|
+
}
|
|
67
|
+
disconnectedCallback() {
|
|
68
|
+
this.removeEventListener(OrRulesJsonRuleChangedEvent.NAME, this._onJsonRuleChanged);
|
|
69
|
+
return super.disconnectedCallback();
|
|
70
|
+
}
|
|
71
|
+
_onJsonRuleChanged() {
|
|
72
|
+
this.validateForm();
|
|
73
|
+
}
|
|
74
|
+
initDialog() {
|
|
75
|
+
if (!this._orMwcDialog)
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
renderDialogHTML(action) {
|
|
79
|
+
const dialog = this.shadowRoot.getElementById("notification-modal");
|
|
80
|
+
if (!this.shadowRoot)
|
|
81
|
+
return;
|
|
82
|
+
const slot = this.shadowRoot.querySelector('.notification-form-slot');
|
|
83
|
+
if (dialog && slot) {
|
|
84
|
+
let container = document.createElement("div");
|
|
85
|
+
slot.assignedNodes({ flatten: true }).forEach((child) => {
|
|
86
|
+
if (child instanceof HTMLElement) {
|
|
87
|
+
container.appendChild(child);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
dialog.content = html `${container}`;
|
|
91
|
+
dialog.dismissAction = null;
|
|
92
|
+
this.requestUpdate();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
firstUpdated(changedProperties) {
|
|
96
|
+
if (changedProperties.has("action")) {
|
|
97
|
+
this.renderDialogHTML(this.action);
|
|
98
|
+
}
|
|
99
|
+
// Possibly, a render is triggered by renderDialogHTML(), so we await the pending update. (if there is any)
|
|
100
|
+
this.getUpdateComplete().finally(() => {
|
|
101
|
+
this.validateForm();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
validateForm() {
|
|
105
|
+
var _a, _b, _c;
|
|
106
|
+
const valid = this.checkForm();
|
|
107
|
+
(_a = this._orMwcDialog) === null || _a === void 0 ? void 0 : _a.setActions((_c = (_b = this._orMwcDialog) === null || _b === void 0 ? void 0 : _b.actions) === null || _c === void 0 ? void 0 : _c.map(action => {
|
|
108
|
+
if (action.actionName === "ok") {
|
|
109
|
+
action.disabled = !valid;
|
|
110
|
+
}
|
|
111
|
+
return action;
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
checkForm() {
|
|
115
|
+
if (this.shadowRoot) {
|
|
116
|
+
const dialog = this._orMwcDialog;
|
|
117
|
+
const root = dialog === null || dialog === void 0 ? void 0 : dialog.shadowRoot;
|
|
118
|
+
if (dialog && root) {
|
|
119
|
+
const messageNotification = root.querySelector("or-rule-form-email-message");
|
|
120
|
+
const pushNotification = root.querySelector("or-rule-form-push-notification");
|
|
121
|
+
const localizedNotification = root.querySelector("or-rule-form-localized");
|
|
122
|
+
if (pushNotification === null || pushNotification === void 0 ? void 0 : pushNotification.shadowRoot) {
|
|
123
|
+
const form = pushNotification.shadowRoot.querySelector('form');
|
|
124
|
+
return checkValidity(form);
|
|
125
|
+
}
|
|
126
|
+
else if (messageNotification === null || messageNotification === void 0 ? void 0 : messageNotification.shadowRoot) {
|
|
127
|
+
const form = messageNotification.shadowRoot.querySelector('form');
|
|
128
|
+
return checkValidity(form);
|
|
129
|
+
}
|
|
130
|
+
else if (localizedNotification === null || localizedNotification === void 0 ? void 0 : localizedNotification.shadowRoot) {
|
|
131
|
+
return localizedNotification.isValid();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
render() {
|
|
137
|
+
const onCancel = () => {
|
|
138
|
+
this.dispatchEvent(new OrRulesNotificationModalCancelEvent());
|
|
139
|
+
};
|
|
140
|
+
const onOk = () => {
|
|
141
|
+
this.dispatchEvent(new OrRulesNotificationModalOkEvent());
|
|
142
|
+
};
|
|
143
|
+
const dismissAction = {
|
|
144
|
+
actionName: "cancel",
|
|
145
|
+
action: onCancel
|
|
146
|
+
};
|
|
147
|
+
const actions = [
|
|
148
|
+
{
|
|
149
|
+
actionName: "cancel",
|
|
150
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="cancel"></or-mwc-input>`,
|
|
151
|
+
action: onCancel
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
actionName: "ok",
|
|
155
|
+
content: "ok",
|
|
156
|
+
disabled: true, // (by default, can be changed in checkForm())
|
|
157
|
+
action: onOk
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
const styles = html `
|
|
161
|
+
<style>
|
|
162
|
+
.mdc-dialog__actions {
|
|
163
|
+
justify-content: space-between !important;
|
|
164
|
+
}
|
|
165
|
+
</style>
|
|
166
|
+
`;
|
|
167
|
+
const notificationPickerModalOpen = () => {
|
|
168
|
+
const dialog = this.shadowRoot.getElementById("notification-modal");
|
|
169
|
+
if (dialog) {
|
|
170
|
+
dialog.open();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
return html `
|
|
174
|
+
<or-mwc-input .type="${InputType.BUTTON}" label="message" @or-mwc-input-changed="${notificationPickerModalOpen}"></or-mwc-input>
|
|
175
|
+
<or-mwc-dialog id="notification-modal" .heading="${this.title}" .dismissAction="${dismissAction}" .actions="${actions}" .styles="${styles}"></or-mwc-dialog>
|
|
176
|
+
<slot class="notification-form-slot"></slot>
|
|
177
|
+
`;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
__decorate([
|
|
181
|
+
property({ type: Object })
|
|
182
|
+
], OrRuleNotificationModal.prototype, "action", void 0);
|
|
183
|
+
__decorate([
|
|
184
|
+
property({ type: String })
|
|
185
|
+
], OrRuleNotificationModal.prototype, "title", void 0);
|
|
186
|
+
__decorate([
|
|
187
|
+
property({ type: Object })
|
|
188
|
+
], OrRuleNotificationModal.prototype, "query", void 0);
|
|
189
|
+
__decorate([
|
|
190
|
+
query("#notification-modal")
|
|
191
|
+
], OrRuleNotificationModal.prototype, "_orMwcDialog", void 0);
|
|
192
|
+
OrRuleNotificationModal = __decorate([
|
|
193
|
+
customElement("or-rule-notification-modal")
|
|
194
|
+
], OrRuleNotificationModal);
|
|
195
|
+
export { OrRuleNotificationModal };
|
|
196
|
+
//# sourceMappingURL=or-rule-notification-modal.js.map
|
|
@@ -1,17 +1,142 @@
|
|
|
1
|
-
var __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
|
+
import { html, LitElement } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { getAssetTypeFromQuery, } from "../../index";
|
|
10
|
+
import "@openremote/or-mwc-components/or-mwc-input";
|
|
11
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
12
|
+
import i18next from "i18next";
|
|
13
|
+
import { OrRulesJsonRuleChangedEvent } from "../or-rule-json-viewer";
|
|
14
|
+
import { translate } from "@openremote/or-translate";
|
|
15
|
+
import { OrMwcDialogOpenedEvent } from "@openremote/or-mwc-components/or-mwc-dialog";
|
|
16
|
+
import { OrMapClickedEvent } from "@openremote/or-map";
|
|
17
|
+
import "@openremote/or-map";
|
|
18
|
+
let OrRuleRadialModal = class OrRuleRadialModal extends translate(i18next)(LitElement) {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.addEventListener(OrMwcDialogOpenedEvent.NAME, this.initRadialMap);
|
|
22
|
+
}
|
|
23
|
+
initRadialMap() {
|
|
24
|
+
const modal = this.shadowRoot.getElementById('radial-modal');
|
|
25
|
+
if (!modal)
|
|
26
|
+
return;
|
|
27
|
+
const map = modal.shadowRoot.querySelector('.or-map');
|
|
28
|
+
if (map) {
|
|
29
|
+
map.addEventListener(OrMapClickedEvent.NAME, (evt) => {
|
|
30
|
+
const lngLat = evt.detail.lngLat;
|
|
31
|
+
const latElement = modal.shadowRoot.querySelector('.location-lat');
|
|
32
|
+
const lngElement = modal.shadowRoot.querySelector('.location-lng');
|
|
33
|
+
latElement.value = lngLat.lat;
|
|
34
|
+
lngElement.value = lngLat.lng;
|
|
35
|
+
const event = new Event('change');
|
|
36
|
+
latElement.dispatchEvent(event);
|
|
37
|
+
lngElement.dispatchEvent(event);
|
|
38
|
+
this.setValuePredicateProperty('lat', lngLat.lat);
|
|
39
|
+
this.setValuePredicateProperty('lng', lngLat.lng);
|
|
40
|
+
});
|
|
41
|
+
const latElement = modal.shadowRoot.querySelector('.location-lat');
|
|
42
|
+
const lngElement = modal.shadowRoot.querySelector('.location-lng');
|
|
43
|
+
if (lngElement.value && latElement.value) {
|
|
44
|
+
const LngLat = [parseFloat(lngElement.value), parseFloat(latElement.value)];
|
|
45
|
+
map.flyTo(LngLat, 15);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
map.flyTo();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
getAttributeName(attributePredicate) {
|
|
53
|
+
return attributePredicate && attributePredicate.name ? attributePredicate.name.value : undefined;
|
|
54
|
+
}
|
|
55
|
+
setValuePredicateProperty(propertyName, value) {
|
|
56
|
+
if (!this.attributePredicate)
|
|
57
|
+
return;
|
|
58
|
+
if (!this.attributePredicate.value)
|
|
59
|
+
return;
|
|
60
|
+
const valuePredicate = this.attributePredicate.value;
|
|
61
|
+
valuePredicate[propertyName] = value;
|
|
62
|
+
this.attributePredicate = Object.assign({}, this.attributePredicate);
|
|
63
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
64
|
+
this.requestUpdate();
|
|
65
|
+
}
|
|
66
|
+
renderDialogHTML(value) {
|
|
67
|
+
const dialog = this.shadowRoot.getElementById("radial-modal");
|
|
68
|
+
if (dialog) {
|
|
69
|
+
dialog.content = html `
|
|
70
|
+
<div style="display:grid">
|
|
71
|
+
<or-map class="or-map" type="VECTOR" style="border: 1px solid #d5d5d5; height: 400px; min-width: 300px; margin-bottom: 20px;">
|
|
72
|
+
<or-map-marker active color="#FF0000" icon="information" lat="${value.lat}" lng="${value.lng}" radius="${value.radius}"></or-map-marker>
|
|
73
|
+
</or-map>
|
|
74
|
+
|
|
75
|
+
<div class="layout horizontal">
|
|
76
|
+
<input hidden class="location-lng" required placeholder=" " type="text" .value="${value && value.lng ? value.lng : null}" />
|
|
77
|
+
<input hidden class="location-lat" required placeholder=" " type="text" .value="${value && value.lat ? value.lat : null}" />
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<label>${i18next.t("radiusMin")}</label>
|
|
81
|
+
<input @change="${(e) => this.setValuePredicateProperty("radius", parseInt(e.target.value))}" style="max-width: calc(50% - 30px);" required placeholder=" " min="100" type="number" .value="${value && value.radius ? value.radius : 100}" />
|
|
82
|
+
</div>`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
render() {
|
|
86
|
+
if (!this.attributePredicate)
|
|
87
|
+
return html ``;
|
|
88
|
+
if (!this.query)
|
|
89
|
+
return html ``;
|
|
90
|
+
const valuePredicate = this.attributePredicate.value;
|
|
91
|
+
if (!this.assetDescriptor || !valuePredicate) {
|
|
92
|
+
return html ``;
|
|
93
|
+
}
|
|
94
|
+
const attributeName = this.getAttributeName(this.attributePredicate);
|
|
95
|
+
const assetType = getAssetTypeFromQuery(this.query);
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
const value = valuePredicate ? valuePredicate : undefined;
|
|
98
|
+
const radiusPickerModalActions = [
|
|
99
|
+
{
|
|
100
|
+
actionName: "cancel",
|
|
101
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="cancel"></or-mwc-input>`,
|
|
102
|
+
action: () => {
|
|
103
|
+
// Nothing to do here
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
actionName: "ok",
|
|
108
|
+
default: true,
|
|
109
|
+
content: html `<or-mwc-input class="button" .type="${InputType.BUTTON}" label="ok"></or-mwc-input>`,
|
|
110
|
+
action: () => {
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
const radialPickerModalOpen = () => {
|
|
115
|
+
const dialog = this.shadowRoot.getElementById("radial-modal");
|
|
116
|
+
if (dialog) {
|
|
117
|
+
dialog.dismissAction = null;
|
|
118
|
+
dialog.open();
|
|
119
|
+
this.renderDialogHTML(value);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.renderDialogHTML(value);
|
|
123
|
+
return html `
|
|
124
|
+
<or-mwc-input .type="${InputType.BUTTON}" label="area" @or-mwc-input-changed="${radialPickerModalOpen}"></or-mwc-input>
|
|
125
|
+
<or-mwc-dialog id="radial-modal" heading="area" .actions="${radiusPickerModalActions}"></or-mwc-dialog>
|
|
126
|
+
`;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
__decorate([
|
|
130
|
+
property({ type: Object })
|
|
131
|
+
], OrRuleRadialModal.prototype, "assetDescriptor", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
property({ type: Object })
|
|
134
|
+
], OrRuleRadialModal.prototype, "attributePredicate", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
property({ type: Object })
|
|
137
|
+
], OrRuleRadialModal.prototype, "query", void 0);
|
|
138
|
+
OrRuleRadialModal = __decorate([
|
|
139
|
+
customElement("or-rule-radial-modal")
|
|
140
|
+
], OrRuleRadialModal);
|
|
141
|
+
export { OrRuleRadialModal };
|
|
142
|
+
//# sourceMappingURL=or-rule-radial-modal.js.map
|
|
@@ -1,8 +1,78 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 { html, LitElement } from "lit";
|
|
10
|
+
import { customElement, property } from "lit/decorators.js";
|
|
11
|
+
let OrRuleWebhookModal = class OrRuleWebhookModal extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.title = i18next.t('message');
|
|
15
|
+
}
|
|
16
|
+
/* ----------------------- */
|
|
17
|
+
firstUpdated(changedProperties) {
|
|
18
|
+
if (changedProperties.has("action")) {
|
|
19
|
+
this.renderDialogHTML(this.action);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
renderDialogHTML(action) {
|
|
23
|
+
const dialog = this.shadowRoot.getElementById("webhook-modal");
|
|
24
|
+
if (!this.shadowRoot)
|
|
25
|
+
return;
|
|
26
|
+
const slot = this.shadowRoot.querySelector('.webhook-form-slot');
|
|
27
|
+
if (dialog && slot) {
|
|
28
|
+
let container = document.createElement("div");
|
|
29
|
+
slot.assignedNodes({ flatten: true }).forEach((child) => {
|
|
30
|
+
if (child instanceof HTMLElement) {
|
|
31
|
+
container.appendChild(child);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
dialog.content = html `${container}`;
|
|
35
|
+
dialog.dismissAction = null;
|
|
36
|
+
this.requestUpdate();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
closeForm(event) {
|
|
40
|
+
const dialog = this.shadowRoot.host;
|
|
41
|
+
dialog.close();
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
if (!this.action) {
|
|
45
|
+
return html `${i18next.t('errorOccurred')}`;
|
|
46
|
+
}
|
|
47
|
+
const webhookModalActions = [
|
|
48
|
+
{
|
|
49
|
+
actionName: "", content: html `
|
|
50
|
+
<or-mwc-input .type="${InputType.BUTTON}" label="ok"
|
|
51
|
+
@or-mwc-input-changed="${this.closeForm}"></or-mwc-input>`
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
const webhookModalOpen = () => {
|
|
55
|
+
const dialog = this.shadowRoot.getElementById("webhook-modal");
|
|
56
|
+
if (dialog) {
|
|
57
|
+
dialog.open();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return html `
|
|
61
|
+
<or-mwc-input type="${InputType.BUTTON}" label="message"
|
|
62
|
+
@or-mwc-input-changed="${webhookModalOpen}"></or-mwc-input>
|
|
63
|
+
<or-mwc-dialog id="webhook-modal" heading="${this.title}" .actions="${webhookModalActions}"></or-mwc-dialog>
|
|
64
|
+
<slot class="webhook-form-slot"></slot>
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
__decorate([
|
|
69
|
+
property({ type: Object })
|
|
70
|
+
], OrRuleWebhookModal.prototype, "action", void 0);
|
|
71
|
+
__decorate([
|
|
72
|
+
property({ type: String })
|
|
73
|
+
], OrRuleWebhookModal.prototype, "title", void 0);
|
|
74
|
+
OrRuleWebhookModal = __decorate([
|
|
75
|
+
customElement("or-rule-webhook-modal")
|
|
76
|
+
], OrRuleWebhookModal);
|
|
77
|
+
export { OrRuleWebhookModal };
|
|
78
|
+
//# sourceMappingURL=or-rule-webhook-modal.js.map
|
|
@@ -1,5 +1,97 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
/*
|
|
17
|
+
* Copyright 2024, OpenRemote Inc.
|
|
18
|
+
*
|
|
19
|
+
* See the CONTRIBUTORS.txt file in the distribution for a
|
|
20
|
+
* full listing of individual contributors.
|
|
21
|
+
*
|
|
22
|
+
* This program is free software: you can redistribute it and/or modify
|
|
23
|
+
* it under the terms of the GNU Affero General Public License as
|
|
24
|
+
* published by the Free Software Foundation, either version 3 of the
|
|
25
|
+
* License, or (at your option) any later version.
|
|
26
|
+
*
|
|
27
|
+
* This program is distributed in the hope that it will be useful,
|
|
28
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30
|
+
* GNU Affero General Public License for more details.
|
|
31
|
+
*
|
|
32
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
33
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
34
|
+
*/
|
|
35
|
+
import { html, LitElement } from "lit";
|
|
36
|
+
import { customElement, property } from "lit/decorators.js";
|
|
37
|
+
import "./modals/or-rule-alarm-modal";
|
|
38
|
+
import "./forms/or-rule-form-alarm";
|
|
39
|
+
import manager from "@openremote/core";
|
|
40
|
+
let OrRuleActionAlarm = class OrRuleActionAlarm extends LitElement {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this._loadedUsers = [];
|
|
44
|
+
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
const _super = Object.create(null, {
|
|
47
|
+
connectedCallback: { get: () => super.connectedCallback }
|
|
48
|
+
});
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
yield this.loadUsers();
|
|
51
|
+
_super.connectedCallback.call(this);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
loadUsers() {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const usersResponse = yield manager.rest.api.UserResource.query({
|
|
57
|
+
realmPredicate: { name: manager.displayRealm },
|
|
58
|
+
});
|
|
59
|
+
if (usersResponse.status !== 200) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this._loadedUsers = usersResponse.data.filter((user) => user.enabled && !user.serviceAccount);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
render() {
|
|
66
|
+
if (!this.action.alarm || !this.action.alarm.title) {
|
|
67
|
+
return html ``;
|
|
68
|
+
}
|
|
69
|
+
const alarm = this.action.alarm;
|
|
70
|
+
let modalTemplate = ``;
|
|
71
|
+
if (alarm) {
|
|
72
|
+
modalTemplate = html `
|
|
73
|
+
<or-rule-alarm-modal title="alarm." .action="${this.action}">
|
|
74
|
+
<or-rule-form-alarm .users="${this._loadedUsers}" .action="${this.action}"></or-rule-form-alarm>
|
|
75
|
+
</or-rule-alarm-modal>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
return html `${modalTemplate}`;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
__decorate([
|
|
82
|
+
property({ type: Object, attribute: false })
|
|
83
|
+
], OrRuleActionAlarm.prototype, "rule", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
property({ type: Object, attribute: false })
|
|
86
|
+
], OrRuleActionAlarm.prototype, "action", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
property({ type: String, attribute: false })
|
|
89
|
+
], OrRuleActionAlarm.prototype, "actionType", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: Object })
|
|
92
|
+
], OrRuleActionAlarm.prototype, "config", void 0);
|
|
93
|
+
OrRuleActionAlarm = __decorate([
|
|
94
|
+
customElement("or-rule-action-alarm")
|
|
95
|
+
], OrRuleActionAlarm);
|
|
96
|
+
export { OrRuleActionAlarm };
|
|
97
|
+
//# sourceMappingURL=or-rule-action-alarm.js.map
|