UNPKG

homebridge-config-ui-x

Version:

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

1 lines 3.83 kB
import{a as E}from"./chunk-D39XL-zh.js";import{$ as Le,Fr as se,I as Ga,Jr as ve,Kr as v3,M as Fe,Un as g,Vt as U3,Y as Je,Zr as w_,_t as Pn,dt as Nf,fn as Z,gt as Pe,hr as nc,it as Mi,jt as S_,kn as br,pt as Ot,ri as x_,u as An,ui as z0,ut as N_,vt as Py,wr as q}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";var H=t=>({command:t});function B(t,_){if(t&1&&(Pe(0,`div`,7),Ot(1),Je()),t&2){let e=ve();se(),Py(e.error())}}function z(t,_){t&1&&(Pe(0,`p`,9),Ot(1),S_(2,`translate`),Je(),Pe(3,`div`,10)(4,`div`,11),br(5,`i`,12),Je()()),t&2&&(se(),Py(N_(2,1,`restart.please_wait_while_server_restarts`)))}function N(t,_){if(t&1&&(Pe(0,`div`,8)(1,`p`),Ot(2),S_(3,`translate`),Je(),br(4,`p`,13),S_(5,`translate`),Je()),t&2){let e=ve();se(2),Py(N_(3,2,`platform.docker.server_long_time`)),se(2),Mi(`innerHTML`,x_(5,4,`platform.docker.run_with_restart`,w_(7,H,e.command)),Ga)}}var V=(()=>{class t{$api=g(U3);$router=g(le);$settings=g(zt);$toastr=g(z0);$translate=g(Nf);$ws=g(ds);destroyRef=g(Z);io;statusCheckActive=q(!1);statusHandler=e=>{this.statusCheckActive()&&(e.status===`ok`||e.status===`pending`)&&(this.statusCheckActive.set(!1),this.$toastr.success(this.$translate.instant(`platform.docker.container_restarted`),this.$translate.instant(`toast.title_success`)),this.$router.navigate([`/`]))};timeout=q(!1);error=q(!1);command=`<span class="font-monospace">--restart=always</span>`;ngOnInit(){this.initialize()}initialize(){return E(this,null,function*(){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`,this.statusHandler);try{yield this.$api.put(`/platform-tools/docker/restart-container`,{}),this.checkIfServerUp()}catch(e){this.error.set(this.$translate.instant(`restart.toast_server_restart_error`)),console.error(e),this.$toastr.error(this.$translate.instant(`restart.toast_server_restart_error`),this.$translate.instant(`toast.title_error`))}})}ngOnDestroy(){this.io.socket.off(`homebridge-status`,this.statusHandler),this.statusCheckActive.set(!1),this.io.end?.()}checkIfServerUp(){Pn(1e4).pipe(An(this.destroyRef)).subscribe(()=>{this.statusCheckActive.set(!0),this.io.socket.emit(`monitor-server-status`)}),Pn(6e4).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||t)};static ɵcmp=nc({type:t,selectors:[[`app-container-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,`fab`,`fa-docker`,`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,`fas`,`fa-circle-notch`,`fa-spin`],[1,`grey-text`,`mb-0`,3,`innerHTML`]],template:function(d,x){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,B,2,1,`div`,7)(12,z,6,3),Fe(13,N,6,9,`div`,8),Je()()),d&2&&(se(2),Py(N_(3,4,`menu.restart.title`)),se(7),Py(N_(10,6,`platform.docker.title_restarting`)),se(2),Le(x.error()?11:12),se(2),Le(x.timeout()?13:-1))},dependencies:[v3],styles:[`.restart-progress-box[_ngcontent-%COMP%]{font-size:22px;font-weight:300;margin-top:15px}`]})}return t})();export{V as ContainerRestartComponent};