import{a as D}from"./chunk-OKYAIIFA.js";import{d as O}from"./chunk-T3GI7KUT.js";import{b as B}from"./chunk-2H7B6BX7.js";import{h as E,k as R}from"./chunk-WFMP2IAA.js";import{a as k,b as I}from"./chunk-675OFXLW.js";import{Bb as h,Cc as s,Dc as o,Mb as f,Rb as d,Wb as r,Xb as n,Yb as v,ac as $,bd as T,dc as S,ec as _,ib as i,na as c,oc as a,pc as p,qc as x,ub as w,xa as C,ya as y,yc as b,zc as g}from"./chunk-CKNHTRCL.js";var F=(t,l)=>({"fas fa-fw fa-spinner fa-spin":t,"far fa-fw fa-check-circle":l}),j=t=>({"grey-text":t}),M=(t,l)=>({"far fa-fw fa-circle":t,"fas fa-fw fa-spinner fa-spin":l});function P(t,l){t&1&&(r(0,"p",7),a(1),s(2,"translate"),n()),t&2&&(i(),p(o(2,1,"restart.please_wait_while_server_restarts")))}function U(t,l){if(t&1&&(r(0,"div",8),a(1),n()),t&2){let e=_();i(),p(e.error)}}function V(t,l){if(t&1&&(r(0,"div",9)(1,"div",11)(2,"span"),v(3,"i",12),a(4),s(5,"translate"),n()(),r(6,"div",11)(7,"span",12),v(8,"i",12),a(9),s(10,"translate"),n()()()),t&2){let e=_();i(3),f("ngClass",g(9,F,!e.uiOnline,e.uiOnline)),i(),x(" ",o(5,5,"restart.ui_online")," "),i(3),f("ngClass",b(12,j,!e.uiOnline)),i(),f("ngClass",g(14,M,!e.uiOnline,e.uiOnline)),i(),x(" ",o(10,7,"restart.service_ready")," ")}}function z(t,l){if(t&1){let e=$();r(0,"p",15)(1,"button",16),S("click",function(){C(e);let m=_(2);return y(m.viewLogs())}),a(2),s(3,"translate"),n()()}t&2&&(i(2),p(o(3,1,"menu.tooltip_view_logs")))}function A(t,l){if(t&1&&(r(0,"div",10)(1,"p"),a(2),s(3,"translate"),n(),r(4,"p",13),a(5),s(6,"translate"),r(7,"span",14),a(8),n()(),h(9,z,4,3,"p",15),n()),t&2){let e=_();i(2),p(o(3,4,"restart.server_is_taking_long_time_to_restart")),i(3),x(" ",o(6,6,"restart.label_restart_command_executed"),": "),i(3),p(e.resp.command||"End Process"),i(),d(e.uiOnline?9:-1)}}var Y=(()=>{class t{$api=c(R);$router=c(O);$settings=c(B);$toastr=c(E);$translate=c(k);$ws=c(D);checkTimeout;checkDelay;resp={};timeout=!1;error=!1;uiOnline=!1;io;constructor(){}ngOnInit(){this.io=this.$ws.connectToNamespace("status"),this.io.connected.subscribe(()=>{this.io.socket.emit("monitor-server-status"),this.$settings.getAppSettings().catch()}),this.$api.put("/server/restart",{}).subscribe({next:e=>{this.resp=e,this.checkIfServerUp(),e.restartingUI||(this.uiOnline=!0)},error:e=>{console.error(e),this.error=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(){this.checkDelay=setTimeout(()=>{this.io.socket.on("homebridge-status",e=>{this.uiOnline=!0,(e.status==="up"||e.status==="pending")&&(this.$toastr.success(this.$translate.instant("restart.toast_server_restarted"),this.$translate.instant("toast.title_success")),this.$router.navigate(["/"]))})},7e3),this.checkTimeout=setTimeout(()=>{this.$toastr.warning(this.$translate.instant("restart.toast_server_restart_timeout"),this.$translate.instant("toast.title_warning"),{timeOut:1e4}),this.timeout=!0},4e4)}viewLogs(){this.$router.navigate(["/logs"])}ngOnDestroy(){this.io.end(),clearTimeout(this.checkDelay),clearTimeout(this.checkTimeout)}static \u0275fac=function(u){return new(u||t)};static \u0275cmp=w({type:t,selectors:[["ng-component"]],decls:15,vars:10,consts:[[1,"d-flex","justify-content-between"],[1,"primary-text","m-0"],[1,"my-4","align-items-center",2,"max-width","1000px","margin","auto"],[1,"w-100","text-center","primary-text","mb-5"],[1,"fas","fa-fw","fa-power-off",2,"font-size","75px"],[1,"text-center"],[1,"primary-text","mb-4"],[1,"grey-text"],[1,"alert","alert-error","my-4"],[1,"justify-content-center","my-4"],[1,"alert","alert-warning","my-4"],[1,"restart-progress-box","primary-text"],[3,"ngClass"],[1,"grey-text","mb-0"],[1,"text-monospace"],[1,"mt-2","mb-0"],[1,"btn","btn-primary","mb-0",3,"click"]],template:function(u,m){u&1&&(r(0,"div",0)(1,"h3",1),a(2),s(3,"translate"),n()(),r(4,"div",2)(5,"div",3),v(6,"i",4),n(),r(7,"div",5)(8,"h4",6),a(9),s(10,"translate"),n(),h(11,P,3,3,"p",7)(12,U,2,1,"div",8)(13,V,11,17,"div",9)(14,A,10,8,"div",10),n()()),u&2&&(i(2),p(o(3,6,"menu.restart.title")),i(7),p(o(10,8,"restart.title_restart")),i(2),d(m.error?-1:11),i(),d(m.error?12:-1),i(),d(m.error?-1:13),i(),d(m.timeout?14:-1))},dependencies:[T,I],styles:[".restart-progress-box[_ngcontent-%COMP%]{font-size:22px;margin-top:15px}"]})}return t})();export{Y as a};
