iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 10.1 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[28195],{67258:function(e,t,a){a.d(t,{d:function(){return o}});const o=e=>{switch(e.language){case"cs":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},41060:function(e,t,a){a.a(e,async function(e,t){try{a(18111),a(61701),a(62953);var o=a(40445),i=a(5124),r=a(67576),l=a(6412),s=a(44537),n=a(1087),p=a(67258),d=a(46187),c=a(18350),u=a(26300),h=a(94355),g=e([c,u,h]);[c,u,h]=g.then?(await g)():g;let v,b,f,y,m,$,_,k,x=e=>e;const M="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",z="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M13.5,16V19H10.5V16H8L12,12L16,16H13.5M13,9V3.5L18.5,9H13Z";class C extends i.WF{firstUpdated(e){super.firstUpdated(e),this.autoOpenFileDialog&&this._openFilePicker()}get _name(){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return(this.value instanceof FileList?Array.from(this.value):(0,s.e)(this.value)).map(e=>e.name).join(", ")}render(){const e=this.localize||this.hass.localize;return(0,i.qy)(v||(v=x` ${0} `),this.uploading?(0,i.qy)(b||(b=x`<div class="container"> <div class="uploading"> <span class="header">${0}</span> ${0} </div> <ha-progress-bar .indeterminate="${0}" .value="${0}" loading></ha-progress-bar> </div>`),this.uploadingLabel||(this.value?e("ui.components.file-upload.uploading_name",{name:this._name}):e("ui.components.file-upload.uploading")),this.progress?(0,i.qy)(f||(f=x`<div class="progress"> ${0}${0}% </div>`),this.progress,this.hass&&(0,p.d)(this.hass.locale)):i.s6,!this.progress,this.progress):(0,i.qy)(y||(y=x`<label for="${0}" class="container ${0}" ="${0}" ="${0}" ="${0}" ="${0}" ="${0}">${0} <input id="input" type="file" class="file" .accept="${0}" .multiple="${0}" ="${0}"></label>`),this.value?"":"input",(0,l.H)({dragged:this._drag,multiple:this.multiple,value:Boolean(this.value)}),this._handleDrop,this._handleDragStart,this._handleDragStart,this._handleDragEnd,this._handleDragEnd,this.value?"string"==typeof this.value?(0,i.qy)($||($=x`<div class="row"> <div class="value" ="${0}"> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} </div> <ha-icon-button ="${0}" .label="${0}" .path="${0}"></ha-icon-button> </div>`),this._openFilePicker,this.icon||z,this.value,this._clearValue,this.deleteLabel||e("ui.common.delete"),M):(this.value instanceof FileList?Array.from(this.value):(0,s.e)(this.value)).map(t=>(0,i.qy)(_||(_=x`<div class="row"> <div class="value" ="${0}"> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} - ${0} </div> <ha-icon-button ="${0}" .label="${0}" .path="${0}"></ha-icon-button> </div>`),this._openFilePicker,this.icon||z,t.name,(0,d.A)(t.size),this._clearValue,this.deleteLabel||e("ui.common.delete"),M)):(0,i.qy)(m||(m=x`<ha-button size="small" appearance="filled" ="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button> <span class="secondary">${0}</span> <span class="supports">${0}</span>`),this._openFilePicker,this.icon||z,this.label||e("ui.components.file-upload.label"),this.secondary||e("ui.components.file-upload.secondary"),this.supports),this.accept,this.multiple,this._handleFilePicked))}_openFilePicker(){var e;null===(e=this._input)||void 0===e||e.click()}_handleDrop(e){var t;e.preventDefault(),e.stopPropagation(),null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&(0,n.r)(this,"file-picked",{files:this.multiple||1===e.dataTransfer.files.length?Array.from(e.dataTransfer.files):[e.dataTransfer.files[0]]}),this._drag=!1}_handleDragStart(e){e.preventDefault(),e.stopPropagation(),this._drag=!0}_handleDragEnd(e){e.preventDefault(),e.stopPropagation(),this._drag=!1}_handleFilePicked(e){0!==e.target.files.length&&(this.value=e.target.files,(0,n.r)(this,"file-picked",{files:e.target.files}))}_clearValue(e){e.preventDefault(),this._input.value="",this.value=void 0,(0,n.r)(this,"change"),(0,n.r)(this,"files-cleared")}constructor(...e){super(...e),this.multiple=!1,this.disabled=!1,this.uploading=!1,this.autoOpenFileDialog=!1,this._drag=!1}}C.styles=(0,i.AH)(k||(k=x`:host{display:block;height:240px}:host([disabled]){pointer-events:none;color:var(--disabled-text-color)}.container{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;border:solid 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));border-radius:var(--mdc-shape-small,var(--ha-border-radius-sm));height:100%}.row{display:flex;align-items:center}label.container{border:dashed 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));cursor:pointer}.container .uploading{display:flex;flex-direction:column;width:100%;align-items:flex-start;padding:0 32px;box-sizing:border-box}:host([disabled]) .container{border-color:var(--disabled-color)}label.dragged,label:hover{border-style:solid}label.dragged{border-color:var(--primary-color)}.dragged:before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:var(--primary-color);content:"";opacity:var(--dark-divider-opacity);pointer-events:none;border-radius:var(--mdc-shape-small,4px)}label.value{cursor:default}label.value.multiple{justify-content:unset;overflow:auto}.highlight{color:var(--primary-color)}ha-button{margin-bottom:8px}.supports{color:var(--secondary-text-color);font-size:var(--ha-font-size-s)}:host([disabled]) .secondary{color:var(--disabled-text-color)}input.file{display:none}.value{cursor:pointer}.value ha-svg-icon{margin-right:8px;margin-inline-end:8px;margin-inline-start:initial}ha-button{--mdc-button-outline-color:var(--primary-color);--ha-icon-button-size:24px}ha-progress-bar{width:100%;padding:8px 32px;box-sizing:border-box}.header{font-weight:var(--ha-font-weight-medium)}.progress{color:var(--secondary-text-color)}button.link{background:0 0;border:none;padding:0;font-size:var(--ha-font-size-m);color:var(--primary-color);text-decoration:underline;cursor:pointer}`)),(0,o.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,o.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"localize",void 0),(0,o.Cg)([(0,r.MZ)()],C.prototype,"accept",void 0),(0,o.Cg)([(0,r.MZ)()],C.prototype,"icon",void 0),(0,o.Cg)([(0,r.MZ)()],C.prototype,"label",void 0),(0,o.Cg)([(0,r.MZ)()],C.prototype,"secondary",void 0),(0,o.Cg)([(0,r.MZ)({attribute:"uploading-label"})],C.prototype,"uploadingLabel",void 0),(0,o.Cg)([(0,r.MZ)({attribute:"delete-label"})],C.prototype,"deleteLabel",void 0),(0,o.Cg)([(0,r.MZ)()],C.prototype,"supports",void 0),(0,o.Cg)([(0,r.MZ)({type:Object})],C.prototype,"value",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"multiple",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean,reflect:!0})],C.prototype,"disabled",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"uploading",void 0),(0,o.Cg)([(0,r.MZ)({type:Number})],C.prototype,"progress",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean,attribute:"auto-open-file-dialog"})],C.prototype,"autoOpenFileDialog",void 0),(0,o.Cg)([(0,r.wk)()],C.prototype,"_drag",void 0),(0,o.Cg)([(0,r.P)("#input")],C.prototype,"_input",void 0),C=(0,o.Cg)([(0,r.EM)("ha-file-upload")],C),t()}catch(v){t(v)}})},83336:function(e,t,a){a.a(e,async function(e,o){try{a.r(t);a(3362),a(62953);var i=a(40445),r=a(5124),l=a(67576),s=a(41060),n=a(38962),p=a(90248),d=a(1087),c=a(65063),u=a(31420),h=a(12530),g=a(54819),v=a(91926),b=a(6030),f=e([s,n,p,u]);[s,n,p,u]=f.then?(await f)():f;let y,m,$,_=e=>e;const k="M20,6A2,2 0 0,1 22,8V18A2,2 0 0,1 20,20H4A2,2 0 0,1 2,18V6A2,2 0 0,1 4,4H10L12,6H20M10.75,13H14V17H16V13H19.25L15,8.75";class x extends r.WF{render(){return(0,r.qy)(y||(y=_` <ha-icon-button-arrow-prev .label="${0}" ="${0}"></ha-icon-button-arrow-prev> <h1> ${0} </h1> <p> ${0} </p> ${0} <ha-file-upload .uploading="${0}" .icon="${0}" accept="${0}" .localize="${0}" .label="${0}" .secondary="${0}" .supports="${0}" .deleteLabel="${0}" .uploadingLabel="${0}" -picked="${0}"></ha-file-upload> `),this.localize("ui.panel.page-onboarding.restore.back"),this._back,this.localize("ui.panel.page-onboarding.restore.upload_backup"),this.localize("ui.panel.page-onboarding.restore.upload_backup_subtitle"),this._error?(0,r.qy)(m||(m=_`<ha-alert alert-type="error">${0}</ha-alert>`),this._error):r.s6,this._uploading,k,u.xN,this.localize,this.localize("ui.panel.page-onboarding.restore.upload_input_label"),this.localize("ui.panel.page-onboarding.restore.upload_secondary"),this.localize("ui.panel.page-onboarding.restore.upload_supports_tar"),this.localize("ui.panel.page-onboarding.restore.delete"),this.localize("ui.panel.page-onboarding.restore.uploading"),this._filePicked)}async _filePicked(e){this._error=void 0;const t=e.detail.files[0];if(!t||t.type!==u.xN)return void(0,c.showAlertDialog)(this,{title:this.localize("ui.panel.page-onboarding.restore.unsupported.title"),text:this.localize("ui.panel.page-onboarding.restore.unsupported.text"),confirmText:this.localize("ui.panel.page-onboarding.restore.ok")});const a=this.supervisor?[u.mF]:[u.gv];this._uploading=!0;try{const{backup_id:e}=await(0,h.ZR)(t,a);(0,d.r)(this,"backup-uploaded",{backupId:e})}catch(i){var o;this._error="string"==typeof i.body?i.body:(null===(o=i.body)||void 0===o?void 0:o.message)||i.message||"Unknown error occurred"}}_back(){(0,v.oo)(`${location.pathname}?${(0,b.s8)("page")}`)}static get styles(){return[g.o,(0,r.AH)($||($=_`h1,p{text-align:left}.card-actions{display:flex;justify-content:flex-end}`))]}constructor(...e){super(...e),this.supervisor=!1,this._uploading=!1}}(0,i.Cg)([(0,l.MZ)({type:Boolean})],x.prototype,"supervisor",void 0),(0,i.Cg)([(0,l.MZ)({attribute:!1})],x.prototype,"localize",void 0),(0,i.Cg)([(0,l.wk)()],x.prototype,"_uploading",void 0),(0,i.Cg)([(0,l.wk)()],x.prototype,"_error",void 0),x=(0,i.Cg)([(0,l.EM)("onboarding-restore-backup-upload")],x),o()}catch(y){o(y)}})},46187:function(e,t,a){a.d(t,{A:function(){return o}});const o=(e=0,t=2)=>{if(0===e)return"0 Bytes";t=t<0?0:t;const a=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**a).toFixed(t))} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][a]}`}}}]);