@mxtommy/kip
Version:
An advanced and versatile marine instrumentation package to display Signal K data.
2 lines (1 loc) • 7.26 kB
JavaScript
import{a as G,b as J,c as X,d as Y,e as Z,f as ee}from"./chunk-CB4E7PPA.js";import{a as Q}from"./chunk-SHJMXSDM.js";import{c as U,f as z,h as H,j as K}from"./chunk-W6MCE3GH.js";import{a as W}from"./chunk-O5BTKN5D.js";import{r as F}from"./chunk-IXUKD73N.js";import"./chunk-VFJD3XKT.js";import"./chunk-HF7V6XFA.js";import{m as V}from"./chunk-2TP7C66X.js";import{Ba as T,Bb as I,Cb as M,Cc as $,Db as D,Eb as l,Fb as d,Ga as c,Gb as N,Ha as S,Nb as w,Pb as R,Qe as g,Rb as p,Te as B,Ue as j,Wa as f,a as y,b as v,bc as A,ec as m,fc as L,gb as P,le as q,qa as u,va as b,wa as C,xb as E,yb as O,zb as k}from"./chunk-LEY6MANN.js";var te=(n,a)=>a.id;function ie(n,a){if(n&1){let e=w();l(0,"button",9),R("click",function(){let t=b(e).$implicit,o=p();return C(o.displayDashboards(t.displayId))}),m(1),d()}if(n&2){let e=a.$implicit,i=p();A("selected",i.selectedDisplayButtonId()===e.displayId),f(),L(e.displayName)}}function ne(n,a){n&1&&(l(0,"button",5)(1,"i"),m(2,'"No Remote"'),d()())}function se(n,a){n&1&&(l(0,"div",7),N(1,"mat-progress-spinner",10),d())}function oe(n,a){if(n&1){let e=w();l(0,"tile-large-icon",12,0),R("click",function(){let t=b(e).$index,o=p(2);return C(o.setActiveScreen(t))}),d()}if(n&2){let e=a.$implicit,i=a.$index,t=p(2);D("active",t.activeScreenIdx()===i)("svgIcon",e.icon)("iconSize",72)("label",e.name)}}function ae(n,a){if(n&1&&I(0,oe,2,4,"tile-large-icon",11,te),n&2){let e=p();M(e.screens())}}function re(n,a){n&1&&(l(0,"div",8)(1,"mat-icon",13),m(2,"cast"),d(),l(3,"div",14)(4,"p"),m(5,"Select an available remote KIP in the menu."),d(),l(6,"p"),m(7,"To allow remote control of a dashboard, on that KIP device open Options \u2192 Display \u2192 Remote Control and enable it."),d()()())}var De=(()=>{class n{COMMAND_REQUEST_ACTIVE_SCREEN_PATH="self.kip.remote.requestActiveScreen";_settings=u(V);_data=u(F);_requests=u(U);_destroyRef=u(T);pageTitle="Remote Control";appID=this._settings.KipUUID;displayId=c(null);selectedDisplayButtonId=c(null);screensLoading=c(!1);displaysMap=c({});selectedDisplaySub=null;selectedScreenIndexSub=null;displays=$(()=>Object.values(this.displaysMap()).filter(i=>i.displayId!==this.appID).sort((i,t)=>{let o=(i.displayName??"").toLowerCase(),s=(t.displayName??"").toLowerCase();return o&&s?o.localeCompare(s):o?-1:s?1:i.displayId.localeCompare(t.displayId)}));screens=c([]);activeScreenIdx=c(null);constructor(){this._data.subscribePathTree("self.displays.*").pipe(g(this._destroyRef)).subscribe(({path:e,update:i})=>{this.updateDisplayCatalog(e,i.data.value)}),S(()=>{let e=this.displays(),i=this.selectedDisplayButtonId();if(!e.length){this.displayDashboards(null);return}(!i||!e.some(t=>t.displayId===i))&&this.displayDashboards(e[0].displayId)}),S(()=>{this.rebindSelectedDisplaySubscriptions(this.displayId())})}updateDisplayCatalog(e,i){let t=this.extractDisplayId(e);if(!t||t===this.appID)return;let o=`self.displays.${t}`;this.displaysMap.update(s=>{let r=y({},s);if(e===o&&(i===null||typeof i>"u"))return delete r[t],r;let _=(r[t]??{displayId:t,displayName:null}).displayName;if(e===o&&i&&typeof i=="object"){let x=i;typeof x.displayName=="string"?_=x.displayName:x.displayName===null&&(_=null)}return r[t]={displayId:t,displayName:_},r})}rebindSelectedDisplaySubscriptions(e){if(this.selectedDisplaySub?.unsubscribe(),this.selectedDisplaySub=null,this.selectedScreenIndexSub?.unsubscribe(),this.selectedScreenIndexSub=null,!e){this.screensLoading.set(!1),this.screens.set([]),this.activeScreenIdx.set(null);return}this.screensLoading.set(!0),this.selectedDisplaySub=this._data.subscribePath(`self.displays.${e}`,"default").pipe(g(this._destroyRef)).subscribe(i=>{this.screensLoading.set(!1);let t=i.data.value,o=Array.isArray(t?.screens)?t.screens.filter(s=>!!s&&typeof s=="object"&&typeof s.id=="string"&&typeof s.name=="string"&&typeof s.icon=="string"):[];this.screens.set(o),t&&Object.prototype.hasOwnProperty.call(t,"displayName")&&this.displaysMap.update(s=>{let r=s[e];if(!r)return s;let h=typeof t.displayName=="string"?t.displayName:t.displayName===null?null:r.displayName;return h===r.displayName?s:v(y({},s),{[e]:v(y({},r),{displayName:h})})})}),this.selectedScreenIndexSub=this._data.subscribePath(`self.displays.${e}.screenIndex`,"default").pipe(g(this._destroyRef)).subscribe(i=>{let t=i.data.value;this.activeScreenIdx.set(typeof t=="number"?t:null)})}extractDisplayId(e){return e.match(/^self\.displays\.([^.]+)(?:\.|$)/)?.[1]??null}displayDashboards(e){this.displayId.set(e),this.selectedDisplayButtonId.set(e)}setActiveScreen(e){let i=this.activeScreenIdx(),t=this.displayId();if(!t)return;this.activeScreenIdx.set(e),this._requests.putRequest(this.COMMAND_REQUEST_ACTIVE_SCREEN_PATH,{displayId:t,screenIdx:e},this.appID)||(console.error("Failed to set active screen: request was not accepted"),this.activeScreenIdx.set(i))}static \u0275fac=function(i){return new(i||n)};static \u0275cmp=P({type:n,selectors:[["remote-control"]],decls:11,vars:3,consts:[["tile",""],["svgIconId","remote-control",3,"pageTitle"],[1,"sidenav-remote-control-container"],["mode","side","opened",""],["mat-list-item","","tabindex","0",3,"selected"],["mat-list-item","","tabindex","0","disabled","true",2,"text-align","center"],[1,"sidenav-remote-control-content"],["aria-label","Loading screens",1,"loading-container"],["role","status","aria-live","polite",1,"empty-state-msg"],["mat-list-item","","tabindex","0",3,"click"],["mode","indeterminate","diameter","64","strokeWidth","5"],[3,"active","svgIcon","iconSize","label"],[3,"click","active","svgIcon","iconSize","label"],["aria-hidden","true","color","primary",1,"empty-state-icon"],[1,"copy"]],template:function(i,t){i&1&&(N(0,"page-header",1),l(1,"mat-sidenav-container",2)(2,"mat-sidenav",3)(3,"mat-action-list"),I(4,ie,2,3,"button",4,k,!1,ne,3,0,"button",5),d()(),l(7,"mat-sidenav-content",6),E(8,se,2,0,"div",7)(9,ae,2,0)(10,re,8,0,"div",8),d()()),i&2&&(D("pageTitle",t.pageTitle),f(4),M(t.displays()),f(4),O(t.screensLoading()?8:t.screens().length?9:10))},dependencies:[W,Y,J,X,G,K,z,H,q,ee,Z,Q,j,B],styles:[".sidenav-remote-control-container[_ngcontent-%COMP%]{height:calc(100% - 87px);width:calc(100% - 48px);margin:0 24px 24px;border:1px solid var(--mat-sys-outline-variant)}mat-sidenav[_ngcontent-%COMP%]{width:150px;--mat-sidenav-container-shape: square}.selected[_ngcontent-%COMP%]{background-color:var(--mat-sys-inverse-on-surface)}.loading-container[_ngcontent-%COMP%]{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px}.sidenav-remote-control-content[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;align-content:flex-start;height:100%;width:100%;padding:5px;gap:5px;overflow-y:auto;scrollbar-width:none;overflow-x:hidden;scroll-behavior:smooth;flex:1 1 auto;min-height:0}tile-large-icon[_ngcontent-%COMP%]{width:190px}.empty-state-msg[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-wrap:nowrap;align-items:center;justify-content:center;height:100%;width:calc(100% - 150px);min-height:70vh;padding:2rem;text-align:center;color:var(--mat-sys-outline-variant);font-style:italic}.empty-state-icon[_ngcontent-%COMP%]{font-size:4rem;width:4rem;height:4rem;color:var(--mat-sys-outline-variant);margin-bottom:1rem}"]})}return n})();export{De as RemoteControlComponent};