iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.52 kB
JavaScript
export const __rspack_esm_id=35131;export const __rspack_esm_ids=[35131];export const __webpack_modules__={72406(a,t,s){s.a(a,async function(a,o){try{s.r(t),s.d(t,{HuiDialogSelectDashboard:()=>u});s(18111),s(61701);var e=s(62826),i=s(5124),l=s(22441),h=s(1087),r=s(18350),d=(s(93444),s(606)),c=s(65829),_=s(72554),n=s(71730),p=s(99774),g=s(65063),v=s(14503),b=a([r,d,c,_]);[r,d,c,_]=b.then?(await b)():b;class u 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 i.qy` <ha-dialog .open="${this._open}" header-title="${a}" .preventScrimClose="${this._saving}" ="${this._dialogClosed}"> ${this._dashboards&&!this._saving?i.qy` <ha-select .label="${this.hass.localize("ui.panel.lovelace.editor.select_view.dashboard_label")}" ="${this._dashboardChanged}" .value="${this._toUrlPath||""}" .options="${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}))}"></ha-select> `:i.qy`<div class="loading"> <ha-spinner size="medium"></ha-spinner> </div>`} <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" ="${this.closeDialog}" .disabled="${this._saving}"> ${this.hass.localize("ui.common.cancel")} </ha-button> <ha-button slot="primaryAction" ="${this._selectDashboard}" .disabled="${!this._config||this._fromUrlPath===this._toUrlPath||this._saving}"> ${this._params.actionLabel||this.hass.localize("ui.common.move")} </ha-button> </ha-dialog-footer> </ha-dialog> `}async _getDashboards(){let a=this._params.dashboards;if(!a)try{a=await(0,n.SJ)(this.hass)}catch(a){console.error("Error fetching dashboards:",a),(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:this.hass.panels.lovelace?.config?.mode},...a??[]];const t=(0,p.EN)(this.hass),s=this._fromUrlPath||t;for(const a of this._dashboards)if(a.url_path!==s){this._toUrlPath=a.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[v.nA,i.AH`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)()],u.prototype,"_params",void 0),(0,e.Cg)([(0,l.wk)()],u.prototype,"_dashboards",void 0),(0,e.Cg)([(0,l.wk)()],u.prototype,"_fromUrlPath",void 0),(0,e.Cg)([(0,l.wk)()],u.prototype,"_toUrlPath",void 0),(0,e.Cg)([(0,l.wk)()],u.prototype,"_config",void 0),(0,e.Cg)([(0,l.wk)()],u.prototype,"_saving",void 0),(0,e.Cg)([(0,l.wk)()],u.prototype,"_open",void 0),u=(0,e.Cg)([(0,l.EM)("hui-dialog-select-dashboard")],u),o()}catch(a){o(a)}})}};