iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
26 lines • 14.7 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[612],{69470:(e,t,r)=>{"use strict";r.d(t,{j:()=>o,fs:()=>s,$y:()=>n});const i=(e,t,r)=>new Promise(((i,o)=>{const s=document.createElement(e);let n="src",a="body";switch(s.onload=()=>i(t),s.onerror=()=>o(t),e){case"script":s.async=!0,r&&(s.type=r);break;case"link":s.type="text/css",s.rel="stylesheet",n="href",a="head"}s[n]=t,document[a].appendChild(s)})),o=e=>i("link",e),s=e=>i("script",e),n=e=>i("script",e,"module")},85415:(e,t,r)=>{"use strict";r.d(t,{q:()=>i,w:()=>o});const i=(e,t)=>e<t?-1:e>t?1:0,o=(e,t)=>i(e.toLowerCase(),t.toLowerCase())},15327:(e,t,r)=>{"use strict";r.d(t,{eL:()=>i,SN:()=>o,id:()=>s,fg:()=>n,j2:()=>a,JR:()=>l,Y:()=>c,iM:()=>d,Q2:()=>u,Oh:()=>p,vj:()=>h,Gc:()=>f});const i=e=>e.sendMessagePromise({type:"lovelace/resources"}),o=(e,t)=>e.callWS({type:"lovelace/resources/create",...t}),s=(e,t,r)=>e.callWS({type:"lovelace/resources/update",resource_id:t,...r}),n=(e,t)=>e.callWS({type:"lovelace/resources/delete",resource_id:t}),a=e=>e.callWS({type:"lovelace/dashboards/list"}),l=(e,t)=>e.callWS({type:"lovelace/dashboards/create",...t}),c=(e,t,r)=>e.callWS({type:"lovelace/dashboards/update",dashboard_id:t,...r}),d=(e,t)=>e.callWS({type:"lovelace/dashboards/delete",dashboard_id:t}),u=(e,t,r)=>e.sendMessagePromise({type:"lovelace/config",url_path:t,force:r}),p=(e,t,r)=>e.callWS({type:"lovelace/config/save",url_path:t,config:r}),h=(e,t)=>e.callWS({type:"lovelace/config/delete",url_path:t}),f=(e,t,r)=>e.subscribeEvents((e=>{e.data.url_path===t&&r()}),"lovelace_updated")},26765:(e,t,r)=>{"use strict";r.d(t,{Ys:()=>n,g7:()=>a,D9:()=>l});var i=r(47181);const o=()=>Promise.all([r.e(8941),r.e(879),r.e(6372),r.e(6547),r.e(6509),r.e(7230)]).then(r.bind(r,1281)),s=(e,t,r)=>new Promise((s=>{const n=t.cancel,a=t.confirm;(0,i.B)(e,"show-dialog",{dialogTag:"dialog-box",dialogImport:o,dialogParams:{...t,...r,cancel:()=>{s(!!(null==r?void 0:r.prompt)&&null),n&&n()},confirm:e=>{s(!(null==r?void 0:r.prompt)||e),a&&a(e)}}})})),n=(e,t)=>s(e,t),a=(e,t)=>s(e,t,{confirmation:!0}),l=(e,t)=>s(e,t,{prompt:!0})},47917:(e,t,r)=>{"use strict";r.r(t),r.d(t,{HaConfigLovelaceRescources:()=>_});r(29119);var i=r(55317),o=(r(32296),r(8878),r(25782),r(51095),r(15652)),s=r(14516),n=r(85415),a=(r(16509),r(52039),r(15327)),l=r(26765),c=(r(15291),r(96551),r(68500)),d=r(52730),u=r(47181);const p=()=>Promise.all([r.e(6372),r.e(7407)]).then(r.bind(r,75682));function h(){h=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var o=t.placement;if(t.kind===i&&("static"===o||"prototype"===o)){var s="static"===o?e:r;this.defineClassElement(s,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],o={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,o)}),this),e.forEach((function(e){if(!v(e))return r.push(e);var t=this.decorateElement(e,o);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var s=this.decorateConstructor(r,t);return i.push.apply(i,s.finishers),s.finishers=i,s},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],o=e.decorators,s=o.length-1;s>=0;s--){var n=t[e.placement];n.splice(n.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[s])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var o=this.fromClassDescriptor(e),s=this.toClassDescriptor((0,t[i])(o)||o);if(void 0!==s.finisher&&r.push(s.finisher),void 0!==s.elements){e=s.elements;for(var n=0;n<e.length-1;n++)for(var a=n+1;a<e.length;a++)if(e[n].key===e[a].key&&e[n].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[n].key+")")}}return{elements:e,finishers:r}},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 k(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(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 r=b(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)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 "'+i+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var s={kind:t,key:r,placement:i,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"),s.initializer=e.initializer),s},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:g(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},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 r=g(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function f(e){var t,r=b(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 i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function m(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function v(e){return e.decorators&&e.decorators.length}function y(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function g(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function b(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function k(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function w(e,t,r){return(w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=E(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(r):o.value}})(e,t,r||e)}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}let _=function(e,t,r,i){var o=h();if(i)for(var s=0;s<i.length;s++)o=i[s](o);var n=t((function(e){o.initializeInstanceElements(e,a.elements)}),r),a=o.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===s.key&&e.placement===s.placement},i=0;i<e.length;i++){var o,s=e[i];if("method"===s.kind&&(o=t.find(r)))if(y(s.descriptor)||y(o.descriptor)){if(v(s)||v(o))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");o.descriptor=s.descriptor}else{if(v(s)){if(v(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");o.decorators=s.decorators}m(s,o)}else t.push(s)}return t}(n.d.map(f)),e);return o.initializeClassElements(n.F,a.elements),o.runClassFinishers(n.F,a.finishers)}([(0,o.Mo)("ha-config-lovelace-resources")],(function(e,t){class r extends t{constructor(...t){super(...t),e(this)}}return{F:r,d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.Cb)()],key:"isWide",value:void 0},{kind:"field",decorators:[(0,o.Cb)()],key:"narrow",value:void 0},{kind:"field",decorators:[(0,o.Cb)()],key:"route",value:void 0},{kind:"field",decorators:[(0,o.sz)()],key:"_resources",value:()=>[]},{kind:"field",key:"_columns",value(){return(0,s.Z)((e=>({url:{title:this.hass.localize("ui.panel.config.lovelace.resources.picker.headers.url"),sortable:!0,filterable:!0,direction:"asc",grows:!0,forceLTR:!0},type:{title:this.hass.localize("ui.panel.config.lovelace.resources.picker.headers.type"),sortable:!0,filterable:!0,width:"30%",template:e=>o.dy`
${this.hass.localize("ui.panel.config.lovelace.resources.types."+e)||e}
`}})))}},{kind:"method",key:"render",value:function(){return this.hass&&void 0!==this._resources?o.dy`
<hass-tabs-subpage-data-table
.hass=${this.hass}
.narrow=${this.narrow}
back-path="/config"
.route=${this.route}
.tabs=${d.lovelaceTabs}
.columns=${this._columns(this.hass.language)}
.data=${this._resources}
.noDataText=${this.hass.localize("ui.panel.config.lovelace.resources.picker.no_resources")}
@row-click=${this._editResource}
hasFab
clickable
>
<mwc-fab
slot="fab"
title=${this.hass.localize("ui.panel.config.lovelace.resources.picker.add_resource")}
@click=${this._addResource}
>
<ha-svg-icon slot="icon" .path=${i.qX5}></ha-svg-icon>
</mwc-fab>
</hass-tabs-subpage-data-table>
`:o.dy` <hass-loading-screen></hass-loading-screen> `}},{kind:"method",key:"firstUpdated",value:function(e){w(E(r.prototype),"firstUpdated",this).call(this,e),this._getResources()}},{kind:"method",key:"_getResources",value:async function(){this._resources=await(0,a.eL)(this.hass.connection)}},{kind:"method",key:"_editResource",value:function(e){var t,r;if("storage"!==(null===(t=this.hass.panels.lovelace)||void 0===t||null===(r=t.config)||void 0===r?void 0:r.mode))return void(0,l.Ys)(this,{text:this.hass.localize("ui.panel.config.lovelace.resources.cant_edit_yaml")});const i=e.detail.id,o=this._resources.find((e=>e.id===i));this._openDialog(o)}},{kind:"method",key:"_addResource",value:function(){var e,t;"storage"===(null===(e=this.hass.panels.lovelace)||void 0===e||null===(t=e.config)||void 0===t?void 0:t.mode)?this._openDialog():(0,l.Ys)(this,{text:this.hass.localize("ui.panel.config.lovelace.resources.cant_edit_yaml")})}},{kind:"method",key:"_openDialog",value:async function(e){var t,r;t=this,r={resource:e,createResource:async e=>{const t=await(0,a.SN)(this.hass,e);this._resources=this._resources.concat(t).sort(((e,t)=>(0,n.q)(e.url,t.url))),(0,c.k)([t],this.hass.auth.data.hassUrl)},updateResource:async t=>{const r=await(0,a.id)(this.hass,e.id,t);this._resources=this._resources.map((t=>t===e?r:t)),(0,c.k)([r],this.hass.auth.data.hassUrl)},removeResource:async()=>{if(!(await(0,l.g7)(this,{text:this.hass.localize("ui.panel.config.lovelace.resources.confirm_delete")})))return!1;try{return await(0,a.fg)(this.hass,e.id),this._resources=this._resources.filter((t=>t!==e)),(0,l.g7)(this,{title:this.hass.localize("ui.panel.config.lovelace.resources.refresh_header"),text:this.hass.localize("ui.panel.config.lovelace.resources.refresh_body"),confirm:()=>location.reload()}),!0}catch(t){return!1}}},(0,u.B)(t,"show-dialog",{dialogTag:"dialog-lovelace-resource-detail",dialogImport:p,dialogParams:r})}}]}}),o.oi)},68500:(e,t,r)=>{"use strict";r.d(t,{k:()=>n});var i=r(69470);const o={},s={},n=(e,t)=>e.forEach((e=>{const r=new URL(e.url,t).toString();switch(e.type){case"css":if(r in o)break;o[r]=(0,i.j)(r);break;case"js":if(r in s)break;s[r]=(0,i.fs)(r);break;case"module":(0,i.$y)(r);break;default:console.warn("Unknown resource type specified: "+e.type)}}))}}]);
//# sourceMappingURL=chunk.48ed2a7b85a15ef29457.js.map