Files
supervisor/supervisor/api/panel/chunk.fbeedc21f0dfe1202da0.js
2020-05-08 13:58:20 +02:00

2 lines
19 KiB
JavaScript

(self.webpackJsonp=self.webpackJsonp||[]).push([[4],{197:function(e,t,n){"use strict";n.r(t);n(17);var r=n(16),o=(n(44),n(6)),i=n(88);n(23);"".concat(location.protocol,"//").concat(location.host);var s=n(125),a=n(10);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(){var e=g(["\n paper-checkbox {\n display: block;\n margin: 4px;\n }\n .details {\n color: var(--secondary-text-color);\n }\n .warning,\n .error {\n color: var(--google-red-500);\n }\n .buttons {\n display: flex;\n flex-direction: column;\n }\n .buttons li {\n list-style-type: none;\n }\n .buttons .icon {\n margin-right: 16px;\n }\n .no-margin-top {\n margin-top: 0;\n }\n "]);return l=function(){return e},e}function u(){var e=g(["\n <mwc-button\n @click=",'\n slot="secondaryAction"\n >\n <ha-svg-icon path=',' class="icon"></ha-svg-icon>\n Wipe &amp; restore\n </mwc-button>\n ']);return u=function(){return e},e}function d(){var e=g([' <p class="error">Error: ',"</p> "]);return d=function(){return e},e}function h(){var e=g(['\n <paper-input\n autofocus=""\n label="Password"\n type="password"\n @value-changed=',"\n .value=","\n ></paper-input>\n "]);return h=function(){return e},e}function p(){var e=g(["\n <paper-checkbox\n .checked=",'\n @change="','"\n >\n ',"\n </paper-checkbox>\n "]);return p=function(){return e},e}function f(){var e=g(['\n <div>Add-on:</div>\n <paper-dialog-scrollable class="no-margin-top">\n ',"\n </paper-dialog-scrollable>\n "]);return f=function(){return e},e}function m(){var e=g(["\n <paper-checkbox\n .checked=",'\n @change="','"\n >\n ',"\n </paper-checkbox>\n "]);return m=function(){return e},e}function v(){var e=g(['\n <div>Folders:</div>\n <paper-dialog-scrollable class="no-margin-top">\n ',"\n </paper-dialog-scrollable>\n "]);return v=function(){return e},e}function y(){var e=g(["\n <ha-dialog\n open\n stacked\n @closing=","\n .heading=",'\n >\n <div class="details">\n ',"\n (",")<br />\n ","\n </div>\n <div>Home Assistant:</div>\n <paper-checkbox\n .checked=",'\n @change="','"\n >\n Home Assistant ',"\n </paper-checkbox>\n ","\n ","\n ","\n ","\n\n <div>Actions:</div>\n\n <mwc-button @click=",' slot="primaryAction">\n <ha-svg-icon path=',' class="icon"></ha-svg-icon>\n Download Snapshot\n </mwc-button>\n\n <mwc-button\n @click=','\n slot="secondaryAction"\n >\n <ha-svg-icon path=',' class="icon"></ha-svg-icon>\n Restore Selected\n </mwc-button>\n ',"\n <mwc-button @click=",' slot="secondaryAction">\n <ha-svg-icon path=',' class="icon warning"></ha-svg-icon>\n <span class="warning">Delete Snapshot</span>\n </mwc-button>\n </ha-dialog>\n ']);return y=function(){return e},e}function k(){var e=g([""]);return k=function(){return e},e}function g(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function b(e,t,n,r,o,i,s){try{var a=e[i](s),c=a.value}catch(l){return void n(l)}a.done?t(c):Promise.resolve(c).then(r,o)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function s(e){b(i,r,o,s,a,"next",e)}function a(e){b(i,r,o,s,a,"throw",e)}s(void 0)})}}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function E(e){return function(){var t,n=P(e);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var r=P(this).constructor;t=Reflect.construct(n,arguments,r)}else t=n.apply(this,arguments);return function(e,t){if(t&&("object"===c(t)||"function"==typeof t))return t;return O(e)}(this,t)}}function O(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e){var t,n=C(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function A(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function S(e){return e.decorators&&e.decorators.length}function D(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function x(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function C(e){var t=function(e,t){if("object"!==c(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===c(t)?t:String(t)}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}!function(e,t,n,r){var o=function(){var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach(function(n){t.forEach(function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)},this)},this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach(function(r){t.forEach(function(t){var o=t.placement;if(t.kind===r&&("static"===o||"prototype"===o)){var i="static"===o?e:n;this.defineClassElement(i,t)}},this)},this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],o={static:[],prototype:[],own:[]};if(e.forEach(function(e){this.addElementPlacement(e,o)},this),e.forEach(function(e){if(!S(e))return n.push(e);var t=this.decorateElement(e,o);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)},this),!t)return{elements:n,finishers:r};var i=this.decorateConstructor(n,t);return r.push.apply(r,i.finishers),i.finishers=r,i},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],o=e.decorators,i=o.length-1;i>=0;i--){var s=t[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,o[i])(a)||a);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var o=this.fromClassDescriptor(e),i=this.toClassDescriptor((0,t[r])(o)||o);if(void 0!==i.finisher&&n.push(i.finisher),void 0!==i.elements){e=i.elements;for(var s=0;s<e.length-1;s++)for(var a=s+1;a<e.length;a++)if(e[s].key===e[a].key&&e[s].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[s].key+")")}}return{elements:e,finishers:n}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return T(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map(function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t},this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var n=C(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+r+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var i={kind:t,key:n,placement:r,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),i.initializer=e.initializer),i},toElementFinisherExtras:function(e){var t=this.toElementDescriptor(e),n=x(e,"finisher"),r=this.toElementDescriptors(e.extras);return{element:t,finisher:n,extras:r}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var n=x(e,"finisher"),r=this.toElementDescriptors(e.elements);return{elements:r,finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}();if(r)for(var i=0;i<r.length;i++)o=r[i](o);var s=t(function(e){o.initializeInstanceElements(e,a.elements)},n),a=o.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===i.key&&e.placement===i.placement},r=0;r<e.length;r++){var o,i=e[r];if("method"===i.kind&&(o=t.find(n)))if(D(i.descriptor)||D(o.descriptor)){if(S(i)||S(o))throw new ReferenceError("Duplicated methods ("+i.key+") can't be decorated.");o.descriptor=i.descriptor}else{if(S(i)){if(S(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+i.key+").");o.decorators=i.decorators}A(i,o)}else t.push(i)}return t}(s.d.map(j)),e);o.initializeClassElements(s.F,a.elements),o.runClassFinishers(s.F,a.finishers)}([Object(o.d)("dialog-hassio-snapshot")],function(e,t){return{F:function(n){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}(o,t);var r=E(o);function o(){var t;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,o);for(var n=arguments.length,i=new Array(n),s=0;s<n;s++)i[s]=arguments[s];return t=r.call.apply(r,[this].concat(i)),e(O(t)),t}return o}(),d:[{kind:"field",decorators:[Object(o.f)()],key:"hass",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_error",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_snapshot",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_folders",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_addons",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_dialogParams",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_snapshotPassword",value:void 0},{kind:"field",decorators:[Object(o.f)()],key:"_restoreHass",value:function(){return!0}},{kind:"method",key:"showDialog",value:function(){var e=w(regeneratorRuntime.mark(function e(t){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Object(s.c)(this.hass,t.slug);case 2:this._snapshot=e.sent,this._folders=(r=this._snapshot.folders,o=void 0,o=[],r.includes("homeassistant")&&o.push({slug:"homeassistant",name:"Home Assistant configuration",checked:!0}),r.includes("ssl")&&o.push({slug:"ssl",name:"SSL",checked:!0}),r.includes("share")&&o.push({slug:"share",name:"Share",checked:!0}),r.includes("addons/local")&&o.push({slug:"addons/local",name:"Local add-ons",checked:!0}),o).sort(function(e,t){return e.name>t.name?1:-1}),this._addons=(n=this._snapshot.addons,n.map(function(e){return{slug:e.slug,name:e.name,version:e.version,checked:!0}})).sort(function(e,t){return e.name>t.name?1:-1}),this._dialogParams=t;case 6:case"end":return e.stop()}var n,r,o},e,this)}));return function(t){return e.apply(this,arguments)}}()},{kind:"method",key:"render",value:function(){var e=this;return this._dialogParams&&this._snapshot?Object(o.e)(y(),this._closeDialog,Object(i.a)(this.hass,this._computeName),"full"===this._snapshot.type?"Full snapshot":"Partial snapshot",this._computeSize,this._formatDatetime(this._snapshot.date),this._restoreHass,function(t){e._restoreHass=t.target.checked},this._snapshot.homeassistant,this._folders.length?Object(o.e)(v(),this._folders.map(function(t){return Object(o.e)(m(),t.checked,function(n){return e._updateFolders(t,n.target.checked)},t.name)})):"",this._addons.length?Object(o.e)(f(),this._addons.map(function(t){return Object(o.e)(p(),t.checked,function(n){return e._updateAddons(t,n.target.checked)},t.name)})):"",this._snapshot.protected?Object(o.e)(h(),this._passwordInput,this._snapshotPassword):"",this._error?Object(o.e)(d(),this._error):"",this._downloadClicked,r.n,this._partialRestoreClicked,r.s,"full"===this._snapshot.type?Object(o.e)(u(),this._fullRestoreClicked,r.s):"",this._deleteClicked,r.k):Object(o.e)(k())}},{kind:"get",static:!0,key:"styles",value:function(){return[a.c,Object(o.c)(l())]}},{kind:"method",key:"_updateFolders",value:function(e,t){this._folders=this._folders.map(function(n){return n.slug===e.slug&&(n.checked=t),n})}},{kind:"method",key:"_updateAddons",value:function(e,t){this._addons=this._addons.map(function(n){return n.slug===e.slug&&(n.checked=t),n})}},{kind:"method",key:"_passwordInput",value:function(e){this._snapshotPassword=e.detail.value}},{kind:"method",key:"_partialRestoreClicked",value:function(){var e=this;if(confirm("Are you sure you want to restore this snapshot?")){var t=this._addons.filter(function(e){return e.checked}).map(function(e){return e.slug}),n=this._folders.filter(function(e){return e.checked}).map(function(e){return e.slug}),r={homeassistant:this._restoreHass,addons:t,folders:n};this._snapshot.protected&&(r.password=this._snapshotPassword),this.hass.callApi("POST","hassio/snapshots/".concat(this._snapshot.slug,"/restore/partial"),r).then(function(){alert("Snapshot restored!"),e._closeDialog()},function(t){e._error=t.body.message})}}},{kind:"method",key:"_fullRestoreClicked",value:function(){var e=this;if(confirm("Are you sure you want to restore this snapshot?")){var t=this._snapshot.protected?{password:this._snapshotPassword}:void 0;this.hass.callApi("POST","hassio/snapshots/".concat(this._snapshot.slug,"/restore/full"),t).then(function(){alert("Snapshot restored!"),e._closeDialog()},function(t){e._error=t.body.message})}}},{kind:"method",key:"_deleteClicked",value:function(){var e=this;confirm("Are you sure you want to delete this snapshot?")&&this.hass.callApi("POST","hassio/snapshots/".concat(this._snapshot.slug,"/remove")).then(function(){e._dialogParams.onDelete(),e._closeDialog()},function(t){e._error=t.body.message})}},{kind:"method",key:"_downloadClicked",value:function(){var e=w(regeneratorRuntime.mark(function e(){var t,n,r;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o=this.hass,i="/api/hassio/snapshots/".concat(this._snapshot.slug,"/download"),o.callWS({type:"auth/sign_path",path:i});case 3:t=e.sent,e.next=10;break;case 6:return e.prev=6,e.t0=e.catch(0),alert("Error: ".concat(e.t0.message)),e.abrupt("return");case 10:n=this._computeName.replace(/[^a-z0-9]+/gi,"_"),(r=document.createElement("a")).href=t.path,r.download="Hass_io_".concat(n,".tar"),this.shadowRoot.appendChild(r),r.click(),this.shadowRoot.removeChild(r);case 17:case"end":return e.stop()}var o,i},e,this,[[0,6]])}));return function(){return e.apply(this,arguments)}}()},{kind:"get",key:"_computeName",value:function(){return this._snapshot?this._snapshot.name||this._snapshot.slug:"Unnamed snapshot"}},{kind:"get",key:"_computeSize",value:function(){return Math.ceil(10*this._snapshot.size)/10+" MB"}},{kind:"method",key:"_formatDatetime",value:function(e){return new Date(e).toLocaleDateString(navigator.language,{weekday:"long",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}},{kind:"method",key:"_closeDialog",value:function(){this._dialogParams=void 0,this._snapshot=void 0,this._snapshotPassword="",this._folders=[],this._addons=[]}}]}},o.a)}}]);
//# sourceMappingURL=chunk.fbeedc21f0dfe1202da0.js.map