UNPKG

homebridge-config-ui-x

Version:

A web based management, configuration and control platform for Homebridge.

1 lines 4.88 kB
import{a as E}from"./chunk-D39XL-zh.js";import{$ as Le,Ct as Qo,Fr as se,Jr as ve,K as J,Kr as v3,M as Fe,Pr as sc,Q as Ko,Un as g,Vt as U3,X as Jt,Y as Je,_t as Pn,ai as xi,d as Ay,dt as Nf,fn as Z,gt as Pe,hr as nc,jt as S_,kn as br,pt as Ot,sr as kt,u as An,ui as z0,ut as N_,vt as Py,wr as q$1}from"./chunk-D96TCRAL.js";import{l as le}from"./chunk-DZYp0NQB.js";import{n as zt}from"./chunk-CdJ3i4Aq.js";import"./main-E3N63CH7.js";import{t as ds}from"./chunk-CiY-LsUw.js";import{t as p}from"./chunk-BinBJ-zk2.js";function j(i,x){if(i&1&&(Pe(0,`div`,7),Ot(1),Je()),i&2){let t=ve();se(),Py(t.error())}}function q(i,x){if(i&1&&(Pe(0,`p`,9),Ot(1),S_(2,`translate`),Je(),Pe(3,`div`,10)(4,`div`,11)(5,`span`),br(6,`i`,12),Ot(7),S_(8,`translate`),Je()(),Pe(9,`div`,11)(10,`span`),br(11,`i`,12),Ot(12),S_(13,`translate`),Je()()()),i&2){let t=ve();se(),Py(N_(2,9,`restart.please_wait_while_server_restarts`)),se(5),Jt(t.uiIcon()),se(),kt(` `,N_(8,11,`restart.ui_online`),` `),se(3),Ay(`grey-text`,!t.uiOnline()),se(),Jt(t.serviceIcon()),se(),kt(` `,N_(13,13,`restart.service_ready`),` `)}}function L(i,x){if(i&1){let t=sc();Pe(0,`p`,15)(1,`button`,16),xi(`click`,function(){Ko(t);return Qo(ve(2).viewLogs())}),Ot(2),S_(3,`translate`),Je()()}i&2&&(se(2),kt(` `,N_(3,1,`menu.tooltip_view_logs`),` `))}function V(i,x){if(i&1&&(Pe(0,`div`,8)(1,`p`),Ot(2),S_(3,`translate`),Je(),Pe(4,`p`,13),Ot(5),S_(6,`translate`),Pe(7,`span`,14),Ot(8),Je()(),Fe(9,L,4,3,`p`,15),Je()),i&2){let t=ve();se(2),Py(N_(3,4,`restart.server_is_taking_long_time_to_restart`)),se(3),kt(` `,N_(6,6,`restart.label_restart_command_executed`),`: `),se(3),Py(t.resp().command||`End Process`),se(),Le(t.uiOnline()?9:-1)}}var it=(()=>{class i{$api=g(U3);$cache=g(p);$router=g(le);$settings=g(zt);$toastr=g(z0);$translate=g(Nf);$ws=g(ds);destroyRef=g(Z);uiOnline=q$1(!1);error=q$1(!1);resp=q$1({});timeout=q$1(!1);uiIcon=J(()=>this.uiOnline()?`far fa-check-circle`:`fas fa-circle-notch fa-spin`);serviceIcon=J(()=>this.uiOnline()?`fas fa-circle-notch fa-spin`:`far fa-circle`);io;statusCheckActive=q$1(!1);ngOnInit(){this.io=this.$ws.connectToNamespace(`status`),this.io.connected.pipe(An(this.destroyRef)).subscribe(()=>{this.io.socket.emit(`monitor-server-status`),this.$settings.getAppSettings().catch(()=>{})}),this.io.socket.on(`homebridge-status`,m=>{this.statusCheckActive()&&(this.uiOnline.set(!0),(m.status===`ok`||m.status===`pending`)&&(this.statusCheckActive.set(!1),this.$toastr.success(this.$translate.instant(`restart.toast_server_restarted`),this.$translate.instant(`toast.title_success`)),this.$router.navigate([`/`])))}),this.$router.parseUrl(this.$router.url).queryParams.restarting===`true`?(this.uiOnline.set(!0),this.checkIfServerUp()):this.performRestart()}ngOnDestroy(){this.io.end?.(),this.statusCheckActive.set(!1)}viewLogs(){this.$router.navigate([`/logs`])}performRestart(){return E(this,null,function*(){try{let t=yield this.$api.put(`/server/restart`,{});this.$cache.invalidateAll(),this.resp.set(t),this.checkIfServerUp(),t.restartingUI||this.uiOnline.set(!0)}catch(t){console.error(t),this.error.set(this.$translate.instant(`restart.toast_server_restart_error`)),this.$toastr.error(this.$translate.instant(`restart.toast_server_restart_error`),this.$translate.instant(`toast.title_error`))}})}checkIfServerUp(){Pn(7e3).pipe(An(this.destroyRef)).subscribe(()=>{this.statusCheckActive.set(!0),this.io.socket.emit(`monitor-server-status`)}),Pn(4e4).pipe(An(this.destroyRef)).subscribe(()=>{this.$toastr.warning(this.$translate.instant(`restart.toast_server_restart_timeout`),this.$translate.instant(`toast.title_warning`),{timeOut:1e4}),this.timeout.set(!0)})}static ɵfac=function(d){return new(d||i)};static ɵcmp=nc({type:i,selectors:[[`app-restart`]],decls:14,vars:8,consts:[[1,`d-flex`,`justify-content-between`],[1,`primary-text`,`m-0`],[1,`my-4`,`align-items-center`,`container-narrow`],[1,`w-100`,`text-center`,`primary-text`,`mb-5`],[`aria-hidden`,`true`,1,`fas`,`fa-power-off`,`icon-xl`],[1,`text-center`],[1,`primary-text`,`mb-4`],[1,`alert`,`alert-error`,`my-4`],[1,`alert`,`alert-warning`,`my-4`],[1,`grey-text`],[1,`justify-content-center`,`my-4`],[1,`restart-progress-box`,`primary-text`],[`aria-hidden`,`true`],[1,`grey-text`,`mb-0`],[1,`font-monospace`],[1,`mt-2`,`mb-0`],[`type`,`button`,1,`btn`,`btn-primary`,`mb-0`,3,`click`]],template:function(d,m){d&1&&(Pe(0,`div`,0)(1,`h3`,1),Ot(2),S_(3,`translate`),Je()(),Pe(4,`div`,2)(5,`div`,3),br(6,`i`,4),Je(),Pe(7,`div`,5)(8,`h4`,6),Ot(9),S_(10,`translate`),Je(),Fe(11,j,2,1,`div`,7)(12,q,14,15),Fe(13,V,10,8,`div`,8),Je()()),d&2&&(se(2),Py(N_(3,4,`menu.restart.title`)),se(7),Py(N_(10,6,`restart.title_restart`)),se(2),Le(m.error()?11:12),se(2),Le(m.timeout()?13:-1))},dependencies:[v3],styles:[`.restart-progress-box[_ngcontent-%COMP%]{font-size:22px;font-weight:300;margin-top:15px}`]})}return i})();export{it as RestartComponent};