@openremote/or-rules 1.8.0-snapshot.20250818141417 → 1.8.0-snapshot.20250818162953

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.
@@ -30,6 +30,6 @@ var __decorate=this&&this.__decorate||function(e,t,o,i){var r,d=arguments.length
30
30
  border-radius: 100%;
31
31
  pointer-events: none;
32
32
  border: 1px solid rgb(80,80,80);
33
- }`}get socketTypeString(){return this.socket.type.toString().toLowerCase().replace("_array","")}disconnectedCallback(){this.identityDeleted=delete n.map[this.socket.id],l.removeListener("connectioncreated",this.forceUpdate),l.removeListener("connectionremoved",this.forceUpdate),l.removeListener("nodeadded",this.forceUpdate),l.removeListener("noderemoved",this.forceUpdate),l.removeListener("cleared",this.forceUpdate),n.map[this.socket.nodeId].removeEventListener("updated",this.forceUpdate)}firstUpdated(){this.title=s.humanLike(this.socketTypeString),this.linkIdentity(),l.addListener("connectioncreated",this.forceUpdate),l.addListener("connectionremoved",this.forceUpdate),l.addListener("nodeadded",this.forceUpdate),l.addListener("noderemoved",this.forceUpdate),l.addListener("cleared",this.forceUpdate),n.map[this.socket.nodeId].addEventListener("updated",this.forceUpdate);let e="input"===this.side;this.addEventListener("mousedown",t=>{this.linkIdentity(),1===t.buttons&&(l.isCurrentlyConnecting||(l.startConnectionDrag(t,this.socket,e),t.stopPropagation(),t.stopImmediatePropagation()))}),this.addEventListener("mouseup",t=>{l.createUndoSnapshot(),this.linkIdentity(),l.endConnectionDrag(t,this.socket,e),l.notifyChange(),1===t.buttons&&(t.stopPropagation(),t.stopImmediatePropagation())})}updated(){this.linkIdentity()}render(){let e=`var(--${this.socketTypeString})`,o=t`<div class="socket">
33
+ }`}get socketTypeString(){return this.socket.type.toString().toLowerCase().replace("_array","")}disconnectedCallback(){this.identityDeleted=delete n.map[this.socket.id],l.removeListener("connectioncreated",this.forceUpdate),l.removeListener("connectionremoved",this.forceUpdate),l.removeListener("nodeadded",this.forceUpdate),l.removeListener("noderemoved",this.forceUpdate),l.removeListener("cleared",this.forceUpdate),n.map[this.socket.nodeId].removeEventListener("updated",this.forceUpdate)}firstUpdated(){this.title=s.humanLike(this.socketTypeString),this.linkIdentity(),l.addListener("connectioncreated",this.forceUpdate),l.addListener("connectionremoved",this.forceUpdate),l.addListener("nodeadded",this.forceUpdate),l.addListener("noderemoved",this.forceUpdate),l.addListener("cleared",this.forceUpdate),n.map[this.socket.nodeId].addEventListener("updated",this.forceUpdate);let e="input"===this.side,t=t=>{this.linkIdentity(),1===t.buttons&&(l.isCurrentlyConnecting||(l.startConnectionDrag(t,this.socket,e),t.stopPropagation(),t.stopImmediatePropagation()))},o=t=>{l.createUndoSnapshot(),this.linkIdentity(),l.endConnectionDrag(t,this.socket,e),l.notifyChange(),1===t.buttons&&(t.stopPropagation(),t.stopImmediatePropagation())};this.addEventListener("mousedown",t),this.addEventListener("mouseup",o)}updated(){this.linkIdentity()}render(){let e=`var(--${this.socketTypeString})`,o=t`<div class="socket">
34
34
  <div class="circle" id="circle" style="background: ${e}"></div>
