import{a as T}from"./chunk-54LXMJYQ.js";import"./chunk-VZDFTSCE.js";import{d as $}from"./chunk-LV5TYHZ7.js";import{b as S}from"./chunk-EYGXMMT2.js";import{k as g,l as _,n as E,q as y}from"./chunk-NJYCNYHB.js";import{Ib as v,La as n,Vb as a,Wa as h,Wb as s,ja as o,lb as c,mb as d,mc as m,nc as l,vb as r,wb as i,xb as u}from"./chunk-ZHRPBG7M.js";function C(t,f){if(t&1&&(r(0,"div",7),a(1),i()),t&2){let e=v();n(),s(e.error)}}function w(t,f){t&1&&(r(0,"p",9),a(1),m(2,"translate"),i(),r(3,"div",10)(4,"div",11),u(5,"i",12),i()()),t&2&&(n(),s(l(2,1,"restart.please_wait_while_server_restarts")))}function k(t,f){t&1&&(r(0,"div",8),a(1),m(2,"translate"),i()),t&2&&(n(),s(l(2,1,"platform.linux.long_time")))}var z=(()=>{class t{$api=o(y);$router=o($);$settings=o(S);$toastr=o(E);$translate=o(g);$ws=o(T);checkTimeout;checkDelay;io;resp={};timeout=!1;error=!1;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("/platform-tools/linux/restart-host",{}).subscribe({next:e=>{this.resp=e,this.checkIfServerUp()},error:e=>{console.error(e),this.error=this.$translate.instant("platform.linux.server_restart_error"),this.$toastr.error(this.$translate.instant("platform.linux.server_restart_error"),this.$translate.instant("toast.title_error"))}})}ngOnDestroy(){this.io.end(),clearTimeout(this.checkDelay),clearTimeout(this.checkTimeout)}checkIfServerUp(){this.checkDelay=setTimeout(()=>{this.io.socket.on("homebridge-status",e=>{(e.status==="up"||e.status==="pending")&&(this.$toastr.success(this.$translate.instant("platform.linux.server_restarted"),this.$translate.instant("toast.title_success")),this.$router.navigate(["/"]))})},3e4),this.checkTimeout=setTimeout(()=>{this.$toastr.warning(this.$translate.instant("platform.linux.server_taking_long_time"),this.$translate.instant("toast.title_warning"),{timeOut:1e4}),this.timeout=!0},12e4)}static \u0275fac=function(p){return new(p||t)};static \u0275cmp=h({type:t,selectors:[["ng-component"]],decls:14,vars:8,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-power-off",2,"font-size","75px"],[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,"fas","fa-spinner","fa-spin"]],template:function(p,x){p&1&&(r(0,"div",0)(1,"h3",1),a(2),m(3,"translate"),i()(),r(4,"div",2)(5,"div",3),u(6,"i",4),i(),r(7,"div",5)(8,"h4",6),a(9),m(10,"translate"),i(),c(11,C,2,1,"div",7)(12,w,6,3),c(13,k,3,3,"div",8),i()()),p&2&&(n(2),s(l(3,4,"menu.restart.title")),n(7),s(l(10,6,"platform.linux.restarting_server")),n(2),d(x.error?11:12),n(2),d(x.timeout?13:-1))},dependencies:[_],styles:[".restart-progress-box[_ngcontent-%COMP%]{font-size:22px;font-weight:300;margin-top:15px}"]})}return t})();export{z as RestartLinuxComponent};
