homebridge-config-ui-x
Version:
A web based management, configuration and control platform for Homebridge.
2 lines (1 loc) • 3.63 kB
JavaScript
import{a as B}from"./chunk-GXCQWWJO.js";import{e as k}from"./chunk-ODMFCOQJ.js";import{a as g}from"./chunk-XPK2EQJA.js";import"./chunk-2GN26TCR.js";import{b as M}from"./chunk-4NRNA47I.js";import{C as R,D as T,F as D,I}from"./chunk-QCMOCU6Q.js";import{Ab as h,Dc as m,Ec as c,Fc as w,Jb as o,Kb as i,Lb as p,Ta as C,Tb as S,Ya as r,Zb as u,aa as n,kc as a,lc as s,ma as y,mb as $,sa as f,w as l,zb as v,zc as b}from"./chunk-ZMC752RO.js";import{h as E}from"./chunk-B4AJQJMI.js";var z=t=>({command:t});function O(t,_){if(t&1&&(o(0,"div",7),a(1),i()),t&2){let e=u();r(),s(e.error())}}function j(t,_){t&1&&(o(0,"p",9),a(1),m(2,"translate"),i(),o(3,"div",10)(4,"div",11),p(5,"i",12),i()()),t&2&&(r(),s(c(2,1,"restart.please_wait_while_server_restarts")))}function A(t,_){if(t&1&&(o(0,"div",8)(1,"p"),a(2),m(3,"translate"),i(),p(4,"p",13),m(5,"translate"),i()),t&2){let e=u();r(2),s(c(3,2,"platform.docker.server_long_time")),r(2),S("innerHTML",w(5,4,"platform.docker.run_with_restart",b(7,z,e.command)),C)}}var V=(()=>{class t{$api=n(I);$router=n(k);$settings=n(M);$toastr=n(D);$translate=n(R);$ws=n(B);destroyRef=n(y);io;timeout=f(!1);error=f(!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.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(()=>{}));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.end?.()}checkIfServerUp(){l(1e4).pipe(g(this.destroyRef)).subscribe(()=>{this.io.socket.on("homebridge-status",e=>{(e.status==="ok"||e.status==="pending")&&(this.$toastr.success(this.$translate.instant("platform.docker.container_restarted"),this.$translate.instant("toast.title_success")),this.$router.navigate(["/"]))})}),l(6e4).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||t)};static \u0275cmp=$({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&&(o(0,"div",0)(1,"h3",1),a(2),m(3,"translate"),i()(),o(4,"div",2)(5,"div",3),p(6,"i",4),i(),o(7,"div",5)(8,"h4",6),a(9),m(10,"translate"),i(),v(11,O,2,1,"div",7)(12,j,6,3),v(13,A,6,9,"div",8),i()()),d&2&&(r(2),s(c(3,4,"menu.restart.title")),r(7),s(c(10,6,"platform.docker.title_restarting")),r(2),h(x.error()?11:12),r(2),h(x.timeout()?13:-1))},dependencies:[T],styles:[".restart-progress-box[_ngcontent-%COMP%]{font-size:22px;font-weight:300;margin-top:15px}"],changeDetection:0})}return t})();export{V as ContainerRestartComponent};