@openremote/or-dashboard-builder 1.2.1 → 1.2.2

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/dist/umd/index.js CHANGED
@@ -368,7 +368,7 @@
368
368
  ${this.icon?$`<or-icon class="mdc-icon-button__icon" aria-hidden="true" icon="${this.icon}"></or-icon>`:""}
369
369
  ${this.iconOn?$`<or-icon class="mdc-icon-button__icon mdc-icon-button__icon--on" aria-hidden="true" icon="${this.iconOn}"></or-icon>`:""}
370
370
  </button>
371
- `;case lr.BUTTON:case lr.BUTTON_MOMENTARY:{const t=t=>{this.disabled&&t.stopPropagation(),n&&this.dispatchEvent(new sr(!0,null))},e=t=>{this.disabled&&t.stopPropagation(),n&&this.dispatchEvent(new sr(!1,!0))},i=t=>{this.disabled&&t.stopPropagation(),n||this.dispatchEvent(new sr(!0,null))},n=this.type===lr.BUTTON_MOMENTARY,r=!this.action&&!this.label;let a={"mdc-icon-button":r,"mdc-fab":!r&&this.action,"mdc-fab--extended":!r&&this.action&&!!this.label,"mdc-fab--mini":!r&&this.action&&(this.compact||this.comfortable),"mdc-button":!r&&!this.action,"mdc-button--raised":!r&&!this.action&&this.raised,"mdc-button--unelevated":!r&&!this.action&&this.unElevated,"mdc-button--outlined":!r&&!this.action&&this.outlined,"mdc-button--rounded":!r&&!this.action&&this.rounded,"mdc-button--fullwidth":this.fullWidth};return $`
371
+ `;case lr.BUTTON:case lr.BUTTON_MOMENTARY:{const t=t=>{this.disabled&&t.stopPropagation(),n&&this.dispatchEvent(new sr(!0,null))},e=t=>{this.disabled&&t.stopPropagation(),n&&this.dispatchEvent(new sr(!1,!0))},i=t=>{this.disabled&&t.stopPropagation(),n||this.dispatchEvent(new sr(!0,null))},n=this.type===lr.BUTTON_MOMENTARY,r=!this.action&&!this.label;!r||this.iconTrailing||this.icon||(this.icon="circle");const a={"mdc-icon-button":r,"mdc-fab":!r&&this.action,"mdc-fab--extended":!r&&this.action&&!!this.label,"mdc-fab--mini":!r&&this.action&&(this.compact||this.comfortable),"mdc-button":!r&&!this.action,"mdc-button--raised":!r&&!this.action&&this.raised,"mdc-button--unelevated":!r&&!this.action&&this.unElevated,"mdc-button--outlined":!r&&!this.action&&(this.outlined||n),"mdc-button--rounded":!r&&!this.action&&this.rounded,"mdc-button--fullwidth":this.fullWidth};return $`
372
372
  <button id="component" class="${Vt(a)}"
373
373
  ?readonly="${this.readonly}"
374
374
  ?disabled="${this.disabled}"
@@ -714,7 +714,7 @@
714
714
  <or-mwc-input type="button" class="mdc-button mdc-snackbar__action" label="${this.buttonText}">
715
715
  </or-mwc-input>
716
716
  </div>
717
- `:$``};
717
+ `:$``}
718
718
  </div>
719
719
  </div>
