@openremote/or-rules 1.8.0-snapshot.20250725120000 → 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,271 +1,54 @@
|
|
|
1
|
-
var __decorate = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
align-items: center;
|
|
56
|
-
}
|
|
57
|
-
.selected-asset-container:hover {
|
|
58
|
-
cursor: pointer;
|
|
59
|
-
background-color: #F9F9F9;
|
|
60
|
-
}
|
|
61
|
-
.selected-asset-label {
|
|
62
|
-
padding: 5px;
|
|
63
|
-
display: flex;
|
|
64
|
-
flex-direction: column;
|
|
65
|
-
line-height: 16px;
|
|
66
|
-
justify-content: flex-start;
|
|
67
|
-
font-size: 14px;
|
|
68
|
-
text-align: left;
|
|
69
|
-
}
|
|
70
|
-
.selected-asset-label .asset {
|
|
71
|
-
color: rgb(76, 76, 76);
|
|
72
|
-
}
|
|
73
|
-
.selected-asset-label .asset-attribute {
|
|
74
|
-
color: grey;
|
|
75
|
-
}
|
|
76
|
-
.selected-asset-icon {
|
|
77
|
-
display: flex;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
padding: 0px 5px 0px 5px;
|
|
80
|
-
--or-icon-width: 20px;
|
|
81
|
-
}`];
|
|
82
|
-
}
|
|
83
|
-
firstUpdated() {
|
|
84
|
-
this.addEventListener("contextmenu", (e) => e.stopPropagation());
|
|
85
|
-
this.addEventListener("mousedown", (e) => {
|
|
86
|
-
project.createUndoSnapshot();
|
|
87
|
-
return project.notifyChange();
|
|
88
|
-
});
|
|
89
|
-
this.resizeObserver = new ResizeObserver((a, b) => {
|
|
90
|
-
const rect = a[0].contentRect;
|
|
91
|
-
this.node.size = { x: rect.width - 20, y: rect.height - 20 };
|
|
92
|
-
});
|
|
93
|
-
this.resizeObserver.observe(this);
|
|
94
|
-
}
|
|
95
|
-
render() {
|
|
96
|
-
switch (this.internal.picker.type) {
|
|
97
|
-
case "ASSET_ATTRIBUTE" /* PickerType.ASSET_ATTRIBUTE */:
|
|
98
|
-
if (this.internal.value && !this.selectedAsset) {
|
|
99
|
-
this.setSelectedAssetFromInternalValue();
|
|
100
|
-
}
|
|
101
|
-
return this.assetAttributeInput;
|
|
102
|
-
case "COLOR" /* PickerType.COLOR */:
|
|
103
|
-
return this.colorInput;
|
|
104
|
-
case "DOUBLE_DROPDOWN" /* PickerType.DOUBLE_DROPDOWN */:
|
|
105
|
-
return this.doubleDropdownInput;
|
|
106
|
-
case "CHECKBOX" /* PickerType.CHECKBOX */:
|
|
107
|
-
return this.checkBoxInput;
|
|
108
|
-
case "DROPDOWN" /* PickerType.DROPDOWN */:
|
|
109
|
-
return this.dropdownInput;
|
|
110
|
-
case "MULTILINE" /* PickerType.MULTILINE */:
|
|
111
|
-
return this.multilineInput;
|
|
112
|
-
case "DATE" /* PickerType.DATE */:
|
|
113
|
-
return this.getNumberInput(0, undefined, 50);
|
|
114
|
-
case "NUMBER" /* PickerType.NUMBER */:
|
|
115
|
-
return this.getNumberInput(undefined, undefined, undefined);
|
|
116
|
-
case "TEXT" /* PickerType.TEXT */:
|
|
117
|
-
return this.textInput;
|
|
118
|
-
default:
|
|
119
|
-
return html `unimplemented picker`;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
setSocketTypeDynamically(value) {
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
const results = (yield rest.api.AssetResource.queryAssets({
|
|
125
|
-
ids: [value.assetId],
|
|
126
|
-
select: {
|
|
127
|
-
attributes: [
|
|
128
|
-
value.attributeName
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
})).data;
|
|
132
|
-
const socket = this.node.outputs[0] || this.node.inputs[0];
|
|
133
|
-
socket.type = "ANY" /* NodeDataType.ANY */;
|
|
134
|
-
if (results == null) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
if (results[0] == null) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (results[0].attributes == null) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
const relevantAttribute = results[0].attributes[value.attributeName];
|
|
145
|
-
const descriptors = AssetModelUtil.getValueDescriptors();
|
|
146
|
-
const relevantDescriptor = descriptors.find((c) => c.name === relevantAttribute.type);
|
|
147
|
-
socket.type = NodeUtilities.convertValueTypeToSocketType(relevantDescriptor);
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
console.error(e);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
setSelectedAssetFromInternalValue() {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
-
const response = yield rest.api.AssetResource.queryAssets({
|
|
157
|
-
ids: [this.internal.value.assetId]
|
|
158
|
-
});
|
|
159
|
-
if (response.data.length === 0) {
|
|
160
|
-
console.warn(`Asset with id ${this.internal.value.assetId} is missing`);
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
this.selectedAsset = response.data[0];
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
get assetAttributeInput() {
|
|
167
|
-
var _a, _b, _c, _d;
|
|
168
|
-
const openDialog = () => {
|
|
169
|
-
const dialog = showDialog(new OrAssetAttributePicker()
|
|
170
|
-
.setShowOnlyRuleStateAttrs(true)
|
|
171
|
-
.setShowOnlyDatapointAttrs(false)
|
|
172
|
-
.setMultiSelect(false));
|
|
173
|
-
dialog.addEventListener(OrAssetAttributePickerPickedEvent.NAME, (ev) => __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
const value = {
|
|
175
|
-
assetId: ev.detail[0].id,
|
|
176
|
-
attributeName: ev.detail[0].name
|
|
177
|
-
};
|
|
178
|
-
yield this.setSocketTypeDynamically(value);
|
|
179
|
-
this.setValue(value);
|
|
180
|
-
yield this.setSelectedAssetFromInternalValue();
|
|
181
|
-
}));
|
|
182
|
-
};
|
|
183
|
-
let selectedAttrLabel = '?';
|
|
184
|
-
if (this.selectedAsset && this.selectedAsset.attributes && ((_b = (_a = this.internal) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.attributeName)) {
|
|
185
|
-
const attrName = (_d = (_c = this.internal) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.attributeName;
|
|
186
|
-
const attributeDescriptor = AssetModelUtil.getAttributeDescriptor(attrName, this.selectedAsset.type);
|
|
187
|
-
let attr = this.selectedAsset.attributes[attrName];
|
|
188
|
-
if (attr) {
|
|
189
|
-
selectedAttrLabel = Util.getAttributeLabel(attr, attributeDescriptor, this.selectedAsset.type, true);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const descriptor = this.selectedAsset ? AssetModelUtil.getAssetDescriptor(this.selectedAsset.type) : undefined;
|
|
193
|
-
const myIcon = getAssetDescriptorIconTemplate(descriptor);
|
|
194
|
-
return html `<div>
|
|
195
|
-
${(this.selectedAsset ?
|
|
196
|
-
html `<div class="attribute-label attribute-label-white selected-asset-container" @click="${() => openDialog()}">
|
|
197
|
-
<div class="selected-asset-icon">${myIcon}</div>
|
|
198
|
-
<div class="selected-asset-label">
|
|
199
|
-
<div class="asset">${this.selectedAsset.name}</div>
|
|
200
|
-
<div class="asset-attribute">${selectedAttrLabel}</div>
|
|
201
|
-
</div>
|
|
202
|
-
</div>` :
|
|
203
|
-
html `<or-mwc-input class="attribute-label-white" .type="${InputType.BUTTON}" label="attribute" icon="plus" @or-mwc-input-changed="${() => openDialog()}"></or-mwc-input>`)}
|
|
204
|
-
</div>`;
|
|
205
|
-
}
|
|
206
|
-
get colorInput() {
|
|
207
|
-
return html `<or-mwc-input type="color"></or-mwc-input>`; // looks strange
|
|
208
|
-
}
|
|
209
|
-
get doubleDropdownInput() {
|
|
210
|
-
return html `unimplemented`;
|
|
211
|
-
}
|
|
212
|
-
get dropdownInput() {
|
|
213
|
-
return html `<writable-dropdown @input="${(e) => this.setValue(e.target.value)}" .value="${this.internal.value}" .options="${this.internal.picker.options}">
|
|
214
|
-
</writable-dropdown>`;
|
|
215
|
-
}
|
|
216
|
-
get checkBoxInput() {
|
|
217
|
-
return html `<input type="checkbox" ?checked="${this.internal.value || false}" @input="${(e) => this.setValue(e.target.checked)}"/>`;
|
|
218
|
-
return html `<or-mwc-input type="checkbox"
|
|
219
|
-
@or-mwc-input-changed="${(e) => {
|
|
220
|
-
this.setValue(e.detail.value);
|
|
221
|
-
}}"></or-mwc-input>`;
|
|
222
|
-
}
|
|
223
|
-
get multilineInput() {
|
|
224
|
-
const sizeString = this.node.size ? `width:${this.node.size.x}px; height:${this.node.size.y}px` : ``;
|
|
225
|
-
return html `<textarea @wheel="${(e) => {
|
|
226
|
-
if (e.target.clientHeight < e.target.scrollHeight) {
|
|
227
|
-
return e.stopPropagation();
|
|
228
|
-
}
|
|
229
|
-
}}" style="${sizeString}" @input="${(e) => this.setValue(e.target.value)}" placeholder="${this.internal.name}">${this.internal.value || ""}</textarea>`;
|
|
230
|
-
}
|
|
231
|
-
getNumberInput(min, max, width) {
|
|
232
|
-
return html `<input
|
|
233
|
-
@wheel="${(e) => {
|
|
234
|
-
if (e.target === this.shadowRoot.activeElement) {
|
|
235
|
-
return e.stopPropagation();
|
|
236
|
-
}
|
|
237
|
-
}}"
|
|
238
|
-
@input="${(e) => this.setValue(parseFloat(e.target.value))}"
|
|
239
|
-
value="${this.internal.value || 0}" type="number" placeholder="${this.internal.name}"
|
|
240
|
-
style="max-width: ${ifDefined(width)}px"
|
|
241
|
-
min="${ifDefined(min)}" max="${ifDefined(max)}"
|
|
242
|
-
/>`;
|
|
243
|
-
}
|
|
244
|
-
get textInput() {
|
|
245
|
-
return html `<input @input="${(e) => this.setValue(e.target.value)}" value="${this.internal.value || ""}" type="text" placeholder="${this.internal.name}"/>`;
|
|
246
|
-
}
|
|
247
|
-
setValue(value) {
|
|
248
|
-
this.node.internals[this.internalIndex].value = value;
|
|
249
|
-
this.onPicked();
|
|
250
|
-
}
|
|
251
|
-
onPicked() {
|
|
252
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
253
|
-
yield this.updateComplete;
|
|
254
|
-
this.dispatchEvent(new CustomEvent("picked"));
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
};
|
|
258
|
-
__decorate([
|
|
259
|
-
property({ converter: nodeConverter, reflect: true })
|
|
260
|
-
], InternalPicker.prototype, "node", void 0);
|
|
261
|
-
__decorate([
|
|
262
|
-
property({ type: Number, reflect: true })
|
|
263
|
-
], InternalPicker.prototype, "internalIndex", void 0);
|
|
264
|
-
__decorate([
|
|
265
|
-
property({ type: Object })
|
|
266
|
-
], InternalPicker.prototype, "selectedAsset", void 0);
|
|
267
|
-
InternalPicker = __decorate([
|
|
268
|
-
customElement("internal-picker")
|
|
269
|
-
], InternalPicker);
|
|
270
|
-
export { InternalPicker };
|
|
271
|
-
//# sourceMappingURL=internal-picker.js.map
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,i,o):s(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o},__awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))(function(s,n){function o(e){try{l(r.next(e))}catch(e){n(e)}}function a(e){try{l(r.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?s(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(o,a)}l((r=r.apply(e,t||[])).next())})};import{LitElement as e,html as t,css as i}from"lit";import{customElement as r,property as s}from"lit/decorators.js";import{AssetModelUtil as n}from"@openremote/model";import{nodeConverter as o}from"../converters/node-converter";import{InputType as a}from"@openremote/or-mwc-components/or-mwc-input";import l from"@openremote/rest";import"@openremote/or-asset-tree";import{ResizeObserver as c}from"resize-observer";import{project as u}from"./flow-editor";import{NodeUtilities as d}from"../node-structure";import{translate as p,i18next as h}from"@openremote/or-translate";import{PickerStyle as m}from"../styles/picker-styles";import{Util as v}from"@openremote/core";import{OrAssetAttributePicker as f,OrAssetAttributePickerPickedEvent as y}from"@openremote/or-attribute-picker";import{showDialog as b}from"@openremote/or-mwc-components/or-mwc-dialog";import{getAssetDescriptorIconTemplate as g}from"@openremote/or-icon";import{ifDefined as w}from"lit/directives/if-defined.js";let InternalPicker=class extends p(h)(e){constructor(){super()}get internal(){return this.node.internals[this.internalIndex]}static get styles(){return[i`
|
|
2
|
+
:host{
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin: 0;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
--or-app-color4: var(--or-mwc-input-color);
|
|
8
|
+
}`,m,i`.attribute-label-white {
|
|
9
|
+
background: #ffffff;
|
|
10
|
+
}
|
|
11
|
+
.selected-asset-container {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
15
|
+
.selected-asset-container:hover {
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
background-color: #F9F9F9;
|
|
18
|
+
}
|
|
19
|
+
.selected-asset-label {
|
|
20
|
+
padding: 5px;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
line-height: 16px;
|
|
24
|
+
justify-content: flex-start;
|
|
25
|
+
font-size: 14px;
|
|
26
|
+
text-align: left;
|
|
27
|
+
}
|
|
28
|
+
.selected-asset-label .asset {
|
|
29
|
+
color: rgb(76, 76, 76);
|
|
30
|
+
}
|
|
31
|
+
.selected-asset-label .asset-attribute {
|
|
32
|
+
color: grey;
|
|
33
|
+
}
|
|
34
|
+
.selected-asset-icon {
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
padding: 0px 5px 0px 5px;
|
|
38
|
+
--or-icon-width: 20px;
|
|
39
|
+
}`]}firstUpdated(){this.addEventListener("contextmenu",e=>e.stopPropagation()),this.addEventListener("mousedown",e=>(u.createUndoSnapshot(),u.notifyChange())),this.resizeObserver=new c((e,t)=>{let i=e[0].contentRect;this.node.size={x:i.width-20,y:i.height-20}}),this.resizeObserver.observe(this)}render(){switch(this.internal.picker.type){case"ASSET_ATTRIBUTE":return this.internal.value&&!this.selectedAsset&&this.setSelectedAssetFromInternalValue(),this.assetAttributeInput;case"COLOR":return this.colorInput;case"DOUBLE_DROPDOWN":return this.doubleDropdownInput;case"CHECKBOX":return this.checkBoxInput;case"DROPDOWN":return this.dropdownInput;case"MULTILINE":return this.multilineInput;case"DATE":return this.getNumberInput(0,void 0,50);case"NUMBER":return this.getNumberInput(void 0,void 0,void 0);case"TEXT":return this.textInput;default:return t`unimplemented picker`}}setSocketTypeDynamically(e){return __awaiter(this,void 0,void 0,function*(){let t=(yield l.api.AssetResource.queryAssets({ids:[e.assetId],select:{attributes:[e.attributeName]}})).data,i=this.node.outputs[0]||this.node.inputs[0];if((i.type="ANY",null!=t&&null!=t[0])&&null!=t[0].attributes)try{let r=t[0].attributes[e.attributeName],s=n.getValueDescriptors().find(e=>e.name===r.type);i.type=d.convertValueTypeToSocketType(s)}catch(e){console.error(e)}})}setSelectedAssetFromInternalValue(){return __awaiter(this,void 0,void 0,function*(){let e=yield l.api.AssetResource.queryAssets({ids:[this.internal.value.assetId]});if(0===e.data.length)return void console.warn(`Asset with id ${this.internal.value.assetId} is missing`);this.selectedAsset=e.data[0]})}get assetAttributeInput(){var e,i,r,s;let o=()=>{b(new f().setShowOnlyRuleStateAttrs(!0).setShowOnlyDatapointAttrs(!1).setMultiSelect(!1)).addEventListener(y.NAME,e=>__awaiter(this,void 0,void 0,function*(){let t={assetId:e.detail[0].id,attributeName:e.detail[0].name};yield this.setSocketTypeDynamically(t),this.setValue(t),yield this.setSelectedAssetFromInternalValue()}))},l="?";if(this.selectedAsset&&this.selectedAsset.attributes&&(null==(i=null==(e=this.internal)?void 0:e.value)?void 0:i.attributeName)){let e=null==(s=null==(r=this.internal)?void 0:r.value)?void 0:s.attributeName,t=n.getAttributeDescriptor(e,this.selectedAsset.type),i=this.selectedAsset.attributes[e];i&&(l=v.getAttributeLabel(i,t,this.selectedAsset.type,!0))}let c=g(this.selectedAsset?n.getAssetDescriptor(this.selectedAsset.type):void 0);return t`<div>
|
|
40
|
+
${this.selectedAsset?t`<div class="attribute-label attribute-label-white selected-asset-container" @click="${()=>o()}">
|
|
41
|
+
<div class="selected-asset-icon">${c}</div>
|
|
42
|
+
<div class="selected-asset-label">
|
|
43
|
+
<div class="asset">${this.selectedAsset.name}</div>
|
|
44
|
+
<div class="asset-attribute">${l}</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>`:t`<or-mwc-input class="attribute-label-white" .type="${a.BUTTON}" label="attribute" icon="plus" @or-mwc-input-changed="${()=>o()}"></or-mwc-input>`}
|
|
47
|
+
</div>`}get colorInput(){return t`<or-mwc-input type="color"></or-mwc-input>`}get doubleDropdownInput(){return t`unimplemented`}get dropdownInput(){return t`<writable-dropdown @input="${e=>this.setValue(e.target.value)}" .value="${this.internal.value}" .options="${this.internal.picker.options}">
|
|
48
|
+
</writable-dropdown>`}get checkBoxInput(){return t`<input type="checkbox" ?checked="${this.internal.value||!1}" @input="${e=>this.setValue(e.target.checked)}"/>`}get multilineInput(){let e=this.node.size?`width:${this.node.size.x}px; height:${this.node.size.y}px`:"";return t`<textarea @wheel="${e=>{if(e.target.clientHeight<e.target.scrollHeight)return e.stopPropagation()}}" style="${e}" @input="${e=>this.setValue(e.target.value)}" placeholder="${this.internal.name}">${this.internal.value||""}</textarea>`}getNumberInput(e,i,r){return t`<input
|
|
49
|
+
@wheel="${e=>{if(e.target===this.shadowRoot.activeElement)return e.stopPropagation()}}"
|
|
50
|
+
@input="${e=>this.setValue(parseFloat(e.target.value))}"
|
|
51
|
+
value="${this.internal.value||0}" type="number" placeholder="${this.internal.name}"
|
|
52
|
+
style="max-width: ${w(r)}px"
|
|
53
|
+
min="${w(e)}" max="${w(i)}"
|
|
54
|
+
/>`}get textInput(){return t`<input @input="${e=>this.setValue(e.target.value)}" value="${this.internal.value||""}" type="text" placeholder="${this.internal.name}"/>`}setValue(e){this.node.internals[this.internalIndex].value=e,this.onPicked()}onPicked(){return __awaiter(this,void 0,void 0,function*(){yield this.updateComplete,this.dispatchEvent(new CustomEvent("picked"))})}};__decorate([s({converter:o,reflect:!0})],InternalPicker.prototype,"node",void 0),__decorate([s({type:Number,reflect:!0})],InternalPicker.prototype,"internalIndex",void 0),__decorate([s({type:Object})],InternalPicker.prototype,"selectedAsset",void 0),InternalPicker=__decorate([r("internal-picker")],InternalPicker);export{InternalPicker};
|
|
@@ -1,134 +1,34 @@
|
|
|
1
|
-
var __decorate =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.isDragging = false;
|
|
17
|
-
this.x = 0;
|
|
18
|
-
this.y = 0;
|
|
19
|
-
this.xOffset = 0;
|
|
20
|
-
this.yOffset = 0;
|
|
21
|
-
this.startDrag = (e) => {
|
|
22
|
-
this.xOffset = e.offsetX;
|
|
23
|
-
this.yOffset = e.offsetY;
|
|
24
|
-
this.x = e.clientX;
|
|
25
|
-
this.y = e.clientY;
|
|
26
|
-
this.isDragging = true;
|
|
27
|
-
window.addEventListener("mouseup", this.stopDrag);
|
|
28
|
-
window.addEventListener("mousemove", this.onMove);
|
|
29
|
-
};
|
|
30
|
-
this.onMove = (e) => {
|
|
31
|
-
this.x = e.clientX;
|
|
32
|
-
this.y = e.clientY;
|
|
33
|
-
};
|
|
34
|
-
this.stopDrag = (e) => {
|
|
35
|
-
window.removeEventListener("mouseup", this.stopDrag);
|
|
36
|
-
window.removeEventListener("mousemove", this.onMove);
|
|
37
|
-
this.isDragging = false;
|
|
38
|
-
if (Utilities.isPointInsideBox(e.offsetX, e.offsetY, {
|
|
39
|
-
x: this.workspace.clientRect.left,
|
|
40
|
-
y: this.workspace.clientRect.top,
|
|
41
|
-
width: this.workspace.clientRect.width,
|
|
42
|
-
height: this.workspace.clientRect.height,
|
|
43
|
-
})) {
|
|
44
|
-
const copy = CopyMachine.copy(this.node);
|
|
45
|
-
newIds.add(copy.id);
|
|
46
|
-
copy.position = this.workspace.offsetToWorld({ x: e.offsetX - this.workspace.clientRect.left, y: e.offsetY - this.workspace.clientRect.top });
|
|
47
|
-
project.createUndoSnapshot();
|
|
48
|
-
project.addNode(copy);
|
|
49
|
-
project.notifyChange();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
this.addEventListener("mousedown", this.startDrag);
|
|
53
|
-
}
|
|
54
|
-
static get styles() {
|
|
55
|
-
return css `
|
|
56
|
-
:host, .node-drag-item{
|
|
57
|
-
padding: 4px;
|
|
58
|
-
margin: 0 0 15px 0;
|
|
59
|
-
display: inline-block;
|
|
60
|
-
text-align: center;
|
|
61
|
-
color: white;
|
|
62
|
-
border-radius: var(--roundness);
|
|
63
|
-
box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 5px -5px;
|
|
64
|
-
|
|
65
|
-
width: calc(var(--nodepanel-width) - 4px * 2);
|
|
66
|
-
height: 22px;
|
|
67
|
-
line-height: 22px;
|
|
68
|
-
cursor:grab;
|
|
69
|
-
transition: box-shadow 150ms;
|
|
70
|
-
}
|
|
71
|
-
:host(.small), .small{
|
|
72
|
-
width: 26px;
|
|
73
|
-
height: 26px;
|
|
74
|
-
line-height: 26px;
|
|
75
|
-
margin: 0;
|
|
76
|
-
}
|
|
77
|
-
.node-drag-item{
|
|
78
|
-
z-index: 5000;
|
|
79
|
-
position: fixed;
|
|
80
|
-
background: inherit;
|
|
81
|
-
box-shadow: rgba(0, 0, 0, 0.2) 0 2px 15px;
|
|
82
|
-
filter: opacity(90%);
|
|
83
|
-
pointer-events: none;
|
|
84
|
-
}
|
|
85
|
-
`;
|
|
86
|
-
}
|
|
87
|
-
render() {
|
|
88
|
-
switch (this.node.type) {
|
|
89
|
-
case "INPUT" /* NodeType.INPUT */:
|
|
90
|
-
this.classList.add("input-node");
|
|
91
|
-
break;
|
|
92
|
-
case "PROCESSOR" /* NodeType.PROCESSOR */:
|
|
93
|
-
this.classList.add("processor-node");
|
|
94
|
-
break;
|
|
95
|
-
case "OUTPUT" /* NodeType.OUTPUT */:
|
|
96
|
-
this.classList.add("output-node");
|
|
97
|
-
break;
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var s,r=arguments.length,a=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,o);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(a=(r<3?s(a):r>3?s(t,i,a):s(t,i))||a);return r>3&&a&&Object.defineProperty(t,i,a),a};import{LitElement as e,html as t,css as i}from"lit";import{customElement as o,property as s}from"lit/decorators.js";import{Utilities as r}from"../utils";import{i18next as a,translate as n}from"@openremote/or-translate";import{newIds as d,project as h}from"./flow-editor";import{CopyMachine as l}from"../node-structure";let NodeMenuItem=class extends n(a)(e){constructor(){super(),this.isDragging=!1,this.x=0,this.y=0,this.xOffset=0,this.yOffset=0,this.startDrag=e=>{this.xOffset=e.offsetX,this.yOffset=e.offsetY,this.x=e.clientX,this.y=e.clientY,this.isDragging=!0,window.addEventListener("mouseup",this.stopDrag),window.addEventListener("mousemove",this.onMove)},this.onMove=e=>{this.x=e.clientX,this.y=e.clientY},this.stopDrag=e=>{if(window.removeEventListener("mouseup",this.stopDrag),window.removeEventListener("mousemove",this.onMove),this.isDragging=!1,r.isPointInsideBox(e.offsetX,e.offsetY,{x:this.workspace.clientRect.left,y:this.workspace.clientRect.top,width:this.workspace.clientRect.width,height:this.workspace.clientRect.height})){let t=l.copy(this.node);d.add(t.id),t.position=this.workspace.offsetToWorld({x:e.offsetX-this.workspace.clientRect.left,y:e.offsetY-this.workspace.clientRect.top}),h.createUndoSnapshot(),h.addNode(t),h.notifyChange()}},this.addEventListener("mousedown",this.startDrag)}static get styles(){return i`
|
|
2
|
+
:host, .node-drag-item{
|
|
3
|
+
padding: 4px;
|
|
4
|
+
margin: 0 0 15px 0;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
text-align: center;
|
|
7
|
+
color: white;
|
|
8
|
+
border-radius: var(--roundness);
|
|
9
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 5px -5px;
|
|
10
|
+
|
|
11
|
+
width: calc(var(--nodepanel-width) - 4px * 2);
|
|
12
|
+
height: 22px;
|
|
13
|
+
line-height: 22px;
|
|
14
|
+
cursor:grab;
|
|
15
|
+
transition: box-shadow 150ms;
|
|
98
16
|
}
|
|
99
|
-
|
|
100
|
-
|
|
17
|
+
:host(.small), .small{
|
|
18
|
+
width: 26px;
|
|
19
|
+
height: 26px;
|
|
20
|
+
line-height: 26px;
|
|
21
|
+
margin: 0;
|
|
101
22
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
__decorate([
|
|
116
|
-
property({ attribute: false })
|
|
117
|
-
], NodeMenuItem.prototype, "node", void 0);
|
|
118
|
-
__decorate([
|
|
119
|
-
property({ attribute: false })
|
|
120
|
-
], NodeMenuItem.prototype, "isDragging", void 0);
|
|
121
|
-
__decorate([
|
|
122
|
-
property({ attribute: false })
|
|
123
|
-
], NodeMenuItem.prototype, "x", void 0);
|
|
124
|
-
__decorate([
|
|
125
|
-
property({ attribute: false })
|
|
126
|
-
], NodeMenuItem.prototype, "y", void 0);
|
|
127
|
-
__decorate([
|
|
128
|
-
property({ attribute: false })
|
|
129
|
-
], NodeMenuItem.prototype, "workspace", void 0);
|
|
130
|
-
NodeMenuItem = __decorate([
|
|
131
|
-
customElement("node-menu-item")
|
|
132
|
-
], NodeMenuItem);
|
|
133
|
-
export { NodeMenuItem };
|
|
134
|
-
//# sourceMappingURL=node-menu-item.js.map
|
|
23
|
+
.node-drag-item{
|
|
24
|
+
z-index: 5000;
|
|
25
|
+
position: fixed;
|
|
26
|
+
background: inherit;
|
|
27
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0 2px 15px;
|
|
28
|
+
filter: opacity(90%);
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
}
|
|
31
|
+
`}render(){switch(this.node.type){case"INPUT":this.classList.add("input-node");break;case"PROCESSOR":this.classList.add("processor-node");break;case"OUTPUT":this.classList.add("output-node")}return this.node.displayCharacter&&this.classList.add("small"),this.title=a.t(this.node.name,r.humanLike(this.node.name.toLowerCase())),t`
|
|
32
|
+
<div class="label">${this.flowNodeName}</div>
|
|
33
|
+
${this.isDragging?this.dragNodeTemplate:null}
|
|
34
|
+
`}get dragNodeTemplate(){return t`<div class="node-drag-item ${this.node.displayCharacter?"small":null}" style="top: ${this.y-this.yOffset}px; left: ${this.x-this.xOffset}px"><div class="label">${this.flowNodeName}</div></div>`}get flowNodeName(){return a.t(this.node.displayCharacter?"flow."+this.node.displayCharacter:"flow."+this.node.name,this.node.displayCharacter||this.node.name||"invalid node name")}};__decorate([s({attribute:!1})],NodeMenuItem.prototype,"node",void 0),__decorate([s({attribute:!1})],NodeMenuItem.prototype,"isDragging",void 0),__decorate([s({attribute:!1})],NodeMenuItem.prototype,"x",void 0),__decorate([s({attribute:!1})],NodeMenuItem.prototype,"y",void 0),__decorate([s({attribute:!1})],NodeMenuItem.prototype,"workspace",void 0),NodeMenuItem=__decorate([o("node-menu-item")],NodeMenuItem);export{NodeMenuItem};
|