@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,60 +1,104 @@
|
|
|
1
|
-
var __decorate=this&&this.__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
|
-
align-items:
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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 { LitElement, html, css } from "lit";
|
|
8
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
9
|
+
import { i18next, translate } from "@openremote/or-translate";
|
|
10
|
+
let NodePanel = class NodePanel extends translate(i18next)(LitElement) {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.nodes = [];
|
|
14
|
+
}
|
|
15
|
+
static get styles() {
|
|
16
|
+
return css `
|
|
17
|
+
.list{
|
|
18
|
+
overflow-x: hidden;
|
|
19
|
+
overflow-y: auto;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
align-items: center;
|
|
23
|
+
height: 100%;
|
|
24
|
+
background: #F9F9F9;
|
|
25
|
+
}
|
|
26
|
+
.category{
|
|
27
|
+
display: flex;
|
|
28
|
+
width: 80%;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
align-items: center;
|
|
31
|
+
text-align: center;
|
|
32
|
+
padding: 15px 15px 0 15px;
|
|
33
|
+
}
|
|
34
|
+
.category span{
|
|
35
|
+
margin:0;
|
|
36
|
+
color: rgb(125,125,125);
|
|
37
|
+
padding: 0 0 15px 0 ;
|
|
38
|
+
}
|
|
39
|
+
.small-node-grid{
|
|
40
|
+
display: grid;
|
|
41
|
+
grid-template-columns: repeat(5, 1fr);
|
|
42
|
+
grid-template-rows: repeat(2, 1fr);
|
|
43
|
+
grid-gap: 6px;
|
|
44
|
+
justify-items: stretch;
|
|
45
|
+
align-items: stretch;
|
|
46
|
+
margin-bottom: 15px;
|
|
47
|
+
width: var(--nodepanel-width);
|
|
48
|
+
}
|
|
49
|
+
.input-node{ background-color: var(--input-color); }
|
|
50
|
+
.processor-node{ background-color: var(--processor-color); }
|
|
51
|
+
.output-node{ background-color: var(--output-color); }
|
|
52
|
+
.input-node:hover{ background-color: var(--input-color-h); }
|
|
53
|
+
.processor-node:hover{ background-color: var(--processor-color-h); }
|
|
54
|
+
.output-node:hover{ background-color: var(--output-color-h); }`;
|
|
55
|
+
}
|
|
56
|
+
firstUpdated() {
|
|
57
|
+
if (this.drawer)
|
|
58
|
+
this.drawer.open = true;
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
return html `
|
|
62
|
+
<!-- <or-mwc-drawer rightsided dismissible transparent> -->
|
|
63
|
+
${this.listTemplate}
|
|
64
|
+
<!-- </or-mwc-drawer> -->
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
nodeTemplate(node) {
|
|
68
|
+
return html `<node-menu-item class="node-item" .node="${node}" .workspace="${this.application.editorWorkspace}"></node-menu-item>`;
|
|
69
|
+
}
|
|
70
|
+
get listTemplate() {
|
|
71
|
+
return html `
|
|
72
|
+
<div class="list">
|
|
73
|
+
<div class="category"> <span>${i18next.t("input", "Input")}</span>
|
|
74
|
+
${this.nodes.filter((n) => n.type === "INPUT" /* NodeType.INPUT */).map((n) => this.nodeTemplate(n))}
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="category"><span>${i18next.t("processors", "Processors")}</span>
|
|
78
|
+
<div class="small-node-grid">
|
|
79
|
+
${this.nodes.filter((n) => n.type === "PROCESSOR" /* NodeType.PROCESSOR */ && n.displayCharacter).sort((a, b) => a.priority - b.priority).map((n) => this.nodeTemplate(n))}
|
|
80
|
+
</div>
|
|
81
|
+
${this.nodes.filter((n) => n.type === "PROCESSOR" /* NodeType.PROCESSOR */ && !n.displayCharacter).map((n) => this.nodeTemplate(n))}
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div class="category"> <span>${i18next.t("output", "Output")}</span>
|
|
85
|
+
${this.nodes.filter((n) => n.type === "OUTPUT" /* NodeType.OUTPUT */).map((n) => this.nodeTemplate(n))}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__decorate([
|
|
92
|
+
property({ type: Array })
|
|
93
|
+
], NodePanel.prototype, "nodes", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
query("or-mwc-drawer")
|
|
96
|
+
], NodePanel.prototype, "drawer", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ attribute: false })
|
|
99
|
+
], NodePanel.prototype, "application", void 0);
|
|
100
|
+
NodePanel = __decorate([
|
|
101
|
+
customElement("node-panel")
|
|
102
|
+
], NodePanel);
|
|
103
|
+
export { NodePanel };
|
|
104
|
+
//# sourceMappingURL=node-panel.js.map
|
|
@@ -1,23 +1,55 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 { LitElement, html, css } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { i18next, translate } from "@openremote/or-translate";
|
|
10
|
+
let NotificationDialog = class NotificationDialog extends translate(i18next)(LitElement) {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this.buttonText = i18next.t("ok");
|
|
14
|
+
this.message = " ";
|
|
15
|
+
}
|
|
16
|
+
static get styles() {
|
|
17
|
+
return css `
|
|
18
|
+
.message{
|
|
19
|
+
width: 100%;
|
|
20
|
+
padding: 15px 5px 25px 5px;
|
|
21
|
+
text-align: center;
|
|
22
|
+
max-width: 50vw;
|
|
23
|
+
overflow: auto;
|
|
24
|
+
user-select: text;
|
|
25
|
+
}
|
|
26
|
+
.container{
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
justify-content: space-evenly;
|
|
31
|
+
justify-content: space-around;
|
|
32
|
+
}`;
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
return html `
|
|
36
|
+
<div class="message">${this.message}</div>
|
|
37
|
+
<div class="container">
|
|
38
|
+
<or-mwc-input type="button" unElevated label="${this.buttonText}"
|
|
39
|
+
@click="${() => { this.dispatchEvent(new CustomEvent("closed")); }}">
|
|
40
|
+
</or-mwc-input>
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ type: String })
|
|
47
|
+
], NotificationDialog.prototype, "buttonText", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
property({ type: String })
|
|
50
|
+
], NotificationDialog.prototype, "message", void 0);
|
|
51
|
+
NotificationDialog = __decorate([
|
|
52
|
+
customElement("notification-dialog")
|
|
53
|
+
], NotificationDialog);
|
|
54
|
+
export { NotificationDialog };
|
|
55
|
+
//# sourceMappingURL=notification-dialog.js.map
|
|
@@ -1,55 +1,114 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 { LitElement, css, html } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { modal } from "./flow-editor";
|
|
10
|
+
import { translate, i18next } from "@openremote/or-translate";
|
|
11
|
+
let PopupModal = class PopupModal extends translate(i18next)(LitElement) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.closeButton = true;
|
|
15
|
+
this.isOpen = false;
|
|
16
|
+
}
|
|
17
|
+
close() {
|
|
18
|
+
this.isOpen = false;
|
|
19
|
+
}
|
|
20
|
+
open() {
|
|
21
|
+
this.isOpen = true;
|
|
22
|
+
}
|
|
23
|
+
static get styles() {
|
|
24
|
+
return css `
|
|
25
|
+
:host{
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 0;
|
|
28
|
+
right: 0;
|
|
29
|
+
top: 0;
|
|
30
|
+
bottom: 0;
|
|
31
|
+
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
|
|
36
|
+
background: rgba(0, 0, 0, 0.2);
|
|
37
|
+
z-index: 10000;
|
|
38
|
+
|
|
39
|
+
--topbar-height: 42px;
|
|
40
|
+
--closebutton-padding: 12px;
|
|
41
|
+
--modal-padding: 10px;
|
|
42
|
+
}
|
|
43
|
+
:host(:not([isopen])){
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
.modal{
|
|
47
|
+
min-width: 300px;
|
|
48
|
+
min-height: 64px;
|
|
49
|
+
width: auto;
|
|
50
|
+
height: auto;
|
|
51
|
+
display: inline-block;
|
|
52
|
+
background: white;
|
|
53
|
+
border-radius: var(--roundness);
|
|
54
|
+
position: relative;
|
|
55
|
+
padding: var(--modal-padding);
|
|
56
|
+
}
|
|
57
|
+
.close-button{
|
|
58
|
+
position: absolute;
|
|
59
|
+
top: 0;
|
|
60
|
+
right: 0;
|
|
61
|
+
width: calc(var(--topbar-height) - var(--closebutton-padding) * 2);
|
|
62
|
+
height: calc(var(--topbar-height) - var(--closebutton-padding) * 2);
|
|
63
|
+
padding: var(--closebutton-padding);
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
}
|
|
66
|
+
.title{
|
|
67
|
+
margin: 0;
|
|
68
|
+
height: calc(var(--topbar-height) - var(--modal-padding));
|
|
69
|
+
width: 100%;
|
|
70
|
+
text-transform: uppercase;
|
|
71
|
+
font-weight: bold;
|
|
72
|
+
}`;
|
|
73
|
+
}
|
|
74
|
+
firstUpdated() {
|
|
75
|
+
modal.element = this;
|
|
76
|
+
this.addEventListener("mousedown", this.close);
|
|
77
|
+
window.addEventListener("keyup", (e) => {
|
|
78
|
+
if (e.key === "Escape") {
|
|
79
|
+
this.close();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
if (!this.isOpen) {
|
|
85
|
+
this.style.display = "none";
|
|
86
|
+
return html ``;
|
|
19
87
|
}
|
|
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
|
-
text-transform: uppercase;
|
|
48
|
-
font-weight: bold;
|
|
49
|
-
}`}firstUpdated(){n.element=this,this.addEventListener("mousedown",this.close),window.addEventListener("keyup",t=>{"Escape"===t.key&&this.close()})}render(){return this.isOpen?(this.style.display="",e`
|
|
50
|
-
<div class="modal" @mousedown="${t=>{t.stopPropagation()}}">
|
|
51
|
-
<div class="title">${this.header}</div>
|
|
52
|
-
${this.content}
|
|
53
|
-
${this.closeButton?e`<or-icon class="close-button" icon="window-close" @click="${this.close}"></or-icon>`:null}
|
|
54
|
-
</div>
|
|
55
|
-
`):(this.style.display="none",e``)}};__decorate([r({type:Boolean})],PopupModal.prototype,"closeButton",void 0),__decorate([r({type:String})],PopupModal.prototype,"header",void 0),__decorate([r({attribute:!1})],PopupModal.prototype,"content",void 0),__decorate([r({type:Boolean,reflect:!0})],PopupModal.prototype,"isOpen",void 0),PopupModal=__decorate([i("popup-modal")],PopupModal);export{PopupModal};
|
|
88
|
+
this.style.display = "";
|
|
89
|
+
return html `
|
|
90
|
+
<div class="modal" @mousedown="${(e) => { e.stopPropagation(); }}">
|
|
91
|
+
<div class="title">${this.header}</div>
|
|
92
|
+
${this.content}
|
|
93
|
+
${this.closeButton ? html `<or-icon class="close-button" icon="window-close" @click="${this.close}"></or-icon>` : null}
|
|
94
|
+
</div>
|
|
95
|
+
`;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ type: Boolean })
|
|
100
|
+
], PopupModal.prototype, "closeButton", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: String })
|
|
103
|
+
], PopupModal.prototype, "header", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ attribute: false })
|
|
106
|
+
], PopupModal.prototype, "content", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
property({ type: Boolean, reflect: true })
|
|
109
|
+
], PopupModal.prototype, "isOpen", void 0);
|
|
110
|
+
PopupModal = __decorate([
|
|
111
|
+
customElement("popup-modal")
|
|
112
|
+
], PopupModal);
|
|
113
|
+
export { PopupModal };
|
|
114
|
+
//# sourceMappingURL=popup-modal.js.map
|
|
@@ -1,32 +1,121 @@
|
|
|
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
|
-
|
|
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 { LitElement, css, html } from "lit";
|
|
17
|
+
import { customElement, property } from "lit/decorators.js";
|
|
18
|
+
import rest from "@openremote/rest";
|
|
19
|
+
import { i18next, translate } from "@openremote/or-translate";
|
|
20
|
+
import { Utilities } from "../utils";
|
|
21
|
+
import { Status } from "../models/status";
|
|
22
|
+
import { exporter, project, modal } from "./flow-editor";
|
|
23
|
+
let RuleBrowser = class RuleBrowser extends translate(i18next)(LitElement) {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.status = Status.Idle;
|
|
27
|
+
this.retrievedRules = [];
|
|
28
|
+
this.loadRule = (r) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
this.status = Status.Loading;
|
|
30
|
+
let response;
|
|
31
|
+
try {
|
|
32
|
+
response = yield rest.api.RulesResource.getGlobalRuleset(r.id);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
modal.notification("Failure", "Something went wrong loading " + r.name);
|
|
36
|
+
this.status = Status.Failure;
|
|
37
|
+
return;
|
|
25
38
|
}
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
const ruleset = response.data;
|
|
40
|
+
const collection = exporter.jsonToFlow(ruleset.rules);
|
|
41
|
+
project.fromNodeCollection(collection);
|
|
42
|
+
project.setCurrentProject(r.id, r.name, collection.description);
|
|
43
|
+
this.dispatchEvent(new CustomEvent("ruleloaded"));
|
|
44
|
+
});
|
|
45
|
+
this.getButton = (r) => {
|
|
46
|
+
return html `<div class="list-button" @click="${() => { this.loadRule(r); }}">${Utilities.ellipsis(r.name, 50)}
|
|
47
|
+
${r.error ? html `<or-icon title="${Utilities.humanLike(r.status)}" icon="alert-outline"></or-icon>` : null}
|
|
48
|
+
${r.enabled ? null : html `<or-icon title="${i18next.t("disabled")}" icon="sleep"></or-icon>`}
|
|
49
|
+
</div>`;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static get styles() {
|
|
53
|
+
return css `
|
|
54
|
+
.list-button {
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
padding: 8px 0 8px 8px;
|
|
57
|
+
}
|
|
58
|
+
.list-button:hover {
|
|
59
|
+
background: whitesmoke;
|
|
60
|
+
}
|
|
61
|
+
.list-button:active {
|
|
62
|
+
background: none;
|
|
63
|
+
}
|
|
64
|
+
or-icon{
|
|
65
|
+
width: 18px;
|
|
66
|
+
vertical-align: text-top;
|
|
67
|
+
}
|
|
68
|
+
or-icon[icon=loading]{
|
|
69
|
+
animation: spin 600ms infinite linear;
|
|
70
|
+
}
|
|
71
|
+
@keyframes spin{
|
|
72
|
+
0%{
|
|
73
|
+
transform: rotateZ(0deg);
|
|
74
|
+
}
|
|
75
|
+
100%{
|
|
76
|
+
transform: rotateZ(360deg);
|
|
77
|
+
}
|
|
78
|
+
}`;
|
|
79
|
+
}
|
|
80
|
+
firstUpdated() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
this.status = Status.Loading;
|
|
83
|
+
try {
|
|
84
|
+
const response = yield rest.api.RulesResource.getGlobalRulesets();
|
|
85
|
+
this.retrievedRules = response.data;
|
|
86
|
+
this.status = Status.Success;
|
|
28
87
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
88
|
+
catch (error) {
|
|
89
|
+
this.status = Status.Failure;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
let result = html ``;
|
|
95
|
+
switch (this.status) {
|
|
96
|
+
case Status.Loading:
|
|
97
|
+
result = html `<span style="text-align: center;"><or-icon icon="loading"></or-icon></span>`;
|
|
98
|
+
break;
|
|
99
|
+
case Status.Success:
|
|
100
|
+
result = html `${this.retrievedRules.length === 0 ?
|
|
101
|
+
html `<span>No rules to display</span>` :
|
|
102
|
+
this.retrievedRules.map((r) => this.getButton(r))}`;
|
|
103
|
+
break;
|
|
104
|
+
case Status.Failure:
|
|
105
|
+
result = html `<span>Failed to load rules</span>`;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
return html `
|
|
109
|
+
<div style="display: flex; flex-direction: column; width: auto; align-items: stretch;">
|
|
110
|
+
${result}
|
|
111
|
+
</div>`;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__decorate([
|
|
115
|
+
property({ type: Number })
|
|
116
|
+
], RuleBrowser.prototype, "status", void 0);
|
|
117
|
+
RuleBrowser = __decorate([
|
|
118
|
+
customElement("rule-browser")
|
|
119
|
+
], RuleBrowser);
|
|
120
|
+
export { RuleBrowser };
|
|
121
|
+
//# sourceMappingURL=rule-browser.js.map
|