720
720
  `}updated(t){super.updated(t),t.has("_open")&&this._open&&this.open()}onClose(t){this.buttonAction&&this.buttonAction(),this.dispatchChangedEvent({opened:!1,closeReason:t})}onOpen(){this.dispatchChangedEvent({opened:!0})}dispatchChangedEvent(t){this.dispatchEvent(new la(t))}};oa([ft({type:String,attribute:!1})],ca.prototype,"text",void 0),oa([ft({type:String})],ca.prototype,"buttonText",void 0),oa([ft({type:Object,attribute:!1})],ca.prototype,"buttonAction",void 0),oa([ft({type:Number})],ca.prototype,"timeout",void 0),oa([ft({type:Boolean})],ca.prototype,"_open",void 0),oa([yt("#mdc-snackbar")],ca.prototype,"_mdcElem",void 0),ca=oa([ht("or-mwc-snackbar")],ca);var ua,ha=p(8880),ma=function(t,e,i,n){return new(i||(i=Promise))((function(r,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function s(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,s)}l((n=n.apply(t,e||[])).next())}))};!function(t){t[t.DESKTOP=0]="DESKTOP",t[t.MOBILE=1]="MOBILE"}(ua||(ua={}));class pa{static create(t,e=ua.DESKTOP,i=An().displayRealm,n=!0){var r;return ma(this,void 0,void 0,(function*(){const a=()=>(Math.random()+1).toString(36).substring(2);return t?(t.id=a(),t.template&&(t.template.id=a(),null===(r=t.template.widgets)||void 0===r||r.forEach((t=>t.id=a())))):t={realm:i,displayName:this.getDefaultDisplayName(e),template:{id:a(),columns:this.getDefaultColumns(e),maxScreenWidth:this.getDefaultMaxScreenWidth(e),refreshInterval:"OFF",screenPresets:this.getDefaultScreenPresets(e)}},n?(yield An().rest.api.DashboardResource.create(t)).data:t}))}static delete(t,e=An().displayRealm){return ma(this,void 0,void 0,(function*(){return(yield An().rest.api.DashboardResource.delete(e,t)).data}))}static getDefaultColumns(t){switch(t){case ua.MOBILE:return 4;case ua.DESKTOP:default:return 12}}static getDefaultDisplayName(t){switch(t){case ua.DESKTOP:return In.i18next.t("dashboard.initialName");case ua.MOBILE:return In.i18next.t("dashboard.initialName")+" ("+In.i18next.t("dashboard.size.mobile")+")"}}static getDefaultScreenPresets(t){return t===ua.MOBILE?[{id:"mobile",displayName:"dashboard.size.mobile",breakpoint:640,scalingPreset:"KEEP_LAYOUT"}]:[{id:"mobile",displayName:"dashboard.size.mobile",breakpoint:640,scalingPreset:"WRAP_TO_SINGLE_COLUMN"}]}static getDefaultMaxScreenWidth(t){switch(t){case ua.DESKTOP:return 4e3;case ua.MOBILE:return 640}}}var fa=p(768),ga=function(t,e,i,n){var r,a=arguments.length,o=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(a<3?r(o):a>3?r(e,i,o):r(e,i))||o);return a>3&&o&&Object.defineProperty(e,i,o),o};const _a=o`
@@ -2532,7 +2532,7 @@
2532
2532
  flex-wrap: wrap;
2533
2533
  position: relative;
2534
2534
  }
2535
- `;let ad=ed=class extends $o{constructor(){super(...arguments),this._loading=!0,this._startedByUser=!1,this._refreshTimer=void 0}static getManifest(){return{displayName:"Gateway",displayIcon:"lan-connect",minColumnWidth:1,minColumnHeight:1,getContentHtml:t=>new ed(t),getSettingsHtml:t=>new td(t),getDefaultConfig:()=>({type:"HTTPS",target:"localhost",targetPort:443})}}refreshContent(t){this.widgetConfig=JSON.parse(JSON.stringify(this.widgetConfig))}static get styles(){return[...super.styles,rd]}disconnectedCallback(){this._activeTunnel&&(this._startedByUser?this._stopTunnel(this._activeTunnel).then((()=>{console.warn("Stopped the active tunnel, as it was created through the widget.")})):console.warn("Keeping the active tunnel open, as it is not started through the widget.")),this._refreshTimer&&clearTimeout(this._refreshTimer),super.disconnectedCallback()}firstUpdated(t){return this.widgetConfig&&setTimeout((()=>{const t=this._getTunnelInfoByConfig(this.widgetConfig);this._getActiveTunnel(t).then((t=>{t&&(console.log("Existing tunnel found!",t),this._setActiveTunnel(t,!0))})).catch((t=>{console.error(t)})).finally((()=>{this._loading=!1}))}),500),super.firstUpdated(t)}render(){var t;const e=(null===(t=this.getEditMode)||void 0===t?void 0:t.call(this))||!this._isConfigComplete(this.widgetConfig);return $`
2535
+ `;let ad=ed=class extends $o{constructor(){super(...arguments),this._loading=!0,this._isReady=!1,this._startedByUser=!1,this._refreshTimer=void 0}static getManifest(){return{displayName:"Gateway",displayIcon:"lan-connect",minColumnWidth:1,minColumnHeight:1,getContentHtml:t=>new ed(t),getSettingsHtml:t=>new td(t),getDefaultConfig:()=>({type:"HTTPS",target:"localhost",targetPort:443})}}refreshContent(t){this.widgetConfig=JSON.parse(JSON.stringify(this.widgetConfig)),this._readyCheck(this.widgetConfig)}static get styles(){return[...super.styles,rd]}disconnectedCallback(){this._activeTunnel&&(this._startedByUser?this._stopTunnel(this._activeTunnel).then((()=>{console.warn("Stopped the active tunnel, as it was created through the widget.")})):console.warn("Keeping the active tunnel open, as it is not started through the widget.")),this._refreshTimer&&clearTimeout(this._refreshTimer),super.disconnectedCallback()}firstUpdated(t){if(this.widgetConfig){const t=this._getTunnelInfoByConfig(this.widgetConfig);this._readyCheck(this.widgetConfig),setTimeout((()=>{this._getActiveTunnel(t).then((t=>{t&&(console.log("Existing tunnel found!",t),this._setActiveTunnel(t,!0))})).catch((t=>{console.error(t)})).finally((()=>{this._loading=!1}))}),500)}return super.firstUpdated(t)}render(){var t;this._getTunnelInfoByConfig(this.widgetConfig);const e=(null===(t=this.getEditMode)||void 0===t?void 0:t.call(this))||!this._isConfigComplete(this.widgetConfig)||!this._isReady;return $`
2536
2536
  <div id="gateway-widget-wrapper">
