UNPKG

iobroker.lovelace

Version:

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

1 lines 18.3 kB
export const __rspack_esm_id=89747;export const __rspack_esm_ids=[89747];export const __webpack_modules__={25995(e,a,t){t.d(a,{Vw:()=>l,kG:()=>i,y6:()=>s});const o=(e,a,t)=>new Promise((o,s)=>{const i=document.createElement(e);let l="src",r="body";switch(i.onload=()=>o(a),i.onerror=()=>s(a),e){case"script":i.async=!0,t&&(i.type=t);break;case"link":i.type="text/css",i.rel="stylesheet",l="href",r="head"}i[l]=a,document[r].appendChild(i)}),s=e=>o("link",e),i=e=>o("script",e),l=e=>o("script",e,"module")},75248(e,a,t){t.a(e,async function(e,o){try{t.r(a),t.d(a,{HaIconOverflowMenu:()=>b});t(18111),t(61701);var s=t(62826),i=(t(68825),t(5124)),l=t(22441),r=t(93421),n=t(57237),d=t(14503),h=t(29823),c=(t(70947),t(26300)),p=(t(67094),t(34127)),u=e([h,c,p]);[h,c,p]=u.then?(await u)():u;const g="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z";class b extends i.WF{render(){return 0===this.items.length?i.s6:i.qy` ${this.narrow?i.qy` <ha-dropdown @wa-show="${this._handleIconOverflowMenuOpened}" @click="${n.d}"> <ha-icon-button .label="${this._localize("ui.common.overflow_menu")}" .path="${g}" slot="trigger"></ha-icon-button> ${this.items.map(e=>e.divider?i.qy`<wa-divider></wa-divider>`:i.qy`<ha-dropdown-item ?disabled="${e.disabled}" @click="${e.action}" variant="${e.warning?"danger":"default"}"> <ha-svg-icon slot="icon" .path="${e.path}"></ha-svg-icon> ${e.label} </ha-dropdown-item>`)} </ha-dropdown>`:i.qy` ${this.items.map(e=>e.narrowOnly?i.s6:e.divider?i.qy`<div role="separator"></div>`:i.qy`<ha-tooltip .disabled="${!e.tooltip}" .for="icon-button-${e.label}">${e.tooltip??""} </ha-tooltip><ha-icon-button .id="icon-button-${e.label}" @click="${e.action}" .label="${e.label}" .path="${e.path}" ?disabled="${e.disabled}"></ha-icon-button> `)} `} `}_handleIconOverflowMenuOpened(e){e.stopPropagation()}static get styles(){return[d.RF,i.AH`:host{display:flex;justify-content:flex-end;cursor:initial}div[role=separator]{border-right:1px solid var(--divider-color);width:1px}`]}constructor(...e){super(...e),this.items=[],this.narrow=!1}}(0,s.Cg)([(0,l.wk)(),(0,r.IW)()],b.prototype,"_localize",void 0),(0,s.Cg)([(0,l.MZ)({type:Array})],b.prototype,"items",void 0),(0,s.Cg)([(0,l.MZ)({type:Boolean})],b.prototype,"narrow",void 0),b=(0,s.Cg)([(0,l.EM)("ha-icon-overflow-menu")],b),o()}catch(e){o(e)}})},25612(e,a,t){t.d(a,{KQ:()=>r,Uh:()=>i,Zg:()=>s,kZ:()=>o,o8:()=>l});const o=e=>e.sendMessagePromise({type:"lovelace/resources"}),s=(e,a)=>e.callWS({type:"lovelace/resources/create",...a}),i=(e,a,t)=>e.callWS({type:"lovelace/resources/update",resource_id:a,...t}),l=(e,a)=>e.callWS({type:"lovelace/resources/delete",resource_id:a}),r=e=>e.callWS({type:"lovelace/info"})},23296(e,a,t){t.a(e,async function(e,o){try{t.r(a);var s=t(62826),i=t(5124),l=t(22441),r=t(91926),n=t(65829),d=t(90248),h=t(2054),c=t(14503),p=e([n,d,h]);[n,d,h]=p.then?(await p)():p;class u extends i.WF{render(){return i.qy` ${this.noToolbar?"":i.qy`<div class="toolbar"> ${this.rootnav||history.state?.root?i.qy` <ha-menu-button .hass="${this.hass}" .narrow="${this.narrow}"></ha-menu-button> `:i.qy` <ha-icon-button-arrow-prev .hass="${this.hass}" @click="${this._handleBack}"></ha-icon-button-arrow-prev> `} </div>`} <div class="content"> <ha-spinner></ha-spinner> ${this.message?i.qy`<div id="loading-text">${this.message}</div>`:i.s6} </div> `}_handleBack(){(0,r.OE)()}static get styles(){return[c.RF,i.AH`:host{display:block;height:100%;background-color:var(--primary-background-color)}.toolbar{display:flex;align-items:center;font-size:var(--ha-font-size-xl);height:var(--header-height);padding:8px 12px;pointer-events:none;background-color:var(--app-header-background-color);font-weight:var(--ha-font-weight-normal);color:var(--app-header-text-color,#fff);border-bottom:var(--app-header-border-bottom,none);box-sizing:border-box}@media (max-width:599px){.toolbar{padding:4px}}ha-icon-button-arrow-prev,ha-menu-button{pointer-events:auto}.content{height:calc(100% - var(--header-height));display:flex;flex-direction:column;align-items:center;justify-content:center}#loading-text{max-width:350px;margin-top:16px}`]}constructor(...e){super(...e),this.noToolbar=!1,this.rootnav=!1,this.narrow=!1}}(0,s.Cg)([(0,l.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,s.Cg)([(0,l.MZ)({type:Boolean,attribute:"no-toolbar"})],u.prototype,"noToolbar",void 0),(0,s.Cg)([(0,l.MZ)({type:Boolean})],u.prototype,"rootnav",void 0),(0,s.Cg)([(0,l.MZ)({type:Boolean})],u.prototype,"narrow",void 0),(0,s.Cg)([(0,l.MZ)()],u.prototype,"message",void 0),u=(0,s.Cg)([(0,l.EM)("hass-loading-screen")],u),o()}catch(e){o(e)}})},7083(e,a,t){t.d(a,{Y:()=>i});var o=t(1087);const s=()=>Promise.all([t.e(92769),t.e(39636)]).then(t.bind(t,65631)),i=(e,a)=>{(0,o.r)(e,"show-dialog",{dialogTag:"ha-dialog-new-dashboard",dialogImport:s,dialogParams:a})}},49406(e,a,t){t.a(e,async function(e,o){try{t.r(a),t.d(a,{HaConfigLovelaceDashboards:()=>E,PANEL_DASHBOARDS:()=>O});t(44114),t(18111),t(22489),t(20116),t(61701),t(13579),t(17642),t(58004),t(33853),t(45876),t(32475),t(15024),t(31698);var s=t(62826),i=t(5124),l=t(22441),r=t(22786),n=t(93905),d=t(91926),h=t(52220),c=t(38962),p=t(18350),u=t(29823),g=(t(70947),t(47680),t(26300)),b=t(75248),_=(t(67094),t(34127)),v=t(48250),m=t(35952),f=t(25612),y=t(71730),w=t(99774),$=t(65063),C=t(23296),k=t(72553),x=t(35697),A=t(15656),M=t(7083),q=t(68370),z=t(47758),D=t(96489),L=t(60653),H=e([c,p,u,g,b,_,C,k]);[c,p,u,g,b,_,C,k]=H.then?(await H)():H;const S="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z",P="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",Z="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",V="M12 20C7.6 20 4 16.4 4 12S7.6 4 12 4 20 7.6 20 12 16.4 20 12 20M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M11 14H13V17H16V12H18L12 7L6 12H8V17H11V14",T="M12 3L2 12H5V20H10V14H14V15.11L19.43 9.68L12 3M21.04 11.14C20.9 11.14 20.76 11.2 20.65 11.3L19.65 12.3L21.7 14.35L22.7 13.35C22.91 13.14 22.91 12.79 22.7 12.58L21.42 11.3C21.32 11.2 21.18 11.14 21.04 11.14M19.06 12.88L13 18.94V21H15.06L21.11 14.93L19.06 12.88Z",I="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",W="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",O=["lovelace","home","light","security","climate","energy","maintenance","logbook","history","browser-mod"];class E extends i.WF{willUpdate(){this.hasUpdated||this.hass.loadFragmentTranslation("lovelace")}render(){if(!this.hass||void 0===this._dashboards)return i.qy` <hass-loading-screen></hass-loading-screen> `;const e=this.hass.systemData?.default_panel||"home";return i.qy` <hass-tabs-subpage-data-table .hass="${this.hass}" .narrow="${this.narrow}" back-path="/config" .route="${this.route}" .tabs="${q.lovelaceTabs}" .columns="${this._columns(this.narrow,this.hass.language,this._dashboards,this.hass.localize)}" .data="${this._getItems(this._dashboards,e,this.hass.panels)}" .initialGroupColumn="${this._activeGrouping}" .initialCollapsedGroups="${this._activeCollapsed}" .initialSorting="${this._activeSorting}" .columnOrder="${this._activeColumnOrder}" .hiddenColumns="${this._activeHiddenColumns}" @grouping-changed="${this._handleGroupingChanged}" @collapsed-changed="${this._handleCollapseChanged}" @columns-changed="${this._handleColumnsChanged}" @sorting-changed="${this._handleSortingChanged}" .filter="${this._filter}" @search-changed="${this._handleSearchChange}" @row-click="${this._handleRowClicked}" id="url_path" has-fab clickable> <ha-dropdown slot="toolbar-icon"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${Z}"></ha-icon-button> <a href="/config/lovelace/resources"> <ha-dropdown-item> ${this.hass.localize("ui.panel.config.lovelace.resources.caption")} </ha-dropdown-item> </a> </ha-dropdown> <ha-button slot="fab" size="large" @click="${this._addDashboard}"> <ha-svg-icon slot="start" .path="${W}"></ha-svg-icon> ${this.hass.localize("ui.panel.config.lovelace.dashboards.picker.add_dashboard")} </ha-button> </hass-tabs-subpage-data-table> `}firstUpdated(e){super.firstUpdated(e);const a=window;a.llResProm||(a.llResProm=(0,f.kZ)(this.hass.connection)),a.llResProm.then(e=>{(0,x.n)(e,this.hass)}).catch(e=>{a.llResProm=void 0,console.error("Unable to preload Lovelace resources",e)}),this._getDashboards()}async _getDashboards(){this._dashboards=await(0,y.SJ)(this.hass)}_handleRowClicked(e){e.stopPropagation();const a=e.detail.id;(0,d.oo)(`/${a}`)}_handleEdit(e){const a=e.url_path;if("energy"===a)return void(0,d.oo)("/config/energy");const t=this._dashboards.find(e=>e.url_path===a);this._openDetailDialog(t,a)}_handleEditPanel(e){const a=this.hass.panels[e.url_path];if(!a)return;const t=this.hass.systemData?.default_panel||"home";(0,L.x)(this,{urlPath:a.url_path,title:(0,w.hL)(this.hass,a)||a.url_path,icon:(0,w.Q)(a),requireAdmin:a.require_admin||!1,showInSidebar:a.show_in_sidebar||!1,isDefault:a.url_path===t,updatePanel:async e=>{await(0,w.W5)(this.hass,a.url_path,e)}})}async _addDashboard(){(0,M.Y)(this,{selectConfig:async({config:e})=>{let a;if(e&&(0,m.Wu)(e)){const{strategyClass:t,fieldSuggestions:o}=await(0,A.TG)(this.hass,e.strategy.type);if(a=o,t.configRequired)return void(0,z.d)(this,{config:e,saveConfig:async e=>{const{fieldSuggestions:a}=await(0,A.TG)(this.hass,e.strategy.type);this._openDetailDialog(void 0,void 0,e,a)}})}this._openDetailDialog(void 0,void 0,e,a)}})}async _openDetailDialog(e,a,t,o){const s=this.hass.systemData?.default_panel||"home";(0,D.B)(this,{dashboard:e,urlPath:a,isDefault:e?.url_path===s,suggestions:o,takenUrlPaths:e?void 0:this._collectTakenDashboardUrlPaths(),createDashboard:async e=>{const a=await(0,y.n6)(this.hass,e);this._dashboards=this._dashboards.concat(a).sort((e,a)=>(0,h.xL)(e.url_path,a.url_path,this.hass.locale.language)),t&&await(0,m.ql)(this.hass,a.url_path,t)},updateDashboard:async a=>{const t=await(0,y.mQ)(this.hass,e.id,a);this._dashboards=this._dashboards.map(a=>a===e?t:a)},removeDashboard:async()=>!!e&&this._deleteDashboard(e)})}_collectTakenDashboardUrlPaths(){const e=new Set;for(const a of this._dashboards??[])e.add(a.url_path);for(const a of Object.keys(this.hass.panels))e.add(a);return e.add("lovelace"),e}async _deleteDashboard(e){if(!await(0,$.dk)(this,{title:this.hass.localize("ui.panel.config.lovelace.dashboards.confirm_delete_title",{dashboard_title:e.title}),text:this.hass.localize("ui.panel.config.lovelace.dashboards.confirm_delete_text"),confirmText:this.hass.localize("ui.common.delete"),destructive:!0}))return!1;try{return await(0,y.A_)(this.hass,e.id),this._dashboards=this._dashboards.filter(a=>a!==e),!0}catch(e){return!1}}_handleSortingChanged(e){this._activeSorting=e.detail}_handleSearchChange(e){this._filter=e.detail.value}_handleColumnsChanged(e){this._activeColumnOrder=e.detail.columnOrder,this._activeHiddenColumns=e.detail.hiddenColumns}_handleGroupingChanged(e){this._activeGrouping=e.detail.value}_handleCollapseChanged(e){this._activeCollapsed=e.detail.value}constructor(...e){super(...e),this.isWide=!1,this.narrow=!1,this._dashboards=[],this._filter="",this._activeGrouping="localized_type",this._activeCollapsed=[],this._columns=(0,r.A)((e,a,t,o)=>{const s={icon:{title:"",moveable:!1,showNarrow:!0,label:o("ui.panel.config.lovelace.dashboards.picker.headers.icon"),type:"icon",template:e=>e.icon?i.qy` <ha-icon slot="item-icon" .icon="${e.icon}"></ha-icon> `:i.s6},title:{title:o("ui.panel.config.lovelace.dashboards.picker.headers.title"),main:!0,sortable:!0,filterable:!0,flex:2,template:e?void 0:e=>i.qy` <span style="display:flex;align-items:center;gap:var(--ha-space-2);min-width:0;width:100%"> <span style="min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1">${e.title}</span> ${e.default?i.qy` <ha-svg-icon .id="default-icon-${e.title}" style="flex-shrink:0" .path="${V}"></ha-svg-icon> <ha-tooltip .for="default-icon-${e.title}" placement="right"> ${this.hass.localize("ui.panel.config.lovelace.dashboards.default_dashboard")} </ha-tooltip> `:i.s6} </span> `}};return s.localized_type={title:o("ui.panel.config.lovelace.dashboards.picker.headers.type"),sortable:!0,groupable:!0,filterable:!0},s.mode={title:o("ui.panel.config.lovelace.dashboards.picker.headers.conf_mode"),sortable:!0,filterable:!0,template:e=>i.qy` ${this.hass.localize(`ui.panel.config.lovelace.dashboards.conf_mode.${e.mode}`)||e.mode} `},t.some(e=>e.filename)&&(s.filename={title:o("ui.panel.config.lovelace.dashboards.picker.headers.filename"),sortable:!0,filterable:!0}),s.require_admin={title:o("ui.panel.config.lovelace.dashboards.picker.headers.require_admin"),sortable:!0,hidden:e,type:"icon",minWidth:"120px",maxWidth:"120px",template:e=>e.require_admin?i.qy`<ha-svg-icon .path="${S}"></ha-svg-icon>`:i.qy`—`},s.show_in_sidebar={title:o("ui.panel.config.lovelace.dashboards.picker.headers.sidebar"),hidden:e,type:"icon",minWidth:"120px",maxWidth:"120px",template:e=>e.show_in_sidebar?i.qy`<ha-svg-icon .path="${S}"></ha-svg-icon>`:i.qy`—`},s.actions={title:"",label:this.hass.localize("ui.panel.config.generic.headers.actions"),type:"overflow-menu",showNarrow:!0,moveable:!1,hideable:!1,template:e=>i.qy` <ha-icon-overflow-menu narrow .items="${[{path:T,label:o("ui.panel.config.lovelace.dashboards.picker.set_as_default"),action:()=>this._handleSetAsDefault(e),disabled:e.default},..."built_in"===e.type?[{path:I,label:this.hass.localize("ui.panel.config.lovelace.dashboards.picker.edit"),action:()=>this._handleEditPanel(e)}]:[],..."user_created"===e.type&&"storage"===e.mode?[{path:I,label:this.hass.localize("ui.panel.config.lovelace.dashboards.picker.edit"),action:()=>this._handleEdit(e)},{label:this.hass.localize("ui.panel.config.lovelace.dashboards.picker.delete"),path:P,action:()=>this._handleDelete(e),warning:!0}]:[]]}"> </ha-icon-overflow-menu> `},s}),this._getItems=(0,r.A)((e,a,t)=>{const o=[];return O.forEach(e=>{const s=t[e];if(!s)return;const i={icon:(0,w.Q)(s),title:(0,w.hL)(this.hass,s)||s.url_path,show_in_sidebar:s.show_in_sidebar||!1,mode:"storage",url_path:s.url_path,filename:"",default:a===s.url_path,require_admin:s.require_admin||!1,type:"built_in",localized_type:this._localizeType("built_in")};o.push(i)}),o.push(...e.sort((e,a)=>(0,h.xL)(e.title,a.title,this.hass.locale.language)).map(e=>({filename:"",...e,default:a===e.url_path,type:"user_created",localized_type:this._localizeType("user_created")}))),o}),this._localizeType=e=>this.hass.localize(`ui.panel.config.lovelace.dashboards.picker.type.${e}`),this._handleSetAsDefault=async e=>{if(e.default)return;if(e.require_admin)return void(0,$.showAlertDialog)(this,{title:this.hass.localize("ui.panel.config.lovelace.dashboards.detail.set_default_admin_only_title"),text:this.hass.localize("ui.panel.config.lovelace.dashboards.detail.set_default_admin_only_text")});await(0,$.dk)(this,{title:this.hass.localize("ui.panel.config.lovelace.dashboards.detail.set_default_confirm_title"),text:i.qy`${this.hass.localize("ui.panel.config.lovelace.dashboards.detail.set_default_confirm_text")}<br><br><ha-alert alert-type="info">${this.hass.localize("ui.panel.config.lovelace.dashboards.detail.set_default_confirm_note")}</ha-alert>`,confirmText:this.hass.localize("ui.common.ok"),dismissText:this.hass.localize("ui.common.cancel"),destructive:!1})&&await(0,v.x0)(this.hass.connection,"core",{...this.hass.systemData,default_panel:e.url_path})},this._handleDelete=async e=>{const a=this._dashboards.find(a=>a.url_path===e.url_path);a&&this._deleteDashboard(a)}}}E.styles=i.AH`ha-dropdown a{text-decoration:none}`,(0,s.Cg)([(0,l.MZ)({attribute:!1})],E.prototype,"hass",void 0),(0,s.Cg)([(0,l.MZ)({attribute:"is-wide",type:Boolean})],E.prototype,"isWide",void 0),(0,s.Cg)([(0,l.MZ)({type:Boolean})],E.prototype,"narrow",void 0),(0,s.Cg)([(0,l.MZ)({attribute:!1})],E.prototype,"route",void 0),(0,s.Cg)([(0,l.wk)()],E.prototype,"_dashboards",void 0),(0,s.Cg)([(0,l.wk)(),(0,n.I)({storage:"sessionStorage",key:"lovelace-dashboards-table-search",state:!0,subscribe:!1})],E.prototype,"_filter",void 0),(0,s.Cg)([(0,n.I)({key:"lovelace-dashboards-table-sort",state:!1,subscribe:!1})],E.prototype,"_activeSorting",void 0),(0,s.Cg)([(0,n.I)({key:"lovelace-dashboards-table-column-order",state:!1,subscribe:!1})],E.prototype,"_activeColumnOrder",void 0),(0,s.Cg)([(0,n.I)({key:"lovelace-dashboards-table-hidden-columns",state:!1,subscribe:!1})],E.prototype,"_activeHiddenColumns",void 0),(0,s.Cg)([(0,n.I)({key:"lovelace-dashboards-table-grouping",state:!1,subscribe:!1})],E.prototype,"_activeGrouping",void 0),(0,s.Cg)([(0,n.I)({key:"lovelace-dashboards-table-collapsed",state:!1,subscribe:!1})],E.prototype,"_activeCollapsed",void 0),E=(0,s.Cg)([(0,l.EM)("ha-config-lovelace-dashboards")],E),o()}catch(e){o(e)}})},47758(e,a,t){t.d(a,{d:()=>i});var o=t(1087);const s=()=>Promise.all([t.e(72130),t.e(85010),t.e(25950),t.e(34310),t.e(23331)]).then(t.bind(t,35632)),i=(e,a)=>{(0,o.r)(e,"show-dialog",{dialogTag:"dialog-lovelace-dashboard-configure-strategy",dialogImport:s,dialogParams:a})}},96489(e,a,t){t.d(a,{B:()=>i});var o=t(1087);const s=()=>t.e(92348).then(t.bind(t,3863)),i=(e,a)=>{(0,o.r)(e,"show-dialog",{dialogTag:"dialog-lovelace-dashboard-detail",dialogImport:s,dialogParams:a})}},60653(e,a,t){t.d(a,{x:()=>i});var o=t(1087);const s=()=>t.e(79524).then(t.bind(t,41231)),i=(e,a)=>{(0,o.r)(e,"show-dialog",{dialogTag:"dialog-panel-detail",dialogImport:s,dialogParams:a})}},35697(e,a,t){t.d(a,{$:()=>n,n:()=>r});t(18111),t(22489),t(7588),t(61701),t(14603),t(47566),t(98721);var o=t(25995);const s={},i={},l=(e,a)=>{const t=new URL(e.url,a.auth.data.hassUrl).toString();switch(e.type){case"css":{if(t in s)return s[t];const e=(0,o.y6)(t);return s[t]=e,e}case"js":{if(t in i)return i[t];const e=(0,o.kG)(t);return i[t]=e,e}case"module":return(0,o.Vw)(t);default:return void console.warn(`Unknown resource type specified: ${e.type}`)}},r=(e,a)=>{e.forEach(e=>{l(e,a)})},n=async(e,a)=>{const t=e.map(e=>l(e,a)).filter(e=>void 0!==e);await Promise.allSettled(t)}}};