35
35
  </div>`;if(!this.renderLabel)return o;let i=t`<div class="label">${c.t(s.humanLike(this.socket.name))}</div>`;return"input"===this.side?t`${o}${i}`:t`${i}${o}`}linkIdentity(){this.identityDeleted||(n.map[this.socket.id]=this)}};__decorate([r({type:Object})],FlowNodeSocket.prototype,"socket",void 0),__decorate([r({type:String})],FlowNodeSocket.prototype,"side",void 0),__decorate([r({type:Boolean})],FlowNodeSocket.prototype,"renderLabel",void 0),__decorate([d("#circle")],FlowNodeSocket.prototype,"circleElem",void 0),FlowNodeSocket=__decorate([i("flow-node-socket")],FlowNodeSocket);export{FlowNodeSocket};
@@ -9,9 +9,9 @@ var __decorate=this&&this.__decorate||function(t,e,o,r){var i,a=arguments.length
9
9
  .min-width {
10
10
  min-width: 200px;
11
11
  }
12
- `,OrRuleAlarmModal=class extends n(l)(o){static get styles(){return style}constructor(){super(),this.title="settings",this.addEventListener(s.NAME,this.initDialog)}initDialog(){if(!this.shadowRoot.getElementById("alarm-modal"))return}renderDialogHTML(t){let o=this.shadowRoot.getElementById("alarm-modal");if(!this.shadowRoot)return;let r=this.shadowRoot.querySelector(".alarm-form-slot");if(o&&r){let t=document.createElement("div");r.assignedNodes({flatten:!0}).forEach(e=>{e instanceof HTMLElement&&t.appendChild(e)}),o.content=e`${t}`,o.dismissAction=null,this.requestUpdate()}}firstUpdated(t){t.has("action")&&this.renderDialogHTML(this.action)}checkForm(){let t=this.shadowRoot.host;if(this.shadowRoot){let e=this.shadowRoot.querySelector("or-rule-form-alarm");if(e&&e.shadowRoot)return checkValidity(e.shadowRoot.querySelector("form"),t)}}render(){var t;if(!this.action)return e``;let o=[{actionName:"cancel",content:e`<or-mwc-input class="button" .type="${a.BUTTON}" .label="${l.t("cancel")}"></or-mwc-input>`,action:t=>{}},{actionName:"",content:e`<or-mwc-input class="button" .type="${a.BUTTON}" .label="${l.t("ok")}" @or-mwc-input-changed="${this.checkForm}"></or-mwc-input>`}];return e`
12
+ `,OrRuleAlarmModal=class extends n(l)(o){static get styles(){return style}constructor(){super(),this.title="settings",this.addEventListener(s.NAME,this.initDialog)}initDialog(){if(!this.shadowRoot.getElementById("alarm-modal"))return}renderDialogHTML(t){let o=this.shadowRoot.getElementById("alarm-modal");if(!this.shadowRoot)return;let r=this.shadowRoot.querySelector(".alarm-form-slot");if(o&&r){let t=document.createElement("div");r.assignedNodes({flatten:!0}).forEach(e=>{e instanceof HTMLElement&&t.appendChild(e)}),o.content=e`${t}`,o.dismissAction=null,this.requestUpdate()}}firstUpdated(t){t.has("action")&&this.renderDialogHTML(this.action)}checkForm(){let t=this.shadowRoot.host;if(this.shadowRoot){let e=this.shadowRoot.querySelector("or-rule-form-alarm");if(e&&e.shadowRoot)return checkValidity(e.shadowRoot.querySelector("form"),t)}}render(){var t;if(!this.action)return e``;let o=[{actionName:"cancel",content:e`<or-mwc-input class="button" .type="${a.BUTTON}" .label="${l.t("cancel")}"></or-mwc-input>`,action:t=>{}},{actionName:"",content:e`<or-mwc-input class="button" .type="${a.BUTTON}" .label="${l.t("ok")}" @or-mwc-input-changed="${this.checkForm}"></or-mwc-input>`}],r=()=>{let t=this.shadowRoot.getElementById("alarm-modal");t&&t.open()};return e`
13
13
  <or-mwc-input style="width: 200px" .type="${a.SELECT}" .value="${null==(t=this.action.alarm)?void 0:t.severity}" .label="${l.t("alarm.severity")}" .options="${[["LOW",l.t("alarm.severity_LOW")],["MEDIUM",l.t("alarm.severity_MEDIUM")],["HIGH",l.t("alarm.severity_HIGH")]]}" @or-mwc-input-changed="${t=>this.setActionAlarmSeverity(t.detail.value)}"></or-mwc-input>
14
- <or-mwc-input .type="${a.BUTTON}" .label="${l.t("settings")}" @or-mwc-input-changed="${()=>{let t=this.shadowRoot.getElementById("alarm-modal");t&&t.open()}}"></or-mwc-input>
14
+ <or-mwc-input .type="${a.BUTTON}" .label="${l.t("settings")}" @or-mwc-input-changed="${r}"></or-mwc-input>
15
15
  <or-mwc-dialog id="alarm-modal" heading="${this.title}" .actions="${o}"></or-mwc-dialog>
16
16
  <slot class="alarm-form-slot"></slot>
17
17
  `}setActionAlarmSeverity(t){if(t&&this.action.alarm){let e=this.action.alarm;e.severity=t,this.action.alarm=Object.assign({},e)}this.dispatchEvent(new c),this.requestUpdate()}};__decorate([i({type:Object,attribute:!1})],OrRuleAlarmModal.prototype,"action",void 0),__decorate([i({type:String})],OrRuleAlarmModal.prototype,"title",void 0),__decorate([i({type:Object})],OrRuleAlarmModal.prototype,"query",void 0),OrRuleAlarmModal=__decorate([r("or-rule-alarm-modal")],OrRuleAlarmModal);export{OrRuleAlarmModal};
@@ -1,11 +1,11 @@
1
- var __decorate=this&&this.__decorate||function(t,o,e,i){var n,r=arguments.length,a=r<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 l=t.length-1;l>=0;l--)(n=t[l])&&(a=(r<3?n(a):r>3?n(o,e,a):n(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a};import{html as t,LitElement as o}from"lit";import{customElement as e,property as i,query as n}from"lit/decorators.js";import"@openremote/or-mwc-components/or-mwc-input";import{InputType as r}from"@openremote/or-mwc-components/or-mwc-input";import a from"i18next";import{translate as l}from"@openremote/or-translate";import{OrMwcDialogOpenedEvent as c}from"@openremote/or-mwc-components/or-mwc-dialog";import{OrRulesJsonRuleChangedEvent as s}from"../or-rule-json-viewer";let checkValidity=t=>{if(t){let o=t.querySelectorAll("or-mwc-input");return Array.prototype.slice.call(o).every(t=>{if(!t.shadowRoot)return!1;{let o=t.shadowRoot.querySelector("input, textarea, select");return!!(o&&o.checkValidity())||(t._mdcComponent&&(t._mdcComponent.valid=!1,t._mdcComponent.helperTextContent="required"),!1)}})}};export class OrRulesNotificationModalCancelEvent extends CustomEvent{constructor(){super(OrRulesNotificationModalCancelEvent.NAME,{bubbles:!0,composed:!0})}}OrRulesNotificationModalCancelEvent.NAME="or-rules-notification-modal-cancel";export class OrRulesNotificationModalOkEvent extends CustomEvent{constructor(){super(OrRulesNotificationModalOkEvent.NAME,{bubbles:!0,composed:!0})}}OrRulesNotificationModalOkEvent.NAME="or-rules-notification-modal-ok";let OrRuleNotificationModal=class extends l(a)(o){constructor(){super(),this.title="message",this.addEventListener(c.NAME,this.initDialog)}connectedCallback(){return this.addEventListener(s.NAME,this._onJsonRuleChanged),super.connectedCallback()}disconnectedCallback(){return this.removeEventListener(s.NAME,this._onJsonRuleChanged),super.disconnectedCallback()}_onJsonRuleChanged(){this.validateForm()}initDialog(){if(!this._orMwcDialog)return}renderDialogHTML(o){let e=this.shadowRoot.getElementById("notification-modal");if(!this.shadowRoot)return;let i=this.shadowRoot.querySelector(".notification-form-slot");if(e&&i){let o=document.createElement("div");i.assignedNodes({flatten:!0}).forEach(t=>{t instanceof HTMLElement&&o.appendChild(t)}),e.content=t`${o}`,e.dismissAction=null,this.requestUpdate()}}firstUpdated(t){t.has("action")&&this.renderDialogHTML(this.action),this.getUpdateComplete().finally(()=>{this.validateForm()})}validateForm(){var t,o,e;let i=this.checkForm();null==(t=this._orMwcDialog)||t.setActions(null==(e=null==(o=this._orMwcDialog)?void 0:o.actions)?void 0:e.map(t=>("ok"===t.actionName&&(t.disabled=!i),t)))}checkForm(){if(this.shadowRoot){let t=this._orMwcDialog,o=null==t?void 0:t.shadowRoot;if(t&&o){let t=o.querySelector("or-rule-form-email-message"),e=o.querySelector("or-rule-form-push-notification"),i=o.querySelector("or-rule-form-localized");if(null==e?void 0:e.shadowRoot)return checkValidity(e.shadowRoot.querySelector("form"));if(null==t?void 0:t.shadowRoot)return checkValidity(t.shadowRoot.querySelector("form"));if(null==i?void 0:i.shadowRoot)return i.isValid()}}}render(){let o=()=>{this.dispatchEvent(new OrRulesNotificationModalCancelEvent)},e=[{actionName:"cancel",content:t`<or-mwc-input class="button" .type="${r.BUTTON}" label="cancel"></or-mwc-input>`,action:o},{actionName:"ok",content:"ok",disabled:!0,action:()=>{this.dispatchEvent(new OrRulesNotificationModalOkEvent)}}],i=t`
1
+ var __decorate=this&&this.__decorate||function(t,o,e,i){var n,r=arguments.length,a=r<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 l=t.length-1;l>=0;l--)(n=t[l])&&(a=(r<3?n(a):r>3?n(o,e,a):n(o,e))||a);return r>3&&a&&Object.defineProperty(o,e,a),a};import{html as t,LitElement as o}from"lit";import{customElement as e,property as i,query as n}from"lit/decorators.js";import"@openremote/or-mwc-components/or-mwc-input";import{InputType as r}from"@openremote/or-mwc-components/or-mwc-input";import a from"i18next";import{translate as l}from"@openremote/or-translate";import{OrMwcDialogOpenedEvent as c}from"@openremote/or-mwc-components/or-mwc-dialog";import{OrRulesJsonRuleChangedEvent as s}from"../or-rule-json-viewer";let checkValidity=t=>{if(t){let o=t.querySelectorAll("or-mwc-input");return Array.prototype.slice.call(o).every(t=>{if(!t.shadowRoot)return!1;{let o=t.shadowRoot.querySelector("input, textarea, select");return!!(o&&o.checkValidity())||(t._mdcComponent&&(t._mdcComponent.valid=!1,t._mdcComponent.helperTextContent="required"),!1)}})}};export class OrRulesNotificationModalCancelEvent extends CustomEvent{constructor(){super(OrRulesNotificationModalCancelEvent.NAME,{bubbles:!0,composed:!0})}}OrRulesNotificationModalCancelEvent.NAME="or-rules-notification-modal-cancel";export class OrRulesNotificationModalOkEvent extends CustomEvent{constructor(){super(OrRulesNotificationModalOkEvent.NAME,{bubbles:!0,composed:!0})}}OrRulesNotificationModalOkEvent.NAME="or-rules-notification-modal-ok";let OrRuleNotificationModal=class extends l(a)(o){constructor(){super(),this.title="message",this.addEventListener(c.NAME,this.initDialog)}connectedCallback(){return this.addEventListener(s.NAME,this._onJsonRuleChanged),super.connectedCallback()}disconnectedCallback(){return this.removeEventListener(s.NAME,this._onJsonRuleChanged),super.disconnectedCallback()}_onJsonRuleChanged(){this.validateForm()}initDialog(){if(!this._orMwcDialog)return}renderDialogHTML(o){let e=this.shadowRoot.getElementById("notification-modal");if(!this.shadowRoot)return;let i=this.shadowRoot.querySelector(".notification-form-slot");if(e&&i){let o=document.createElement("div");i.assignedNodes({flatten:!0}).forEach(t=>{t instanceof HTMLElement&&o.appendChild(t)}),e.content=t`${o}`,e.dismissAction=null,this.requestUpdate()}}firstUpdated(t){t.has("action")&&this.renderDialogHTML(this.action),this.getUpdateComplete().finally(()=>{this.validateForm()})}validateForm(){var t,o,e;let i=this.checkForm();null==(t=this._orMwcDialog)||t.setActions(null==(e=null==(o=this._orMwcDialog)?void 0:o.actions)?void 0:e.map(t=>("ok"===t.actionName&&(t.disabled=!i),t)))}checkForm(){if(this.shadowRoot){let t=this._orMwcDialog,o=null==t?void 0:t.shadowRoot;if(t&&o){let t=o.querySelector("or-rule-form-email-message"),e=o.querySelector("or-rule-form-push-notification"),i=o.querySelector("or-rule-form-localized");if(null==e?void 0:e.shadowRoot)return checkValidity(e.shadowRoot.querySelector("form"));if(null==t?void 0:t.shadowRoot)return checkValidity(t.shadowRoot.querySelector("form"));if(null==i?void 0:i.shadowRoot)return i.isValid()}}}render(){let o=()=>{this.dispatchEvent(new OrRulesNotificationModalCancelEvent)},e=()=>{this.dispatchEvent(new OrRulesNotificationModalOkEvent)},i=[{actionName:"cancel",content:t`<or-mwc-input class="button" .type="${r.BUTTON}" label="cancel"></or-mwc-input>`,action:o},{actionName:"ok",content:"ok",disabled:!0,action:e}],n=t`
2
2
  <style>
3
3
  .mdc-dialog__actions {
4
4
  justify-content: space-between !important;
5
5
  }
6
6
  </style>
7
- `;return t`
8
- <or-mwc-input .type="${r.BUTTON}" label="message" @or-mwc-input-changed="${()=>{let t=this.shadowRoot.getElementById("notification-modal");t&&t.open()}}"></or-mwc-input>
9
- <or-mwc-dialog id="notification-modal" .heading="${this.title}" .dismissAction="${{actionName:"cancel",action:o}}" .actions="${e}" .styles="${i}"></or-mwc-dialog>
7
+ `,a=()=>{let t=this.shadowRoot.getElementById("notification-modal");t&&t.open()};return t`
8
+ <or-mwc-input .type="${r.BUTTON}" label="message" @or-mwc-input-changed="${a}"></or-mwc-input>
9
+ <or-mwc-dialog id="notification-modal" .heading="${this.title}" .dismissAction="${{actionName:"cancel",action:o}}" .actions="${i}" .styles="${n}"></or-mwc-dialog>
10
10
  <slot class="notification-form-slot"></slot>
11
11
  `}};__decorate([i({type:Object})],OrRuleNotificationModal.prototype,"action",void 0),__decorate([i({type:String})],OrRuleNotificationModal.prototype,"title",void 0),__decorate([i({type:Object})],OrRuleNotificationModal.prototype,"query",void 0),__decorate([n("#notification-modal")],OrRuleNotificationModal.prototype,"_orMwcDialog",void 0),OrRuleNotificationModal=__decorate([e("or-rule-notification-modal")],OrRuleNotificationModal);export{OrRuleNotificationModal};
@@ -11,7 +11,7 @@ var __decorate=this&&this.__decorate||function(e,t,a,r){var o,i=arguments.length
11
11
 
12
12
  <label>${l.t("radiusMin")}</label>
13
13
  <input @change="${e=>this.setValuePredicateProperty("radius",parseInt(e.target.value))}" style="max-width: calc(50% - 30px);" required placeholder=" " min="100" type="number" .value="${t&&t.radius?t.radius:100}" />
14
- </div>`)}render(){if(!this.attributePredicate||!this.query)return e``;let t=this.attributePredicate.value;if(!this.assetDescriptor||!t)return e``;this.getAttributeName(this.attributePredicate),o(this.query);let a=t||void 0,r=[{actionName:"cancel",content:e`<or-mwc-input class="button" .type="${i.BUTTON}" label="cancel"></or-mwc-input>`,action:()=>{}},{actionName:"ok",default:!0,content:e`<or-mwc-input class="button" .type="${i.BUTTON}" label="ok"></or-mwc-input>`,action:()=>{}}];return this.renderDialogHTML(a),e`
15
- <or-mwc-input .type="${i.BUTTON}" label="area" @or-mwc-input-changed="${()=>{let e=this.shadowRoot.getElementById("radial-modal");e&&(e.dismissAction=null,e.open(),this.renderDialogHTML(a))}}"></or-mwc-input>
14
+ </div>`)}render(){if(!this.attributePredicate||!this.query)return e``;let t=this.attributePredicate.value;if(!this.assetDescriptor||!t)return e``;this.getAttributeName(this.attributePredicate),o(this.query);let a=t||void 0,r=[{actionName:"cancel",content:e`<or-mwc-input class="button" .type="${i.BUTTON}" label="cancel"></or-mwc-input>`,action:()=>{}},{actionName:"ok",default:!0,content:e`<or-mwc-input class="button" .type="${i.BUTTON}" label="ok"></or-mwc-input>`,action:()=>{}}],l=()=>{let e=this.shadowRoot.getElementById("radial-modal");e&&(e.dismissAction=null,e.open(),this.renderDialogHTML(a))};return this.renderDialogHTML(a),e`
15
+ <or-mwc-input .type="${i.BUTTON}" label="area" @or-mwc-input-changed="${l}"></or-mwc-input>
16
16
  <or-mwc-dialog id="radial-modal" heading="area" .actions="${r}"></or-mwc-dialog>
17
17
  `}};__decorate([r({type:Object})],OrRuleRadialModal.prototype,"assetDescriptor",void 0),__decorate([r({type:Object})],OrRuleRadialModal.prototype,"attributePredicate",void 0),__decorate([r({type:Object})],OrRuleRadialModal.prototype,"query",void 0),OrRuleRadialModal=__decorate([a("or-rule-radial-modal")],OrRuleRadialModal);export{OrRuleRadialModal};
@@ -1,8 +1,8 @@
1
1
  var __decorate=this&&this.__decorate||function(e,o,t,r){var l,i=arguments.length,a=i<3?o:null===r?r=Object.getOwnPropertyDescriptor(o,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,o,t,r);else for(var n=e.length-1;n>=0;n--)(l=e[n])&&(a=(i<3?l(a):i>3?l(o,t,a):l(o,t))||a);return i>3&&a&&Object.defineProperty(o,t,a),a};import{InputType as e}from"@openremote/or-mwc-components/or-mwc-input";import{i18next as o}from"@openremote/or-translate";import{html as t,LitElement as r}from"lit";import{customElement as l,property as i}from"lit/decorators.js";let OrRuleWebhookModal=class extends r{constructor(){super(),this.title=o.t("message")}firstUpdated(e){e.has("action")&&this.renderDialogHTML(this.action)}renderDialogHTML(e){let o=this.shadowRoot.getElementById("webhook-modal");if(!this.shadowRoot)return;let r=this.shadowRoot.querySelector(".webhook-form-slot");if(o&&r){let e=document.createElement("div");r.assignedNodes({flatten:!0}).forEach(o=>{o instanceof HTMLElement&&e.appendChild(o)}),o.content=t`${e}`,o.dismissAction=null,this.requestUpdate()}}closeForm(e){this.shadowRoot.host.close()}render(){if(!this.action)return t`${o.t("errorOccurred")}`;let r=[{actionName:"",content:t`
2
2
  <or-mwc-input .type="${e.BUTTON}" label="ok"
3
- @or-mwc-input-changed="${this.closeForm}"></or-mwc-input>`}];return t`
3
+ @or-mwc-input-changed="${this.closeForm}"></or-mwc-input>`}],l=()=>{let e=this.shadowRoot.getElementById("webhook-modal");e&&e.open()};return t`
4
4
  <or-mwc-input type="${e.BUTTON}" label="message"
5
- @or-mwc-input-changed="${()=>{let e=this.shadowRoot.getElementById("webhook-modal");e&&e.open()}}"></or-mwc-input>
5
+ @or-mwc-input-changed="${l}"></or-mwc-input>
6
6
  <or-mwc-dialog id="webhook-modal" heading="${this.title}" .actions="${r}"></or-mwc-dialog>
7
7
  <slot class="webhook-form-slot"></slot>
8
8
  `}};__decorate([i({type:Object})],OrRuleWebhookModal.prototype,"action",void 0),__decorate([i({type:String})],OrRuleWebhookModal.prototype,"title",void 0),OrRuleWebhookModal=__decorate([l("or-rule-webhook-modal")],OrRuleWebhookModal);export{OrRuleWebhookModal};
