@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,216 +1,29 @@
|
|
|
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
|
-
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
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,r){var i,s=arguments.length,n=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,r);else for(var p=e.length-1;p>=0;p--)(i=e[p])&&(n=(s<3?i(n):s>3?i(t,o,n):i(t,o))||n);return s>3&&n&&Object.defineProperty(t,o,n),n};import{css as e,html as t,LitElement as o}from"lit";import{customElement as r,property as i,query as s}from"lit/decorators.js";import{AssetModelUtil as n}from"@openremote/model";import{getAssetTypeFromQuery as p}from"../index";import"./or-rule-asset-query";import"./or-rule-trigger-query";import"@openremote/or-mwc-components/or-mwc-menu";import{getContentWithMenuTemplate as l}from"@openremote/or-mwc-components/or-mwc-menu";import"@openremote/or-icon";import"@openremote/or-translate";import{InputType as c}from"@openremote/or-mwc-components/or-mwc-input";import{Util as a}from"@openremote/core";import{i18next as u,translate as d}from"@openremote/or-translate";import{OrRulesJsonRuleChangedEvent as y}from"./or-rule-json-viewer";let TIMER_COLOR="4b87ea",DATE_TIME_COLOR="6AEAA4";export function getWhenTypesMenu(e,t){let o=!0,r=!0,i=!0;e&&e.controls&&e.controls.allowedConditionTypes&&(o=e.controls.allowedConditionTypes.indexOf("assetQuery")>=0,r=e.controls.allowedConditionTypes.indexOf("agentQuery")>=0,i=e.controls.allowedConditionTypes.indexOf("time")>=0);let s=[];if(t){if(o){let e=t.filter(e=>"agent"!==e.assetDescriptor.descriptorType).map(e=>{let t=n.getAssetDescriptorColour(e),o=n.getAssetDescriptorIcon(e);return{text:a.getAssetTypeLabel(e.assetDescriptor),value:e.assetDescriptor.name,icon:o||n.getAssetDescriptorIcon("ThingAsset"),styleMap:t?{"--or-icon-fill":"#"+t}:void 0}});s.push(...e.sort(a.sortByString(e=>e.text)))}if(o&&r&&s.push(null),r){let e=t.filter(e=>"agent"===e.assetDescriptor.descriptorType).map(e=>{let t=n.getAssetDescriptorColour(e),o=n.getAssetDescriptorIcon(e);return{text:a.getAssetTypeLabel(e.assetDescriptor),value:e.assetDescriptor.name,icon:o||n.getAssetDescriptorIcon("ThingAsset"),styleMap:t?{"--or-icon-fill":"#"+t}:void 0}});s.push(...e.sort(a.sortByString(e=>e.text)))}}return i&&(s.push(null),s.push({text:u.t("time"),icon:"timer",value:"time",styleMap:{"--or-icon-fill":"#"+TIMER_COLOR}})),s}export function updateRuleConditionType(e,t,o){if(t)if("time"===t){e.assets=void 0;let t=new Date;e.cron=a.formatCronString(void 0,void 0,void 0,t.getUTCHours().toString(),t.getUTCMinutes().toString())}else e.cron=void 0,o&&o.json&&o.json.whenAssetQuery?e.assets=JSON.parse(JSON.stringify(o.json.whenAssetQuery)):e.assets={},e.assets.types=[t];else e.assets=void 0,e.cron=void 0,e.sun=void 0}let style=e`
|
|
2
|
+
:host {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: row;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
or-rule-asset-query {
|
|
8
|
+
flex-grow: 1;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#type {
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
text-transform: capitalize;
|
|
14
|
+
margin: 14px 3px auto 0;
|
|
15
|
+
}
|
|
16
|
+
`,OrRuleCondition=class extends d(u)(o){constructor(){super(...arguments),this.readonly=!1}static get styles(){return style}render(){let e=!this.config||!this.config.controls||!0!==this.config.controls.hideConditionTypeOptions,o=this.type;if(!o&&!e)return t`<span>INVALID CONFIG - NO TYPE SPECIFIED AND TYPE SELECTOR DISABLED</span>`;let r="",i="";if(e){let e,i="inherit";if(o)if("time"===o)e="timer",i=TIMER_COLOR;else{let t=n.getAssetDescriptor(o);e=n.getAssetDescriptorIcon(t)||e,i=n.getAssetDescriptorColour(t)||i}r=this.readonly?t`
|
|
17
|
+
<div id="type" style="--or-mwc-input-color: #${i}">
|
|
18
|
+
<or-mwc-input readonly type="${c.BUTTON}" .icon="${e||""}"></or-mwc-input>
|
|
19
|
+
</div>
|
|
20
|
+
`:t`
|
|
21
|
+
<div id="type" style="--or-mwc-input-color: #${i}">
|
|
22
|
+
${l(t`<or-mwc-input type="${c.BUTTON}" .icon="${e||""}"></or-mwc-input>`,getWhenTypesMenu(this.config,this.assetInfos),o,e=>this.type=e)}
|
|
23
|
+
</div>
|
|
24
|
+
`}return o&&(i="time"===o?t`<or-rule-trigger-query id="asset-query" .condition="${this.ruleCondition}"></or-rule-trigger-query>`:t`<or-rule-asset-query id="asset-query" .config="${this.config}" .assetInfos="${this.assetInfos}" .readonly="${this.readonly}"
|
|
25
|
+
.condition="${this.ruleCondition}" .assetProvider="${this.assetProvider}"
|
|
26
|
+
></or-rule-asset-query>`),t`
|
|
27
|
+
${r}
|
|
28
|
+
${i}
|
|
29
|
+
`}get type(){let e=p(this.ruleCondition.assets);return e||(this.ruleCondition.cron||this.ruleCondition.sun?"time":void 0)}set type(e){updateRuleConditionType(this.ruleCondition,e,this.config),this._assetQuery&&this._assetQuery.refresh(),this.dispatchEvent(new y),this.requestUpdate()}};__decorate([i({type:Object,attribute:!1})],OrRuleCondition.prototype,"ruleCondition",void 0),__decorate([i({type:Object})],OrRuleCondition.prototype,"config",void 0),__decorate([i({type:Object})],OrRuleCondition.prototype,"assetInfos",void 0),__decorate([i({type:Object})],OrRuleCondition.prototype,"assetProvider",void 0),__decorate([s("#asset-query")],OrRuleCondition.prototype,"_assetQuery",void 0),OrRuleCondition=__decorate([r("or-rule-condition")],OrRuleCondition);
|