homebridge-config-ui-x
Version:
A web based management, configuration and control platform for Homebridge.
2 lines (1 loc) • 18.7 kB
JavaScript
import{a as re}from"./chunk-TUN7H57E.js";import{a as oe}from"./chunk-ZHD5CT2Q.js";import{a as le}from"./chunk-RBTY27L3.js";import{a as ne}from"./chunk-ZIPKQJZO.js";import{a as ee}from"./chunk-GXCQWWJO.js";import{a as te,b as ie}from"./chunk-CG4JSQF7.js";import{a as Z}from"./chunk-IZINVULT.js";import{t as z}from"./chunk-YATM6BZO.js";import{a as W,b as H,d as R,e as V,f as X,g as G}from"./chunk-ODMFCOQJ.js";import{a as q}from"./chunk-XPK2EQJA.js";import{b as Y,c as D}from"./chunk-2GN26TCR.js";import{b as B}from"./chunk-4NRNA47I.js";import{C as A,D as J,F as Q,H as I,o as K}from"./chunk-QCMOCU6Q.js";import{Ab as S,Dc as d,Ec as l,Fb as _,Gb as i,Hb as a,Ib as p,Pc as j,Sb as M,Xb as u,Ya as r,Zb as C,aa as c,ea as E,ga as b,gb as U,ha as x,ic as O,kc as g,lb as $,lc as f,mb as T,n as F,sa as w,va as L,xb as m,yc as v,zb as y}from"./chunk-ZMC752RO.js";import{g as de,h as P}from"./chunk-B4AJQJMI.js";var se=de(le(),1);var N=()=>["/"],ce=()=>({exact:!0}),me=()=>["/plugins"],ue=()=>["/accessories"],ge=()=>["/logs"],_e=()=>["/support"],he=()=>["/platform-tools/terminal"],fe=()=>["/config"],ve=()=>["/settings"],be=()=>["/power-options"];function xe(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",20),d(2,"translate"),d(3,"translate"),u("click",function(){b(e);let t=C();return x(t.openUnderVoltageModal())})("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(4,"div",12),p(5,"i",21),a(),i(6,"div",14),g(7),d(8,"translate"),a()()()}s&2&&(r(),m("aria-label",`${l(2,2,"rpi.throttled.undervoltage_title")} - ${l(3,4,"rpi.throttled.undervoltage_description")}`),r(6),f(l(8,6,"rpi.throttled.undervoltage_title")))}function Ce(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",15),d(2,"translate"),u("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(3,"div",12),p(4,"i",22),a(),i(5,"div",14),g(6),d(7,"translate"),a()()()}s&2&&(r(),_("routerLink",v(7,he)),m("aria-label",l(2,3,"menu.linux.label_terminal")),r(5),f(l(7,5,"menu.linux.label_terminal")))}function we(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",15),d(2,"translate"),u("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(3,"div",12),p(4,"i",23),a(),i(5,"div",14),g(6),d(7,"translate"),a()()()}s&2&&(r(),_("routerLink",v(7,fe)),m("aria-label",l(2,3,"menu.config_json_editor")),r(5),f(l(7,5,"menu.config_json_editor")))}function ye(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",15),d(2,"translate"),u("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(3,"div",12),p(4,"i",24),a(),i(5,"div",14),g(6),d(7,"translate"),a()()()}s&2&&(r(),_("routerLink",v(7,ve)),m("aria-label",l(2,3,"menu.label_settings")),r(5),f(l(7,5,"menu.label_settings")))}function Se(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",15),d(2,"translate"),u("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(3,"div",12),p(4,"i",25),a(),i(5,"div",14),g(6),d(7,"translate"),a()()()}s&2&&(r(),_("routerLink",v(7,be)),m("aria-label",l(2,3,"menu.restart.title")),r(5),f(l(7,5,"menu.restart.title")))}function Me(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",20),d(2,"translate"),u("click",function(){b(e);let t=C();return x(t.reloadPage())})("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(3,"div",12),p(4,"i",26),a(),i(5,"div",14),g(6),d(7,"translate"),a()()()}s&2&&(r(),m("aria-label",l(2,2,"menu.reload")),r(5),f(l(7,4,"menu.reload")))}function ke(s,k){if(s&1){let e=M();i(0,"div",10)(1,"div",20),d(2,"translate"),u("click",function(){b(e);let t=C();return x(t.logout())})("keydown",function(t){b(e);let o=C();return x(o.handleKeydown(t))}),i(3,"div",12),p(4,"i",27),a(),i(5,"div",14),g(6),d(7,"translate"),a()()()}s&2&&(r(),m("aria-label",l(2,2,"menu.tooltip_logout")),r(5),f(l(7,4,"menu.tooltip_logout")))}var ae=(()=>{class s{injector=c(E);$auth=c(D);$authHelper=c(Z);$settings=c(B);$modal=c(z);$notification=c(Y);$renderer=c(U);$router=c(V);$toastr=c(Q);$translate=c(A);initialIsExpanded=j(!1);isExpanded=w(!1);formAuth=w(this.$settings.formAuth);isAdmin=this.$auth.user.admin;enableTerminalAccess=this.$settings.env.enableTerminalAccess;rPiCurrentlyUnderVoltage=w(!1);rPiWasUnderVoltage=w(!1);legacyOtpToastShown=w(!1);isMobile=w(!1);freezeMenu=w(!1);isPwa=re();sidebarMouseEnterListener=()=>this.openSidebar();sidebarMouseLeaveListener=()=>this.closeSidebar();touchstartListener;clickListener;constructor(){this.isMobile.set(window.innerWidth<768),L(()=>{let n=this.$notification.raspberryPiThrottled();n["Under Voltage"]&&this.rPiCurrentlyUnderVoltage.set(!0),n["Under-voltage has occurred"]&&this.rPiWasUnderVoltage.set(!0)}),L(()=>{let n=this.$notification.formAuthEnabled();n!==null&&this.formAuth.set(n)}),L(()=>{this.$notification.legacyOtpDetected()&&!this.legacyOtpToastShown()&&(this.legacyOtpToastShown.set(!0),setTimeout(()=>{this.$toastr.warning(this.$translate.instant("users.toast_legacy_otp_message"),this.$translate.instant("users.toast_legacy_otp_title"),{timeOut:0,tapToDismiss:!0,disableTimeOut:!0}).onTap.subscribe(()=>{this.$router.navigate(["/users"])})},3e3))});let e;window.addEventListener("resize",()=>{clearTimeout(e),e=setTimeout(()=>{this.updateListeners()},500)}),this.$router.events.pipe(q()).subscribe(n=>P(this,null,function*(){if(n instanceof W&&this.$settings.formAuth&&n.url!=="/login"&&!(yield this.$authHelper.isAuthenticated())){window.sessionStorage.setItem("target_route",n.url),yield this.$router.navigate(["/login"]);return}n instanceof H&&queueMicrotask(()=>{this.closeSidebar(),this.freezeMenu.set(!0),setTimeout(()=>{this.freezeMenu.set(!1)},750)})}))}ngOnInit(){this.isExpanded.set(this.initialIsExpanded());let e=document.querySelector(".sidebar"),n=document.querySelector(".m-header"),t=document.querySelector(".content");this.isMobile()?(this.touchstartListener=o=>{if(t.contains(o.target)&&this.isExpanded()){o.preventDefault(),this.toggleSidebar();return}!e.contains(o.target)&&!n.contains(o.target)&&this.isExpanded()&&(o.preventDefault(),this.closeSidebar())},document.addEventListener("touchstart",this.touchstartListener,{passive:!1})):(this.updateListeners(),n.addEventListener("mouseenter",this.sidebarMouseEnterListener,{passive:!1}),n.addEventListener("mouseleave",this.sidebarMouseLeaveListener,{passive:!1}),this.clickListener=o=>{e.contains(o.target)&&o.clientX>60&&this.closeSidebar()},document.addEventListener("click",this.clickListener,{passive:!1}))}toggleSidebar(){this.freezeMenu()||(this.isExpanded.set(!this.isExpanded()),this.updateContentStyles())}openUnderVoltageModal(){let e=$([{provide:ie,useValue:{title:this.$translate.instant("rpi.throttled.undervoltage_title"),message:this.$translate.instant(this.rPiCurrentlyUnderVoltage()?"rpi.throttled.currently_message":"rpi.throttled.previously_message"),ctaButtonLabel:this.$translate.instant("form.button_more_info"),faIconClass:"fas fa-bolt yellow-text",ctaButtonLink:"https://pimylifeup.com/raspberry-pi-low-voltage-warning"}}],this.injector);this.$modal.open(oe,{size:"lg",backdrop:"static",injector:e})}handleKeydown(e){if(e.key==="Enter"){let n=e.target;["menuitem","button"].includes(n.getAttribute("role"))&&n.click()}}reloadPage(){window.location.reload()}ngOnDestroy(){this.touchstartListener&&document.removeEventListener("touchstart",this.touchstartListener),this.clickListener&&document.removeEventListener("click",this.clickListener);let e=document.querySelector(".sidebar"),n=document.querySelector(".m-header");e&&(e.removeEventListener("mouseenter",this.sidebarMouseEnterListener),e.removeEventListener("mouseleave",this.sidebarMouseLeaveListener)),n&&(n.removeEventListener("mouseenter",this.sidebarMouseEnterListener),n.removeEventListener("mouseleave",this.sidebarMouseLeaveListener))}logout(){this.$auth.logout()}openSidebar(){this.freezeMenu()||(this.isExpanded.set(!0),this.updateContentStyles())}closeSidebar(){this.freezeMenu()||(this.isExpanded.set(!1),this.updateContentStyles())}updateContentStyles(){let e=document.querySelector(".content");this.isExpanded()?(this.$renderer.setStyle(e,"opacity","20%"),this.$renderer.setStyle(e,"pointer-events","none"),this.$renderer.setStyle(e,"overflow","hidden")):(this.$renderer.removeStyle(e,"opacity"),this.$renderer.removeStyle(e,"pointer-events"),this.$renderer.removeStyle(e,"overflow"))}updateListeners(){this.isMobile.set(window.innerWidth<768);let e=document.querySelector(".sidebar");e.removeEventListener("mouseenter",this.sidebarMouseEnterListener),e.removeEventListener("mouseleave",this.sidebarMouseLeaveListener),(this.isMobile()||!this.isMobile()&&this.$settings.menuMode!=="freeze")&&(e.addEventListener("mouseenter",this.sidebarMouseEnterListener,{passive:!1}),e.addEventListener("mouseleave",this.sidebarMouseLeaveListener,{passive:!1}))}static \u0275fac=function(n){return new(n||s)};static \u0275cmp=T({type:s,selectors:[["app-sidebar"]],inputs:{initialIsExpanded:[1,"initialIsExpanded"]},decls:68,vars:68,consts:[["tabindex","0","role","button",1,"m-header","text-end",3,"click","keydown"],[1,"me-2","d-block","d-lg-none","m-header-label"],[3,"routerLink"],["ngSrc","assets/homebridge-logo.svg","alt","HB Logo","height","35","width","35",1,"hb-logo-img"],[1,"hb-logo-text-mobile"],[1,"hamburger-icon"],["role","navigation","id","sidebar",1,"sidebar"],["tabindex","0","role","button",1,"header",3,"click","keydown"],[1,"hb-logo-text"],[1,"link-wrapper"],[1,"link"],["role","menuitem","tabindex","0","routerLinkActive","active",1,"link-row",3,"keydown","routerLink","routerLinkActiveOptions"],[1,"icon"],[1,"fa","fa-house"],[1,"title"],["role","menuitem","tabindex","0","routerLinkActive","active",1,"link-row",3,"keydown","routerLink"],[1,"fa","fa-plug"],[1,"fa","fa-lightbulb"],[1,"fa","fa-wave-square"],[1,"fa","fa-question-circle-o"],["role","menuitem","tabindex","0",1,"link-row",3,"click","keydown"],[1,"fas","fa-bolt","fa-beat","yellow-text","fa-beat-scale-lg"],[1,"fa","fa-terminal"],[1,"fa","fa-code"],[1,"fa","fa-cog"],[1,"fa","fa-power-off"],[1,"fa","fa-refresh"],[1,"fa","fa-right-from-bracket"]],template:function(n,t){n&1&&(i(0,"div",0),d(1,"translate"),u("click",function(){return t.toggleSidebar()})("keydown",function(h){return t.handleKeydown(h)}),p(2,"span",1),i(3,"a",2),d(4,"translate"),p(5,"img",3),i(6,"div",4),g(7,"Homebridge"),a()(),i(8,"div",5),p(9,"span")(10,"span")(11,"span")(12,"span"),a()(),i(13,"div",6)(14,"div",7),u("click",function(){return t.toggleSidebar()})("keydown",function(h){return t.handleKeydown(h)}),i(15,"a",2),d(16,"translate"),p(17,"img",3),i(18,"div",8),g(19,"Homebridge"),a()()(),i(20,"div",9)(21,"div",10)(22,"div",11),d(23,"translate"),u("keydown",function(h){return t.handleKeydown(h)}),i(24,"div",12),p(25,"i",13),a(),i(26,"div",14),g(27),d(28,"translate"),a()()(),y(29,xe,9,8,"div",10),i(30,"div",10)(31,"div",15),d(32,"translate"),u("keydown",function(h){return t.handleKeydown(h)}),i(33,"div",12),p(34,"i",16),a(),i(35,"div",14),g(36),d(37,"translate"),a()()(),i(38,"div",10)(39,"div",15),d(40,"translate"),u("keydown",function(h){return t.handleKeydown(h)}),i(41,"div",12),p(42,"i",17),a(),i(43,"div",14),g(44),d(45,"translate"),a()()(),i(46,"div",10)(47,"div",15),d(48,"translate"),u("keydown",function(h){return t.handleKeydown(h)}),i(49,"div",12),p(50,"i",18),a(),i(51,"div",14),g(52),d(53,"translate"),a()()(),y(54,Ce,8,8,"div",10),y(55,we,8,8,"div",10),y(56,ye,8,8,"div",10),i(57,"div",10)(58,"div",15),d(59,"translate"),u("keydown",function(h){return t.handleKeydown(h)}),i(60,"div",12),p(61,"i",19),a(),i(62,"div",14),g(63),d(64,"translate"),a()()(),y(65,Se,8,8,"div",10),y(66,Me,8,6,"div",10),y(67,ke,8,6,"div",10),a()()),n&2&&(m("aria-expanded",t.isExpanded()?"true":"false")("aria-controls","sidebar")("aria-label",l(1,34,"menu.sidebar.aria_menu")),r(3),_("routerLink",v(60,N)),m("aria-label",l(4,36,"menu.label_status")),r(5),O("hamburger-icon-cross",t.isExpanded()),r(5),O("expanded",t.isExpanded()),r(2),_("routerLink",v(61,N)),m("aria-label",l(16,38,"menu.label_status")),r(7),_("routerLink",v(62,N))("routerLinkActiveOptions",v(63,ce)),m("aria-label",l(23,40,"menu.label_status")),r(5),f(l(28,42,"menu.label_status")),r(2),S(t.rPiWasUnderVoltage()||t.rPiCurrentlyUnderVoltage()?29:-1),r(2),_("routerLink",v(64,me)),m("aria-label",l(32,44,"menu.label_plugins")),r(5),f(l(37,46,"menu.label_plugins")),r(3),_("routerLink",v(65,ue)),m("aria-label",l(40,48,"menu.label_accessories")),r(5),f(l(45,50,"menu.label_accessories")),r(3),_("routerLink",v(66,ge)),m("aria-label",l(48,52,"menu.linux.label_logs")),r(5),f(l(53,54,"menu.linux.label_logs")),r(2),S(t.enableTerminalAccess&&t.isAdmin?54:-1),r(),S(t.isAdmin?55:-1),r(),S(t.isAdmin?56:-1),r(2),_("routerLink",v(67,_e)),m("aria-label",l(59,56,"support.title")),r(5),f(l(64,58,"support.title")),r(2),S(t.isAdmin?65:-1),r(),S(t.isPwa?66:-1),r(),S(t.formAuth()?67:-1))},dependencies:[X,K,G,J],styles:[".m-header[_ngcontent-%COMP%]{position:fixed;top:0;left:0;width:100%;height:65px;z-index:510;display:flex;align-items:center;padding-left:3px;padding-right:3px}.m-header[_ngcontent-%COMP%]:hover{cursor:pointer}@media(min-width:768px){.m-header[_ngcontent-%COMP%]{display:none}}.m-header-label[_ngcontent-%COMP%]{font-size:.9rem;color:#ddd}.hb-logo-img[_ngcontent-%COMP%]{height:35px;width:35px}.fa-beat-scale-lg[_ngcontent-%COMP%]{--fa-beat-scale: 1.5}.sidebar[_ngcontent-%COMP%]{position:fixed;left:0;top:0;height:100vh;transition:.3s;width:60px;z-index:500}.sidebar[_ngcontent-%COMP%] .header[_ngcontent-%COMP%]{display:flex;flex-direction:column;justify-content:center;padding:15px 10px 15px 11px;font-size:.85rem}.sidebar[_ngcontent-%COMP%] .header[_ngcontent-%COMP%]:hover{cursor:pointer}.sidebar[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%]{overflow-x:hidden;overflow-y:auto;max-height:calc(100vh - 80px)!important;scrollbar-width:thin}@media(max-width:767px){.sidebar[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%]{padding-bottom:60px}}.sidebar[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%] .link[_ngcontent-%COMP%] .link-row[_ngcontent-%COMP%]{display:flex;align-items:center;padding:15px 10px;cursor:pointer;transition:.2s;font-size:17px}.sidebar[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%] .link[_ngcontent-%COMP%] .link-row[_ngcontent-%COMP%] .icon[_ngcontent-%COMP%]{flex:0 0 38px;display:flex;align-items:center;justify-content:center}.sidebar[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%] .link[_ngcontent-%COMP%] .link-row[_ngcontent-%COMP%] .title[_ngcontent-%COMP%]{flex:1;transition:.3s;max-width:0;overflow:hidden;white-space:nowrap}@media(max-width:767px){.sidebar[_ngcontent-%COMP%]{width:0}.sidebar[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%]{display:none}}.sidebar.expanded[_ngcontent-%COMP%]{width:210px}@media(max-width:767px){.sidebar.expanded[_ngcontent-%COMP%]{width:210px}.sidebar.expanded[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%]{display:block}}.sidebar.expanded[_ngcontent-%COMP%] .link-wrapper[_ngcontent-%COMP%] .link[_ngcontent-%COMP%] .link-row[_ngcontent-%COMP%] .title[_ngcontent-%COMP%]{max-width:150px;padding-left:10px}.hamburger-icon[_ngcontent-%COMP%]{margin:-7px 0 0 25px}@media(min-width:768px){.hb-logo-text[_ngcontent-%COMP%]{color:#fff;position:absolute;top:17px;font-size:22px;padding-left:3px}.sidebar.expanded[_ngcontent-%COMP%] .hb-logo-text[_ngcontent-%COMP%]{opacity:1;left:55px;transition:.3s}.sidebar[_ngcontent-%COMP%]:not(.expanded) .hb-logo-text[_ngcontent-%COMP%]{opacity:0;left:40px;transition:.3s}.hb-logo-text-mobile[_ngcontent-%COMP%], .hamburger-icon[_ngcontent-%COMP%]{display:none!important}}@media(max-width:767px){.hb-logo-text[_ngcontent-%COMP%]{display:none!important}.hb-logo-text-mobile[_ngcontent-%COMP%]{color:#fff;position:absolute;top:17px;font-size:22px;padding-left:3px;opacity:1;left:55px}.hamburger-icon[_ngcontent-%COMP%]{position:absolute;right:10px;top:28px;width:30px;transform:rotate(0);transition:.5s ease-in-out;cursor:pointer}.hamburger-icon[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:block;position:absolute;height:2px;width:100%;background-color:#fff;border-radius:9px;opacity:1;left:0;transform:rotate(0);transition:.25s ease-in-out}.hamburger-icon[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(1){top:0}.hamburger-icon[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(2), .hamburger-icon[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(3){top:10px}.hamburger-icon[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(4){top:20px}.hamburger-icon-cross[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(1){top:10px;width:0;left:50%}.hamburger-icon-cross[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(2){transform:rotate(45deg)}.hamburger-icon-cross[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(3){transform:rotate(-45deg)}.hamburger-icon-cross[_ngcontent-%COMP%] span[_ngcontent-%COMP%]:nth-child(4){top:10px;width:0;left:50%}}"],changeDetection:0})}return s})();var ot=(()=>{class s{injector=c(E);$auth=c(D);$modal=c(z);$router=c(V);$settings=c(B);$translate=c(A);$ws=c(ee);io;sidebarExpanded=w(!1);ngOnInit(){this.io=this.$ws.connectToNamespace("app"),this.io.socket.on("reconnect",()=>{this.$auth.checkToken()}),this.compareServerUiVersion()}compareServerUiVersion(){return P(this,null,function*(){if(this.$settings.settingsLoaded||(yield F(this.$settings.onSettingsLoaded)),!this.$router.url.endsWith("/restart")&&(0,se.lt)(this.$settings.uiVersion,I.serverTarget)){console.log(`Server restart required. UI Version: ${I.serverTarget} - Server Version: ${this.$settings.uiVersion} `);let e=$([{provide:te,useValue:{title:this.$translate.instant("platform.version.service_restart_required"),message:this.$translate.instant("platform.version.restart_required",{serverVersion:this.$settings.uiVersion,uiVersion:I.serverTarget}),confirmButtonLabel:this.$translate.instant("menu.tooltip_restart"),faIconClass:"fas fa-power-off orange-text"}}],this.injector),n=this.$modal.open(ne,{size:"lg",backdrop:"static",injector:e});try{yield n.result,this.$router.navigate(["/restart"])}catch(t){}}})}static \u0275fac=function(n){return new(n||s)};static \u0275cmp=T({type:s,selectors:[["app-layout"]],decls:3,vars:3,consts:[[3,"initialIsExpanded"],[1,"content","px-3","p-md-4"]],template:function(n,t){n&1&&(p(0,"app-sidebar",0),i(1,"div",1),p(2,"router-outlet"),a()),n&2&&(_("initialIsExpanded",t.sidebarExpanded()),r(),O("sidebarExpanded",t.sidebarExpanded()))},dependencies:[ae,R],styles:[".content[_ngcontent-%COMP%]{margin-left:60px;transition:.3s;height:100%}@media(max-width:767px){.content[_ngcontent-%COMP%]{margin-left:0;padding-top:85px!important}}@media(min-width:768px){.content[_ngcontent-%COMP%]{height:100%}}a[_ngcontent-%COMP%]:hover{text-decoration:none!important}"],changeDetection:0})}return s})();export{ot as LayoutComponent};