@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.
Files changed (73) hide show
  1. package/README.md +30 -30
  2. package/custom-elements.json +13 -13
  3. package/dist/umd/index.bundle.js +4744 -4744
  4. package/dist/umd/index.bundle.js.map +1 -1
  5. package/lib/flow-viewer/components/confirmation-dialog.js +61 -24
  6. package/lib/flow-viewer/components/connection-container.js +35 -1
  7. package/lib/flow-viewer/components/connection-line.js +117 -28
  8. package/lib/flow-viewer/components/context-menu.js +140 -45
  9. package/lib/flow-viewer/components/editor-workspace.js +282 -20
  10. package/lib/flow-viewer/components/flow-editor.js +160 -47
  11. package/lib/flow-viewer/components/flow-node-socket.js +146 -31
  12. package/lib/flow-viewer/components/flow-node.js +192 -29
  13. package/lib/flow-viewer/components/internal-picker.js +271 -54
  14. package/lib/flow-viewer/components/node-menu-item.js +132 -32
  15. package/lib/flow-viewer/components/node-panel.js +104 -60
  16. package/lib/flow-viewer/components/notification-dialog.js +55 -23
  17. package/lib/flow-viewer/components/popup-modal.js +113 -54
  18. package/lib/flow-viewer/components/rule-browser.js +119 -30
  19. package/lib/flow-viewer/components/selectable-element.js +71 -1
  20. package/lib/flow-viewer/components/selection-box.js +119 -15
  21. package/lib/flow-viewer/components/top-bar.js +116 -49
  22. package/lib/flow-viewer/components/workspace-contextmenu-options.js +128 -5
  23. package/lib/flow-viewer/components/writable-dropdown.js +51 -5
  24. package/lib/flow-viewer/converters/node-converter.js +10 -1
  25. package/lib/flow-viewer/flow-viewer.js +19 -1
  26. package/lib/flow-viewer/models/camera.js +2 -1
  27. package/lib/flow-viewer/models/context-menu-button.js +2 -1
  28. package/lib/flow-viewer/models/light-node-collection.js +2 -1
  29. package/lib/flow-viewer/models/status.js +8 -1
  30. package/lib/flow-viewer/node-structure/copy.machine.js +34 -1
  31. package/lib/flow-viewer/node-structure/identity.assigner.js +10 -1
  32. package/lib/flow-viewer/node-structure/identity.dom.link.js +4 -1
  33. package/lib/flow-viewer/node-structure/index.js +5 -1
  34. package/lib/flow-viewer/node-structure/socket.type.matcher.js +50 -1
  35. package/lib/flow-viewer/node-structure/utils.js +109 -1
  36. package/lib/flow-viewer/services/copy-paste-manager.js +59 -1
  37. package/lib/flow-viewer/services/exporter.js +67 -1
  38. package/lib/flow-viewer/services/input.js +80 -1
  39. package/lib/flow-viewer/services/integration.js +27 -1
  40. package/lib/flow-viewer/services/modal.js +29 -8
  41. package/lib/flow-viewer/services/project.js +222 -1
  42. package/lib/flow-viewer/services/shortcuts.js +63 -1
  43. package/lib/flow-viewer/styles/editor-workspace-style.js +55 -53
  44. package/lib/flow-viewer/styles/flow-node-style.js +95 -93
  45. package/lib/flow-viewer/styles/picker-styles.js +31 -29
  46. package/lib/flow-viewer/utils.js +49 -1
  47. package/lib/index.js +953 -56
  48. package/lib/json-viewer/forms/or-rule-form-alarm.js +91 -18
  49. package/lib/json-viewer/forms/or-rule-form-email-message.js +51 -12
  50. package/lib/json-viewer/forms/or-rule-form-localized.js +269 -43
  51. package/lib/json-viewer/forms/or-rule-form-push-notification.js +152 -63
  52. package/lib/json-viewer/forms/or-rule-form-webhook.js +296 -101
  53. package/lib/json-viewer/modals/or-rule-alarm-modal.js +173 -17
  54. package/lib/json-viewer/modals/or-rule-notification-modal.js +196 -11
  55. package/lib/json-viewer/modals/or-rule-radial-modal.js +142 -17
  56. package/lib/json-viewer/modals/or-rule-webhook-modal.js +78 -8
  57. package/lib/json-viewer/or-rule-action-alarm.js +97 -5
  58. package/lib/json-viewer/or-rule-action-attribute.js +235 -33
  59. package/lib/json-viewer/or-rule-action-notification.js +465 -56
  60. package/lib/json-viewer/or-rule-action-webhook.js +49 -18
  61. package/lib/json-viewer/or-rule-asset-query.js +849 -126
  62. package/lib/json-viewer/or-rule-condition.js +216 -29
  63. package/lib/json-viewer/or-rule-json-viewer.js +393 -34
  64. package/lib/json-viewer/or-rule-then-otherwise.js +609 -113
  65. package/lib/json-viewer/or-rule-trigger-query.js +227 -57
  66. package/lib/json-viewer/or-rule-when.js +343 -126
  67. package/lib/or-rule-group-viewer.js +106 -12
  68. package/lib/or-rule-text-viewer.js +133 -22
  69. package/lib/or-rule-tree.js +601 -57
  70. package/lib/or-rule-validity.js +373 -62
  71. package/lib/or-rule-viewer.js +361 -81
  72. package/lib/style.js +89 -64
  73. package/package.json +11 -11
