homebridge-config-ui-x
Version:
A web based management, configuration and control platform for Homebridge.
1 lines • 11.1 kB
JavaScript
import {Y}from'./chunk-CG3i5q02.js';import {p}from'./chunk-BWu8OGjA.js';import {A}from'./chunk-WUyBXYN7.js';import {g,av as fe$1,X as I3,l as le$1,z as zt,a1 as M0,a2 as bf,W,E,a5 as x,a4 as w,J as Ja,K as Kn,b7 as Xn,b8 as Yn,bb as Vt,e as Hn,be as ln,k as K8,m as La,s as At,t as f_,R as Rd,q as rc,u as Re,y as ie,N as Ny,G as h_,D as ly,a6 as vr,O as Oe,o as dy,b1 as dT,bv as lT,U as ye,b4 as fT,a8 as nc,I as Rt,x as Cy,a9 as Go,aa as Wo,bt as Fy,by as t_,Q as KC,bu as ky,T as JC,bo as xy}from'./main-ONDCASUV.js';function le(i,g){i&1&&(La(0,"div",12),dy(1,"i",13),Rd(),La(2,"p",14),At(3),f_(4,"translate"),Rd()),i&2&&(ie(3),Ny(h_(4,1,"reset.no_accessories")));}function de(i,g){if(i&1&&(La(0,"option",24),At(1),Rd()),i&2){let e=g.$implicit;ly("value",e._id),ie(),xy("",e.name," (",e._username,")");}}function me(i,g){if(i&1){let e=nc();La(0,"li",20),At(1),f_(2,"translate"),Rd(),La(3,"li",18)(4,"label",21),At(5),f_(6,"translate"),Rd(),La(7,"div",22)(8,"select",23),Fy("ngModelChange",function(t){Go(e);let o=ye(2);return t_(o.selectedBridge,t)||(o.selectedBridge=t),Wo(t)}),rc("change",function(t){Go(e);let o=ye(2);return Wo(o.onBridgeChange(t))}),dT(9,de,2,3,"option",24,lT),Rd(),KC(),Rd()();}if(i&2){let e=ye(2);ie(),Ny(h_(2,3,"form.label.changes_kept")),ie(4),Ny(h_(6,5,"reset.accessory_ind.bridge")),ie(3),ky("ngModel",e.selectedBridge),JC(),ie(),fT(e.pairings());}}function pe(i,g){if(i&1&&(La(0,"li",18)(1,"span",25),At(2),f_(3,"translate"),Rd(),La(4,"div",26),At(5),Rd()()),i&2){let e=ye(2);ie(2),Ny(h_(3,2,"reset.accessory_ind.bridge")),ie(3),Rt(" ",e.getCurrentlySelectedBridge()," ");}}function ue(i,g){if(i&1){let e=nc();La(0,"li",27)(1,"span",28),dy(2,"i",29),Rd(),La(3,"span",30),At(4),dy(5,"br"),La(6,"small")(7,"span",31),At(8),Rd()()(),La(9,"button",32),f_(10,"translate"),rc("click",function(){let t=Go(e).$implicit,o=ye(2);return Wo(o.toggleList(t.UUID||t.uuid,t.$cacheFile,t.$protocol,t.$deviceId))}),dy(11,"i",33),Rd()();}if(i&2){let e=g.$implicit,n=ye(2);Cy("list-group-item-highlight",n.shouldHighlight(e.UUID||e.uuid,e.$cacheFile)),ie(2),Cy("fa-matter",e.$protocol==="matter")("fa-hap",e.$protocol!=="matter"),ie(2),Rt(" ",e.displayName," "),ie(4),Ny(e.UUID||e.uuid),ie(),Cy("btn-danger",!n.isInList(e.UUID||e.uuid,e.$cacheFile,e.$protocol))("btn-elegant",n.isInList(e.UUID||e.uuid,e.$cacheFile,e.$protocol)),ly("disabled",n.clicked()),vr("aria-label",h_(10,22,"form.button_delete")),ie(2),Cy("fa-trash",!n.isInList(e.UUID||e.uuid,e.$cacheFile,e.$protocol))("fa-undo",n.isInList(e.UUID||e.uuid,e.$cacheFile,e.$protocol)&&!n.clicked())("fa-circle-notch",n.isInList(e.UUID||e.uuid,e.$cacheFile,e.$protocol)&&n.clicked())("fa-spin",n.isInList(e.UUID||e.uuid,e.$cacheFile,e.$protocol)&&n.clicked());}}function _e(i,g){if(i&1&&(La(0,"div",12),dy(1,"i",15),Rd(),La(2,"ul",16)(3,"li"),At(4),f_(5,"translate"),Rd(),La(6,"li"),At(7),f_(8,"translate"),Rd(),La(9,"li"),At(10),f_(11,"translate"),Rd()(),La(12,"ul",17),Re(13,me,11,7),Re(14,pe,6,4,"li",18),dT(15,ue,12,24,"li",19,lT),Rd()),i&2){let e=ye();ie(4),Ny(h_(5,5,"reset.accessory_ind.list_1")),ie(3),Ny(h_(8,7,"reset.accessory_ind.list_2")),ie(3),Ny(h_(11,9,"reset.accessory_ind.list_3")),ie(3),Oe(e.pairings().length>1?13:-1),ie(),Oe(e.pairings().length===1?14:-1),ie(),fT(e.selectedBridgeAccessories());}}function ge(i,g){if(i&1){let e=nc();La(0,"button",34),rc("click",function(){Go(e);let t=ye();return Wo(t.dismissModal())}),At(1),f_(2,"translate"),Rd();}if(i&2){let e=ye();ly("disabled",e.clicked()),ie(),Rt(" ",h_(2,2,"form.button_close")," ");}}function he(i,g){if(i&1){let e=nc();La(0,"button",35),rc("click",function(){Go(e);let t=ye();return Wo(t.dismissModal())}),At(1),f_(2,"translate"),Rd();}i&2&&(ie(),Rt(" ",h_(2,1,"form.button_close")," "));}function ve(i,g){if(i&1&&At(0),i&2){let e=ye(3);Rt(" (",e.toDelete().length,") ");}}function fe(i,g){if(i&1&&(At(0),f_(1,"translate"),Re(2,ve,1,1)),i&2){let e=ye(2);Rt(" ",h_(1,2,"form.button_remove")," "),ie(2),Oe(e.toDelete().length>0?2:-1);}}function xe(i,g){i&1&&dy(0,"i",37);}function Ce(i,g){if(i&1){let e=nc();La(0,"button",36),rc("click",function(){Go(e);let t=ye();return Wo(t.removeAccessories())}),Re(1,fe,3,4)(2,xe,1,0,"i",37),Rd();}if(i&2){let e=ye();ly("disabled",!e.toDelete().length||e.clicked()),ie(),Oe(e.clicked()?2:1);}}var Fe=(()=>{class i{$activeModal=g(fe$1);$accessoryOverview=g(Y);$api=g(I3);$router=g(le$1);$settings=g(zt);$toastr=g(M0);$translate=g(bf);modalData=g(p);selectedBridge=this.modalData.selectedBridge;highlightUuid=this.modalData.highlightUuid;highlightCacheFile=this.modalData.highlightCacheFile;pairings=W([]);clicked=W(false);currentSelectedBridge=W("");selectedBridgeAccessories=W([]);accessoriesExist=W(false);toDelete=W([]);isMatterSupported=this.$settings.isFeatureEnabled("matterSupport");ngOnInit(){this.currentSelectedBridge.set(this.selectedBridge),this.loadCachedAccessories();}onBridgeChange(e){let n=e.target.value;this.currentSelectedBridge.set(n),this.selectedBridgeAccessories.set(this.pairings().find(t=>t._id===this.currentSelectedBridge())?.accessories||[]);}getCurrentlySelectedBridge(){let e=this.pairings().find(n=>n._id===this.currentSelectedBridge());return e?`${e.name} - ${e._username}`:""}toggleList(e,n,t,o){this.toDelete().some(l=>l.uuid===e&&l.cacheFile===n&&l.protocol===t)?this.toDelete.set(this.toDelete().filter(l=>l.uuid!==e||l.cacheFile!==n||l.protocol!==t)):this.toDelete.update(l=>[...l,{cacheFile:n,uuid:e,protocol:t,deviceId:o}]);}isInList(e,n,t){return this.toDelete().some(o=>o.uuid===e&&o.cacheFile===n&&o.protocol===t)}shouldHighlight(e,n){return !!this.highlightUuid&&this.selectedBridgeAccessories().length>1&&e===this.highlightUuid&&n===this.highlightCacheFile}removeAccessories(){return E(this,null,function*(){this.clicked.set(true);let e=this.toDelete().filter(o=>o.protocol==="hap").map(o=>({uuid:o.uuid,cacheFile:o.cacheFile})),n=this.toDelete().filter(o=>o.protocol==="matter").map(o=>({uuid:o.uuid,deviceId:o.deviceId})),t=[];if(e.length>0&&t.push(this.$api.delete("/server/cached-accessories",{body:e})),this.isMatterSupported&&n.length>0&&t.push(this.$api.delete("/server/matter-accessories",{body:n})),t.length===0){this.clicked.set(false);return}try{yield Promise.all(t),this.$accessoryOverview.invalidate(),this.$toastr.success(this.$translate.instant("reset.accessory_ind.done"),this.$translate.instant("toast.title_success")),this.$activeModal.close(),this.$router.navigate(["/restart"],{queryParams:{restarting:!0}});}catch(o){this.clicked.set(false),console.error(o),this.$toastr.error(this.$translate.instant("reset.accessory_ind.fail"),this.$translate.instant("toast.title_error"));}})}dismissModal(){this.$activeModal.dismiss("Dismiss");}loadCachedAccessories(){return E(this,null,function*(){try{let{hapAccessories:e,matterAccessories:n,pairings:t}=yield this.$accessoryOverview.get(),o=this.isMatterSupported?n:[],l=new Map(t.map(c=>[c._id,x(w({},c),{accessories:[]})]));e.sort((c,d)=>c.displayName.localeCompare(d.displayName)).forEach(c=>{let d=t.find(ce=>ce._main),A$1=c.$cacheFile?.split(".")?.[1]||d._id;(!this.selectedBridge||this.selectedBridge===A$1)&&(l.has(A$1)||l.set(A$1,{_id:A$1,_username:A$1.match(A).join(":"),name:this.$translate.instant("reset.accessory_ind.unknown"),accessories:[]}),c.$protocol="hap",l.get(A$1).accessories.push(c));}),this.isMatterSupported&&o.sort((c,d)=>c.displayName.localeCompare(d.displayName)).forEach(c=>{let d=c.$deviceId;(!this.selectedBridge||this.selectedBridge===d)&&(l.has(d)||l.set(d,{_id:d,_username:d.match(A).join(":"),name:this.$translate.instant("reset.accessory_ind.unknown"),accessories:[]}),c.$protocol="matter",c.$cacheFile=d,l.get(d).accessories.push(c));});let re=[...l.values()].filter(c=>c.accessories.length>0).sort((c,d)=>c._main&&!d._main?-1:!c._main&&d._main?1:c.name.localeCompare(d.name));this.pairings.set(re);let D=this.selectedBridge||this.pairings()[0]?._id;D&&(this.selectedBridge=D,this.currentSelectedBridge.set(D),this.accessoriesExist.set(!0),this.selectedBridgeAccessories.set(this.pairings().find(c=>c._id===D)?.accessories||[]),this.highlightUuid&&this.selectedBridgeAccessories().length>1&&setTimeout(()=>document.querySelector(".list-group-item-highlight")?.scrollIntoView({block:"center",behavior:"smooth"}),250));}catch(e){console.error(e),this.$toastr.error(this.$translate.instant("reset.error_message"),this.$translate.instant("toast.title_error")),this.$activeModal.close();}})}static \u0275fac=function(n){return new(n||i)};static \u0275cmp=Ja({type:i,selectors:[["app-remove-individual-accessories"]],decls:17,vars:11,consts:[[1,"modal-content"],[1,"modal-header"],[1,"modal-title"],["type","button","data-bs-dismiss","modal",1,"btn-close",3,"click","disabled"],[1,"modal-body"],[1,"modal-footer","justify-content-between"],[1,"text-start"],["type","button","data-bs-dismiss","modal",1,"btn","btn-elegant",3,"disabled"],[1,"text-center"],["type","button","data-bs-dismiss","modal",1,"btn","btn-elegant"],[1,"text-end"],["type","button","data-bs-dismiss","modal",1,"btn","btn-danger",3,"disabled"],[1,"text-center","mb-3"],[1,"fas","fa-circle-check","primary-text","icon-xl"],[1,"mb-0","text-center"],[1,"fas","fa-network-wired","primary-text","icon-xl"],[1,"mb-3"],[1,"list-group","list-group-box","mb-0"],[1,"list-group-item","d-flex","flex-column","flex-md-row","align-items-center"],[1,"list-group-item","d-flex","justify-content-between","align-items-center",3,"list-group-item-highlight"],[1,"list-group-item","text-center","grey-text","small"],["for","bridgeSelect",1,"mb-2","mb-md-0","w-100","w-md-50"],[1,"text-start","text-md-end","w-100","w-md-50"],["id","bridgeSelect",1,"custom-select",3,"ngModelChange","change","ngModel"],[3,"value"],[1,"mb-2","mb-md-0","w-100","w-md-50"],[1,"text-start","text-md-end","w-100","w-md-50","grey-text","font-monospace"],[1,"list-group-item","d-flex","justify-content-between","align-items-center"],[1,"me-3"],[1,"fas","fa-lg"],[1,"flex-grow-1"],[1,"font-monospace","grey-text"],["type","button",1,"btn","btn-danger","m-0","ms-3",3,"click","disabled"],[1,"fas"],["type","button","data-bs-dismiss","modal",1,"btn","btn-elegant",3,"click","disabled"],["type","button","data-bs-dismiss","modal",1,"btn","btn-elegant",3,"click"],["type","button","data-bs-dismiss","modal",1,"btn","btn-danger",3,"click","disabled"],[1,"fas","fa-circle-notch","fa-spin"]],template:function(n,t){n&1&&(La(0,"div",0)(1,"div",1)(2,"h5",2),At(3),f_(4,"translate"),Rd(),La(5,"button",3),f_(6,"translate"),rc("click",function(){return t.dismissModal()}),Rd()(),La(7,"div",4),Re(8,le,5,3)(9,_e,17,11),Rd(),La(10,"div",5)(11,"div",6),Re(12,ge,3,4,"button",7),Rd(),La(13,"div",8),Re(14,he,3,3,"button",9),Rd(),La(15,"div",10),Re(16,Ce,3,2,"button",11),Rd()()()),n&2&&(ie(3),Ny(h_(4,7,"reset.accessory_ind.title")),ie(2),ly("disabled",t.clicked()),vr("aria-label",h_(6,9,"form.button_close")),ie(3),Oe(t.accessoriesExist()?9:8),ie(4),Oe(t.accessoriesExist()?12:-1),ie(2),Oe(t.accessoriesExist()?-1:14),ie(2),Oe(t.accessoriesExist()?16:-1));},dependencies:[Kn,Xn,Yn,Vt,Hn,ln,K8],encapsulation:2})}return i})();export{Fe as F};