homebridge-config-ui-x
Version:
A web based management, configuration and control platform for Homebridge.
4 lines (3 loc) • 11.9 kB
JavaScript
import{a as ct}from"./chunk-JV663RTB.js";import"./chunk-NHCHC3LD.js";import{a as P}from"./chunk-ZIPKQJZO.js";import{a as ht}from"./chunk-M5NPMQ5Y.js";import"./chunk-GXCQWWJO.js";import{b as at}from"./chunk-NAG4LCT2.js";import{a as O}from"./chunk-CG4JSQF7.js";import{a as lt}from"./chunk-YMS6PENN.js";import{t as st}from"./chunk-YATM6BZO.js";import{a as G}from"./chunk-XPK2EQJA.js";import{c as U}from"./chunk-2GN26TCR.js";import{D as rt,c as X,e as Y,f as Z,g as tt,j as et,m as ot,r as it,s as nt}from"./chunk-ORSKS7BY.js";import{b as K}from"./chunk-4NRNA47I.js";import{C as Q,D as H,F as W,I as J}from"./chunk-QCMOCU6Q.js";import{Ab as x,Dc as s,Ec as l,F as I,Fb as b,Gb as d,Hb as m,I as D,Ib as h,Qc as E,Sb as v,Xa as j,Xb as g,Ya as r,Zb as p,aa as c,d as q,ea as V,ec as z,fc as A,ga as u,ha as f,ic as B,jc as R,kc as L,lb as $,lc as M,ma as F,mb as N,sa as T,xb as _,zb as y}from"./chunk-ZMC752RO.js";import{g as pt,h as S}from"./chunk-B4AJQJMI.js";var k=pt(ht(),1);var gt=["logoutput"],ut=["searchInput"];function ft(i,C){if(i&1){let e=v();d(0,"div",5)(1,"button",9),s(2,"translate"),s(3,"translate"),g("click",function(){u(e);let t=p();return f(t.showSearch())}),h(4,"i"),m(),d(5,"button",9),s(6,"translate"),s(7,"translate"),g("click",function(){u(e);let t=p();return f(t.downloadLogFile())}),h(8,"i",10),m(),d(9,"button",11),s(10,"translate"),s(11,"translate"),g("click",function(){u(e);let t=p();return f(t.truncateLogFile())}),h(12,"i",12),m()()}if(i&2){let e=p();r(),b("openDelay",150)("ngbTooltip",l(2,11,"form.search")),_("aria-label",l(3,13,"form.search")),r(3),R(`fas fa-search${e.showSearchBar()?" primary-text":""}`),r(),b("openDelay",150)("ngbTooltip",l(6,15,"form.button_download")),_("aria-label",l(7,17,"form.button_download")),r(4),b("openDelay",150)("ngbTooltip",l(10,19,"form.button_delete")),_("aria-label",l(11,21,"form.button_delete"))}}function bt(i,C){if(i&1){let e=v();d(0,"button",18),s(1,"translate"),g("click",function(){u(e);let t=p(2);return f(t.onClearSearch())}),h(2,"i",19),m()}i&2&&_("aria-label",l(1,1,"form.button_clear"))}function _t(i,C){i&1&&(d(0,"span",17),L(1),s(2,"translate"),m()),i&2&&(r(),M(l(2,1,"common.labels.beta")))}function wt(i,C){if(i&1){let e=v();d(0,"div",6)(1,"div",13)(2,"form",14),g("ngSubmit",function(){u(e);let t=p();return f(t.onSubmit(t.form.value))}),h(3,"input",15,1),s(5,"translate"),y(6,bt,3,3,"button",16)(7,_t,3,3,"span",17),m()()()}if(i&2){let e,o=p();r(2),b("formGroup",o.form),r(),B("search-bar-light",o.terminalTheme==="light")("is-invalid",o.searchInputInvalid),b("placeholder",l(5,7,"logs.placeholder_search_logs")),r(3),x((e=o.form.get("query"))!=null&&e.value?6:7)}}var zt=(()=>{class i{destroyRef=c(F);injector=c(V);$api=c(J);$auth=c(U);$log=c(ct);$modal=c(st);$settings=c(K);$toastr=c(W);$translate=c(Q);termTarget=E("logoutput");searchInput=E("searchInput");resizeEvent=new q;isAdmin=this.$auth.user.admin;showSearchBar=T(!1);showExitButton=T(!1);terminalTheme="dark";form=new tt({query:new et("")});get searchInputInvalid(){let e=(this.form.get("query")?.value||"").trim();return e.length>0&&e.length<3}onWindowResize(){this.resizeEvent.next(void 0)}ngOnInit(){let e=this.$translate.instant("menu.linux.label_logs");if(this.$settings.setPageTitle(e),this.terminalTheme=this.$settings.getEffectiveTerminalLightingMode(),this.terminalTheme==="dark"?window.document.querySelector("body").classList.add("bg-black"):window.document.querySelector("body").classList.add("bg-white"),this.$settings.actualLightingMode==="light"&&this.terminalTheme==="dark"){window.document.querySelector("body").classList.add("theme-transition");let t=this.termTarget()?.nativeElement;t&&t.classList.add("theme-transition")}this.$log.startTerminal(this.termTarget(),this.$settings.getTerminalOptions(),this.resizeEvent),this.form.get("query")?.valueChanges.pipe(I(500),D(),G(this.destroyRef)).subscribe(t=>{let n=t||"",a=n.trim();a!==n&&this.form.get("query")?.setValue(a,{emitEvent:!1}),a.length>=3?(this.showExitButton.set(!0),this.$log.setSearchFilter(a),this.$log.scrollToBottom()):a.length<3&&this.showExitButton()&&(this.showExitButton.set(!1),this.$log.clearSearchFilter(),this.$log.scrollToBottom())})}showSearch(){if(this.showSearchBar())this.showSearchBar.set(!1),this.showExitButton.set(!1),this.form.setValue({query:""}),this.$log.clearSearchFilter();else{this.showSearchBar.set(!0);let e=this.searchInput();e&&setTimeout(()=>e.nativeElement.focus(),10)}setTimeout(()=>this.resizeEvent.next(void 0),10),this.$log.scrollToBottom()}onSubmit(e){let o=(e.query||"").trim();!o.length||o.length<3?(o.length||this.showSearchBar.set(!1),this.form.setValue({query:""}),this.showExitButton.set(!1),this.$log.clearSearchFilter()):(this.showExitButton.set(!0),this.$log.setSearchFilter(o)),this.$log.scrollToBottom()}onClearSearch(){this.form.setValue({query:""}),this.showExitButton.set(!1),this.$log.clearSearchFilter(),this.$log.scrollToBottom()}canDeactivate(e){let o=this.$settings.getEffectiveTerminalLightingMode();return this.$settings.actualLightingMode==="light"&&o==="dark"?(this.showSearchBar()&&this.showSearchBar.set(!1),window.document.querySelector("body").classList.remove("theme-transition"),new Promise(n=>{let a=e&&(e.includes("/platform-tools/terminal")||e.includes("/logs")),w=this.termTarget()?.nativeElement;w&&w.classList.add("fade-out"),a?setTimeout(()=>{n(!0)},250):(setTimeout(()=>{window.document.querySelector("body").classList.remove("bg-black"),window.document.querySelector("body").classList.remove("bg-white")},250),setTimeout(()=>{n(!0)},500))})):(window.document.querySelector("body").classList.remove("bg-black"),window.document.querySelector("body").classList.remove("bg-white"),Promise.resolve(!0))}ngOnDestroy(){window.document.querySelector("body").classList.remove("light-mode"),this.resizeEvent.complete(),this.$log.destroyTerminal()}downloadLogFile(){return S(this,null,function*(){let e=$([{provide:O,useValue:{title:this.$translate.instant("logs.title_download_log_file"),message:this.$translate.instant("logs.download_warning"),confirmButtonLabel:this.$translate.instant("form.button_download"),faIconClass:"fas fa-user-secret primary-text"}}],this.injector),o=this.$modal.open(P,{size:"lg",backdrop:"static",injector:e});try{yield o.result;try{let t=yield this.$api.get("/platform-tools/hb-service/log/download",{observe:"response",responseType:"blob"}),n=this.$log.getSearchFilter();if(n){let w=(yield t.body.text()).split(`
`).filter(dt=>dt.replace(at,"").toLowerCase().includes(n.toLowerCase())),mt=new Blob([w.join(`
`)],{type:"text/plain"});(0,k.saveAs)(mt,"homebridge.log.txt")}else(0,k.saveAs)(t.body,"homebridge.log.txt")}catch(t){let n;try{if(t&&typeof t=="object"&&"error"in t){let a=yield t.error.text();n=JSON.parse(a).message}}catch(a){console.error(a)}this.$toastr.error(n||this.$translate.instant("logs.download.error"),this.$translate.instant("toast.title_error"))}}catch(t){}})}truncateLogFile(){return S(this,null,function*(){let e=$([{provide:O,useValue:{title:this.$translate.instant("logs.title_truncate_log_file"),message:this.$translate.instant("logs.truncate_log_warning"),confirmButtonLabel:this.$translate.instant("form.button_delete"),confirmButtonClass:"btn-danger",faIconClass:"fas fa-circle-exclamation primary-text"}}],this.injector),o=this.$modal.open(P,{size:"lg",backdrop:"static",injector:e});try{yield o.result;try{yield this.$api.put("/platform-tools/hb-service/log/truncate",{}),this.$toastr.success(this.$translate.instant("logs.log_file_truncated"),this.$translate.instant("toast.title_success")),this.$log.term.clear()}catch(t){console.error(t);let n=t&&typeof t=="object"&&"error"in t&&t.error&&typeof t.error=="object"&&"message"in t.error?String(t.error.message):this.$translate.instant("logs.truncate.error");this.$toastr.error(n,this.$translate.instant("toast.title_error"))}}catch(t){}})}static \u0275fac=function(o){return new(o||i)};static \u0275cmp=N({type:i,selectors:[["app-logs"]],viewQuery:function(o,t){o&1&&z(t.termTarget,gt,5)(t.searchInput,ut,5),o&2&&A(2)},hostBindings:function(o,t){o&1&&g("resize",function(){return t.onWindowResize()},j)},decls:10,vars:9,consts:[["logoutput",""],["searchInput",""],[1,"row","mb-3"],[1,"col-6"],[1,"primary-text","m-0"],[1,"col-6","text-end"],[1,"row"],[1,"flex-column","d-flex","align-items-stretch"],["id","log-output",1,"align-self-end","w-100","h-100","mb-1"],["type","button","container","body","placement","bottom","triggers","hover",1,"btn","btn-elegant","my-0","me-2",3,"click","openDelay","ngbTooltip"],[1,"fas","fa-download"],["type","button","container","body","placement","bottom","triggers","hover",1,"btn","btn-elegant","my-0","me-0",3,"click","openDelay","ngbTooltip"],[1,"fas","fa-trash-alt"],[1,"col-md-12"],["novalidate","",3,"ngSubmit","formGroup"],["type","text","id","logs-search","formControlName","query",1,"search-bar",3,"placeholder"],["type","button",1,"search-bar-clear"],[1,"search-bar-badge","badge","badge-primary","badge-beta"],["type","button",1,"search-bar-clear",3,"click"],["aria-hidden","true",1,"fas","fa-square-xmark"]],template:function(o,t){o&1&&(d(0,"div",2)(1,"div",3)(2,"h3",4),L(3),s(4,"translate"),m()(),y(5,ft,13,23,"div",5),m(),y(6,wt,8,9,"div",6),d(7,"div",7),h(8,"div",8,0),m()),o&2&&(r(3),M(l(4,7,"menu.linux.label_logs")),r(2),x(t.isAdmin?5:-1),r(),x(t.showSearchBar()?6:-1),r(),B("adjust-for-mobile",!t.showSearchBar())("adjust-for-mobile-with-search",t.showSearchBar()))},dependencies:[lt,rt,ot,X,Y,Z,nt,it,H],styles:["#log-output.theme-transition[_ngcontent-%COMP%]{opacity:0;animation:_ngcontent-%COMP%_fadeIn .25s ease-in-out .25s forwards}#log-output.theme-transition.fade-out[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_fadeOut .25s ease-in-out forwards!important;opacity:1}@keyframes _ngcontent-%COMP%_fadeIn{to{opacity:1}}@keyframes _ngcontent-%COMP%_fadeOut{to{opacity:0}}.search-bar[_ngcontent-%COMP%]{outline:none;box-sizing:inherit!important;height:50px!important;width:100%;padding:10px 45px 10px 10px;margin-bottom:15px;background-color:#111!important;color:#999!important;border:0 #242424!important}@media(hover:hover){.search-bar[_ngcontent-%COMP%]:hover{border:1px solid #242424!important}}.search-bar[_ngcontent-%COMP%]:focus{border:1px solid #242424!important;box-shadow:inherit!important;color:#eee!important}.search-bar[_ngcontent-%COMP%]::placeholder{color:#636363!important;opacity:1!important}.search-bar.search-bar-light[_ngcontent-%COMP%]{background-color:#fff!important;color:#000!important;border:.5px solid #d0d0d0!important}@media(hover:hover){.search-bar.search-bar-light[_ngcontent-%COMP%]:hover{border:1px solid #000000!important}}.search-bar.search-bar-light[_ngcontent-%COMP%]:focus{border:1px solid #000000!important;box-shadow:0 1px #000!important;color:#000!important}.search-bar.search-bar-light[_ngcontent-%COMP%]::placeholder{color:#757575!important;opacity:1!important}.search-bar.is-invalid[_ngcontent-%COMP%]{border:1px solid #d32f2f!important;box-shadow:0 1px #d32f2f!important}@media(hover:hover){.search-bar.is-invalid[_ngcontent-%COMP%]:hover{border:1px solid #d32f2f!important;box-shadow:0 1px #d32f2f!important}}.search-bar.is-invalid[_ngcontent-%COMP%]:focus{border:1px solid #d32f2f!important;box-shadow:0 1px #d32f2f!important}.search-bar-clear[_ngcontent-%COMP%]{position:absolute;right:8px;top:8px;height:50px;background:transparent;border:none;font-size:20px;color:#636363;cursor:pointer;padding:0 8px;display:flex;align-items:center}.search-bar-clear[_ngcontent-%COMP%]:hover{color:#999}.search-bar-badge[_ngcontent-%COMP%]{position:absolute;right:10px;top:16px;font-size:.75rem;padding:.25em .5em}.adjust-for-mobile-with-search[_ngcontent-%COMP%]{height:calc(100% - 97px);width:calc(100% + 17px);overflow:hidden}@media(max-width:767px){.adjust-for-mobile-with-search[_ngcontent-%COMP%]{height:calc(100% - 125px);width:calc(100% + 16px)}}"],changeDetection:0})}return i})();export{zt as LogsComponent};