homebridge-config-ui-x
Version:
A web based management, configuration and control platform for Homebridge.
2 lines (1 loc) • 4.81 kB
JavaScript
import{a as U}from"./chunk-LKHNMMNU.js";import{a as P}from"./chunk-GAHGBZ7U.js";import{a as g}from"./chunk-IL6HHVES.js";import"./chunk-LKBXKG4K.js";import{b as N}from"./chunk-RFCSHRPV.js";import{f as O}from"./chunk-3APJQTJL.js";import{$c as A,Ea as e,Kb as D,Lb as y,Mb as a,Nb as l,Ob as v,Ra as w,Yc as M,Zc as T,aa as s,cb as h,db as f,dc as o,dd as B,ec as c,fa as $,ga as S,la as I,lc as C,mb as n,nb as r,ob as _,qa as p,vb as k,x as E,yb as R,zb as u}from"./chunk-LTGI3NYM.js";import{h as b}from"./chunk-B4AJQJMI.js";function j(i,x){if(i&1&&(n(0,"div",7),a(1),r()),i&2){let t=u();e(),l(t.error())}}function q(i,x){if(i&1&&(n(0,"p",9),a(1),o(2,"translate"),r(),n(3,"div",10)(4,"div",11)(5,"span"),_(6,"i",12),a(7),o(8,"translate"),r()(),n(9,"div",11)(10,"span"),_(11,"i",12),a(12),o(13,"translate"),r()()()),i&2){let t=u();e(),l(c(2,9,"restart.please_wait_while_server_restarts")),e(5),y(t.uiIcon()),e(),v(" ",c(8,11,"restart.ui_online")," "),e(3),D("grey-text",!t.uiOnline()),e(),y(t.serviceIcon()),e(),v(" ",c(13,13,"restart.service_ready")," ")}}function L(i,x){if(i&1){let t=k();n(0,"p",15)(1,"button",16),R("click",function(){$(t);let m=u(2);return S(m.viewLogs())}),a(2),o(3,"translate"),r()()}i&2&&(e(2),v(" ",c(3,1,"menu.tooltip_view_logs")," "))}function V(i,x){if(i&1&&(n(0,"div",8)(1,"p"),a(2),o(3,"translate"),r(),n(4,"p",13),a(5),o(6,"translate"),n(7,"span",14),a(8),r()(),h(9,L,4,3,"p",15),r()),i&2){let t=u();e(2),l(c(3,4,"restart.server_is_taking_long_time_to_restart")),e(3),v(" ",c(6,6,"restart.label_restart_command_executed"),": "),e(3),l(t.resp().command||"End Process"),e(),f(t.uiOnline()?9:-1)}}var it=(()=>{class i{$api=s(B);$cache=s(U);$router=s(O);$settings=s(N);$toastr=s(A);$translate=s(M);$ws=s(P);destroyRef=s(I);uiOnline=p(!1);error=p(!1);resp=p({});timeout=p(!1);uiIcon=C(()=>this.uiOnline()?"far fa-check-circle":"fas fa-circle-notch fa-spin");serviceIcon=C(()=>this.uiOnline()?"fas fa-circle-notch fa-spin":"far fa-circle");io;statusCheckActive=p(!1);ngOnInit(){this.io=this.$ws.connectToNamespace("status"),this.io.connected.pipe(g(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 b(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(){E(7e3).pipe(g(this.destroyRef)).subscribe(()=>{this.statusCheckActive.set(!0),this.io.socket.emit("monitor-server-status")}),E(4e4).pipe(g(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 \u0275fac=function(d){return new(d||i)};static \u0275cmp=w({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&&(n(0,"div",0)(1,"h3",1),a(2),o(3,"translate"),r()(),n(4,"div",2)(5,"div",3),_(6,"i",4),r(),n(7,"div",5)(8,"h4",6),a(9),o(10,"translate"),r(),h(11,j,2,1,"div",7)(12,q,14,15),h(13,V,10,8,"div",8),r()()),d&2&&(e(2),l(c(3,4,"menu.restart.title")),e(7),l(c(10,6,"restart.title_restart")),e(2),f(m.error()?11:12),e(2),f(m.timeout()?13:-1))},dependencies:[T],styles:[".restart-progress-box[_ngcontent-%COMP%]{font-size:22px;font-weight:300;margin-top:15px}"],changeDetection:0})}return i})();export{it as RestartComponent};