@@ -35,7 +35,7 @@ var __decorate=this&&this.__decorate||function(t,e,i,o){var r,n=arguments.length
35
35
  <input hidden class="location-lat" required placeholder=" " type="text" .value="${t&&t.coordinates?t.coordinates[1]:null}" />
36
36
  </div>
37
37
  </div>
38
- `)}render(){var e,o;let r=[{actionName:"close",default:!0,content:i`<or-mwc-input class="button" .type="${t.BUTTON}" label="close"></or-mwc-input>`,action:()=>{}}];return this.renderDialogHTML(null==(e=this.condition.sun)?void 0:e.location),i`
38
+ `)}render(){var e,o;let r=[{actionName:"close",default:!0,content:i`<or-mwc-input class="button" .type="${t.BUTTON}" label="close"></or-mwc-input>`,action:()=>{}}],n=()=>{var t;let e=this.shadowRoot.getElementById("map-modal");e&&(e.dismissAction=null,e.open(),this.renderDialogHTML(null==(t=this.condition.sun)?void 0:t.location))};return this.renderDialogHTML(null==(e=this.condition.sun)?void 0:e.location),i`
39
39
  <div class="trigger-group">
40
40
  <or-mwc-input class="min-width" type="${t.SELECT}" .options="${this.triggerOptions.map(t=>t.value)}" .value="${this.selectedTrigger.value}" label="${h.t("triggerType")}"
41
41
  @or-mwc-input-changed="${t=>{this.setTrigger(this.triggerOptions.find(e=>e.value==t.detail.value))}}">
@@ -49,7 +49,7 @@ var __decorate=this&&this.__decorate||function(t,e,i,o){var r,n=arguments.length
49
49
  <or-mwc-input class="min-width width" type="${t.NUMBER}" .value="${null==(o=this.condition.sun)?void 0:o.offsetMins}" label="${h.t("offsetInMinutes")}"
50
50
  @or-mwc-input-changed="${t=>{this.setOffset(t.detail.value)}}">
51
51
  </or-mwc-input>
52
- <or-mwc-input type="${t.BUTTON}" class="min-width" @or-mwc-input-changed="${()=>{var t;let e=this.shadowRoot.getElementById("map-modal");e&&(e.dismissAction=null,e.open(),this.renderDialogHTML(null==(t=this.condition.sun)?void 0:t.location))}}" label="location"></or-mwc-input>
52
+ <or-mwc-input type="${t.BUTTON}" class="min-width" @or-mwc-input-changed="${n}" label="location"></or-mwc-input>
53
53
  <or-mwc-dialog id="map-modal" heading="${h.t("pickLocation")}" .actions="${r}"></or-mwc-dialog>
54
54
  `}
55
55
  `:void 0}
@@ -1,4 +1,4 @@
1
- var OrRuleTree_1,__decorate=this&&this.__decorate||function(e,t,r,l){var s,i=arguments.length,o=i<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,r):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,l);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(o=(i<3?s(o):i>3?s(t,r,o):s(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o},__awaiter=this&&this.__awaiter||function(e,t,r,l){return new(r||(r=Promise))(function(s,i){function o(e){try{a(l.next(e))}catch(e){i(e)}}function n(e){try{a(l.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):((t=e.value)instanceof r?t:new r(function(e){e(t)})).then(o,n)}a((l=l.apply(e,t||[])).next())})};import{OrTreeMenu as e,TreeMenuSelection as t}from"@openremote/or-tree-menu";import{customElement as r,property as l,state as s}from"lit/decorators.js";import{css as i,html as o}from"lit";import n,{Util as a}from"@openremote/core";import{i18next as u}from"@openremote/or-translate";import{getContentWithMenuTemplate as d}from"@openremote/or-mwc-components/or-mwc-menu";import{InputType as c}from"@openremote/or-mwc-components/or-mwc-input";import{showOkCancelDialog as p}from"@openremote/or-mwc-components/or-mwc-dialog";import{OrRules as h,OrRulesAddEvent as g,OrRulesRequestAddEvent as m,OrRulesRequestDeleteEvent as R,OrRulesRequestGroupEvent as f,OrRulesRequestSelectionEvent as _,OrRulesSelectionEvent as v,RuleViewInfoMap as O}from"./index";import{ifDefined as T}from"lit/directives/if-defined.js";import{when as y}from"lit/directives/when.js";let styling=i`
1
+ var OrRuleTree_1,__decorate=this&&this.__decorate||function(e,t,l,r){var s,i=arguments.length,o=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,l):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,l,r);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(o=(i<3?s(o):i>3?s(t,l,o):s(t,l))||o);return i>3&&o&&Object.defineProperty(t,l,o),o},__awaiter=this&&this.__awaiter||function(e,t,l,r){return new(l||(l=Promise))(function(s,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function n(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):((t=e.value)instanceof l?t:new l(function(e){e(t)})).then(o,n)}a((r=r.apply(e,t||[])).next())})};import{OrTreeMenu as e,TreeMenuSelection as t}from"@openremote/or-tree-menu";import{customElement as l,property as r,state as s}from"lit/decorators.js";import{css as i,html as o}from"lit";import n,{Util as a}from"@openremote/core";import{i18next as u}from"@openremote/or-translate";import{getContentWithMenuTemplate as d}from"@openremote/or-mwc-components/or-mwc-menu";import{InputType as c}from"@openremote/or-mwc-components/or-mwc-input";import{showOkCancelDialog as p}from"@openremote/or-mwc-components/or-mwc-dialog";import{OrRules as h,OrRulesAddEvent as g,OrRulesRequestAddEvent as m,OrRulesRequestDeleteEvent as R,OrRulesRequestGroupEvent as f,OrRulesRequestSelectionEvent as _,OrRulesSelectionEvent as v,RuleViewInfoMap as O}from"./index";import{ifDefined as T}from"lit/directives/if-defined.js";import{when as y}from"lit/directives/when.js";let styling=i`
2
2
  .iconfill-gray {
3
3
  --or-icon-fill: var(--internal-or-rules-list-icon-color-ok);
4
4
  }
@@ -17,16 +17,16 @@ var OrRuleTree_1,__decorate=this&&this.__decorate||function(e,t,r,l){var s,i=arg
17
17
  color: var(--or-app-color7, white);
18
18
  --or-icon-fill: var(--or-app-color7, white);
19
19
  }
20
- `;export var RuleTreeSorting;!function(e){e.NAME="name",e.CREATED_ON="createdOn",e.LANGUAGE="language",e.STATUS="status"}(RuleTreeSorting||(RuleTreeSorting={}));let OrRuleTree=OrRuleTree_1=class extends e{constructor(){super(...arguments),this.global=!1,this.readonly=!1,this.nodes=[],this.draggable=!0,this.selection=t.MULTI,this.sortOptions=[RuleTreeSorting.NAME,RuleTreeSorting.CREATED_ON,RuleTreeSorting.STATUS,RuleTreeSorting.LANGUAGE],this.sortBy=RuleTreeSorting.NAME,this.groupFirst=!0,this.menuTitle="rules",this._loadingPromises=[],this._selectedTypes=new Set,this._cachedEmptyGroupNodes=[]}static get styles(){return[...super.styles,styling]}willUpdate(e){var r,l,s;if(e.has("rules"))if(this.rules){let e=this._getRuleNodes(this.rules),t=new Set(e.map(e=>e.id)),r=this._cachedEmptyGroupNodes.filter(e=>!t.has(e.id));this.nodes=[...e,...r],this._cachedEmptyGroupNodes=r}else this._loadRulesets(this.global).then(e=>this.rules=e);return e.has("nodes")&&(this._cachedEmptyGroupNodes=(null==(r=this.nodes)?void 0:r.filter(e=>!!e.children&&0===e.children.length))||[]),e.has("config")&&this.config&&(null==(l=this.config.controls)?void 0:l.multiSelect)!==void 0&&(this.selection=(null==(s=this.config.controls)?void 0:s.multiSelect)?t.MULTI:t.LEAF),super.willUpdate(e)}firstUpdated(e){this.rules||this._loadRulesets(this.global).then(e=>{this.rules=e})}_getSingleNodeSlotTemplate(e){var t,r,l;return o`
20
+ `;export var RuleTreeSorting;!function(e){e.NAME="name",e.CREATED_ON="createdOn",e.LANGUAGE="language",e.STATUS="status"}(RuleTreeSorting||(RuleTreeSorting={}));let OrRuleTree=OrRuleTree_1=class extends e{constructor(){super(...arguments),this.global=!1,this.readonly=!1,this.nodes=[],this.draggable=!0,this.selection=t.MULTI,this.sortOptions=[RuleTreeSorting.NAME,RuleTreeSorting.CREATED_ON,RuleTreeSorting.STATUS,RuleTreeSorting.LANGUAGE],this.sortBy=RuleTreeSorting.NAME,this.groupFirst=!0,this.menuTitle="rules",this._loadingPromises=[],this._selectedTypes=new Set,this._cachedEmptyGroupNodes=[]}static get styles(){return[...super.styles,styling]}willUpdate(e){var l,r,s;if(e.has("rules"))if(this.rules){let e=this._getRuleNodes(this.rules),t=new Set(e.map(e=>e.id)),l=this._cachedEmptyGroupNodes.filter(e=>!t.has(e.id));this.nodes=[...e,...l],this._cachedEmptyGroupNodes=l}else this._loadRulesets(this.global).then(e=>this.rules=e);return e.has("nodes")&&(this._cachedEmptyGroupNodes=(null==(l=this.nodes)?void 0:l.filter(e=>!!e.children&&0===e.children.length))||[]),e.has("config")&&this.config&&(null==(r=this.config.controls)?void 0:r.multiSelect)!==void 0&&(this.selection=(null==(s=this.config.controls)?void 0:s.multiSelect)?t.MULTI:t.LEAF),super.willUpdate(e)}firstUpdated(e){this.rules||this._loadRulesets(this.global).then(e=>{this.rules=e})}_getSingleNodeSlotTemplate(e){var t,l,r;return o`
21
21
  <or-icon slot="prefix" icon="${this._getRulesetLangIcon(null==(t=e.ruleset)?void 0:t.lang)}"></or-icon>
22
22
  <span>${e.label}</span>
23
- <or-icon slot="suffix" icon=${T(this._getRulesetStatusIcon(null==(r=e.ruleset)?void 0:r.status))}
24
- class=${this._getRulesetStatusColorClass(null==(l=e.ruleset)?void 0:l.status)}
23
+ <or-icon slot="suffix" icon=${T(this._getRulesetStatusIcon(null==(l=e.ruleset)?void 0:l.status))}
24
+ class=${this._getRulesetStatusColorClass(null==(r=e.ruleset)?void 0:r.status)}
25
25
  ></or-icon>
26
- `}_getGroupNodeSlotTemplate(e){var t;let r,l=null==(t=e.children)?void 0:t.map(e=>{var t;return null==(t=e.ruleset)?void 0:t.status}).filter(e=>e);if(null==l?void 0:l.find(e=>["LOOP_ERROR","EXECUTION_ERROR","COMPILATION_ERROR"].includes(e))){let e=["LOOP_ERROR","EXECUTION_ERROR","COMPILATION_ERROR"].map(e=>[e,l.filter(t=>t===e).length]).reduce((e,t)=>t[1]>e[1]?t:e)[0];r=this._getRulesetStatusIcon(e)}return o`
26
+ `}_getGroupNodeSlotTemplate(e){var t;let l,r=null==(t=e.children)?void 0:t.map(e=>{var t;return null==(t=e.ruleset)?void 0:t.status}).filter(e=>e);if(null==r?void 0:r.find(e=>["LOOP_ERROR","EXECUTION_ERROR","COMPILATION_ERROR"].includes(e))){let e=["LOOP_ERROR","EXECUTION_ERROR","COMPILATION_ERROR"].map(e=>[e,r.filter(t=>t===e).length]).reduce((e,t)=>t[1]>e[1]?t:e)[0];l=this._getRulesetStatusIcon(e)}return o`
27
27
  <or-icon slot="prefix" icon="folder"></or-icon>
28
28
  <span>${e.label}</span>
29
- <or-icon slot="suffix" icon=${T(r)} class="iconfill-red"></or-icon>
29
+ <or-icon slot="suffix" icon=${T(l)} class="iconfill-red"></or-icon>
30
30
  `}_getHeaderTemplate(){return o`
31
31
  ${y(n.isSuperUser(),()=>o`
32
32
  <div id="rules-tree-global-header">
@@ -53,5 +53,5 @@ var OrRuleTree_1,__decorate=this&&this.__decorate||function(e,t,r,l){var s,i=arg
53
53
  ${this._getSortActionTemplate(this.sortBy,this.sortOptions)}
54
54
  </div>
55
55
  </div>
56
- `}_onGlobalSwitch(e){this.global=e.detail.value,this.refresh()}_onCopyClicked(e){let t=this._findSelectedTreeNodes();if(1!==t.length)return;let r=t[0],l=JSON.parse(JSON.stringify(r.ruleset));delete l.lastModified,delete l.createdOn,delete l.status,delete l.error,delete l.id,l.name=l.name+" copy",(!this.config||!this.config.rulesetCopyHandler||this.config.rulesetCopyHandler(l))&&a.dispatchCancellableEvent(this,new m({ruleset:l,sourceRuleset:r.ruleset})).then(e=>{e.allow&&this.dispatchEvent(new g(e.detail))})}_onDeleteClicked(e){let t=this._findSelectedTreeNodes();if(t.length>0){let e=t.map(e=>e.ruleset).filter(e=>e),r=t.filter(e=>e.children),l=r.map(e=>e.label),s=r.flatMap(e=>e.children).flatMap(e=>e.ruleset?[e.ruleset]:[]);e.push(...s);let i=e.map(e=>({ruleset:e,selected:!0}));if(0===i.length&&r.length>0)return void p(u.t("deleteRulesetGroups"),u.t("deleteRulesetGroupsConfirm",{groupNames:l}),u.t("delete")).then(e=>{e&&(this.deselectAllNodes(),this.nodes=this.nodes.filter(e=>!l.includes(e.label)))});a.dispatchCancellableEvent(this,new R(i)).then(t=>{if(t.allow){let t=e.map(e=>e.name);p(u.t("deleteRulesets"),u.t("deleteRulesetsConfirm",{ruleNames:t}),u.t("delete")).then(t=>{t&&(this.deselectAllNodes(),this._deleteRulesets(e).catch(e=>console.error(e)).finally(()=>{this.nodes=this.nodes.filter(e=>!l.includes(e.label)),this.refresh()}))})}})}}_deleteRulesets(e){return __awaiter(this,void 0,void 0,function*(){let t=[];return e.forEach(e=>{switch(e.type){case"asset":t.push(n.rest.api.RulesResource.deleteAssetRuleset(e.id));break;case"realm":t.push(n.rest.api.RulesResource.deleteRealmRuleset(e.id));break;case"global":t.push(n.rest.api.RulesResource.deleteGlobalRuleset(e.id))}}),Promise.all(t)})}selectRuleset(e,t=!1){let r=this.nodes.find(t=>t.ruleset===e);if(r){let e=this._getUiNodeFromTree(r);e&&this._selectNode(e,!t)}else console.warn("Could not select ruleset; it was not found.")}_dispatchSelectEvent(e){let t=this._lastSelectedNode?this._getTreeNodeFromTree(this._lastSelectedNode):void 0,r=!e||e.length>1?void 0:e[0],l=e=>!!(null==e?void 0:e.children),s=t?l(t)?[{type:"group",groupId:t.id}]:[{type:"rule",ruleset:t.ruleset,selected:!1}]:[],i=r?l(r)?[{type:"group",groupId:r.id}]:[{type:"rule",ruleset:r.ruleset,selected:!0}]:[];if(!this.dispatchEvent(new _({oldNodes:s,newNodes:i})))return!1;this.dispatchEvent(new v({oldNodes:s,newNodes:i}));let o=new Set;return(null==e?void 0:e.find(e=>l(e)))&&o.add("group"),(null==e?void 0:e.find(e=>!l(e)))&&o.add("ruleset"),this._selectedTypes=o,super._dispatchSelectEvent(e)}deselectAllNodes(){super.deselectAllNodes(),this._selectedTypes=new Set}_getRuleNodes(e){let t=Array.from(new Set(e.map(e=>{var t;return null==(t=e.meta)?void 0:t.groupId}).filter(e=>e))).map(t=>({id:t,label:t,children:e.filter(e=>{var r;return(null==(r=e.meta)?void 0:r.groupId)===t}).map(e=>{var t;return{id:null==(t=e.id)?void 0:t.toString(),ruleset:e,label:e.name}})}));return[...e.filter(e=>{var t;return!(null==(t=e.meta)?void 0:t.groupId)}).map(e=>{var t;return{id:null==(t=e.id)?void 0:t.toString(),ruleset:e,label:e.name}}),...t]}_loadRulesets(){return __awaiter(this,arguments,void 0,function*(e=!1,t=n.displayRealm){if(e){let e=n.rest.api.RulesResource.getGlobalRulesets({fullyPopulate:!0});return(yield e).data}{let e=n.rest.api.RulesResource.getRealmRulesets(t,{fullyPopulate:!0});return(yield e).data}})}refresh(){return __awaiter(this,void 0,void 0,function*(){this._cachedEmptyGroupNodes=this.nodes.filter(e=>!!e.children&&0===e.children.length),yield this.getUpdateComplete();let e=this._loadRulesets(this.global);return e.then(e=>{this.rules=e}),e})}_getAddActionTemplate(){let e=(this._getAllowedLanguages()||[]).map(e=>({value:e,text:u.t("rulesLanguages."+e)}));return e.push(null),e.push({value:"group",text:u.t("group")}),d(o`
57
- <or-mwc-input type=${c.BUTTON} icon="plus" title="${u.t("addRule")}"></or-mwc-input>`,e,void 0,e=>{var t;"group"===(t=String(e))?this._onGroupAddClick():this._onRulesetAddClick(t)})}_onRulesetAddClick(e,t=this.global){let r=t?"global":"realm",l=n.isSuperUser()?n.displayRealm:n.config.realm,s={type:r,name:h.DEFAULT_RULESET_NAME,lang:e,realm:l,rules:void 0},i=this._findSelectedTreeNodes();if(1===i.length&&i[0].children){let e=i[0].id;e&&(s.meta=Object.assign(Object.assign({},s.meta||{}),{groupId:e}))}(!this.config||!this.config.rulesetAddHandler||this.config.rulesetAddHandler(s))&&(this.config&&this.config.rulesetTemplates&&this.config.rulesetTemplates[e]?s.rules=this.config.rulesetTemplates[e]:s.rules=O[e].viewRulesetTemplate,"realm"===r&&(s.realm=l),a.dispatchCancellableEvent(this,new m({ruleset:s,isCopy:!1})).then(e=>{e.allow&&this.dispatchEvent(new g(e.detail))}))}_onGroupAddClick(){this.deselectAllNodes();let e=u.t("ruleGroupNameDefault")||"Group name";this.dispatchEvent(new f(e))}_getSortFunction(e){switch(e){case RuleTreeSorting.LANGUAGE:return a.sortByString(e=>{var t;return(null==(t=e.ruleset)?void 0:t.lang)||e.label});case RuleTreeSorting.CREATED_ON:return a.sortByNumber(e=>{var t;return(null==(t=e.ruleset)?void 0:t.createdOn)||0});case RuleTreeSorting.STATUS:return a.sortByString(e=>{var t;return(null==(t=e.ruleset)?void 0:t.status)||e.label});default:return super._getSortFunction(e)}}_getAllowedLanguages(e=this.config,t=this.global){var r;let l=(null==(r=null==e?void 0:e.controls)?void 0:r.allowedLanguages)?[...e.controls.allowedLanguages]:OrRuleTree_1.DEFAULT_ALLOWED_LANGUAGES,s=l.indexOf("GROOVY"),i=l.indexOf("FLOW");return n.isSuperUser()?s<0&&l.push("GROOVY"):s>0&&l.splice(s,1),t&&i>0&&l.splice(i,1),l}_getRulesetLangIcon(e){switch(e){case"JSON":return"ray-start-arrow";case"FLOW":return"transit-connection-variant";case"GROOVY":return"alpha-g-box-outline";case"JAVASCRIPT":return"language-javascript";default:return"mdi-state-machine"}}_getRulesetStatusIcon(e){switch(e){case"DEPLOYED":return;case"READY":return"check";case"COMPILATION_ERROR":case"LOOP_ERROR":case"EXECUTION_ERROR":return"alert-octagon";case"DISABLED":return"minus-circle";case"PAUSED":return"calendar-arrow-right";case"EXPIRED":return"calendar-remove";case"REMOVED":return"close";default:return"stop"}}_getRulesetStatusColorClass(e){switch(e){case"DEPLOYED":case"READY":case"DISABLED":case"PAUSED":case"EXPIRED":case"REMOVED":default:return"iconfill-gray";case"COMPILATION_ERROR":case"LOOP_ERROR":case"EXECUTION_ERROR":return"iconfill-red"}}};OrRuleTree.DEFAULT_ALLOWED_LANGUAGES=["JSON","GROOVY","JAVASCRIPT","FLOW"],__decorate([l({type:Array})],OrRuleTree.prototype,"rules",void 0),__decorate([l({type:Object})],OrRuleTree.prototype,"config",void 0),__decorate([l({type:Boolean})],OrRuleTree.prototype,"global",void 0),__decorate([l({type:Boolean})],OrRuleTree.prototype,"readonly",void 0),__decorate([s()],OrRuleTree.prototype,"_loadingPromises",void 0),__decorate([s()],OrRuleTree.prototype,"_selectedTypes",void 0),OrRuleTree=OrRuleTree_1=__decorate([r("or-rule-tree")],OrRuleTree);export{OrRuleTree};
56
+ `}_onGlobalSwitch(e){this.global=e.detail.value,this.refresh()}_onCopyClicked(e){let t=this._findSelectedTreeNodes();if(1!==t.length)return;let l=t[0],r=JSON.parse(JSON.stringify(l.ruleset));delete r.lastModified,delete r.createdOn,delete r.status,delete r.error,delete r.id,r.name=r.name+" copy",(!this.config||!this.config.rulesetCopyHandler||this.config.rulesetCopyHandler(r))&&a.dispatchCancellableEvent(this,new m({ruleset:r,sourceRuleset:l.ruleset})).then(e=>{e.allow&&this.dispatchEvent(new g(e.detail))})}_onDeleteClicked(e){let t=this._findSelectedTreeNodes();if(t.length>0){let e=t.map(e=>e.ruleset).filter(e=>e),l=t.filter(e=>e.children),r=l.map(e=>e.label),s=l.flatMap(e=>e.children).flatMap(e=>e.ruleset?[e.ruleset]:[]);e.push(...s);let i=e.map(e=>({ruleset:e,selected:!0}));if(0===i.length&&l.length>0)return void p(u.t("deleteRulesetGroups"),u.t("deleteRulesetGroupsConfirm",{groupNames:r}),u.t("delete")).then(e=>{e&&(this.deselectAllNodes(),this.nodes=this.nodes.filter(e=>!r.includes(e.label)))});a.dispatchCancellableEvent(this,new R(i)).then(t=>{if(t.allow){let t=e.map(e=>e.name);p(u.t("deleteRulesets"),u.t("deleteRulesetsConfirm",{ruleNames:t}),u.t("delete")).then(t=>{t&&(this.deselectAllNodes(),this._deleteRulesets(e).catch(e=>console.error(e)).finally(()=>{this.nodes=this.nodes.filter(e=>!r.includes(e.label)),this.refresh()}))})}})}}_deleteRulesets(e){return __awaiter(this,void 0,void 0,function*(){let t=[];return e.forEach(e=>{switch(e.type){case"asset":t.push(n.rest.api.RulesResource.deleteAssetRuleset(e.id));break;case"realm":t.push(n.rest.api.RulesResource.deleteRealmRuleset(e.id));break;case"global":t.push(n.rest.api.RulesResource.deleteGlobalRuleset(e.id))}}),Promise.all(t)})}selectRuleset(e,t=!1){let l=this.nodes.find(t=>t.ruleset===e);if(l){let e=this._getUiNodeFromTree(l);e&&this._selectNode(e,!t)}else console.warn("Could not select ruleset; it was not found.")}_dispatchSelectEvent(e){let t=this._lastSelectedNode?this._getTreeNodeFromTree(this._lastSelectedNode):void 0,l=!e||e.length>1?void 0:e[0],r=e=>!!(null==e?void 0:e.children),s=t?r(t)?[{type:"group",groupId:t.id}]:[{type:"rule",ruleset:t.ruleset,selected:!1}]:[],i=l?r(l)?[{type:"group",groupId:l.id}]:[{type:"rule",ruleset:l.ruleset,selected:!0}]:[];if(!this.dispatchEvent(new _({oldNodes:s,newNodes:i})))return!1;this.dispatchEvent(new v({oldNodes:s,newNodes:i}));let o=new Set;return(null==e?void 0:e.find(e=>r(e)))&&o.add("group"),(null==e?void 0:e.find(e=>!r(e)))&&o.add("ruleset"),this._selectedTypes=o,super._dispatchSelectEvent(e)}deselectAllNodes(){super.deselectAllNodes(),this._selectedTypes=new Set}_getRuleNodes(e){let t=Array.from(new Set(e.map(e=>{var t;return null==(t=e.meta)?void 0:t.groupId}).filter(e=>e))).map(t=>({id:t,label:t,children:e.filter(e=>{var l;return(null==(l=e.meta)?void 0:l.groupId)===t}).map(e=>{var t;return{id:null==(t=e.id)?void 0:t.toString(),ruleset:e,label:e.name}})}));return[...e.filter(e=>{var t;return!(null==(t=e.meta)?void 0:t.groupId)}).map(e=>{var t;return{id:null==(t=e.id)?void 0:t.toString(),ruleset:e,label:e.name}}),...t]}_loadRulesets(){return __awaiter(this,arguments,void 0,function*(e=!1,t=n.displayRealm){if(e){let e=n.rest.api.RulesResource.getGlobalRulesets({fullyPopulate:!0});return(yield e).data}{let e=n.rest.api.RulesResource.getRealmRulesets(t,{fullyPopulate:!0});return(yield e).data}})}refresh(){return __awaiter(this,void 0,void 0,function*(){this._cachedEmptyGroupNodes=this.nodes.filter(e=>!!e.children&&0===e.children.length),yield this.getUpdateComplete();let e=this._loadRulesets(this.global);return e.then(e=>{this.rules=e}),e})}_getAddActionTemplate(){let e=(this._getAllowedLanguages()||[]).map(e=>({value:e,text:u.t("rulesLanguages."+e)}));e.push(null),e.push({value:"group",text:u.t("group")});let t=e=>{"group"===e?this._onGroupAddClick():this._onRulesetAddClick(e)};return d(o`
57
+ <or-mwc-input type=${c.BUTTON} icon="plus" title="${u.t("addRule")}"></or-mwc-input>`,e,void 0,e=>t(String(e)))}_onRulesetAddClick(e,t=this.global){let l=t?"global":"realm",r=n.isSuperUser()?n.displayRealm:n.config.realm,s={type:l,name:h.DEFAULT_RULESET_NAME,lang:e,realm:r,rules:void 0},i=this._findSelectedTreeNodes();if(1===i.length&&i[0].children){let e=i[0].id;e&&(s.meta=Object.assign(Object.assign({},s.meta||{}),{groupId:e}))}(!this.config||!this.config.rulesetAddHandler||this.config.rulesetAddHandler(s))&&(this.config&&this.config.rulesetTemplates&&this.config.rulesetTemplates[e]?s.rules=this.config.rulesetTemplates[e]:s.rules=O[e].viewRulesetTemplate,"realm"===l&&(s.realm=r),a.dispatchCancellableEvent(this,new m({ruleset:s,isCopy:!1})).then(e=>{e.allow&&this.dispatchEvent(new g(e.detail))}))}_onGroupAddClick(){this.deselectAllNodes();let e=u.t("ruleGroupNameDefault")||"Group name";this.dispatchEvent(new f(e))}_getSortFunction(e){switch(e){case RuleTreeSorting.LANGUAGE:return a.sortByString(e=>{var t;return(null==(t=e.ruleset)?void 0:t.lang)||e.label});case RuleTreeSorting.CREATED_ON:return a.sortByNumber(e=>{var t;return(null==(t=e.ruleset)?void 0:t.createdOn)||0});case RuleTreeSorting.STATUS:return a.sortByString(e=>{var t;return(null==(t=e.ruleset)?void 0:t.status)||e.label});default:return super._getSortFunction(e)}}_getAllowedLanguages(e=this.config,t=this.global){var l;let r=(null==(l=null==e?void 0:e.controls)?void 0:l.allowedLanguages)?[...e.controls.allowedLanguages]:OrRuleTree_1.DEFAULT_ALLOWED_LANGUAGES,s=r.indexOf("GROOVY"),i=r.indexOf("FLOW");return n.isSuperUser()?s<0&&r.push("GROOVY"):s>0&&r.splice(s,1),t&&i>0&&r.splice(i,1),r}_getRulesetLangIcon(e){switch(e){case"JSON":return"ray-start-arrow";case"FLOW":return"transit-connection-variant";case"GROOVY":return"alpha-g-box-outline";case"JAVASCRIPT":return"language-javascript";default:return"mdi-state-machine"}}_getRulesetStatusIcon(e){switch(e){case"DEPLOYED":return;case"READY":return"check";case"COMPILATION_ERROR":case"LOOP_ERROR":case"EXECUTION_ERROR":return"alert-octagon";case"DISABLED":return"minus-circle";case"PAUSED":return"calendar-arrow-right";case"EXPIRED":return"calendar-remove";case"REMOVED":return"close";default:return"stop"}}_getRulesetStatusColorClass(e){switch(e){case"DEPLOYED":case"READY":case"DISABLED":case"PAUSED":case"EXPIRED":case"REMOVED":default:return"iconfill-gray";case"COMPILATION_ERROR":case"LOOP_ERROR":case"EXECUTION_ERROR":return"iconfill-red"}}};OrRuleTree.DEFAULT_ALLOWED_LANGUAGES=["JSON","GROOVY","JAVASCRIPT","FLOW"],__decorate([r({type:Array})],OrRuleTree.prototype,"rules",void 0),__decorate([r({type:Object})],OrRuleTree.prototype,"config",void 0),__decorate([r({type:Boolean})],OrRuleTree.prototype,"global",void 0),__decorate([r({type:Boolean})],OrRuleTree.prototype,"readonly",void 0),__decorate([s()],OrRuleTree.prototype,"_loadingPromises",void 0),__decorate([s()],OrRuleTree.prototype,"_selectedTypes",void 0),OrRuleTree=OrRuleTree_1=__decorate([l("or-rule-tree")],OrRuleTree);export{OrRuleTree};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openremote/or-rules",
3
- "version": "1.8.0-snapshot.20250818141417",
3
+ "version": "1.8.0-snapshot.20250818162953",
4
4
  "description": "OpenRemote rules related UI components",
5
5
  "customElements": "custom-elements.json",
6
6
  "main": "dist/umd/index.bundle.js",
@@ -18,15 +18,15 @@
18
18
  "author": "OpenRemote",
19
19
  "license": "AGPL-3.0-or-later",
20
20
  "dependencies": {
21
- "@openremote/core": "1.8.0-snapshot.20250818141417",
22
- "@openremote/model": "1.8.0-snapshot.20250818141417",
23
- "@openremote/or-attribute-input": "1.8.0-snapshot.20250818141417",
24
- "@openremote/or-components": "1.8.0-snapshot.20250818141417",
25
- "@openremote/or-icon": "1.8.0-snapshot.20250818141417",
26
- "@openremote/or-mwc-components": "1.8.0-snapshot.20250818141417",
27
- "@openremote/or-translate": "1.8.0-snapshot.20250818141417",
28
- "@openremote/or-tree-menu": "1.8.0-snapshot.20250818141417",
29
- "@openremote/rest": "1.8.0-snapshot.20250818141417",
21
+ "@openremote/core": "1.8.0-snapshot.20250818162953",
22
+ "@openremote/model": "1.8.0-snapshot.20250818162953",
23
+ "@openremote/or-attribute-input": "1.8.0-snapshot.20250818162953",
24
+ "@openremote/or-components": "1.8.0-snapshot.20250818162953",
25
+ "@openremote/or-icon": "1.8.0-snapshot.20250818162953",
26
+ "@openremote/or-mwc-components": "1.8.0-snapshot.20250818162953",
27
+ "@openremote/or-translate": "1.8.0-snapshot.20250818162953",
28
+ "@openremote/or-tree-menu": "1.8.0-snapshot.20250818162953",
29
+ "@openremote/rest": "1.8.0-snapshot.20250818162953",
30
30
  "ace-builds": "^1.41.0",
31
31
  "iso-639-1": "^3.1.3",
32
32
  "linqts": "^1.12.6",
@@ -37,7 +37,7 @@
37
37
  "shortid": "^2.2.15"
38
38
  },
39
39
  "devDependencies": {
40
- "@openremote/util": "1.8.0-snapshot.20250818141417",
40
+ "@openremote/util": "1.8.0-snapshot.20250818162953",
41
41
  "@types/shortid": "^0.0.29"
42
42
  },
43
43
  "publishConfig": {