1
mirror of https://github.com/home-assistant/supervisor synced 2024-09-27 19:03:30 +02:00
ha-supervisor/supervisor/api/panel/frontend_es5/2094-jp3V24jtsr8.js
2023-07-05 10:16:49 +02:00

2 lines
12 KiB
JavaScript

"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[2094],{72094:function(e,t,r){r.r(t);var s=r(99312),n=r(81043),a=r(88962),i=r(33368),o=r(71650),c=r(82390),u=r(69205),d=r(70906),l=r(91808),h=r(34541),p=r(47838),v=r(68144),f=r(79932),g=r(47181),x=r(83849),b=r(15493),m=r(96151),k=(r(5666),r(34154)),_=r(41682),y=r(63864);function w(e){return document.cookie="ingress_session=".concat(e,";path=/api/hassio_ingress/;SameSite=Strict").concat("https:"===location.protocol?";Secure":""),e}var Z,T,z,D,S,C,A=function(){var e=(0,n.Z)((0,s.Z)().mark((function e(t){var r,n;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(0,y.I)(t.config.version,2021,2,4)){e.next=5;break}return e.next=3,t.callWS({type:"supervisor/api",endpoint:"/ingress/session",method:"post"});case 3:return r=e.sent,e.abrupt("return",w(r.session));case 5:return e.next=7,t.callApi("POST","hassio/ingress/session");case 7:return n=e.sent,e.abrupt("return",w(n.data.session));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),M=function(){var e=(0,n.Z)((0,s.Z)().mark((function e(t,r){return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(0,y.I)(t.config.version,2021,2,4)){e.next=4;break}return e.next=3,t.callWS({type:"supervisor/api",endpoint:"/ingress/validate_session",method:"post",data:{session:r}});case 3:return e.abrupt("return");case 4:return e.next=6,t.callApi("POST","hassio/ingress/validate_session",{session:r});case 6:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),I=r(26765);r(15291),r(15803),(0,l.Z)([(0,f.Mo)("hassio-ingress-view")],(function(e,t){var r,l,y,w=function(t){(0,u.Z)(s,t);var r=(0,d.Z)(s);function s(){var t;(0,o.Z)(this,s);for(var n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=r.call.apply(r,[this].concat(a)),e((0,c.Z)(t)),t}return(0,i.Z)(s)}(t);return{F:w,d:[{kind:"field",decorators:[(0,f.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,f.Cb)({attribute:!1})],key:"supervisor",value:void 0},{kind:"field",decorators:[(0,f.Cb)({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[(0,f.Cb)({type:Boolean})],key:"ingressPanel",value:function(){return!1}},{kind:"field",decorators:[(0,f.Cb)({type:Boolean})],key:"narrow",value:function(){return!1}},{kind:"field",decorators:[(0,f.SB)()],key:"_addon",value:void 0},{kind:"field",decorators:[(0,f.SB)()],key:"_loadingMessage",value:void 0},{kind:"field",key:"_sessionKeepAlive",value:void 0},{kind:"field",key:"_fetchDataTimeout",value:void 0},{kind:"method",key:"disconnectedCallback",value:function(){(0,h.Z)((0,p.Z)(w.prototype),"disconnectedCallback",this).call(this),this._sessionKeepAlive&&(clearInterval(this._sessionKeepAlive),this._sessionKeepAlive=void 0),this._fetchDataTimeout&&(clearInterval(this._fetchDataTimeout),this._fetchDataTimeout=void 0)}},{kind:"method",key:"render",value:function(){if(!this._addon)return(0,v.dy)(Z||(Z=(0,a.Z)(['<hass-loading-screen .message="','"></hass-loading-screen>'])),this._loadingMessage);var e=(0,v.dy)(T||(T=(0,a.Z)(['<iframe title="','" src="','" @load="','"> </iframe>'])),this._addon.name,this._addon.ingress_url,this._checkLoaded);return this.ingressPanel?(0,v.dy)(D||(D=(0,a.Z)(["",""])),this.narrow||"always_hidden"===this.hass.dockedSidebar?(0,v.dy)(S||(S=(0,a.Z)(['<div class="header"> <ha-icon-button .label="','" .path="','" @click="','"></ha-icon-button> <div class="main-title">',"</div> </div> ",""])),this.hass.localize("ui.sidebar.sidebar_toggle"),"M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z",this._toggleMenu,this._addon.name,e):e):(0,v.dy)(z||(z=(0,a.Z)(['<hass-subpage .hass="','" .header="','" .narrow="','"> '," </hass-subpage>"])),this.hass,this._addon.name,this.narrow,e)}},{kind:"method",key:"firstUpdated",value:(y=(0,n.Z)((0,s.Z)().mark((function e(){var t,r;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==this.route.path){e.next=34;break}if(!(t=(0,b.io)("addon"))){e.next=34;break}return e.prev=3,e.next=6,(0,k.AD)(this.hass,t);case 6:r=e.sent,e.next=17;break;case 9:return e.prev=9,e.t0=e.catch(3),e.next=13,(0,I.Ys)(this,{text:(0,_.js)(e.t0),title:t});case 13:return e.next=15,(0,m.y)();case 15:return(0,x.c)("/hassio/store",{replace:!0}),e.abrupt("return");case 17:if(r.version){e.next=25;break}return e.next=20,(0,I.Ys)(this,{text:this.supervisor.localize("my.error_addon_not_installed"),title:r.name});case 20:return e.next=22,(0,m.y)();case 22:(0,x.c)("/hassio/addon/".concat(r.slug,"/info"),{replace:!0}),e.next=34;break;case 25:if(r.ingress){e.next=33;break}return e.next=28,(0,I.Ys)(this,{text:this.supervisor.localize("my.error_addon_no_ingress"),title:r.name});case 28:return e.next=30,(0,m.y)();case 30:(0,x.c)("/hassio/addon/".concat(r.slug,"/info"),{replace:!0}),e.next=34;break;case 33:(0,x.c)("/hassio/ingress/".concat(r.slug),{replace:!0});case 34:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(){return y.apply(this,arguments)})},{kind:"method",key:"willUpdate",value:function(e){if((0,h.Z)((0,p.Z)(w.prototype),"willUpdate",this).call(this,e),e.has("route")){var t=this.route.path.substring(1),r=e.get("route"),s=r?r.path.substring(1):void 0;t&&t!==s&&(this._loadingMessage=void 0,this._fetchData(t))}}},{kind:"method",key:"_fetchData",value:(l=(0,n.Z)((0,s.Z)().mark((function e(t){var r,a,i,o=this;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=A(this.hass),e.prev=1,e.next=4,(0,k.AD)(this.hass,t);case 4:a=e.sent,e.next=17;break;case 7:return e.prev=7,e.t0=e.catch(1),e.next=11,this.updateComplete;case 11:return e.next=13,(0,I.Ys)(this,{text:this.supervisor.localize("ingress.error_addon_info")||"Unable to fetch add-on info to start Ingress",title:"Supervisor"});case 13:return e.next=15,(0,m.y)();case 15:return(0,x.c)("/hassio/store",{replace:!0}),e.abrupt("return");case 17:if(a.version){e.next=26;break}return e.next=20,this.updateComplete;case 20:return e.next=22,(0,I.Ys)(this,{text:this.supervisor.localize("ingress.error_addon_not_installed")||"The add-on is not installed. Please install it first",title:a.name});case 22:return e.next=24,(0,m.y)();case 24:return(0,x.c)("/hassio/addon/".concat(a.slug,"/info"),{replace:!0}),e.abrupt("return");case 26:if(a.ingress_url){e.next=35;break}return e.next=29,this.updateComplete;case 29:return e.next=31,(0,I.Ys)(this,{text:this.supervisor.localize("ingress.error_addon_not_supported")||"This add-on does not support Ingress",title:a.name});case 31:return e.next=33,(0,m.y)();case 33:return history.back(),e.abrupt("return");case 35:if(a.state&&["startup","started"].includes(a.state)){e.next=65;break}return e.next=38,this.updateComplete;case 38:return e.next=40,(0,I.g7)(this,{text:this.supervisor.localize("ingress.error_addon_not_running")||"The add-on is not running. Do you want to start it now?",title:a.name,confirmText:this.supervisor.localize("ingress.start_addon")||"Start add-on",dismissText:this.supervisor.localize("common.no")||"No"});case 40:if(!e.sent){e.next=61;break}return e.prev=42,this._loadingMessage=this.supervisor.localize("ingress.addon_starting")||"The add-on is starting, this can take some time...",e.next=46,(0,k.kP)(this.hass,t);case 46:return(0,g.B)(this,"supervisor-collection-refresh",{collection:"addon"}),this._fetchData(t),e.abrupt("return");case 51:return e.prev=51,e.t1=e.catch(42),e.next=55,(0,I.Ys)(this,{text:this.supervisor.localize("ingress.error_starting_addon")||"Error starting the add-on",title:a.name});case 55:return e.next=57,(0,m.y)();case 57:return(0,x.c)("/hassio/addon/".concat(a.slug,"/logs"),{replace:!0}),e.abrupt("return");case 59:e.next=65;break;case 61:return e.next=63,(0,m.y)();case 63:return(0,x.c)("/hassio/addon/".concat(a.slug,"/info"),{replace:!0}),e.abrupt("return");case 65:if("startup"!==a.state){e.next=69;break}return this._loadingMessage=this.supervisor.localize("ingress.addon_starting")||"The add-on is starting, this can take some time...",this._fetchDataTimeout=window.setTimeout((function(){o._fetchData(t)}),500),e.abrupt("return");case 69:if("started"===a.state){e.next=71;break}return e.abrupt("return");case 71:return this._loadingMessage=void 0,this._fetchDataTimeout&&(clearInterval(this._fetchDataTimeout),this._fetchDataTimeout=void 0),e.prev=73,e.next=76,r;case 76:i=e.sent,e.next=88;break;case 79:return e.prev=79,e.t2=e.catch(73),this._sessionKeepAlive&&clearInterval(this._sessionKeepAlive),e.next=84,(0,I.Ys)(this,{text:this.supervisor.localize("ingress.error_creating_session")||"Unable to create an Ingress session",title:a.name});case 84:return e.next=86,(0,m.y)();case 86:return history.back(),e.abrupt("return");case 88:this._sessionKeepAlive&&clearInterval(this._sessionKeepAlive),this._sessionKeepAlive=window.setInterval((0,n.Z)((0,s.Z)().mark((function e(){return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,M(o.hass,i);case 3:e.next=10;break;case 5:return e.prev=5,e.t0=e.catch(0),e.next=9,A(o.hass);case 9:i=e.sent;case 10:case"end":return e.stop()}}),e,null,[[0,5]])}))),6e4),this._addon=a;case 91:case"end":return e.stop()}}),e,this,[[1,7],[42,51],[73,79]])}))),function(e){return l.apply(this,arguments)})},{kind:"method",key:"_checkLoaded",value:(r=(0,n.Z)((0,s.Z)().mark((function e(t){var r=this;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._addon){e.next=2;break}return e.abrupt("return");case 2:if("502: Bad Gateway"!==t.target.contentDocument.body.textContent){e.next=6;break}return e.next=5,this.updateComplete;case 5:(0,I.g7)(this,{text:this.supervisor.localize("ingress.error_addon_not_ready")||"The add-on seems to not be ready, it might still be starting. Do you want to try again?",title:this._addon.name,confirmText:this.supervisor.localize("ingress.retry")||"Retry",dismissText:this.supervisor.localize("common.no")||"No",confirm:function(){var e=(0,n.Z)((0,s.Z)().mark((function e(){var t;return(0,s.Z)().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r._addon,r._addon=void 0,e.next=4,Promise.all([r.updateComplete,new Promise((function(e){setTimeout(e,500)}))]);case 4:r._addon=t;case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{kind:"method",key:"_toggleMenu",value:function(){(0,g.B)(this,"hass-toggle-menu")}},{kind:"get",static:!0,key:"styles",value:function(){return(0,v.iv)(C||(C=(0,a.Z)(["iframe{display:block;width:100%;height:100%;border:0}.header+iframe{height:calc(100% - 40px)}.header{display:flex;align-items:center;font-size:16px;height:40px;padding:0 16px;pointer-events:none;background-color:var(--app-header-background-color);font-weight:400;color:var(--app-header-text-color,#fff);border-bottom:var(--app-header-border-bottom,none);box-sizing:border-box;--mdc-icon-size:20px}.main-title{margin:0 0 0 24px;line-height:20px;flex-grow:1}ha-icon-button{pointer-events:auto}hass-subpage{--app-header-background-color:var(--sidebar-background-color);--app-header-text-color:var(--sidebar-text-color);--app-header-border-bottom:1px solid var(--divider-color)}"])))}}]}}),v.oi)},15493:function(e,t,r){r.d(t,{Q2:function(){return a},io:function(){return i},ou:function(){return o}});var s=r(62746),n=r(40039),a=function(){var e,t={},r=new URLSearchParams(location.search),a=(0,n.Z)(r.entries());try{for(a.s();!(e=a.n()).done;){var i=(0,s.Z)(e.value,2),o=i[0],c=i[1];t[o]=c}}catch(u){a.e(u)}finally{a.f()}return t},i=function(e){return new URLSearchParams(window.location.search).get(e)},o=function(e){var t=new URLSearchParams;return Object.entries(e).forEach((function(e){var r=(0,s.Z)(e,2),n=r[0],a=r[1];t.append(n,a)})),t.toString()}}}]);
//# sourceMappingURL=2094-jp3V24jtsr8.js.map