iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 14.6 kB
JavaScript
/*! For license information please see 856.7e2cfb994ab78ce5.js.LICENSE.txt */
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[856],{9579:function(t,e,i){i.a(t,async function(t,o){try{i.r(e);i(3362),i(62953);var s=i(40445),a=i(5124),n=i(67576),r=i(63672),l=i(1087),h=i(18350),d=(i(93444),i(72554)),g=i(29823),c=(i(70947),i(26300)),u=i(14503),p=i(92255),_=i(53338),m=i(5106),f=t([h,d,g,c,m]);[h,d,g,c,m]=f.then?(await f)():f;let v,y,C=t=>t;const E="M12,15C7.58,15 4,16.79 4,19V21H20V19C20,16.79 16.42,15 12,15M8,9A4,4 0 0,0 12,13A4,4 0 0,0 16,9M11.5,2C11.2,2 11,2.21 11,2.5V5.5H10V3C10,3 7.75,3.86 7.75,6.75C7.75,6.75 7,6.89 7,8H17C16.95,6.89 16.25,6.75 16.25,6.75C16.25,3.86 14,3 14,3V5.5H13V2.5C13,2.21 12.81,2 12.5,2H11.5Z",b="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",w="M3 6V8H14V6H3M3 10V12H14V10H3M20 10.1C19.9 10.1 19.7 10.2 19.6 10.3L18.6 11.3L20.7 13.4L21.7 12.4C21.9 12.2 21.9 11.8 21.7 11.6L20.4 10.3C20.3 10.2 20.2 10.1 20 10.1M18.1 11.9L12 17.9V20H14.1L20.2 13.9L18.1 11.9M3 14V16H10V14H3Z";class $ extends a.WF{async showDialog(t){this._params=t,this._strategyConfig=t.config.strategy,this._open=!0,await this.updateComplete}closeDialog(){this._open=!1}_dialogClosed(){this._params=void 0,this._strategyConfig=void 0,this._guiModeAvailable=!0,this._GUImode=!0,(0,l.r)(this,"dialog-closed",{dialog:this.localName})}_handleConfigChanged(t){t.stopPropagation(),this._guiModeAvailable=t.detail.guiModeAvailable,this._strategyConfig=t.detail.config}_handleGUIModeChanged(t){t.stopPropagation(),this._GUImode=t.detail.guiMode,this._guiModeAvailable=t.detail.guiModeAvailable}async _save(){await this._params.saveConfig(Object.assign(Object.assign({},this._params.config),{},{strategy:this._strategyConfig})),(0,p.f)(this,this.hass),this.closeDialog()}async _delete(t){t.stopPropagation(),await this._params.deleteDashboard()&&this.closeDialog()}_cancel(t){t.stopPropagation(),this.closeDialog()}_handleAction(t){const e=t.detail.item.value;if(e)switch(e){case"toggle-mode":this._toggleMode();break;case"take-control":this._takeControl()}}_toggleMode(){var t;null===(t=this._strategyEditorEl)||void 0===t||t.toggleMode()}_takeControl(){this._params.takeControl(),this.closeDialog()}render(){if(!this._params||!this._strategyConfig)return a.s6;const t=(0,_._V)(this._strategyConfig),e=this.hass.localize("ui.panel.lovelace.editor.strategy-editor.header");return(0,a.qy)(v||(v=C` <ha-dialog .open="${0}" header-title="${0}" header-subtitle="${0}" width="large" ="${0}"> <ha-dropdown placement="bottom-end" slot="headerActionItems" -select="${0}"> <ha-icon-button slot="trigger" .label="${0}" .path="${0}"></ha-icon-button> <ha-dropdown-item value="toggle-mode" .disabled="${0}"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item value="take-control"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="content"> <hui-dashboard-strategy-element-editor .hass="${0}" .lovelace="${0}" .value="${0}" -changed="${0}" -changed="${0}" autofocus></hui-dashboard-strategy-element-editor> </div> <ha-dialog-footer slot="footer"> <ha-button slot="secondaryAction" variant="danger" appearance="plain" ="${0}"> ${0} </ha-button> <ha-button slot="secondaryAction" appearance="plain" ="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" ="${0}"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,e||"-",(0,r.J)(this._params.title),this._dialogClosed,this._handleAction,this.hass.localize("ui.common.menu"),b,!this._guiModeAvailable&&!this._GUImode,this.hass.localize("ui.panel.lovelace.editor.edit_view.edit_"+(this._GUImode?"yaml":"ui")),w,this.hass.localize("ui.panel.lovelace.editor.strategy-editor.take_control"),E,this.hass,this._params.config,t,this._handleConfigChanged,this._handleGUIModeChanged,this._delete,this.hass.localize("ui.common.delete"),this._cancel,this.hass.localize("ui.common.cancel"),this._save,this.hass.localize("ui.common.save"))}static get styles(){return[u.nA,u.kO,(0,a.AH)(y||(y=C`ha-dialog{--dialog-content-padding:0 24px}`))]}constructor(...t){super(...t),this._GUImode=!0,this._guiModeAvailable=!0,this._open=!1}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,s.Cg)([(0,n.wk)()],$.prototype,"_params",void 0),(0,s.Cg)([(0,n.wk)()],$.prototype,"_strategyConfig",void 0),(0,s.Cg)([(0,n.wk)()],$.prototype,"_GUImode",void 0),(0,s.Cg)([(0,n.wk)()],$.prototype,"_guiModeAvailable",void 0),(0,s.Cg)([(0,n.wk)()],$.prototype,"_open",void 0),(0,s.Cg)([(0,n.P)("hui-dashboard-strategy-element-editor")],$.prototype,"_strategyEditorEl",void 0),$=(0,s.Cg)([(0,n.EM)("dialog-dashboard-strategy-editor")],$),o()}catch(v){o(v)}})},5106:function(t,e,i){i.a(t,async function(t,e){try{i(3362);var o=i(40445),s=i(67576),a=i(15656),n=i(63277),r=t([n]);n=(r.then?(await r)():r)[0];class l extends n.U{async getConfigElement(){const t=await(0,a.Nu)("dashboard",this.configElementType);if(t&&t.getConfigElement)return t.getConfigElement()}}l=(0,o.Cg)([(0,s.EM)("hui-dashboard-strategy-element-editor")],l),e()}catch(l){e(l)}})},39039:function(t,e,i){i.d(e,{r:function(){return o}});i(16280);class o extends Error{constructor(t,e,i){super(t),this.name="GUISupportError",this.warnings=e,this.errors=i}}},91322:function(t,e,i){i.a(t,async function(t,o){try{i.d(e,{m:function(){return I}});i(18111),i(7588),i(61701),i(3362),i(62953);var s=i(40445),a=i(5124),n=i(67576),r=i(74985),l=i(1087),h=i(78978),d=i(19459),g=i(38962),c=i(65829),u=i(10763),p=i(39039),_=t([g,c,u]);[g,c,u]=_.then?(await _)():_;let m,f,v,y,C,E,b,w,$,M,k,A,U=t=>t;class I extends a.WF{get value(){return this._config}set value(t){this._config&&(0,d.b)(t,this._config,{compareSymbols:!0})||(this._config=t,this._errors=void 0,this._setConfig())}_setConfig(){if(!this._errors&&!this._yamlError)try{this._updateConfigElement()}catch(t){this._errors=[t.message]}this.updateComplete.then(()=>{var t;(0,l.r)(this,"config-changed",{config:this.value,error:null===(t=this._errors)||void 0===t?void 0:t.join(", "),guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})})}get hasWarning(){return void 0!==this._warnings&&this._warnings.length>0}get hasError(){return this._yamlError||void 0!==this._errors&&this._errors.length>0}get GUImode(){return this._guiMode}set GUImode(t){this._guiMode=t,this.updateComplete.then(()=>{(0,l.r)(this,"GUImode-changed",{guiMode:t,guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})})}toggleMode(){var t;this.GUImode||(null===(t=this._yamlEditor)||void 0===t||t.disableCodeEditorFullscreen());this.GUImode=!this.GUImode}focusYamlEditor(){var t;null!==(t=this._configElement)&&void 0!==t&&t.focusYamlEditor&&this._configElement.focusYamlEditor(),this._yamlEditor&&this._yamlEditor.focus()}async getConfigElement(){}async getConfigForm(){}renderConfigElement(){return(0,a.qy)(m||(m=U`${0}`),this._configElement)}_renderSubElement(){return(0,a.qy)(f||(f=U` <hui-sub-element-editor .hass="${0}" .config="${0}" -back="${0}" -changed="${0}"> </hui-sub-element-editor> `),this.hass,this._subElementEditorConfig,this._goBack,this._subElementChanged)}_subElementChanged(t){var e,i;t.stopPropagation();const o=t.detail.config;this._subElementEditorConfig=Object.assign(Object.assign({},this._subElementEditorConfig),{},{elementConfig:o}),null===(e=(i=this._subElementEditorConfig).saveElementConfig)||void 0===e||e.call(i,o)}_goBack(t){t.stopPropagation(),this._subElementEditorConfig=void 0}async _editSubElement(t){t.stopPropagation(),await Promise.all([i.e(92769),i.e(3283),i.e(80131),i.e(70183),i.e(67218),i.e(98470),i.e(99788),i.e(58303),i.e(21543),i.e(66283),i.e(46601),i.e(94956),i.e(26092),i.e(39005),i.e(8851),i.e(59704),i.e(25322),i.e(55392),i.e(71572),i.e(55076),i.e(36332),i.e(77563),i.e(15862),i.e(99143),i.e(97500),i.e(12009),i.e(66990),i.e(20282),i.e(87857),i.e(81804),i.e(92363),i.e(53387)]).then(i.bind(i,81287)),this._subElementEditorConfig={type:t.detail.type,elementConfig:t.detail.config,context:t.detail.context,saveElementConfig:t.detail.saveConfig}}render(){var t;return(0,a.qy)(v||(v=U` <div class="wrapper"> ${0} ${0} ${0} ${0} </div> `),this.GUImode?(0,a.qy)(y||(y=U` <div class="gui-editor" -sub-element="${0}"> ${0} </div> `),this._editSubElement,this._loading?(0,a.qy)(C||(C=U` <ha-spinner class="center margin-bot"></ha-spinner> `)):(0,r.P)(this._subElementEditorConfig?this._renderSubElement():this.renderConfigElement())):(0,a.qy)(E||(E=U` <div class="yaml-editor"> <ha-yaml-editor .defaultValue="${0}" autofocus .inDialog="${0}" -changed="${0}" ="${0}" dir="ltr"></ha-yaml-editor> </div> `),this._config,this.inDialog,this._handleYAMLChanged,this._ignoreKeydown),!1===this._guiSupported&&!1===this._loading?(0,a.qy)(b||(b=U` <ha-alert alert-type="info" .title="${0}"> ${0} <br> ${0} </ha-alert> `),this.hass.localize("ui.errors.config.visual_editor_not_supported"),this.hass.localize("ui.errors.config.visual_editor_not_supported_reason_type"),this.hass.localize("ui.errors.config.edit_in_yaml_supported")):a.s6,null!==(t=this._errors)&&void 0!==t&&t.length?(0,a.qy)(w||(w=U` <ha-alert alert-type="error" .title="${0}"> <ul> ${0} </ul> </ha-alert> `),this.hass.localize("ui.errors.config.configuration_error"),this._errors.map(t=>(0,a.qy)($||($=U`<li>${0}</li>`),t))):a.s6,this.hasWarning?(0,a.qy)(M||(M=U` <ha-alert alert-type="warning" .title="${0}"> <ul> ${0} </ul> ${0} </ha-alert> `),this.hass.localize("ui.errors.config.visual_editor_not_supported"),this._warnings.map(t=>(0,a.qy)(k||(k=U`<li>${0}</li>`),t)),this.hass.localize("ui.errors.config.edit_in_yaml_supported")):a.s6)}updated(t){super.updated(t),this._configElement&&t.has("hass")&&(this._configElement.hass=this.hass),this._configElement&&"lovelace"in this._configElement&&t.has("lovelace")&&(this._configElement.lovelace=this.lovelace),this._configElement&&t.has("context")&&(this._configElement.context=this.context)}_handleUIConfigChanged(t){if(t.stopPropagation(),!this.GUImode)return;const e=t.detail.config;Object.keys(e).forEach(t=>{void 0===e[t]&&delete e[t]}),this.value=e}_handleYAMLChanged(t){t.stopPropagation(),t.detail.isValid?(this._config=t.detail.value,this._errors=void 0,this._yamlError=!1):this._yamlError=!0,this._setConfig()}async unloadConfigElement(){this._configElement=void 0,this._guiSupported=void 0}async loadConfigElement(){if(this._configElement)return;let t=await this.getConfigElement();if(!t){const e=await this.getConfigForm();if(e){await i.e(15106).then(i.bind(i,15737)),t=document.createElement("hui-form-editor");const{schema:o,assertConfig:s,computeLabel:a,computeHelper:n}=e;t.schema=o,a&&(t.computeLabel=a),n&&(t.computeHelper=n),s&&(t.assertConfig=s)}}t?(t.hass=this.hass,"lovelace"in t&&(t.lovelace=this.lovelace),t.context=this.context,t.addEventListener("config-changed",t=>this._handleUIConfigChanged(t)),this._guiSupported=!0):this._guiSupported=!1,this._configElement=t}async _updateConfigElement(){if(!this.value)return;const t=++this._loadCount;try{if(this._errors=void 0,this._warnings=void 0,await this.loadConfigElement(),this._configElement)try{this._configElement.setConfig(this.value)}catch(i){const t=(0,h._)(this.hass,i);throw new p.r("Config is not supported",t.warnings,t.errors)}else this._guiSupported=!1,this.GUImode=!1}catch(i){if(t!==this._loadCount)return;var e;if(i instanceof p.r)this._warnings=null!==(e=i.warnings)&&void 0!==e?e:[i.message],this._errors=i.errors||void 0;else this._errors=[i.message];this.GUImode=!1}finally{this._loading=!1}}_ignoreKeydown(t){t.stopPropagation()}constructor(...t){super(...t),this.inDialog=!1,this._guiMode=!0,this._loading=!1,this._yamlError=!1,this._loadCount=0}}I.styles=(0,a.AH)(A||(A=U`:host{display:flex}.wrapper{width:100%}.gui-editor,.yaml-editor{padding:8px 0px}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}ha-spinner{display:block;margin:auto}`)),(0,s.Cg)([(0,n.MZ)({attribute:!1})],I.prototype,"hass",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],I.prototype,"lovelace",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],I.prototype,"context",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean,attribute:"in-dialog"})],I.prototype,"inDialog",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_config",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_configElement",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_subElementEditorConfig",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_guiMode",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_errors",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_warnings",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_guiSupported",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_loading",void 0),(0,s.Cg)([(0,n.wk)()],I.prototype,"_yamlError",void 0),(0,s.Cg)([(0,n.P)("ha-yaml-editor")],I.prototype,"_yamlEditor",void 0),o()}catch(m){o(m)}})},63277:function(t,e,i){i.a(t,async function(t,o){try{i.d(e,{U:function(){return l}});i(16280),i(3362);var s=i(40445),a=i(67576),n=i(91322),r=t([n]);n=(r.then?(await r)():r)[0];class l extends n.m{get configElementType(){return this.value?this.value.type:void 0}async loadConfigElement(){if(this._configElementType!==this.configElementType){if(this.unloadConfigElement(),!this.configElementType)throw new Error(this.hass.localize("ui.errors.config.no_type_provided"));this._configElementType=this.configElementType}return super.loadConfigElement()}}(0,s.Cg)([(0,a.wk)()],l.prototype,"_configElementType",void 0),o()}catch(l){o(l)}})},92255:function(t,e,i){i.d(e,{f:function(){return s}});var o=i(81619);const s=(t,e)=>(0,o.P)(t,{message:e.localize("ui.common.successfully_saved")})},74985:function(t,e,i){i.d(e,{P:function(){return r}});i(88454),i(29452),i(62953);var o=i(5055),s=i(42017),a=i(63937);const n=t=>(0,a.ps)(t)?t._$litType$.h:t.strings,r=(0,s.u$)(class extends s.WL{render(t){return[t]}update(t,[e]){const i=(0,a.qb)(this.it)?n(this.it):null,s=(0,a.qb)(e)?n(e):null;if(null!==i&&(null===s||i!==s)){const e=(0,a.cN)(t).pop();let s=this.et.get(i);if(void 0===s){const t=document.createDocumentFragment();s=(0,o.XX)(o.s6,t),s.setConnected(!1),this.et.set(i,s)}(0,a.mY)(s,[e]),(0,a.Dx)(s,void 0,e)}if(null!==s){if(null===i||i!==s){const e=this.et.get(s);if(void 0!==e){const i=(0,a.cN)(e).pop();(0,a.Jz)(t),(0,a.Dx)(t,void 0,i),(0,a.mY)(t,[i])}}this.it=e}else this.it=void 0;return this.render(e)}constructor(t){super(t),this.et=new WeakMap}})}}]);