UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 3.75 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[35131],{72406:function(a,t,s){s.a(a,async function(a,o){try{s.r(t),s.d(t,{HuiDialogSelectDashboard:function(){return P}});s(18111),s(61701),s(3362),s(62953);var e=s(40445),i=s(5124),l=s(67576),h=s(1087),r=s(18350),d=(s(93444),s(606)),n=s(65829),c=s(72554),_=s(71730),p=s(99774),g=s(65063),u=s(14503),v=a([r,d,n,c]);[r,d,n,c]=v.then?(await v)():v;let b,m,f,y,C=a=>a;class P extends i.WF{showDialog(a){this._config=a.lovelaceConfig,this._fromUrlPath=a.urlPath,this._params=a,this._open=!0,this._getDashboards()}closeDialog(){this._open&&(0,h.r)(this,"dialog-closed",{dialog:this.localName}),this._saving=!1,this._dashboards=void 0,this._toUrlPath=void 0,this._open=!1,this._params=void 0}_dialogClosed(){this.closeDialog()}render(){if(!this._params)return i.s6;const a=this._params.header||this.hass.localize("ui.panel.lovelace.editor.select_dashboard.header");return(0,i.qy)(b||(b=C` <ha-dialog .open="${0}" header-title="${0}" .preventScrimClose="${0}" @closed="${0}"> ${0} <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" @click="${0}" .disabled="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" @click="${0}" .disabled="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,a,this._saving,this._dialogClosed,this._dashboards&&!this._saving?(0,i.qy)(m||(m=C` <ha-select .label="${0}" @selected="${0}" .value="${0}" .options="${0}"></ha-select> `),this.hass.localize("ui.panel.lovelace.editor.select_view.dashboard_label"),this._dashboardChanged,this._toUrlPath||"",this._dashboards.map(a=>({value:a.url_path,label:a.title,disabled:"storage"!==a.mode||a.url_path===this._fromUrlPath||"lovelace"===a.url_path&&null===this._fromUrlPath}))):(0,i.qy)(f||(f=C`<div class="loading"> <ha-spinner size="medium"></ha-spinner> </div>`)),this.closeDialog,this._saving,this.hass.localize("ui.common.cancel"),this._selectDashboard,!this._config||this._fromUrlPath===this._toUrlPath||this._saving,this._params.actionLabel||this.hass.localize("ui.common.move"))}async _getDashboards(){var a;let t=this._params.dashboards;if(!t)try{t=await(0,_.SJ)(this.hass)}catch(e){console.error("Error fetching dashboards:",e),(0,g.showAlertDialog)(this,{title:this.hass.localize("ui.panel.lovelace.editor.select_dashboard.error_title"),text:this.hass.localize("ui.panel.lovelace.editor.select_dashboard.error_text")})}this._dashboards=[{id:"lovelace",url_path:"lovelace",require_admin:!1,show_in_sidebar:!0,title:this.hass.localize("ui.common.default"),mode:null===(a=this.hass.panels.lovelace)||void 0===a||null===(a=a.config)||void 0===a?void 0:a.mode},...null!=t?t:[]];const s=(0,p.EN)(this.hass),o=this._fromUrlPath||s;for(const i of this._dashboards)if(i.url_path!==o){this._toUrlPath=i.url_path;break}}async _dashboardChanged(a){const t=a.detail.value;t!==this._toUrlPath&&(this._toUrlPath=t)}async _selectDashboard(){this._saving=!0,"lovelace"===this._toUrlPath&&(this._toUrlPath=null),this._params.dashboardSelectedCallback(this._toUrlPath),this.closeDialog()}static get styles(){return[u.nA,(0,i.AH)(y||(y=C`ha-select{width:100%}.loading{display:flex;justify-content:center}`))]}constructor(...a){super(...a),this._saving=!1,this._open=!1}}(0,e.Cg)([(0,l.wk)()],P.prototype,"_params",void 0),(0,e.Cg)([(0,l.wk)()],P.prototype,"_dashboards",void 0),(0,e.Cg)([(0,l.wk)()],P.prototype,"_fromUrlPath",void 0),(0,e.Cg)([(0,l.wk)()],P.prototype,"_toUrlPath",void 0),(0,e.Cg)([(0,l.wk)()],P.prototype,"_config",void 0),(0,e.Cg)([(0,l.wk)()],P.prototype,"_saving",void 0),(0,e.Cg)([(0,l.wk)()],P.prototype,"_open",void 0),P=(0,e.Cg)([(0,l.EM)("hui-dialog-select-dashboard")],P),o()}catch(b){o(b)}})}}]);