iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.97 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[87980],{24519:function(a,e,o){o.a(a,async function(a,i){try{o.r(e),o.d(e,{HuiSaveConfig:function(){return w}});o(3362);var t=o(40445),s=o(5124),l=o(67576),n=o(1087),h=o(18350),c=o(72554),r=(o(93444),o(6),o(26300)),p=o(59646),g=o(10763),d=o(14503),f=o(36918),_=o(15656),v=a([h,c,r,p,g]);[h,c,r,p,g]=v.then?(await v)():v;let u,m,y,C,$,A,k=a=>a;const b="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z",z={views:[{title:"Home"}]};class w extends s.WF{showDialog(a){this._params=a,this._emptyConfig=!1,this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._params=void 0,(0,n.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params)return s.s6;const a=this.hass.localize("ui.panel.lovelace.editor.save_config.header");return(0,s.qy)(u||(u=k` <ha-dialog .open="${0}" header-title="${0}" prevent-scrim-close ="${0}"> <ha-icon-button .path="${0}" .label="${0}" .href="${0}" title="${0}" target="_blank" rel="noreferrer" slot="headerActionItems"></ha-icon-button> <div> <p> ${0} </p> ${0} </div> ${0} </ha-dialog> `),this._open,a,this._dialogClosed,b,this.hass.localize("ui.common.help"),(0,f.o)(this.hass,"/lovelace/"),this.hass.localize("ui.panel.lovelace.menu.help"),this.hass.localize("ui.panel.lovelace.editor.save_config.para"),"storage"===this._params.mode?(0,s.qy)(m||(m=k` <p> ${0} </p> <ha-formfield .label="${0}"> <ha-switch .checked="${0}" ="${0}" autofocus></ha-switch></ha-formfield> `),this.hass.localize("ui.panel.lovelace.editor.save_config.para_sure"),this.hass.localize("ui.panel.lovelace.editor.save_config.empty_config"),this._emptyConfig,this._emptyConfigChanged):(0,s.qy)(y||(y=k` <p> ${0} </p> <p> ${0} </p> <p> ${0} </p> <ha-yaml-editor .defaultValue="${0}" autofocus></ha-yaml-editor> `),this.hass.localize("ui.panel.lovelace.editor.save_config.yaml_mode"),this.hass.localize("ui.panel.lovelace.editor.save_config.yaml_control"),this.hass.localize("ui.panel.lovelace.editor.save_config.yaml_config"),this._params.lovelace.config),"storage"===this._params.mode?(0,s.qy)(C||(C=k` <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" appearance="plain" ="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" ="${0}" .loading="${0}"> ${0} </ha-button> </ha-dialog-footer> `),this.closeDialog,this.hass.localize("ui.common.cancel"),this._saveConfig,this._saving,this.hass.localize("ui.panel.lovelace.editor.save_config.save")):(0,s.qy)($||($=k` <ha-dialog-footer slot="footer"> <ha-button slot="primaryAction" ="${0}"> ${0} </ha-button> </ha-dialog-footer> `),this.closeDialog,this.hass.localize("ui.panel.lovelace.editor.save_config.close")))}_emptyConfigChanged(a){this._emptyConfig=a.target.checked}async _saveConfig(){if(this.hass&&this._params){this._saving=!0;try{const a=this._params.lovelace;await a.saveConfig(this._emptyConfig?z:await(0,_.d4)(a.config,this.hass)),a.setEditMode(!0),this._saving=!1,this.closeDialog()}catch(a){alert(`Saving failed: ${a.message}`),this._saving=!1}}}static get styles(){return[d.nA,(0,s.AH)(A||(A=k`ha-dialog{--dialog-content-padding:0 24px 24px 24px}ha-dialog ha-icon-button[slot=headerActionItems]{color:var(--secondary-text-color)}`))]}constructor(){super(),this._emptyConfig=!1,this._open=!1,this._saving=!1}}(0,t.Cg)([(0,l.MZ)({attribute:!1})],w.prototype,"hass",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_params",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_emptyConfig",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_saving",void 0),(0,t.Cg)([(0,l.wk)()],w.prototype,"_open",void 0),w=(0,t.Cg)([(0,l.EM)("hui-dialog-save-config")],w),i()}catch(u){i(u)}})}}]);