@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,33 +1,235 @@
|
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
import { css, html, LitElement } from "lit";
|
|
17
|
+
import { customElement, property } from "lit/decorators.js";
|
|
18
|
+
import { getAssetIdsFromQuery, getAssetTypeFromQuery } from "../index";
|
|
19
|
+
import { AssetModelUtil } from "@openremote/model";
|
|
20
|
+
import { Util } from "@openremote/core";
|
|
21
|
+
import "@openremote/or-attribute-input";
|
|
22
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
23
|
+
import i18next from "i18next";
|
|
24
|
+
import { OrRulesJsonRuleChangedEvent } from "./or-rule-json-viewer";
|
|
25
|
+
import { translate } from "@openremote/or-translate";
|
|
26
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
27
|
+
import { when } from "lit/directives/when.js";
|
|
28
|
+
// language=CSS
|
|
29
|
+
const style = css `
|
|
30
|
+
:host {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host > * {
|
|
38
|
+
margin: 0 3px 6px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.min-width {
|
|
42
|
+
min-width: 200px;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
let OrRuleActionAttribute = class OrRuleActionAttribute extends translate(i18next)(LitElement) {
|
|
46
|
+
static get styles() {
|
|
47
|
+
return style;
|
|
48
|
+
}
|
|
49
|
+
shouldUpdate(_changedProperties) {
|
|
50
|
+
if (_changedProperties.has("action")) {
|
|
51
|
+
this._assets = undefined;
|
|
52
|
+
}
|
|
53
|
+
return super.shouldUpdate(_changedProperties);
|
|
54
|
+
}
|
|
55
|
+
refresh() {
|
|
56
|
+
// Clear assets
|
|
57
|
+
this._assets = undefined;
|
|
58
|
+
}
|
|
59
|
+
_getAssetType() {
|
|
60
|
+
if (!this.action.target) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const query = this.action.target.assets ? this.action.target.assets : this.action.target.matchedAssets ? this.action.target.matchedAssets : undefined;
|
|
64
|
+
return query ? getAssetTypeFromQuery(query) : undefined;
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
if (!this.action.target) {
|
|
68
|
+
return html ``;
|
|
69
|
+
}
|
|
70
|
+
const assetType = this._getAssetType();
|
|
71
|
+
if (!assetType) {
|
|
72
|
+
return html ``;
|
|
73
|
+
}
|
|
74
|
+
const query = this.action.target.assets ? this.action.target.assets : this.action.target.matchedAssets ? this.action.target.matchedAssets : undefined;
|
|
75
|
+
const assetDescriptor = this.assetInfos ? this.assetInfos.find((assetTypeInfo) => assetTypeInfo.assetDescriptor.name === assetType) : undefined;
|
|
76
|
+
if (!assetDescriptor) {
|
|
77
|
+
return html ``;
|
|
78
|
+
}
|
|
79
|
+
if (!this._assets) {
|
|
80
|
+
this.loadAssets(assetType);
|
|
81
|
+
}
|
|
82
|
+
// TODO: Add multiselect support
|
|
83
|
+
const ids = getAssetIdsFromQuery(query);
|
|
84
|
+
const idValue = ids && ids.length > 0 ? ids[0] : "*";
|
|
85
|
+
const idOptions = [
|
|
86
|
+
["*", i18next.t("matched")]
|
|
87
|
+
];
|
|
88
|
+
let searchProvider;
|
|
89
|
+
return html `
|
|
90
|
+
|
|
91
|
+
<!-- Show SELECT input with 'loading' until the assets are retrieved -->
|
|
92
|
+
${when((!this._assets), () => html `
|
|
93
|
+
<or-mwc-input id="matchSelect" class="min-width" type="${InputType.SELECT}" .readonly="${true}" .label="${i18next.t('loading')}"></or-mwc-input>
|
|
94
|
+
`, () => {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
// Set list of displayed assets, and filtering assets out if needed.
|
|
97
|
+
// If <= 25 assets: display everything
|
|
98
|
+
// If between 25 and 100 assets: display everything with search functionality
|
|
99
|
+
// If > 100 assets: only display if in line with search input
|
|
100
|
+
if (this._assets.length <= 25) {
|
|
101
|
+
idOptions.push(...this._assets.map((asset) => [asset.id, asset.name]));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
searchProvider = (search) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
var _a;
|
|
106
|
+
if (search) {
|
|
107
|
+
return this._assets.filter((asset) => { var _a; return (_a = asset.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search.toLowerCase()); }).map((asset) => [asset.id, asset.name]);
|
|
108
|
+
}
|
|
109
|
+
else if (this._assets.length <= 100) {
|
|
110
|
+
idOptions.push(...this._assets.map((asset) => [asset.id, asset.name]));
|
|
111
|
+
return idOptions;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const asset = (_a = this._assets) === null || _a === void 0 ? void 0 : _a.find((asset) => asset.id == idValue);
|
|
115
|
+
if (asset && idOptions.find(([id, _value]) => id == asset.id) == undefined) {
|
|
116
|
+
idOptions.push([asset.id, asset.name]); // add selected asset if there is one.
|
|
117
|
+
}
|
|
118
|
+
return idOptions;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// Get selected asset and its descriptors
|
|
123
|
+
const asset = idValue && idValue !== "*" ? this._assets.find(a => a.id === idValue) : undefined;
|
|
124
|
+
const descriptors = AssetModelUtil.getAttributeAndValueDescriptors(assetType, this.action.attributeName, asset && asset.attributes && this.action.attributeName ? asset.attributes[this.action.attributeName] : undefined);
|
|
125
|
+
// Only RW attributes can be used in actions
|
|
126
|
+
let attributes = [];
|
|
127
|
+
if (asset && asset.attributes) {
|
|
128
|
+
attributes = Object.values(asset.attributes)
|
|
129
|
+
.map((attr) => {
|
|
130
|
+
const label = Util.getAttributeLabel(attr, descriptors[0], assetType, false);
|
|
131
|
+
return [attr.name, label];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else if (assetDescriptor) {
|
|
135
|
+
const assetTypeInfo = AssetModelUtil.getAssetTypeInfo(assetDescriptor);
|
|
136
|
+
attributes =
|
|
137
|
+
!assetTypeInfo || !assetTypeInfo.attributeDescriptors
|
|
138
|
+
? []
|
|
139
|
+
: assetTypeInfo.attributeDescriptors.map((ad) => {
|
|
140
|
+
const label = Util.getAttributeLabel(ad, descriptors[0], assetType, false);
|
|
141
|
+
return [ad.name, label];
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
attributes.sort(Util.sortByString((attr) => attr[1]));
|
|
145
|
+
let attributeInput;
|
|
146
|
+
if (this.action.attributeName) {
|
|
147
|
+
const label = descriptors[1] && (descriptors[1].name === "boolean" /* WellknownValueTypes.BOOLEAN */) ? "" : i18next.t("value");
|
|
148
|
+
let inputType;
|
|
149
|
+
if ((_b = (_a = descriptors[0]) === null || _a === void 0 ? void 0 : _a.format) === null || _b === void 0 ? void 0 : _b.asSlider)
|
|
150
|
+
inputType = InputType.NUMBER;
|
|
151
|
+
attributeInput = html `<or-attribute-input ?compact=${descriptors[1] && (descriptors[1].name === "GEO_JSONPoint" /* WellknownValueTypes.GEOJSONPOINT */)} .inputType="${ifDefined(inputType)}" @or-attribute-input-changed="${(ev) => this.setActionAttributeValue(ev.detail.value)}" .customProvider="${(_c = this.config) === null || _c === void 0 ? void 0 : _c.inputProvider}" .label="${label}" .assetType="${assetType}" .attributeDescriptor="${descriptors[0]}" .attributeValueDescriptor="${descriptors[1]}" .value="${this.action.value}" .readonly="${this.readonly || false}"></or-attribute-input>`;
|
|
152
|
+
}
|
|
153
|
+
return html `
|
|
154
|
+
<or-mwc-input id="matchSelect" class="min-width" .label="${i18next.t("asset")}" .type="${InputType.SELECT}"
|
|
155
|
+
.options="${idOptions}" .searchProvider="${searchProvider}" .value="${idValue}" .readonly="${this.readonly || false}"
|
|
156
|
+
@or-mwc-input-changed="${(e) => { this._assetId = (e.detail.value); this.refresh(); }}"
|
|
157
|
+
></or-mwc-input>
|
|
158
|
+
${attributes.length > 0 ? html `
|
|
159
|
+
<or-mwc-input id="attributeSelect" class="min-width" .label="${i18next.t("attribute")}" .type="${InputType.SELECT}" @or-mwc-input-changed="${(e) => this.setActionAttributeName(e.detail.value)}" .readonly="${this.readonly || false}" ?searchable="${(attributes.length >= 25)}" .options="${attributes}" .value="${this.action.attributeName}"></or-mwc-input>
|
|
160
|
+
${attributeInput}
|
|
161
|
+
` : html `
|
|
162
|
+
<or-translate value="No attributes with write permission"></or-translate>
|
|
163
|
+
`}
|
|
164
|
+
`;
|
|
165
|
+
})}
|
|
166
|
+
`;
|
|
167
|
+
}
|
|
168
|
+
set _assetId(assetId) {
|
|
169
|
+
const assetType = this._getAssetType();
|
|
170
|
+
if (assetId === "*") {
|
|
171
|
+
this.action.target.assets = undefined;
|
|
172
|
+
this.action.target = {
|
|
173
|
+
matchedAssets: {
|
|
174
|
+
types: [
|
|
175
|
+
assetType || ""
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.action.target.matchedAssets = undefined;
|
|
182
|
+
this.action.target = {
|
|
183
|
+
assets: {
|
|
184
|
+
ids: [
|
|
185
|
+
assetId
|
|
186
|
+
],
|
|
187
|
+
types: [
|
|
188
|
+
assetType || ""
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
194
|
+
this.requestUpdate();
|
|
195
|
+
}
|
|
196
|
+
setActionAttributeName(name) {
|
|
197
|
+
this.action.attributeName = name;
|
|
198
|
+
this.action.value = undefined;
|
|
199
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
200
|
+
this.requestUpdate();
|
|
201
|
+
}
|
|
202
|
+
setActionAttributeValue(value) {
|
|
203
|
+
this.action.value = value;
|
|
204
|
+
this.dispatchEvent(new OrRulesJsonRuleChangedEvent());
|
|
205
|
+
this.requestUpdate();
|
|
206
|
+
}
|
|
207
|
+
loadAssets(type) {
|
|
208
|
+
this.assetProvider(type).then(assets => {
|
|
209
|
+
this._assets = assets;
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: Object, attribute: false })
|
|
215
|
+
], OrRuleActionAttribute.prototype, "action", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property({ type: Object, attribute: false })
|
|
218
|
+
], OrRuleActionAttribute.prototype, "targetTypeMap", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
property({ type: Object })
|
|
221
|
+
], OrRuleActionAttribute.prototype, "config", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
property({ type: Object })
|
|
224
|
+
], OrRuleActionAttribute.prototype, "assetInfos", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: Object })
|
|
227
|
+
], OrRuleActionAttribute.prototype, "assetProvider", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Array, attribute: false })
|
|
230
|
+
], OrRuleActionAttribute.prototype, "_assets", void 0);
|
|
231
|
+
OrRuleActionAttribute = __decorate([
|
|
232
|
+
customElement("or-rule-action-attribute")
|
|
233
|
+
], OrRuleActionAttribute);
|
|
234
|
+
export { OrRuleActionAttribute };
|
|
235
|
+
//# sourceMappingURL=or-rule-action-attribute.js.map
|