homebridge-config-ui-x
Version:
A web based management, configuration and control platform for Homebridge.
2 lines (1 loc) • 3.58 kB
JavaScript
import{a as B}from"./chunk-GAHGBZ7U.js";import{a as _}from"./chunk-IL6HHVES.js";import"./chunk-LKBXKG4K.js";import{b as M}from"./chunk-RFCSHRPV.js";import{f as k}from"./chunk-3APJQTJL.js";import{$b as b,$c as D,Ea as r,Mb as s,Nb as m,Ra as $,Yc as R,Zc as T,aa as n,cb as v,db as h,dc as c,dd as I,ec as d,fc as w,la as y,mb as o,nb as i,ob as p,qa as f,wb as S,x as l,za as C,zb as u}from"./chunk-LTGI3NYM.js";import{h as E}from"./chunk-B4AJQJMI.js";var z=t=>({command:t});function O(t,g){if(t&1&&(o(0,"div",7),s(1),i()),t&2){let e=u();r(),m(e.error())}}function j(t,g){t&1&&(o(0,"p",9),s(1),c(2,"translate"),i(),o(3,"div",10)(4,"div",11),p(5,"i",12),i()()),t&2&&(r(),m(d(2,1,"restart.please_wait_while_server_restarts")))}function H(t,g){if(t&1&&(o(0,"div",8)(1,"p"),s(2),c(3,"translate"),i(),p(4,"p",13),c(5,"translate"),i()),t&2){let e=u();r(2),m(d(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(()=>{})});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(_(this.destroyRef)).subscribe(()=>{let e=a=>{(a.status==="ok"||a.status==="pending")&&(this.io.socket.off("homebridge-status",e),this.$toastr.success(this.$translate.instant("platform.docker.container_restarted"),this.$translate.instant("toast.title_success")),this.$router.navigate(["/"]))};this.io.socket.on("homebridge-status",e),this.io.socket.emit("monitor-server-status")}),l(6e4).pipe(_(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(a){return new(a||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(a,x){a&1&&(o(0,"div",0)(1,"h3",1),s(2),c(3,"translate"),i()(),o(4,"div",2)(5,"div",3),p(6,"i",4),i(),o(7,"div",5)(8,"h4",6),s(9),c(10,"translate"),i(),v(11,O,2,1,"div",7)(12,j,6,3),v(13,H,6,9,"div",8),i()()),a&2&&(r(2),m(d(3,4,"menu.restart.title")),r(7),m(d(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};