"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[223],{2223:(Z,c,s)=>{s.r(c),s.d(c,{LogsModule:()=>I});var f=s(6895),g=s(8304),r=s(4463),m=s(7750),h=s(5861),p=s(4327),v=s(7579),d=s(1862),t=s(4650),$=s(2503),b=s(9274),y=s(6726),L=s(7185);const w=["logoutput"],x=[{path:"",component:(()=>{class o{$settings;$api;$log;$toastr;$translate;$modal;termTarget;resizeEvent=new v.x;constructor(e,n,a,i,l,u){this.$settings=e,this.$api=n,this.$log=a,this.$toastr=i,this.$translate=l,this.$modal=u}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(){var e=this;const n=this.$modal.open(d.X,{size:"lg",backdrop:"static"});n.componentInstance.title=this.$translate.instant("logs.title_download_log_file"),n.componentInstance.message=this.$translate.instant("logs.message_download_warning"),n.componentInstance.confirmButtonLabel=this.$translate.instant("logs.label_download"),n.componentInstance.faIconClass="fas fa-fw fa-user-secret primary-text",n.result.then(()=>{this.$api.get("/platform-tools/hb-service/log/download",{observe:"response",responseType:"blob"}).subscribe(a=>{(0,p.saveAs)(a.body,"homebridge.log.txt")},function(){var a=(0,h.Z)(function*(i){let l;try{l=JSON.parse(yield i.error.text()).message}catch{}e.$toastr.error(l||"Failed to download log file",e.$translate.instant("toast.title_error"))});return function(i){return a.apply(this,arguments)}}())}).catch(()=>{})}truncateLogFile(){const e=this.$modal.open(d.X,{size:"lg",backdrop:"static"});e.componentInstance.title=this.$translate.instant("logs.title_truncate_log_file"),e.componentInstance.message=this.$translate.instant("logs.message_truncate_log_warning"),e.componentInstance.confirmButtonLabel=this.$translate.instant("form.button_delete"),e.componentInstance.confirmButtonClass="btn-danger",e.componentInstance.faIconClass="fas fa-fw fa-circle-exclamation primary-text",e.result.then(()=>{this.$api.put("/platform-tools/hb-service/log/truncate",{}).subscribe(()=>{this.$toastr.success(this.$translate.instant("logs.message_log_file_truncated"),this.$translate.instant("toast.title_success")),this.$log.term.clear()},n=>{this.$toastr.error(n.error.message||"Failed to truncate log file",this.$translate.instant("toast.title_error"))})}).catch(()=>{})}static \u0275fac=function(n){return new(n||o)(t.Y36($.g),t.Y36(b.s),t.Y36(y.$),t.Y36(L._W),t.Y36(r.sK),t.Y36(g.FF))};static \u0275cmp=t.Xpm({type:o,selectors:[["app-logs"]],viewQuery:function(n,a){if(1&n&&t.Gf(w,7),2&n){let i;t.iGM(i=t.CRH())&&(a.termTarget=i.first)}},hostBindings:function(n,a){1&n&&t.NdJ("resize",function(l){return a.onWindowResize(l)},!1,t.Jf7)},decls:15,vars:9,consts:[[1,"row","mb-3"],[1,"col-6"],[1,"primary-text","m-0"],[1,"col-6","text-right"],[1,"btn","btn-elegant","my-0",3,"click"],[1,"fas","fa-fw","fa-download"],[1,"btn","btn-elegant","my-0","mr-0",3,"click"],[1,"fas","fa-fw","fa-trash-alt"],[1,"flex-column","d-flex","align-items-stretch",2,"height","calc(100% - 52px)"],["id","log-output",1,"terminal","align-self-end","w-100","h-100","mb-1"],["logoutput",""]],template:function(n,a){1&n&&(t.TgZ(0,"div",0)(1,"div",1)(2,"h3",2),t._uU(3),t.ALo(4,"translate"),t.qZA()(),t.TgZ(5,"div",3)(6,"button",4),t.NdJ("click",function(){return a.downloadLogFile()}),t.ALo(7,"translate"),t._UZ(8,"i",5),t.qZA(),t.TgZ(9,"button",6),t.NdJ("click",function(){return a.truncateLogFile()}),t.ALo(10,"translate"),t._UZ(11,"i",7),t.qZA()()(),t.TgZ(12,"div",8),t._UZ(13,"div",9,10),t.qZA()),2&n&&(t.xp6(3),t.Oqu(t.lcZ(4,3,"menu.linux.label_logs")),t.xp6(3),t.uIk("aria-label",t.lcZ(7,5,"logs.label_download")),t.xp6(3),t.uIk("aria-label",t.lcZ(10,7,"form.button_delete")))},dependencies:[r.X$]})}return o})()}];let C=(()=>{class o{static \u0275fac=function(n){return new(n||o)};static \u0275mod=t.oAB({type:o});static \u0275inj=t.cJS({imports:[m.Bz.forChild(x),m.Bz]})}return o})(),I=(()=>{class o{static \u0275fac=function(n){return new(n||o)};static \u0275mod=t.oAB({type:o});static \u0275inj=t.cJS({imports:[f.ez,C,g.IJ,r.aw.forChild()]})}return o})()}}]);