UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

2 lines 3.17 kB
export const __webpack_ids__=["47473"];export const __webpack_modules__={74564:function(t,o,e){e.d(o,{Z:()=>n});const i=t=>{const o=parseFloat(t);if(isNaN(o))throw new Error(`${t} is not a number`);return o};function n(t){if(!t)return null;try{if(t.endsWith("%"))return{w:100,h:i(t.substr(0,t.length-1))};const o=t.replace(":","x").split("x");return 0===o.length?null:1===o.length?{w:i(o[0]),h:1}:{w:i(o[0]),h:i(o[1])}}catch(t){}return null}},28528:function(t,o,e){e.r(o),e.d(o,{HuiIframeCard:()=>d});var i=e(44249),n=(e(75656),e(50100),e(18084),e(57243)),r=e(15093),a=e(20552),l=e(69634),s=e(74564),c=(e(99426),e(54977),e(39583));let d=(0,i.Z)([(0,r.Mo)("hui-iframe-card")],(function(t,o){return{F:class extends o{constructor(...o){super(...o),t(this)}},d:[{kind:"method",static:!0,key:"getConfigElement",value:async function(){return await e.e("67521").then(e.bind(e,2849)),document.createElement("hui-iframe-card-editor")}},{kind:"method",static:!0,key:"getStubConfig",value:function(){return{type:"iframe",url:"https://www.home-assistant.io",aspect_ratio:"50%"}}},{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"layout",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_config",value:void 0},{kind:"method",key:"getCardSize",value:function(){if(!this._config)return 5;return 1+(this._config.aspect_ratio?Number(this._config.aspect_ratio.replace("%","")):50)/25}},{kind:"method",key:"setConfig",value:function(t){if(!t.url)throw new Error("URL required");this._config=t}},{kind:"method",key:"render",value:function(){if(!this._config||!this.hass)return n.Ld;let t="";if(!("panel"===this.layout||"grid"===this.layout))if(this._config.aspect_ratio){const o=(0,s.Z)(this._config.aspect_ratio);o&&o.w>0&&o.h>0&&(t=`${(100*o.h/o.w).toFixed(2)}%`)}else t="50%";const o=new URL(this._config.url,location.toString()).protocol;if("https:"===location.protocol&&"https:"!==o)return n.dy` <ha-alert alert-type="error"> ${this.hass.localize("ui.panel.lovelace.cards.iframe.error_secure_context",{target_protocol:o,context_protocol:location.protocol})} </ha-alert> `;let e="";this._config.allow_open_top_navigation&&(e+="allow-top-navigation-by-user-activation");const i=this._config.disable_sandbox?void 0:`${e} ${c.A}`;return n.dy` <ha-card .header="${this._config.title}"> <div id="root" style="${(0,l.V)({"padding-top":t})}"> <iframe title="${(0,a.o)(this._config.title)}" src="${this._config.url}" sandbox="${(0,a.o)(i)}" allow="${this._config.allow??"fullscreen"}"></iframe> </div> </ha-card> `}},{kind:"method",key:"getGridOptions",value:function(){return{columns:"full",rows:4,min_columns:3,min_rows:2}}},{kind:"field",static:!0,key:"styles",value:()=>n.iv`ha-card{overflow:hidden;width:100%;height:100%;display:flex;flex-direction:column}#root{width:100%;height:100%;position:relative}iframe{position:absolute;border:none;width:100%;height:100%;top:0;left:0}`}]}}),n.oi)},39583:function(t,o,e){e.d(o,{A:()=>i});const i="allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-modals allow-downloads"}}; //# sourceMappingURL=47473.6c5b81aa77ef974f.js.map