@@ -1,60 +1,104 @@
1
- var __decorate=this&&this.__decorate||function(e,t,r,o){var a,i=arguments.length,d=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(e,t,r,o);else for(var n=e.length-1;n>=0;n--)(a=e[n])&&(d=(i<3?a(d):i>3?a(t,r,d):a(t,r))||d);return i>3&&d&&Object.defineProperty(t,r,d),d};import{LitElement as e,html as t,css as r}from"lit";import{customElement as o,property as a,query as i}from"lit/decorators.js";import{i18next as d,translate as n}from"@openremote/or-translate";let NodePanel=class extends n(d)(e){constructor(){super(...arguments),this.nodes=[]}static get styles(){return r`
2
- .list{
3
- overflow-x: hidden;
4
- overflow-y: auto;
5
- display: flex;
6
- flex-direction: column;
7
- align-items: center;
8
- height: 100%;
9
- background: #F9F9F9;
10
- }
11
- .category{
12
- display: flex;
13
- width: 80%;
14
- flex-direction: column;
15
- align-items: center;
16
- text-align: center;
17
- padding: 15px 15px 0 15px;
18
- }
19
- .category span{
20
- margin:0;
21
- color: rgb(125,125,125);
22
- padding: 0 0 15px 0 ;
23
- }
24
- .small-node-grid{
25
- display: grid;
26
- grid-template-columns: repeat(5, 1fr);
27
- grid-template-rows: repeat(2, 1fr);
28
- grid-gap: 6px;
29
- justify-items: stretch;
30
- align-items: stretch;
31
- margin-bottom: 15px;
32
- width: var(--nodepanel-width);
33
- }
34
- .input-node{ background-color: var(--input-color); }
35
- .processor-node{ background-color: var(--processor-color); }
36
- .output-node{ background-color: var(--output-color); }
37
- .input-node:hover{ background-color: var(--input-color-h); }
38
- .processor-node:hover{ background-color: var(--processor-color-h); }
39
- .output-node:hover{ background-color: var(--output-color-h); }`}firstUpdated(){this.drawer&&(this.drawer.open=!0)}render(){return t`
40
- <!-- <or-mwc-drawer rightsided dismissible transparent> -->
41
- ${this.listTemplate}
42
- <!-- </or-mwc-drawer> -->
43
- `}nodeTemplate(e){return t`<node-menu-item class="node-item" .node="${e}" .workspace="${this.application.editorWorkspace}"></node-menu-item>`}get listTemplate(){return t`
44
- <div class="list">
45
- <div class="category"> <span>${d.t("input","Input")}</span>
46
- ${this.nodes.filter(e=>"INPUT"===e.type).map(e=>this.nodeTemplate(e))}
47
- </div>
48
-
49
- <div class="category"><span>${d.t("processors","Processors")}</span>
50
- <div class="small-node-grid">
51
- ${this.nodes.filter(e=>"PROCESSOR"===e.type&&e.displayCharacter).sort((e,t)=>e.priority-t.priority).map(e=>this.nodeTemplate(e))}
52
- </div>
53
- ${this.nodes.filter(e=>"PROCESSOR"===e.type&&!e.displayCharacter).map(e=>this.nodeTemplate(e))}
54
- </div>
55
-
56
- <div class="category"> <span>${d.t("output","Output")}</span>
57
- ${this.nodes.filter(e=>"OUTPUT"===e.type).map(e=>this.nodeTemplate(e))}
58
- </div>
59
- </div>
60
- `}};__decorate([a({type:Array})],NodePanel.prototype,"nodes",void 0),__decorate([i("or-mwc-drawer")],NodePanel.prototype,"drawer",void 0),__decorate([a({attribute:!1})],NodePanel.prototype,"application",void 0),NodePanel=__decorate([o("node-panel")],NodePanel);export{NodePanel};
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||function(t,e,o,i){var n,r=arguments.length,a=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,o,i);else for(var c=t.length-1;c>=0;c--)(n=t[c])&&(a=(r<3?n(a):r>3?n(e,o,a):n(e,o))||a);return r>3&&a&&Object.defineProperty(e,o,a),a};import{LitElement as t,html as e,css as o}from"lit";import{customElement as i,property as n}from"lit/decorators.js";import{i18next as r,translate as a}from"@openremote/or-translate";let NotificationDialog=class extends a(r)(t){constructor(){super(...arguments),this.buttonText=r.t("ok"),this.message=" "}static get styles(){return o`
2
- .message{
3
- width: 100%;
4
- padding: 15px 5px 25px 5px;
5
- text-align: center;
6
- max-width: 50vw;
7
- overflow: auto;
8
- user-select: text;
9
- }
10
- .container{
11
- display: flex;
12
- flex-direction: row;
13
- justify-content: space-between;
14
- justify-content: space-evenly;
15
- justify-content: space-around;
16
- }`}render(){return e`
17
- <div class="message">${this.message}</div>
18
- <div class="container">
19
- <or-mwc-input type="button" unElevated label="${this.buttonText}"
20
- @click="${()=>{this.dispatchEvent(new CustomEvent("closed"))}}">
21
- </or-mwc-input>
22
- </div>
23
- `}};__decorate([n({type:String})],NotificationDialog.prototype,"buttonText",void 0),__decorate([n({type:String})],NotificationDialog.prototype,"message",void 0),NotificationDialog=__decorate([i("notification-dialog")],NotificationDialog);export{NotificationDialog};
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||function(t,o,e,i){var r,n=arguments.length,a=n<3?o:null===i?i=Object.getOwnPropertyDescriptor(o,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,o,e,i);else for(var p=t.length-1;p>=0;p--)(r=t[p])&&(a=(n<3?r(a):n>3?r(o,e,a):r(o,e))||a);return n>3&&a&&Object.defineProperty(o,e,a),a};import{LitElement as t,css as o,html as e}from"lit";import{customElement as i,property as r}from"lit/decorators.js";import{modal as n}from"./flow-editor";import{translate as a,i18next as p}from"@openremote/or-translate";let PopupModal=class extends a(p)(t){constructor(){super(),this.closeButton=!0,this.isOpen=!1}close(){this.isOpen=!1}open(){this.isOpen=!0}static get styles(){return o`
2
- :host{
3
- position: absolute;
4
- left: 0;
5
- right: 0;
6
- top: 0;
7
- bottom: 0;
8
-
9
- display: flex;
10
- justify-content: center;
11
- align-items: center;
12
-
13
- background: rgba(0, 0, 0, 0.2);
14
- z-index: 10000;
15
-
16
- --topbar-height: 42px;
17
- --closebutton-padding: 12px;
18
- --modal-padding: 10px;
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
- :host(:not([isopen])){
21
- display: none;
22
- }
23
- .modal{
24
- min-width: 300px;
25
- min-height: 64px;
26
- width: auto;
27
- height: auto;
28
- display: inline-block;
29
- background: white;
30
- border-radius: var(--roundness);
31
- position: relative;
32
- padding: var(--modal-padding);
33
- }
34
- .close-button{
35
- position: absolute;
36
- top: 0;
37
- right: 0;
38
- width: calc(var(--topbar-height) - var(--closebutton-padding) * 2);
39
- height: calc(var(--topbar-height) - var(--closebutton-padding) * 2);
40
- padding: var(--closebutton-padding);
41
- cursor: pointer;
42
- }
43
- .title{
44
- margin: 0;
45
- height: calc(var(--topbar-height) - var(--modal-padding));
46
- width: 100%;
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=this&&this.__decorate||function(t,e,o,i){var r,s=arguments.length,n=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,o,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(n=(s<3?r(n):s>3?r(e,o,n):r(e,o))||n);return s>3&&n&&Object.defineProperty(e,o,n),n},__awaiter=this&&this.__awaiter||function(t,e,o,i){return new(o||(o=Promise))(function(r,s){function n(t){try{l(i.next(t))}catch(t){s(t)}}function a(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?r(t.value):((e=t.value)instanceof o?e:new o(function(t){t(e)})).then(n,a)}l((i=i.apply(t,e||[])).next())})};import{LitElement as t,css as e,html as o}from"lit";import{customElement as i,property as r}from"lit/decorators.js";import s from"@openremote/rest";import{i18next as n,translate as a}from"@openremote/or-translate";import{Utilities as l}from"../utils";import{Status as u}from"../models/status";import{exporter as c,project as d,modal as p}from"./flow-editor";let RuleBrowser=class extends a(n)(t){constructor(){super(...arguments),this.status=u.Idle,this.retrievedRules=[],this.loadRule=t=>__awaiter(this,void 0,void 0,function*(){let e;this.status=u.Loading;try{e=yield s.api.RulesResource.getGlobalRuleset(t.id)}catch(e){p.notification("Failure","Something went wrong loading "+t.name),this.status=u.Failure;return}let o=e.data,i=c.jsonToFlow(o.rules);d.fromNodeCollection(i),d.setCurrentProject(t.id,t.name,i.description),this.dispatchEvent(new CustomEvent("ruleloaded"))}),this.getButton=t=>o`<div class="list-button" @click="${()=>{this.loadRule(t)}}">${l.ellipsis(t.name,50)}
2
- ${t.error?o`<or-icon title="${l.humanLike(t.status)}" icon="alert-outline"></or-icon>`:null}
3
- ${t.enabled?null:o`<or-icon title="${n.t("disabled")}" icon="sleep"></or-icon>`}
4
- </div>`}static get styles(){return e`
5
- .list-button {
6
- cursor: pointer;
7
- padding: 8px 0 8px 8px;
8
- }
9
- .list-button:hover {
10
- background: whitesmoke;
11
- }
12
- .list-button:active {
13
- background: none;
14
- }
15
- or-icon{
16
- width: 18px;
17
- vertical-align: text-top;
18
- }
19
- or-icon[icon=loading]{
20
- animation: spin 600ms infinite linear;
21
- }
22
- @keyframes spin{
23
- 0%{
24
- transform: rotateZ(0deg);
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
- 100%{
27
- transform: rotateZ(360deg);
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
- }`}firstUpdated(){return __awaiter(this,void 0,void 0,function*(){this.status=u.Loading;try{let t=yield s.api.RulesResource.getGlobalRulesets();this.retrievedRules=t.data,this.status=u.Success}catch(t){this.status=u.Failure}})}render(){let t=o``;switch(this.status){case u.Loading:t=o`<span style="text-align: center;"><or-icon icon="loading"></or-icon></span>`;break;case u.Success:t=o`${0===this.retrievedRules.length?o`<span>No rules to display</span>`:this.retrievedRules.map(t=>this.getButton(t))}`;break;case u.Failure:t=o`<span>Failed to load rules</span>`}return o`
30
- <div style="display: flex; flex-direction: column; width: auto; align-items: stretch;">
31
- ${t}
32
- </div>`}};__decorate([r({type:Number})],RuleBrowser.prototype,"status",void 0),RuleBrowser=__decorate([i("rule-browser")],RuleBrowser);export{RuleBrowser};
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