@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,29 +1,216 @@
|
|
|
1
|
-
var __decorate
|
|
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
|
-
|
|
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 { css, html, LitElement } from "lit";
|
|
8
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
9
|
+
import { AssetModelUtil } from "@openremote/model";
|
|
10
|
+
import { getAssetTypeFromQuery } from "../index";
|
|
11
|
+
import "./or-rule-asset-query";
|
|
12
|
+
import "./or-rule-trigger-query";
|
|
13
|
+
import "@openremote/or-mwc-components/or-mwc-menu";
|
|
14
|
+
import { getContentWithMenuTemplate } from "@openremote/or-mwc-components/or-mwc-menu";
|
|
15
|
+
import "@openremote/or-icon";
|
|
16
|
+
import "@openremote/or-translate";
|
|
17
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
18
|
+
import { Util } from "@openremote/core";
|
|
19
|
+
import { i18next, translate } from "@openremote/or-translate";
|
|
20
|
+
import { OrRulesJsonRuleChangedEvent } from "./or-rule-json-viewer";
|
|
21
|
+
const TIMER_COLOR = "4b87ea";
|
|
22
|
+
const DATE_TIME_COLOR = "6AEAA4";
|
|
23
|
+
export function getWhenTypesMenu(config, assetInfos) {
|
|
24
|
+
let addAssetTypes = true;
|
|
25
|
+
let addAgentTypes = true;
|
|
26
|
+
let addTimer = true;
|
|
27
|
+
if (config && config.controls && config.controls.allowedConditionTypes) {
|
|
28
|
+
addAssetTypes = config.controls.allowedConditionTypes.indexOf("assetQuery" /* ConditionType.ASSET_QUERY */) >= 0;
|
|
29
|
+
addAgentTypes = config.controls.allowedConditionTypes.indexOf("agentQuery" /* ConditionType.AGENT_QUERY */) >= 0;
|
|
30
|
+
addTimer = config.controls.allowedConditionTypes.indexOf("time" /* ConditionType.TIME */) >= 0;
|
|
31
|
+
}
|
|
32
|
+
const menu = [];
|
|
33
|
+
if (assetInfos) {
|
|
34
|
+
if (addAssetTypes) {
|
|
35
|
+
const items = assetInfos.filter((assetInfo) => assetInfo.assetDescriptor.descriptorType !== "agent").map((assetTypeInfo) => {
|
|
36
|
+
const color = AssetModelUtil.getAssetDescriptorColour(assetTypeInfo);
|
|
37
|
+
const icon = AssetModelUtil.getAssetDescriptorIcon(assetTypeInfo);
|
|
38
|
+
const styleMap = color ? { "--or-icon-fill": "#" + color } : undefined;
|
|
39
|
+
return {
|
|
40
|
+
text: Util.getAssetTypeLabel(assetTypeInfo.assetDescriptor),
|
|
41
|
+
value: assetTypeInfo.assetDescriptor.name,
|
|
42
|
+
icon: icon ? icon : AssetModelUtil.getAssetDescriptorIcon("ThingAsset" /* WellknownAssets.THINGASSET */),
|
|
43
|
+
styleMap: styleMap
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
menu.push(...items.sort(Util.sortByString((listItem) => listItem.text)));
|
|
47
|
+
}
|
|
48
|
+
if (addAssetTypes && addAgentTypes) {
|
|
49
|
+
menu.push(null);
|
|
50
|
+
}
|
|
51
|
+
if (addAgentTypes) {
|
|
52
|
+
const items = assetInfos.filter((assetInfo) => assetInfo.assetDescriptor.descriptorType === "agent").map((assetTypeInfo) => {
|
|
53
|
+
const color = AssetModelUtil.getAssetDescriptorColour(assetTypeInfo);
|
|
54
|
+
const icon = AssetModelUtil.getAssetDescriptorIcon(assetTypeInfo);
|
|
55
|
+
const styleMap = color ? { "--or-icon-fill": "#" + color } : undefined;
|
|
56
|
+
return {
|
|
57
|
+
text: Util.getAssetTypeLabel(assetTypeInfo.assetDescriptor),
|
|
58
|
+
value: assetTypeInfo.assetDescriptor.name,
|
|
59
|
+
icon: icon ? icon : AssetModelUtil.getAssetDescriptorIcon("ThingAsset" /* WellknownAssets.THINGASSET */),
|
|
60
|
+
styleMap: styleMap
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
menu.push(...items.sort(Util.sortByString((listItem) => listItem.text)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (addTimer) {
|
|
67
|
+
menu.push(null);
|
|
68
|
+
menu.push({
|
|
69
|
+
text: i18next.t("time"),
|
|
70
|
+
icon: "timer",
|
|
71
|
+
value: "time" /* ConditionType.TIME */,
|
|
72
|
+
styleMap: { "--or-icon-fill": "#" + TIMER_COLOR }
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return menu;
|
|
76
|
+
}
|
|
77
|
+
export function updateRuleConditionType(ruleCondition, value, config) {
|
|
78
|
+
if (!value) {
|
|
79
|
+
ruleCondition.assets = undefined;
|
|
80
|
+
ruleCondition.cron = undefined;
|
|
81
|
+
ruleCondition.sun = undefined;
|
|
82
|
+
}
|
|
83
|
+
else if (value === "time" /* ConditionType.TIME */) {
|
|
84
|
+
ruleCondition.assets = undefined;
|
|
85
|
+
const date = new Date();
|
|
86
|
+
ruleCondition.cron = Util.formatCronString(undefined, undefined, undefined, date.getUTCHours().toString(), date.getUTCMinutes().toString());
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
ruleCondition.cron = undefined;
|
|
90
|
+
if (config && config.json && config.json.whenAssetQuery) {
|
|
91
|
+
ruleCondition.assets = JSON.parse(JSON.stringify(config.json.whenAssetQuery));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
ruleCondition.assets = {};
|
|
95
|
+
}
|
|
96
|
+
ruleCondition.assets.types = [value];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// language=CSS
|
|
100
|
+
const style = css `
|
|
101
|
+
:host {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-direction: row;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
or-rule-asset-query {
|
|
107
|
+
flex-grow: 1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
#type {
|
|
111
|
+
white-space: nowrap;
|
|
112
|
+
text-transform: capitalize;
|
|
113
|
+
margin: 14px 3px auto 0;
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
let OrRuleCondition = class OrRuleCondition extends translate(i18next)(LitElement) {
|
|
117
|
+
constructor() {
|
|
118
|
+
super(...arguments);
|
|
119
|
+
this.readonly = false;
|
|
120
|
+
}
|
|
121
|
+
static get styles() {
|
|
122
|
+
return style;
|
|
123
|
+
}
|
|
124
|
+
render() {
|
|
125
|
+
const showTypeSelect = !this.config || !this.config.controls || this.config.controls.hideConditionTypeOptions !== true;
|
|
126
|
+
const type = this.type;
|
|
127
|
+
if (!type && !showTypeSelect) {
|
|
128
|
+
return html `<span>INVALID CONFIG - NO TYPE SPECIFIED AND TYPE SELECTOR DISABLED</span>`;
|
|
129
|
+
}
|
|
130
|
+
let typeTemplate = ``;
|
|
131
|
+
let template = ``;
|
|
132
|
+
if (showTypeSelect) {
|
|
133
|
+
let buttonIcon;
|
|
134
|
+
let buttonColor = "inherit";
|
|
135
|
+
if (type) {
|
|
136
|
+
switch (type) {
|
|
137
|
+
case "time" /* ConditionType.TIME */:
|
|
138
|
+
buttonIcon = "timer";
|
|
139
|
+
buttonColor = TIMER_COLOR;
|
|
140
|
+
break;
|
|
141
|
+
default:
|
|
142
|
+
const ad = AssetModelUtil.getAssetDescriptor(type);
|
|
143
|
+
buttonIcon = AssetModelUtil.getAssetDescriptorIcon(ad) || buttonIcon;
|
|
144
|
+
buttonColor = AssetModelUtil.getAssetDescriptorColour(ad) || buttonColor;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (this.readonly) {
|
|
149
|
+
typeTemplate = html `
|
|
150
|
+
<div id="type" style="--or-mwc-input-color: #${buttonColor}">
|
|
151
|
+
<or-mwc-input readonly type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-mwc-input>
|
|
152
|
+
</div>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
typeTemplate = html `
|
|
157
|
+
<div id="type" style="--or-mwc-input-color: #${buttonColor}">
|
|
158
|
+
${getContentWithMenuTemplate(html `<or-mwc-input type="${InputType.BUTTON}" .icon="${buttonIcon || ""}"></or-mwc-input>`, getWhenTypesMenu(this.config, this.assetInfos), type, (value) => this.type = value)}
|
|
159
|
+
</div>
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (type) {
|
|
164
|
+
switch (type) {
|
|
165
|
+
case "time" /* ConditionType.TIME */:
|
|
166
|
+
template = html `<or-rule-trigger-query id="asset-query" .condition="${this.ruleCondition}"></or-rule-trigger-query>`;
|
|
167
|
+
break;
|
|
168
|
+
default:
|
|
169
|
+
template = html `<or-rule-asset-query id="asset-query" .config="${this.config}" .assetInfos="${this.assetInfos}" .readonly="${this.readonly}"
|
|
170
|
+
.condition="${this.ruleCondition}" .assetProvider="${this.assetProvider}"
|
|
171
|
+
></or-rule-asset-query>`;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return html `
|
|
176
|
+
${typeTemplate}
|
|
177
|
+
${template}
|
|
178
|
+
`;
|
|
179
|
+
}
|
|
180
|
+
get type() {
|
|
181
|
+
const assetType = getAssetTypeFromQuery(this.ruleCondition.assets);
|
|
182
|
+
if (assetType) {
|
|
183
|
+
return assetType;
|
|
184
|
+
}
|
|
185
|
+
if (this.ruleCondition.cron || this.ruleCondition.sun) {
|
|
186
|
+
return "time" /* ConditionType.TIME */;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
set type(value) {
|
|
190
|
+
updateRuleConditionType(this.ruleCondition, value, this.config);
|
|
191
|
+
if (this._assetQuery) {
|
|
192
|
+
this._assetQuery.refresh();
|
|
193
|
+
}
|
|
194
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
195
|
+
this.requestUpdate();
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
__decorate([
|
|
199
|
+
property({ type: Object, attribute: false })
|
|
200
|
+
], OrRuleCondition.prototype, "ruleCondition", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
property({ type: Object })
|
|
203
|
+
], OrRuleCondition.prototype, "config", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property({ type: Object })
|
|
206
|
+
], OrRuleCondition.prototype, "assetInfos", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: Object })
|
|
209
|
+
], OrRuleCondition.prototype, "assetProvider", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
query("#asset-query")
|
|
212
|
+
], OrRuleCondition.prototype, "_assetQuery", void 0);
|
|
213
|
+
OrRuleCondition = __decorate([
|
|
214
|
+
customElement("or-rule-condition")
|
|
215
|
+
], OrRuleCondition);
|
|
216
|
+
//# sourceMappingURL=or-rule-condition.js.map
|