2537
2537
  <div id="gateway-widget-container">
2538
2538
  ${vt(this._loading,(()=>$`
@@ -2557,13 +2557,13 @@
2557
2557
  <div><or-translate value="gatewayTunnels.closesAt"></or-translate>: ${jo()(null===(t=this._activeTunnel)||void 0===t?void 0:t.autoCloseTime).format("lll")}</div>
2558
2558
  `}))}
2559
2559
  `:$`
2560
- <or-mwc-input .type="${lr.BUTTON}" label="${In.i18next.t("gatewayTunnels.start")}" outlined .disabled="${e}"
2560
+ <or-mwc-input .type="${lr.BUTTON}" label="${e?In.i18next.t("gatewayTunnels.offline"):In.i18next.t("gatewayTunnels.start")}" outlined .disabled="${e}"
2561
2561
  @or-mwc-input-changed="${t=>this._onStartTunnelClick(t)}"
2562
2562
  ></or-mwc-input>
2563
2563
  `}))}
2564
2564
  </div>
2565
2565
  </div>
2566
- `}_onCopyTunnelAddressClick(t){if(this._isConfigComplete(this.widgetConfig)){const t=this._getTunnelInfoByConfig(this.widgetConfig),e=this._getTunnelAddress(t);e?navigator.clipboard.writeText(e).finally((()=>{da(void 0,In.i18next.t("gatewayTunnels.copySuccess"))})):(console.warn("Could not copy tunnel address as it could not be found."),da(void 0,In.i18next.t("errorOccurred")))}else console.warn("Could not copy tunnel address as configuration is not complete."),da(void 0,In.i18next.t("errorOccurred"))}_onStartTunnelClick(t){this._tryStartTunnel(this.widgetConfig)}_onStopTunnelClick(t){this._tryStopTunnel(this.widgetConfig)}_onTunnelNavigateClick(t,e){e?this._navigateToTunnel(e):console.warn("Could not navigate to tunnel as configuration is not complete.")}_setActiveTunnel(t,e=!1){if(this._activeTunnel=t,this._refreshTimer&&clearTimeout(this._refreshTimer),null==t?void 0:t.autoCloseTime){const e=(null==t?void 0:t.autoCloseTime)-Date.now();e>0&&(this._refreshTimer=window.setTimeout((()=>{this._getActiveTunnel(this._getTunnelInfoByConfig(this.widgetConfig)).then((t=>{t?this._setActiveTunnel(t,!0):this._setActiveTunnel(void 0)}))}),e))}t&&!e&&this._navigateToTunnel(t)}_tryStartTunnel(t){if(this._isConfigComplete(t)){const e=this._getTunnelInfoByConfig(t);this._loading=!0,this._getActiveTunnel(e).then((t=>{t?(console.log("Found an active tunnel!",t),this._setActiveTunnel(t),this._loading=!1):this._startTunnel(e).then((t=>{t?(console.log("Started a new tunnel!",t),this._setActiveTunnel(t),this._startedByUser=!0):console.warn("No new tunnel!")})).catch((t=>{console.error(t),da(void 0,In.i18next.t("errorOccurred"))})).finally((()=>{this._loading=!1}))})).catch((t=>{console.error(t),da(void 0,In.i18next.t("errorOccurred")),this._loading=!1}))}}_startTunnel(t){return nd(this,void 0,void 0,(function*(){if(!(t.realm&&t.gatewayId&&t.target&&t.targetPort))throw new Error("Could not start tunnel, as some provided information was not set.");return(yield An().rest.api.GatewayServiceResource.startTunnel(t)).data}))}_getActiveTunnel(t){return nd(this,void 0,void 0,(function*(){if(!(t.realm&&t.gatewayId&&t.target&&t.targetPort))throw new Error("Could not get active tunnel, as some provided information was not set.");const e=yield An().rest.api.GatewayServiceResource.getActiveTunnelInfo(t.realm,t.gatewayId,t.target,t.targetPort);return 204===e.status?void 0:e.data}))}_tryStopTunnel(t){const e=this._getTunnelInfoByConfig(t);this._loading=!0,this._stopTunnel(e).then((()=>{this._setActiveTunnel(void 0),this._startedByUser=!1})).catch((t=>{console.warn(t)})).finally((()=>{this._loading=!1}))}_stopTunnel(t){return nd(this,void 0,void 0,(function*(){return(yield An().rest.api.GatewayServiceResource.stopTunnel(t)).data}))}_navigateToTunnel(t){var e;t.id&&t.realm&&t.gatewayId&&t.target&&t.targetPort||console.warn("Could not navigate to tunnel, as some provided information was not set.");const i=this._getTunnelAddress(t);switch(t.type){case"HTTPS":case"HTTP":null===(e=window.open(i))||void 0===e||e.focus();break;default:console.error("Unknown error when navigating to tunnel.")}}_getTunnelAddress(t){switch(t.type){case"HTTPS":case"HTTP":return"//"+t.id+"."+(t.hostname?t.hostname:window.location.hostname);case"TCP":return(t.hostname?t.hostname:window.location.hostname)+":"+t.assignedPort}}_isConfigComplete(t){return t.gatewayId?t.type?t.target?!!t.targetPort||(console.error("Could not start tunnel, since no gateway target port was configured."),!1):(console.error("Could not start tunnel, since no gateway target was configured."),!1):(console.error("Could not start tunnel, since no gateway type / protocol was configured."),!1):(console.error("Could not start tunnel, since no gateway asset was configured."),!1)}_getTunnelInfoByConfig(t){return{realm:An().displayRealm,gatewayId:t.gatewayId,type:t.type,target:t.target,targetPort:t.targetPort}}};id([gt()],ad.prototype,"_loading",void 0),id([gt()],ad.prototype,"_activeTunnel",void 0),ad=ed=id([ht("gateway-widget")],ad);var od=function(t,e,i,n){var r,a=arguments.length,o=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(a<3?r(o):a>3?r(e,i,o):r(e,i))||o);return a>3&&o&&Object.defineProperty(e,i,o),o};const sd=o`
2566
+ `}_onCopyTunnelAddressClick(t){if(this._isConfigComplete(this.widgetConfig)){const t=this._getTunnelInfoByConfig(this.widgetConfig),e=this._getTunnelAddress(t);e?navigator.clipboard.writeText(e).finally((()=>{da(void 0,In.i18next.t("gatewayTunnels.copySuccess"))})):(console.warn("Could not copy tunnel address as it could not be found."),da(void 0,In.i18next.t("errorOccurred")))}else console.warn("Could not copy tunnel address as configuration is not complete."),da(void 0,In.i18next.t("errorOccurred"))}_onStartTunnelClick(t){this._tryStartTunnel(this.widgetConfig)}_onStopTunnelClick(t){this._tryStopTunnel(this.widgetConfig)}_onTunnelNavigateClick(t,e){e?this._navigateToTunnel(e):console.warn("Could not navigate to tunnel as configuration is not complete.")}_setActiveTunnel(t,e=!1){if(this._activeTunnel=t,this._refreshTimer&&clearTimeout(this._refreshTimer),null==t?void 0:t.autoCloseTime){const e=(null==t?void 0:t.autoCloseTime)-Date.now();e>0&&(this._refreshTimer=window.setTimeout((()=>{this._getActiveTunnel(this._getTunnelInfoByConfig(this.widgetConfig)).then((t=>{t?this._setActiveTunnel(t,!0):this._setActiveTunnel(void 0)}))}),e))}t&&!e&&this._navigateToTunnel(t)}_tryStartTunnel(t){if(this._isConfigComplete(t)){const e=this._getTunnelInfoByConfig(t);this._loading=!0,this._getActiveTunnel(e).then((t=>{t?(console.log("Found an active tunnel!",t),this._setActiveTunnel(t),this._loading=!1):this._startTunnel(e).then((t=>{t?(console.log("Started a new tunnel!",t),this._setActiveTunnel(t),this._startedByUser=!0):console.warn("No new tunnel!")})).catch((t=>{console.error(t),da(void 0,In.i18next.t("errorOccurred"))})).finally((()=>{this._loading=!1}))})).catch((t=>{console.error(t),da(void 0,In.i18next.t("errorOccurred")),this._loading=!1}))}}_startTunnel(t){return nd(this,void 0,void 0,(function*(){if(!(t.realm&&t.gatewayId&&t.target&&t.targetPort))throw new Error("Could not start tunnel, as some provided information was not set.");return(yield An().rest.api.GatewayServiceResource.startTunnel(t)).data}))}_getActiveTunnel(t){return nd(this,void 0,void 0,(function*(){if(!(t.realm&&t.gatewayId&&t.target&&t.targetPort))throw new Error("Could not get active tunnel, as some provided information was not set.");const e=yield An().rest.api.GatewayServiceResource.getActiveTunnelInfo(t.realm,t.gatewayId,t.target,t.targetPort);return 204===e.status?void 0:e.data}))}_getGatewayStatus(t){return nd(this,void 0,void 0,(function*(){const e=yield An().rest.api.AssetResource.get(t.gatewayId);return 200===e.status&&e.data&&e.data.attributes&&e.data.attributes.gatewayStatus?e.data.attributes.gatewayStatus.value:void 0}))}_readyCheck(t){const e=this._getTunnelInfoByConfig(t);this._getGatewayStatus(e).then((t=>{this._isReady="CONNECTED"===t}))}_tryStopTunnel(t){const e=this._getTunnelInfoByConfig(t);this._loading=!0,this._stopTunnel(e).then((()=>{this._setActiveTunnel(void 0),this._startedByUser=!1})).catch((t=>{console.warn(t)})).finally((()=>{this._loading=!1}))}_stopTunnel(t){return nd(this,void 0,void 0,(function*(){return(yield An().rest.api.GatewayServiceResource.stopTunnel(t)).data}))}_navigateToTunnel(t){var e;t.id&&t.realm&&t.gatewayId&&t.target&&t.targetPort||console.warn("Could not navigate to tunnel, as some provided information was not set.");const i=this._getTunnelAddress(t);switch(t.type){case"HTTPS":case"HTTP":null===(e=window.open(i))||void 0===e||e.focus();break;default:console.error("Unknown error when navigating to tunnel.")}}_getTunnelAddress(t){switch(t.type){case"HTTPS":case"HTTP":return"//"+t.id+"."+(t.hostname?t.hostname:window.location.hostname);case"TCP":return(t.hostname?t.hostname:window.location.hostname)+":"+t.assignedPort}}_isConfigComplete(t){return t.gatewayId?t.type?t.target?!!t.targetPort||(console.error("Could not start tunnel, since no gateway target port was configured."),!1):(console.error("Could not start tunnel, since no gateway target was configured."),!1):(console.error("Could not start tunnel, since no gateway type / protocol was configured."),!1):(console.error("Could not start tunnel, since no gateway asset was configured."),!1)}_getTunnelInfoByConfig(t){return{realm:An().displayRealm,gatewayId:t.gatewayId,type:t.type,target:t.target,targetPort:t.targetPort}}};id([gt()],ad.prototype,"_loading",void 0),id([gt()],ad.prototype,"_activeTunnel",void 0),id([gt()],ad.prototype,"_isReady",void 0),ad=ed=id([ht("gateway-widget")],ad);var od=function(t,e,i,n){var r,a=arguments.length,o=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,n);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(o=(a<3?r(o):a>3?r(e,i,o):r(e,i))||o);return a>3&&o&&Object.defineProperty(e,i,o),o};const sd=o`
2567
2567
 
2568
2568
  @media only screen and (min-width: 641px){
2569
2569
  #tree {