UNPKG

homebridge-config-ui-x

Version:

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

2 lines (1 loc) 4.18 kB
import{a as V}from"./chunk-S5L52QFG.js";import{a as q}from"./chunk-77GWB2NW.js";import{a as _}from"./chunk-6M524CF7.js";import{n as B,o as k}from"./chunk-OHFVMRCL.js";import{h as D,k as F}from"./chunk-SXUVUFAV.js";import{a as z,b as E}from"./chunk-KPKQNEWS.js";import{$a as m,Ac as i,Bc as r,Gb as b,Lc as S,Nb as h,Ob as s,Pb as l,Qb as p,Ub as L,Xb as d,_a as y,dc as T,ec as C,g as j,h as w,jc as x,kc as I,la as o,lb as $,n as v,ra as u,sa as f}from"./chunk-QSPBB6EE.js";var H=j(q(),1);var A=["logoutput"],X=(()=>{class c{$api=o(F);$log=o(V);$modal=o(B);$toastr=o(D);$translate=o(z);termTarget=S("logoutput");resizeEvent=new v;constructor(){}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){window.document.querySelector("body").classList.add("bg-black"),this.$log.startTerminal(this.termTarget(),{},this.resizeEvent)}ngOnDestroy(){window.document.querySelector("body").classList.remove("bg-black"),this.$log.destroyTerminal()}downloadLogFile(){let t=this.$modal.open(_,{size:"lg",backdrop:"static"});t.componentInstance.title=this.$translate.instant("logs.title_download_log_file"),t.componentInstance.message=this.$translate.instant("logs.download_warning"),t.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_download"),t.componentInstance.faIconClass="fas fa-fw fa-user-secret primary-text",t.result.then(()=>{this.$api.get("/platform-tools/hb-service/log/download",{observe:"response",responseType:"blob"}).subscribe({next:e=>{(0,H.saveAs)(e.body,"homebridge.log.txt")},error:e=>w(this,null,function*(){let n;try{n=JSON.parse(yield e.error.text()).message}catch(a){console.error(a)}this.$toastr.error(n||this.$translate.instant("logs.download.error"),this.$translate.instant("toast.title_error"))})})}).catch(()=>{})}truncateLogFile(){let t=this.$modal.open(_,{size:"lg",backdrop:"static"});t.componentInstance.title=this.$translate.instant("logs.title_truncate_log_file"),t.componentInstance.message=this.$translate.instant("logs.truncate_log_warning"),t.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_delete"),t.componentInstance.confirmButtonClass="btn-danger",t.componentInstance.faIconClass="fas fa-fw fa-circle-exclamation primary-text",t.result.then(()=>{this.$api.put("/platform-tools/hb-service/log/truncate",{}).subscribe({next:()=>{this.$toastr.success(this.$translate.instant("logs.log_file_truncated"),this.$translate.instant("toast.title_success")),this.$log.term.clear()},error:e=>{console.error(e),this.$toastr.error(e.error.message||this.$translate.instant("logs.truncate.error"),this.$translate.instant("toast.title_error"))}})}).catch(()=>{})}static \u0275fac=function(e){return new(e||c)};static \u0275cmp=$({type:c,selectors:[["ng-component"]],viewQuery:function(e,n){e&1&&T(n.termTarget,A,5),e&2&&C()},hostBindings:function(e,n){e&1&&d("resize",function(g){return n.onWindowResize(g)},y)},decls:17,vars:15,consts:[["logoutput",""],[1,"row","mb-3"],[1,"col-6"],[1,"primary-text","m-0"],[1,"col-6","text-end"],["container","body","placement","bottom","openDelay","150","triggers","hover",1,"btn","btn-elegant","my-0","me-2",3,"click","ngbTooltip"],[1,"fas","fa-fw","fa-download"],["container","body","placement","bottom","openDelay","150","triggers","hover",1,"btn","btn-elegant","my-0","me-0",3,"click","ngbTooltip"],[1,"fas","fa-fw","fa-trash-alt"],[1,"flex-column","d-flex","align-items-stretch","adjust-for-mobile"],["id","log-output",1,"align-self-end","w-100","h-100","mb-1"]],template:function(e,n){if(e&1){let a=L();s(0,"div",1)(1,"div",2)(2,"h3",3),x(3),i(4,"translate"),l()(),s(5,"div",4)(6,"button",5),i(7,"translate"),i(8,"translate"),d("click",function(){return u(a),f(n.downloadLogFile())}),p(9,"i",6),l(),s(10,"button",7),i(11,"translate"),i(12,"translate"),d("click",function(){return u(a),f(n.truncateLogFile())}),p(13,"i",8),l()()(),s(14,"div",9),p(15,"div",10,0),l()}e&2&&(m(3),I(r(4,5,"menu.linux.label_logs")),m(3),h("ngbTooltip",r(7,7,"form.button_download")),b("aria-label",r(8,9,"form.button_download")),m(4),h("ngbTooltip",r(11,11,"form.button_delete")),b("aria-label",r(12,13,"form.button_delete")))},dependencies:[k,E],encapsulation:2})}return c})();export{X as a};