mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-11-08 18:39:33 +00:00
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[1327],{13547:function(e,t,i){i.d(t,{d:function(){return a}});var a=function(e){switch(e.language){case"cz":case"de":case"fi":case"fr":case"sk":case"sv":return" ";default:return""}}},99535:function(e,t,i){var a,n=i(6238),r=i(36683),o=i(89231),l=i(29864),s=i(83647),c=i(8364),u=(i(77052),i(58068)),d=i(98597),p=i(196),h=i(75538);(0,c.A)([(0,p.EM)("ha-button")],(function(e,t){var i=function(t){function i(){var t;(0,o.A)(this,i);for(var a=arguments.length,n=new Array(a),r=0;r<a;r++)n[r]=arguments[r];return t=(0,l.A)(this,i,[].concat(n)),e(t),t}return(0,s.A)(i,t),(0,r.A)(i)}(t);return{F:i,d:[{kind:"field",static:!0,key:"styles",value:function(){return[h.R,(0,d.AH)(a||(a=(0,n.A)(["::slotted([slot=icon]){margin-inline-start:0px;margin-inline-end:8px;direction:var(--direction);display:block}.mdc-button{height:var(--button-height,36px)}.trailing-icon{display:flex}.slot-container{overflow:var(--button-slot-container-overflow,visible)}"])))]}}]}}),u.$)},23011:function(e,t,i){var a=i(1781).A,n=i(94881).A;i.a(e,function(){var e=a(n().mark((function e(t,a){var r,o,l,s,c,u,d,p,h,v,f,g,k,m,y,b,x,A,_,w,M,F,H,Z,z,V,B,D,P,C,L,E,q,T,j,O;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,r=i(6238),o=i(36683),l=i(89231),s=i(29864),c=i(83647),u=i(8364),d=i(76504),p=i(80792),h=i(77052),v=i(35848),f=i(36724),g=i(848),k=i(650),m=i(68113),y=i(58971),b=i(56262),x=i(98168),A=i(18971),_=i(98597),w=i(196),M=i(69760),F=i(77664),i(99535),i(72214),H=i(13547),Z=i(68286),z=i(10826),!(V=t([A])).then){e.next=45;break}return e.next=41,V;case 41:e.t1=e.sent,e.t0=(0,e.t1)(),e.next=46;break;case 45:e.t0=V;case 46:A=e.t0[0],j="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",O="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",(0,u.A)([(0,w.EM)("ha-file-upload")],(function(e,t){var i=function(t){function i(){var t;(0,l.A)(this,i);for(var a=arguments.length,n=new Array(a),r=0;r<a;r++)n[r]=arguments[r];return t=(0,s.A)(this,i,[].concat(n)),e(t),t}return(0,c.A)(i,t),(0,o.A)(i)}(t);return{F:i,d:[{kind:"field",decorators:[(0,w.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,w.MZ)()],key:"accept",value:void 0},{kind:"field",decorators:[(0,w.MZ)()],key:"icon",value:void 0},{kind:"field",decorators:[(0,w.MZ)()],key:"label",value:void 0},{kind:"field",decorators:[(0,w.MZ)()],key:"secondary",value:void 0},{kind:"field",decorators:[(0,w.MZ)()],key:"supports",value:void 0},{kind:"field",decorators:[(0,w.MZ)({type:Object})],key:"value",value:void 0},{kind:"field",decorators:[(0,w.MZ)({type:Boolean})],key:"multiple",value:function(){return!1}},{kind:"field",decorators:[(0,w.MZ)({type:Boolean,reflect:!0})],key:"disabled",value:function(){return!1}},{kind:"field",decorators:[(0,w.MZ)({type:Boolean})],key:"uploading",value:function(){return!1}},{kind:"field",decorators:[(0,w.MZ)({type:Number})],key:"progress",value:void 0},{kind:"field",decorators:[(0,w.MZ)({type:Boolean,attribute:"auto-open-file-dialog"})],key:"autoOpenFileDialog",value:function(){return!1}},{kind:"field",decorators:[(0,w.wk)()],key:"_drag",value:function(){return!1}},{kind:"field",decorators:[(0,w.P)("#input")],key:"_input",value:void 0},{kind:"method",key:"firstUpdated",value:function(e){(0,d.A)((0,p.A)(i.prototype),"firstUpdated",this).call(this,e),this.autoOpenFileDialog&&this._openFilePicker()}},{kind:"method",key:"render",value:function(){var e,t,i,a,n,o=this;return(0,_.qy)(B||(B=(0,r.A)([" "," "])),this.uploading?(0,_.qy)(D||(D=(0,r.A)(['<div class="container"> <div class="row"> <span class="header">',"</span> ",' </div> <mwc-linear-progress .indeterminate="','" .progress="','"></mwc-linear-progress> </div>'])),this.value?null===(e=this.hass)||void 0===e?void 0:e.localize("ui.components.file-upload.uploading_name",{name:this.value.toString()}):null===(t=this.hass)||void 0===t?void 0:t.localize("ui.components.file-upload.uploading"),this.progress?(0,_.qy)(P||(P=(0,r.A)(['<span class="progress">',"","%</span>"])),this.progress,(0,H.d)(this.hass.locale)):"",!this.progress,this.progress?this.progress/100:void 0):(0,_.qy)(C||(C=(0,r.A)(['<label for="','" class="container ','" @drop="','" @dragenter="','" @dragover="','" @dragleave="','" @dragend="','">',' <input id="input" type="file" class="file" .accept="','" .multiple="','" @change="','"></label>'])),this.value?"":"input",(0,M.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,_.qy)(E||(E=(0,r.A)(['<div class="row"> <div class="value" @click="','"> <ha-svg-icon .path="','"></ha-svg-icon> ',' </div> <ha-icon-button @click="','" .label="','" .path="','"></ha-icon-button> </div>'])),this._openFilePicker,this.icon||O,this.value,this._clearValue,(null===(n=this.hass)||void 0===n?void 0:n.localize("ui.common.delete"))||"Delete",j):(this.value instanceof FileList?Array.from(this.value):(0,Z.e)(this.value)).map((function(e){var t;return(0,_.qy)(q||(q=(0,r.A)(['<div class="row"> <div class="value" @click="','"> <ha-svg-icon .path="','"></ha-svg-icon> '," - ",' </div> <ha-icon-button @click="','" .label="','" .path="','"></ha-icon-button> </div>'])),o._openFilePicker,o.icon||O,e.name,(0,z.A)(e.size),o._clearValue,(null===(t=o.hass)||void 0===t?void 0:t.localize("ui.common.delete"))||"Delete",j)})):(0,_.qy)(L||(L=(0,r.A)(['<ha-svg-icon class="big-icon" .path="','"></ha-svg-icon> <ha-button unelevated @click="','"> ',' </ha-button> <span class="secondary">','</span> <span class="supports">',"</span>"])),this.icon||O,this._openFilePicker,this.label||(null===(i=this.hass)||void 0===i?void 0:i.localize("ui.components.file-upload.label")),this.secondary||(null===(a=this.hass)||void 0===a?void 0:a.localize("ui.components.file-upload.secondary")),this.supports),this.accept,this.multiple,this._handleFilePicked))}},{kind:"method",key:"_openFilePicker",value:function(){var e;null===(e=this._input)||void 0===e||e.click()}},{kind:"method",key:"_handleDrop",value:function(e){var t;e.preventDefault(),e.stopPropagation(),null!==(t=e.dataTransfer)&&void 0!==t&&t.files&&(0,F.r)(this,"file-picked",{files:this.multiple||1===e.dataTransfer.files.length?Array.from(e.dataTransfer.files):[e.dataTransfer.files[0]]}),this._drag=!1}},{kind:"method",key:"_handleDragStart",value:function(e){e.preventDefault(),e.stopPropagation(),this._drag=!0}},{kind:"method",key:"_handleDragEnd",value:function(e){e.preventDefault(),e.stopPropagation(),this._drag=!1}},{kind:"method",key:"_handleFilePicked",value:function(e){0!==e.target.files.length&&(this.value=e.target.files,(0,F.r)(this,"file-picked",{files:e.target.files}))}},{kind:"method",key:"_clearValue",value:function(e){e.preventDefault(),this._input.value="",this.value=void 0,(0,F.r)(this,"change")}},{kind:"get",static:!0,key:"styles",value:function(){return(0,_.AH)(T||(T=(0,r.A)([':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,4px);height:100%}label.container{border:dashed 1px var(--mdc-text-field-idle-line-color,rgba(0,0,0,.42));cursor:pointer}:host([disabled]) .container{border-color:var(--disabled-color)}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)}.row{display:flex;width:100%;align-items:center;justify-content:space-between;padding:0 16px;box-sizing:border-box}ha-button{margin-bottom:4px}.supports{color:var(--secondary-text-color);font-size:12px}: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}.big-icon{--mdc-icon-size:48px;margin-bottom:8px}ha-button{--mdc-button-outline-color:var(--primary-color);--mdc-icon-button-size:24px}mwc-linear-progress{width:100%;padding:16px;box-sizing:border-box}.header{font-weight:500}.progress{color:var(--secondary-text-color)}'])))}}]}}),_.WF),a(),e.next=56;break;case 53:e.prev=53,e.t2=e.catch(0),a(e.t2);case 56:case"end":return e.stop()}}),e,null,[[0,53]])})));return function(t,i){return e.apply(this,arguments)}}())},61327:function(e,t,i){var a=i(1781).A,n=i(94881).A;i.a(e,function(){var e=a(n().mark((function e(t,a){var r,o,l,s,c,u,d,p,h,v,f,g,k,m,y,b,x,A,_,w,M,F,H,Z,z;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,r=i(94881),o=i(1781),l=i(6238),s=i(36683),c=i(89231),u=i(29864),d=i(83647),p=i(8364),h=i(77052),v=i(53501),f=i(650),g=i(68113),k=i(58971),m=i(98597),y=i(196),b=i(77664),x=i(14126),A=i(47858),_=i(98876),w=i(33319),i(99535),i(75048),M=i(23011),!(F=t([M])).then){e.next=37;break}return e.next=33,F;case 33:e.t1=e.sent,e.t0=(0,e.t1)(),e.next=38;break;case 37:e.t0=F;case 38:M=e.t0[0],(0,p.A)([(0,y.EM)("ha-picture-upload")],(function(e,t){var i,a,n,p,h=function(t){function i(){var t;(0,c.A)(this,i);for(var a=arguments.length,n=new Array(a),r=0;r<a;r++)n[r]=arguments[r];return t=(0,u.A)(this,i,[].concat(n)),e(t),t}return(0,d.A)(i,t),(0,s.A)(i)}(t);return{F:h,d:[{kind:"field",key:"hass",value:void 0},{kind:"field",decorators:[(0,y.MZ)()],key:"value",value:function(){return null}},{kind:"field",decorators:[(0,y.MZ)()],key:"label",value:void 0},{kind:"field",decorators:[(0,y.MZ)()],key:"secondary",value:void 0},{kind:"field",decorators:[(0,y.MZ)()],key:"supports",value:void 0},{kind:"field",decorators:[(0,y.MZ)()],key:"currentImageAltText",value:void 0},{kind:"field",decorators:[(0,y.MZ)({type:Boolean})],key:"crop",value:function(){return!1}},{kind:"field",decorators:[(0,y.MZ)({attribute:!1})],key:"cropOptions",value:void 0},{kind:"field",decorators:[(0,y.MZ)({type:Boolean})],key:"original",value:function(){return!1}},{kind:"field",decorators:[(0,y.MZ)({type:Number})],key:"size",value:function(){return 512}},{kind:"field",decorators:[(0,y.wk)()],key:"_uploading",value:function(){return!1}},{kind:"method",key:"render",value:function(){return this.value?(0,m.qy)(Z||(Z=(0,l.A)(['<div class="center-vertical"> <div class="value"> <img .src="','" alt="','"> <div> <ha-button @click="','" .label="','"> </ha-button> </div> </div> </div>'])),this.value,this.currentImageAltText||this.hass.localize("ui.components.picture-upload.current_image_alt"),this._handleChangeClick,this.hass.localize("ui.components.picture-upload.change_picture")):(0,m.qy)(H||(H=(0,l.A)([' <ha-file-upload .hass="','" .icon="','" .label="','" .secondary="','" .supports="','" .uploading="','" @file-picked="','" @change="','" accept="image/png, image/jpeg, image/gif"></ha-file-upload> '])),this.hass,"M18 15V18H15V20H18V23H20V20H23V18H20V15H18M13.3 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5V13.3C20.4 13.1 19.7 13 19 13C17.9 13 16.8 13.3 15.9 13.9L14.5 12L11 16.5L8.5 13.5L5 18H13.1C13 18.3 13 18.7 13 19C13 19.7 13.1 20.4 13.3 21Z",this.label||this.hass.localize("ui.components.picture-upload.label"),this.secondary,this.supports||this.hass.localize("ui.components.picture-upload.supported_formats"),this._uploading,this._handleFilePicked,this._handleFileCleared)}},{kind:"method",key:"_handleChangeClick",value:function(){this.value=null,(0,b.r)(this,"change")}},{kind:"method",key:"_handleFilePicked",value:(p=(0,o.A)((0,r.A)().mark((function e(t){var i;return(0,r.A)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=t.detail.files[0],this.crop?this._cropFile(i):this._uploadFile(i);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{kind:"method",key:"_handleFileCleared",value:(n=(0,o.A)((0,r.A)().mark((function e(){return(0,r.A)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.value=null;case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{kind:"method",key:"_cropFile",value:(a=(0,o.A)((0,r.A)().mark((function e(t){var i=this;return(0,r.A)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(["image/png","image/jpeg","image/gif"].includes(t.type)){e.next=3;break}return(0,_.K$)(this,{text:this.hass.localize("ui.components.picture-upload.unsupported_format")}),e.abrupt("return");case 3:(0,w.Q)(this,{file:t,options:this.cropOptions||{round:!1,aspectRatio:NaN},croppedCallback:function(e){i._uploadFile(e)}});case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{kind:"method",key:"_uploadFile",value:(i=(0,o.A)((0,r.A)().mark((function e(t){var i;return(0,r.A)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(["image/png","image/jpeg","image/gif"].includes(t.type)){e.next=3;break}return(0,_.K$)(this,{text:this.hass.localize("ui.components.picture-upload.unsupported_format")}),e.abrupt("return");case 3:return this._uploading=!0,e.prev=4,e.next=7,(0,A.mF)(this.hass,t);case 7:i=e.sent,this.value=(0,A.Q0)(i.id,this.size,this.original),(0,b.r)(this,"change"),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(4),(0,_.K$)(this,{text:e.t0.toString()});case 15:return e.prev=15,this._uploading=!1,e.finish(15);case 18:case"end":return e.stop()}}),e,this,[[4,12,15,18]])}))),function(e){return i.apply(this,arguments)})},{kind:"get",static:!0,key:"styles",value:function(){return[x.RF,(0,m.AH)(z||(z=(0,l.A)([":host{display:block;height:240px}ha-file-upload{height:100%}.center-vertical{display:flex;align-items:center;height:100%}.value{width:100%;display:flex;flex-direction:column;align-items:center}img{max-width:100%;max-height:200px;margin-bottom:4px;border-radius:var(--file-upload-image-border-radius)}"])))]}}]}}),m.WF),a(),e.next=47;break;case 44:e.prev=44,e.t2=e.catch(0),a(e.t2);case 47:case"end":return e.stop()}}),e,null,[[0,44]])})));return function(t,i){return e.apply(this,arguments)}}())},47858:function(e,t,i){i.d(t,{Q0:function(){return o},fO:function(){return r},mF:function(){return l}});var a=i(94881),n=i(1781),r=(i(49150),i(27934),i(77052),i(75658),i(848),i(43859),i(97754),"/api/image/serve/"),o=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!i&&!t)throw new Error("Size must be provided if original is false");return i?"/api/image/serve/".concat(e,"/original"):"/api/image/serve/".concat(e,"/").concat(t,"x").concat(t)},l=function(){var e=(0,n.A)((0,a.A)().mark((function e(t,i){var n,r;return(0,a.A)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new FormData).append("file",i),e.next=4,t.fetchWithAuth("/api/image/upload",{method:"POST",body:n});case 4:if(413!==(r=e.sent).status){e.next=9;break}throw new Error("Uploaded image is too large (".concat(i.name,")"));case 9:if(200===r.status){e.next=11;break}throw new Error("Unknown error");case 11:return e.abrupt("return",r.json());case 12:case"end":return e.stop()}}),e)})));return function(t,i){return e.apply(this,arguments)}}()},33319:function(e,t,i){i.d(t,{Q:function(){return r}});i(21950),i(68113),i(55888),i(56262),i(8339);var a=i(77664),n=function(){return Promise.all([i.e(635),i.e(2658),i.e(5894),i.e(3513),i.e(419)]).then(i.bind(i,50419))},r=function(e,t){(0,a.r)(e,"show-dialog",{dialogTag:"image-cropper-dialog",dialogImport:n,dialogParams:t})}},10826:function(e,t,i){i.d(t,{A:function(){return a}});i(77052),i(86150),i(86245);var a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===e)return"0 Bytes";t=t<0?0:t;var i=Math.floor(Math.log(e)/Math.log(1024));return"".concat(parseFloat((e/Math.pow(1024,i)).toFixed(t))," ").concat(["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i])}}}]);
|
|
//# sourceMappingURL=1327.hMoReOHTsOc.js.map
|