UNPKG

homebridge-config-ui-x

Version:

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

2 lines (1 loc) 4.72 kB
import{a as P}from"./chunk-GXCQWWJO.js";import{e as O}from"./chunk-ODMFCOQJ.js";import{a as C}from"./chunk-XPK2EQJA.js";import"./chunk-2GN26TCR.js";import{b as N}from"./chunk-4NRNA47I.js";import{C as M,D as T,F as A,I as B}from"./chunk-QCMOCU6Q.js";import{Ab as h,Dc as s,Ec as o,Jb as r,Kb as n,Lb as _,Lc as y,Sb as k,Ya as e,Yb as D,Zb as u,aa as c,ga as $,ha as S,ic as R,jc as E,kc as a,lc as l,ma as I,mb as w,mc as v,sa as p,w as x,zb as f}from"./chunk-ZMC752RO.js";import{h as b}from"./chunk-B4AJQJMI.js";function U(i,g){if(i&1&&(r(0,"div",7),a(1),n()),i&2){let t=u();e(),l(t.error())}}function j(i,g){if(i&1&&(r(0,"p",9),a(1),s(2,"translate"),n(),r(3,"div",10)(4,"div",11)(5,"span"),_(6,"i"),a(7),s(8,"translate"),n()(),r(9,"div",11)(10,"span"),_(11,"i"),a(12),s(13,"translate"),n()()()),i&2){let t=u();e(),l(o(2,9,"restart.please_wait_while_server_restarts")),e(5),E(t.uiIcon()),e(),v(" ",o(8,11,"restart.ui_online")," "),e(3),R("grey-text",!t.uiOnline()),e(),E(t.serviceIcon()),e(),v(" ",o(13,13,"restart.service_ready")," ")}}function q(i,g){if(i&1){let t=k();r(0,"p",14)(1,"button",15),D("click",function(){$(t);let m=u(2);return S(m.viewLogs())}),a(2),s(3,"translate"),n()()}i&2&&(e(2),v(" ",o(3,1,"menu.tooltip_view_logs")," "))}function L(i,g){if(i&1&&(r(0,"div",8)(1,"p"),a(2),s(3,"translate"),n(),r(4,"p",12),a(5),s(6,"translate"),r(7,"span",13),a(8),n()(),f(9,q,4,3,"p",14),n()),i&2){let t=u();e(2),l(o(3,4,"restart.server_is_taking_long_time_to_restart")),e(3),v(" ",o(6,6,"restart.label_restart_command_executed"),": "),e(3),l(t.resp().command||"End Process"),e(),h(t.uiOnline()?9:-1)}}var tt=(()=>{class i{$api=c(B);$router=c(O);$settings=c(N);$toastr=c(A);$translate=c(M);$ws=c(P);destroyRef=c(I);uiOnline=p(!1);error=p(!1);resp=p({});timeout=p(!1);uiIcon=y(()=>this.uiOnline()?"far fa-check-circle":"fas fa-circle-notch fa-spin");serviceIcon=y(()=>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.subscribe(()=>{this.io.socket.emit("monitor-server-status"),this.$settings.getAppSettings().catch(()=>{})}),this.io.socket.connected&&(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.$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.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(){x(7e3).pipe(C(this.destroyRef)).subscribe(()=>{this.statusCheckActive.set(!0)}),x(4e4).pipe(C(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"],[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"],[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&&(r(0,"div",0)(1,"h3",1),a(2),s(3,"translate"),n()(),r(4,"div",2)(5,"div",3),_(6,"i",4),n(),r(7,"div",5)(8,"h4",6),a(9),s(10,"translate"),n(),f(11,U,2,1,"div",7)(12,j,14,15),f(13,L,10,8,"div",8),n()()),d&2&&(e(2),l(o(3,4,"menu.restart.title")),e(7),l(o(10,6,"restart.title_restart")),e(2),h(m.error()?11:12),e(2),h(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{tt as RestartComponent};