iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 9.63 kB
JavaScript
export const __rspack_esm_id=28195;export const __rspack_esm_ids=[28195];export const __webpack_modules__={67258(e,t,a){a.d(t,{d:()=>o});const o=e=>{switch(e.language){case"cs":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},41060(e,t,a){a.a(e,async function(e,t){try{a(18111),a(61701);var o=a(62826),i=a(5124),r=a(22441),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;const v="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",b="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 y 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 i.qy` ${this.uploading?i.qy`<div class="container"> <div class="uploading"> <span class="header">${this.uploadingLabel||(this.value?e("ui.components.file-upload.uploading_name",{name:this._name}):e("ui.components.file-upload.uploading"))}</span> ${this.progress?i.qy`<div class="progress"> ${this.progress}${this.hass&&(0,p.d)(this.hass.locale)}% </div>`:i.s6} </div> <ha-progress-bar .indeterminate="${!this.progress}" .value="${this.progress}" loading></ha-progress-bar> </div>`:i.qy`<label for="${this.value?"":"input"}" class="container ${(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?i.qy`<div class="row"> <div class="value" ="${this._openFilePicker}"> <ha-svg-icon .path="${this.icon||b}"></ha-svg-icon> ${this.value} </div> <ha-icon-button ="${this._clearValue}" .label="${this.deleteLabel||e("ui.common.delete")}" .path="${v}"></ha-icon-button> </div>`:(this.value instanceof FileList?Array.from(this.value):(0,s.e)(this.value)).map(t=>i.qy`<div class="row"> <div class="value" ="${this._openFilePicker}"> <ha-svg-icon .path="${this.icon||b}"></ha-svg-icon> ${t.name} - ${(0,d.A)(t.size)} </div> <ha-icon-button ="${this._clearValue}" .label="${this.deleteLabel||e("ui.common.delete")}" .path="${v}"></ha-icon-button> </div>`):i.qy`<ha-button size="small" appearance="filled" ="${this._openFilePicker}"> <ha-svg-icon slot="start" .path="${this.icon||b}"></ha-svg-icon> ${this.label||e("ui.components.file-upload.label")} </ha-button> <span class="secondary">${this.secondary||e("ui.components.file-upload.secondary")}</span> <span class="supports">${this.supports}</span>`} <input id="input" type="file" class="file" .accept="${this.accept}" .multiple="${this.multiple}" ="${this._handleFilePicked}"></label>`} `}_openFilePicker(){this._input?.click()}_handleDrop(e){e.preventDefault(),e.stopPropagation(),e.dataTransfer?.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}}y.styles=i.AH`: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})],y.prototype,"hass",void 0),(0,o.Cg)([(0,r.MZ)({attribute:!1})],y.prototype,"localize",void 0),(0,o.Cg)([(0,r.MZ)()],y.prototype,"accept",void 0),(0,o.Cg)([(0,r.MZ)()],y.prototype,"icon",void 0),(0,o.Cg)([(0,r.MZ)()],y.prototype,"label",void 0),(0,o.Cg)([(0,r.MZ)()],y.prototype,"secondary",void 0),(0,o.Cg)([(0,r.MZ)({attribute:"uploading-label"})],y.prototype,"uploadingLabel",void 0),(0,o.Cg)([(0,r.MZ)({attribute:"delete-label"})],y.prototype,"deleteLabel",void 0),(0,o.Cg)([(0,r.MZ)()],y.prototype,"supports",void 0),(0,o.Cg)([(0,r.MZ)({type:Object})],y.prototype,"value",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"multiple",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean,reflect:!0})],y.prototype,"disabled",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean})],y.prototype,"uploading",void 0),(0,o.Cg)([(0,r.MZ)({type:Number})],y.prototype,"progress",void 0),(0,o.Cg)([(0,r.MZ)({type:Boolean,attribute:"auto-open-file-dialog"})],y.prototype,"autoOpenFileDialog",void 0),(0,o.Cg)([(0,r.wk)()],y.prototype,"_drag",void 0),(0,o.Cg)([(0,r.P)("#input")],y.prototype,"_input",void 0),y=(0,o.Cg)([(0,r.EM)("ha-file-upload")],y),t()}catch(e){t(e)}})},83336(e,t,a){a.a(e,async function(e,o){try{a.r(t);var i=a(62826),r=a(5124),l=a(22441),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),y=e([s,n,p,u]);[s,n,p,u]=y.then?(await y)():y;const f="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 m extends r.WF{render(){return r.qy` <ha-icon-button-arrow-prev .label="${this.localize("ui.panel.page-onboarding.restore.back")}" ="${this._back}"></ha-icon-button-arrow-prev> <h1> ${this.localize("ui.panel.page-onboarding.restore.upload_backup")} </h1> <p> ${this.localize("ui.panel.page-onboarding.restore.upload_backup_subtitle")} </p> ${this._error?r.qy`<ha-alert alert-type="error">${this._error}</ha-alert>`:r.s6} <ha-file-upload .uploading="${this._uploading}" .icon="${f}" accept="${u.xN}" .localize="${this.localize}" .label="${this.localize("ui.panel.page-onboarding.restore.upload_input_label")}" .secondary="${this.localize("ui.panel.page-onboarding.restore.upload_secondary")}" .supports="${this.localize("ui.panel.page-onboarding.restore.upload_supports_tar")}" .deleteLabel="${this.localize("ui.panel.page-onboarding.restore.delete")}" .uploadingLabel="${this.localize("ui.panel.page-onboarding.restore.uploading")}" -picked="${this._filePicked}"></ha-file-upload> `}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(e){this._error="string"==typeof e.body?e.body:e.body?.message||e.message||"Unknown error occurred"}}_back(){(0,v.oo)(`${location.pathname}?${(0,b.s8)("page")}`)}static get styles(){return[g.o,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})],m.prototype,"supervisor",void 0),(0,i.Cg)([(0,l.MZ)({attribute:!1})],m.prototype,"localize",void 0),(0,i.Cg)([(0,l.wk)()],m.prototype,"_uploading",void 0),(0,i.Cg)([(0,l.wk)()],m.prototype,"_error",void 0),m=(0,i.Cg)([(0,l.EM)("onboarding-restore-backup-upload")],m),o()}catch(e){o(e)}})},46187(e,t,a){a.d(t,{A:()=>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]}`}}};