@mxtommy/kip 3.9.0-beta.10 → 3.9.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +49 -12
  2. package/package.json +2 -2
  3. package/public/3rdpartylicenses.txt +38 -38
  4. package/public/{chunk-PKNLASTF.js → chunk-22UVF7E4.js} +1 -1
  5. package/public/{chunk-NXWZM4IV.js → chunk-2NEY3YTE.js} +2 -2
  6. package/public/{chunk-VHFBF47T.js → chunk-3FJFLAW2.js} +1 -1
  7. package/public/{chunk-ZBCOJLI4.js → chunk-4WLU7SQK.js} +1 -1
  8. package/public/{chunk-JY3WVS7C.js → chunk-5KJ57S2K.js} +1 -1
  9. package/public/{chunk-QBSWR6ST.js → chunk-7RQUFCX7.js} +1 -1
  10. package/public/{chunk-NS2FPVWM.js → chunk-7TU3ZWML.js} +1 -1
  11. package/public/{chunk-2YVW3TBK.js → chunk-BPFSYA37.js} +1 -1
  12. package/public/{chunk-RRTCHHRC.js → chunk-EO34EE4V.js} +1 -1
  13. package/public/{chunk-KTDDP73O.js → chunk-EWHP4JKO.js} +1 -1
  14. package/public/{chunk-4JJLPUET.js → chunk-EZMEBXXM.js} +1 -1
  15. package/public/{chunk-TA4GACKT.js → chunk-FEXPC4HW.js} +1 -1
  16. package/public/{chunk-HCXH72CD.js → chunk-FVALI6JO.js} +1 -1
  17. package/public/{chunk-3LEMFOCV.js → chunk-G5XHTLTP.js} +1 -1
  18. package/public/{chunk-35L7BBBD.js → chunk-H5OPY2IR.js} +12 -12
  19. package/public/{chunk-VYUMZVH2.js → chunk-IAZ6ZOIN.js} +1 -1
  20. package/public/{chunk-ITJ6DJR6.js → chunk-LFVNB44Z.js} +1 -1
  21. package/public/{chunk-CQXWGD3T.js → chunk-LR2ASNFJ.js} +1 -1
  22. package/public/{chunk-QQIXD7EO.js → chunk-M5VFYACR.js} +10 -10
  23. package/public/{chunk-H2TTV4FA.js → chunk-MIQ7Z5UW.js} +1 -1
  24. package/public/{chunk-NMEZOCU2.js → chunk-RQ23BH6Q.js} +1 -1
  25. package/public/{chunk-CBUY7NMR.js → chunk-SWYOATEE.js} +1 -1
  26. package/public/{chunk-Q2Y75POI.js → chunk-TOY6DYVQ.js} +1 -1
  27. package/public/{chunk-IHLEBYV7.js → chunk-Y27DLVLA.js} +1 -1
  28. package/public/{chunk-TXPLRBW5.js → chunk-YAK5FQIH.js} +2 -2
  29. package/public/index.html +2 -2
  30. package/public/main-J5SSLV3T.js +53 -0
  31. package/public/{styles-GMXUNVLC.css → styles-AE6JMQ4R.css} +1 -1
  32. package/public/main-JXMQUCCA.js +0 -53
@@ -1 +1 @@
1
- import{a as re}from"./chunk-VHFBF47T.js";import{f as oe,n as ae}from"./chunk-ZBCOJLI4.js";import{h as I}from"./chunk-TXPLRBW5.js";import{a as R}from"./chunk-IHLEBYV7.js";import{a as ie}from"./chunk-2YVW3TBK.js";import{A as B,D as G,E as K,H,K as z,N as Y,P as $,Q,R as X,T as Z,_ as ee,ca as te,da as ne,g as N,h as V,i as A,r as W,t as q,w as J,x as U}from"./chunk-TA4GACKT.js";import{$b as _,Aa as g,Cc as E,Ec as w,Fc as T,Fe as j,Gc as y,Nc as F,Sb as v,Tb as h,Ub as L,Vb as P,Wb as M,Xb as k,Yb as f,Zb as n,_b as i,f as O,gc as b,ic as m,kc as u,lb as c,ta as C,uc as x,wb as D,za as d,zc as o}from"./chunk-35L7BBBD.js";var le=()=>({standalone:!1});function se(r,p){r&1&&(n(0,"div"),o(1,' Writing to the server requires "Login to Server" authentication or a Device token '),i())}function ce(r,p){if(r&1){let e=b();n(0,"div")(1,"mat-form-field",31)(2,"mat-label"),o(3,"Scope"),i(),n(4,"mat-select",32),y("ngModelChange",function(t){d(e);let a=u();return T(a.saveConfigScope,t)||(a.saveConfigScope=t),g(t)}),n(5,"mat-option",33),o(6," Global "),i(),n(7,"mat-option",34),o(8," User "),i()()(),n(9,"mat-form-field",35)(10,"mat-label"),o(11,"Configuration Name"),i(),n(12,"input",36),y("ngModelChange",function(t){d(e);let a=u();return T(a.saveConfigName,t)||(a.saveConfigName=t),g(t)}),i()(),v(13,se,2,0,"div"),i()}if(r&2){let e=u();c(4),w("ngModel",e.saveConfigScope),c(8),w("ngModel",e.saveConfigName),f("ngModelOptions",F(4,le)),c(),h(e.hasToken?-1:13)}}function de(r,p){r&1&&(n(0,"div",10)(1,"p"),o(2,"Server authentication or Device Token required"),i()())}function ge(r,p){if(r&1&&(n(0,"mat-option",39),o(1),i()),r&2){let e=p.$implicit;f("value",e),c(),E(" ",e.scope," / ",e.name," ")}}function pe(r,p){if(r&1){let e=b();n(0,"div")(1,"mat-form-field",37)(2,"mat-label"),o(3,"Configuration"),i(),n(4,"mat-select",38),y("ngModelChange",function(t){d(e);let a=u();return T(a.deleteConfigItem,t)||(a.deleteConfigItem=t),g(t)}),M(5,ge,2,3,"mat-option",39,P),i()()()}if(r&2){let e=u();c(4),w("ngModel",e.deleteConfigItem),c(),k(e.serverConfigList)}}function me(r,p){r&1&&(n(0,"div",10)(1,"p"),o(2,"Authentication or Device Token required"),i()())}function fe(r,p){if(r&1&&(n(0,"mat-option",39),o(1),i()),r&2){let e=p.$implicit;f("value",e),c(),E(" ",e.scope," / ",e.name," ")}}function ue(r,p){if(r&1&&(n(0,"div")(1,"mat-form-field",37)(2,"mat-label"),o(3,"Configuration"),i(),n(4,"mat-select",40),M(5,fe,2,3,"mat-option",39,L),i()()()),r&2){let e=u();c(5),k(e.serverConfigList)}}function Ce(r,p){r&1&&(n(0,"div",10)(1,"p"),o(2,"Authentication or Device Token required"),i()())}var Ne=(()=>{class r{appSettingsService=C(A);storageSvc=C(V);appService=C(R);auth=C(N);fb=C($);pageTitle="Configurations";hasToken=!1;isTokenTypeDevice=!1;tokenSub;supportApplicationData=!1;serverConfigList=[];serverUpgradableConfigList=[];copyConfigForm;storageLocation=null;locations=["Local Storage","Server Storage"];saveConfigName=null;saveConfigScope=null;deleteConfigItem;jsonData=null;ngOnInit(){this.tokenSub=this.auth.authToken$.subscribe(e=>{e&&e.token?(this.hasToken=!0,this.isTokenTypeDevice=e.isDeviceAccessToken,e.isDeviceAccessToken?this.saveConfigScope="global":this.saveConfigScope="user"):this.hasToken=!1}),this.copyConfigForm=this.fb.group({sourceTarget:[{value:"",disabled:!1},q.required]}),this.supportApplicationData=this.storageSvc.isAppDataSupported,this.hasToken&&this.getServerConfigList()}getServerConfigList(e){this.supportApplicationData&&this.storageSvc.listConfigs(e).then(l=>{let t=l.filter(a=>!(a.scope==="user"&&a.name==="default"));e?this.serverUpgradableConfigList=t:this.serverConfigList=t}).catch(l=>{switch(l.status){case 401:this.appService.sendSnackbarNotification("Application Storage Error: "+l.statusText+". Signal K configuration must meet the following requirements; 1) Security enabled. 2) Application Data Storage Interface: On. 3) Either Allow Readonly Access enabled, or connecting with a user.",0,!1);break;default:this.appService.sendSnackbarNotification("Error listing server configurations: "+l,3e3,!1);break}})}saveConfig(e,l,t,a,s){if(this.supportApplicationData){if(l==="user"&&t==="default"&&!s){this.appService.sendSnackbarNotification("Saving configuration with scope 'user' and name 'default' is not allowed.",5e3,!1);return}this.storageSvc.setConfig(l,t,e)?(this.appService.sendSnackbarNotification(`Configuration [${t}] saved to [${l}] storage scope`,5e3,!1),a||this.getServerConfigList()):this.appService.sendSnackbarNotification("Error saving configuration to server",0,!1)}}saveToLocalstorage(e){this.appSettingsService.replaceConfig("appConfig",e.app,!1),this.appSettingsService.replaceConfig("dashboardsConfig",e.dashboards,!1),this.appSettingsService.replaceConfig("themeConfig",e.theme,!1)}copyConfig(){return O(this,null,function*(){let e=null;try{yield this.storageSvc.getConfig(this.copyConfigForm.value.sourceTarget.scope,this.copyConfigForm.value.sourceTarget.name).then(l=>{e=l})}catch(l){this.appService.sendSnackbarNotification("Error retrieving configuration from server: "+l.statusText,3e3,!1);return}this.saveConfig(e,"user","default",!1,!0),this.appSettingsService.reloadApp()})}deleteConfig(e,l,t,a){this.storageSvc.removeItem(e,l,t),this.appService.sendSnackbarNotification(`Configuration [${l}] deleted from [${e}] storage scope`,5e3,!1),a||this.getServerConfigList()}resetConfigToDefault(){this.appSettingsService.resetSettings()}resetConnectionToDefault(){this.appSettingsService.resetConnection()}loadDemoConfig(){this.appSettingsService.loadDemoConfig()}getActiveConfig(){let e;return this.appSettingsService.useSharedConfig?e=this.getLocalConfigFromMemory():e=this.getLocalConfigFromLocalStorage(),e}getLocalConfigFromMemory(){return{app:this.appSettingsService.getAppConfig(),dashboards:this.appSettingsService.getDashboardConfig(),theme:this.appSettingsService.getThemeConfig()}}getLocalConfigFromLocalStorage(){return{app:this.appSettingsService.loadConfigFromLocalStorage("appConfig"),dashboards:this.appSettingsService.loadConfigFromLocalStorage("dashboardsConfig"),theme:this.appSettingsService.loadConfigFromLocalStorage("themeConfig")}}downloadJsonConfig(){let e=this.getActiveConfig(),l=JSON.stringify(e,null,2),t=new Blob([l],{type:"application/json"}),a=window.URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download="KipConfig.json",document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(a)}uploadJsonConfig(e){let t=e.target.files?.[0];if(t&&t.type==="application/json"){let a=new FileReader;a.onload=s=>{try{this.jsonData=JSON.parse(s.target?.result),this.hasToken?this.saveConfig(this.jsonData,"user","default",!1,!0):this.saveToLocalstorage(this.jsonData),this.appSettingsService.reloadApp()}catch(S){this.appService.sendSnackbarNotification("Invalid JSON file",3e3,!1),console.error("Invalid JSON file:",S)}},a.readAsText(t)}else this.appService.sendSnackbarNotification("Please select a valid JSON file",0,!1)}ngOnDestroy(){this.tokenSub.unsubscribe()}static \u0275fac=function(l){return new(l||r)};static \u0275cmp=D({type:r,selectors:[["settings-config"]],decls:82,vars:8,consts:[["saveConfigForm","ngForm"],["deleteConfigForm","ngForm"],["fileInput",""],[3,"pageTitle"],[1,"page-content"],["routerLink","/help"],[1,"flex-container"],[1,"flex-item-rounded-card","rounded-card-color"],["name","saveConfigForm",3,"ngSubmit"],[2,"margin-bottom","16px"],[1,"no-token-notice"],[1,"formActionFooter"],[1,"formActionDivider"],["mat-flat-button","","type","submit","color","accent",3,"disabled"],["name","deleteConfigForm",3,"ngSubmit"],[3,"ngSubmit","formGroup"],[1,"flex-item-reset","rounded-card-color"],[1,"config-operation-container",2,"margin-top","20px"],[1,"download-txt"],[1,"download-btn","btn-div"],["mat-flat-button","","type","button",1,"adv-btn",3,"click"],[1,"upload-txt"],[1,"upload-btn","btn-div"],["type","file","accept",".json","hidden","",3,"change"],["mat-flat-button","",1,"adv-btn",3,"click"],[1,"demo-txt"],[1,"demo-btn","btn-div"],[1,"reset-txt"],[1,"reset-btn","btn-div"],[1,"config-txt"],[1,"config-btn","btn-div"],[2,"width","25%"],["name","serverConfiScope","required","",3,"ngModelChange","ngModel"],["value","global"],["value","user"],[2,"width","70%","padding-left","3%"],["matInput","","name","serverConfigName","placeholder","Enter a name for the configuration","required","",3,"ngModelChange","ngModel","ngModelOptions"],[2,"width","100%"],["name","selectedDeleteItem","required","",3,"ngModelChange","ngModel"],[3,"value"],["formControlName","sourceTarget"]],template:function(l,t){if(l&1){let a=b();_(0,"page-header",3),n(1,"div",4)(2,"p"),o(3," Recommended Reading: To understand configuration management and storage options, consult the "),n(4,"a",5),o(5,"Configuration Management Help"),i(),o(6," section. "),i(),n(7,"div",6)(8,"div",7)(9,"form",8,0),m("ngSubmit",function(){return d(a),g(t.saveConfig(t.getActiveConfig(),t.saveConfigScope,t.saveConfigName))}),n(11,"h2"),o(12,"Backup"),i(),n(13,"p",9),o(14," Create a backup of the current active configuration on the server. "),i(),v(15,ce,14,5,"div")(16,de,3,0,"div",10),n(17,"div",11),_(18,"mat-divider",12),n(19,"button",13),o(20," Create "),i()()()(),n(21,"div",7)(22,"form",14,1),m("ngSubmit",function(){return d(a),g(t.deleteConfig(t.deleteConfigItem.scope,t.deleteConfigItem.name))}),n(24,"h2"),o(25,"Delete"),i(),n(26,"p",9),o(27," Select a backup configuration to permanently delete from the server. "),i(),v(28,pe,7,1,"div")(29,me,3,0,"div",10),n(30,"div",11),_(31,"mat-divider",12),n(32,"button",13),o(33," Delete "),i()()()(),n(34,"div",7)(35,"form",15),m("ngSubmit",function(){return d(a),g(t.copyConfig())}),n(36,"h2"),o(37,"Restore"),i(),n(38,"p",9),o(39," Replace the current configuration with a backup from the server. "),i(),v(40,ue,7,0,"div")(41,Ce,3,0,"div",10),n(42,"div",11),_(43,"mat-divider",12),n(44,"button",13),o(45," Restore "),i()()()(),n(46,"div",16)(47,"h2"),o(48,"Advanced"),i(),n(49,"div",17)(50,"div",18)(51,"p"),o(52,"Download the active configuration to a file."),i()(),n(53,"div",19)(54,"button",20),m("click",function(){return d(a),g(t.downloadJsonConfig())}),o(55," Download "),i()(),n(56,"div",21)(57,"p"),o(58," Select a configuration file to upload. The file must be a valid KIP configuration file of JSON format. "),i()(),n(59,"div",22)(60,"input",23,2),m("change",function(S){return d(a),g(t.uploadJsonConfig(S))}),i(),n(62,"button",24),m("click",function(){d(a);let S=x(61);return g(S.click())}),o(63," Upload "),i()(),n(64,"div",25)(65,"p"),o(66," Load the demonstration configuration and connection to Signal K demo server. WARNING: This will completely reset all your settings. "),i()(),n(67,"div",26)(68,"button",20),m("click",function(){return d(a),g(t.loadDemoConfig())}),o(69," Demo "),i()(),n(70,"div",27)(71,"p"),o(72," Reset all your settings to default. The default configuration has a single Getting Started instruction widget. Your Signal K server connection settings will remain. "),i()(),n(73,"div",28)(74,"button",20),m("click",function(){return d(a),g(t.resetConfigToDefault())}),o(75," Default "),i()(),n(76,"div",29)(77,"p"),o(78," Clear the current connection configuration. This only affects Connectivity tab settings. "),i()(),n(79,"div",30)(80,"button",20),m("click",function(){return d(a),g(t.resetConnectionToDefault())}),o(81," Connection "),i()()()()()()}if(l&2){let a=x(10),s=x(23);f("pageTitle",t.pageTitle),c(15),h(t.hasToken?15:16),c(4),f("disabled",!t.hasToken||!a.valid),c(9),h(t.hasToken?28:29),c(4),f("disabled",!t.hasToken||!s.valid),c(3),f("formGroup",t.copyConfigForm),c(5),h(t.hasToken?40:41),c(4),f("disabled",!t.copyConfigForm.valid)}},dependencies:[I,Q,K,W,J,U,Y,G,B,ie,j,ee,Z,ae,oe,te,X,H,z,re,ne],styles:['[_nghost-%COMP%]{display:block;height:100%;width:100%}.page-content[_ngcontent-%COMP%]{width:100%;height:calc(100% - 63px);overflow-y:auto;scroll-behavior:smooth;padding:0 24px 10px}.flex-item-copy[_ngcontent-%COMP%]{flex:2 1 41%;padding:10px 20px;border-radius:15px}.flex-item-reset[_ngcontent-%COMP%]{flex:1 1 100%;padding:10px 20px;border-radius:15px}a[_ngcontent-%COMP%]{font-size:14px}a[_ngcontent-%COMP%]:hover{text-decoration:underline;cursor:pointer}a[_ngcontent-%COMP%]:link, a[_ngcontent-%COMP%]:visited{color:#8ab4f8;text-decoration:none}.warningText[_ngcontent-%COMP%]{padding-left:15px}.no-token-notice[_ngcontent-%COMP%]{height:58px;contain:content;text-align:center;font-style:italic}.mat-mdc-radio-button[_ngcontent-%COMP%] ~ .mat-radio-button[_ngcontent-%COMP%]{margin-right:16px;margin-left:16px}.config-column[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-basis:100%;flex:1;margin:0 10px}.sources-radio-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;margin:15px 0}.sources-radio-button[_ngcontent-%COMP%]{margin:5px;margin-left:0!important}.select-config[_ngcontent-%COMP%]{margin-left:0}.config-row[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}.btn-div[_ngcontent-%COMP%]{align-self:center}.adv-btn[_ngcontent-%COMP%]{width:100%}.config-operation-container[_ngcontent-%COMP%]{display:grid;grid-template-columns:[col-start] auto [col1-end] min-content [col2-end];grid-template-rows:[row-start] max-content [row1-end] max-content [row2-end];grid-template-areas:"download-txt download-btn" "upload-txt upload-btn" "demo-txt demo-btn" "reset-txt reset-btn" "config-txt config-btn";row-gap:20px;column-gap:10px}.upload-txt[_ngcontent-%COMP%]{grid-area:upload-txt}.upload-btn[_ngcontent-%COMP%]{grid-area:upload-btn}.download-txt[_ngcontent-%COMP%]{grid-area:download-txt}.download-btn[_ngcontent-%COMP%]{grid-area:download-btn}.demo-txt[_ngcontent-%COMP%]{grid-area:demo-txt}.demo-btn[_ngcontent-%COMP%]{grid-area:demo-btn}.reset-txt[_ngcontent-%COMP%]{grid-area:reset-txt}.reset-btn[_ngcontent-%COMP%]{grid-area:reset-btn}.config-txt[_ngcontent-%COMP%]{grid-area:config-txt}.config-btn[_ngcontent-%COMP%]{grid-area:config-btn}']})}return r})();export{Ne as SettingsConfigComponent};
1
+ import{a as re}from"./chunk-3FJFLAW2.js";import{f as oe,n as ae}from"./chunk-4WLU7SQK.js";import{i as I}from"./chunk-YAK5FQIH.js";import{a as R}from"./chunk-Y27DLVLA.js";import{a as ie}from"./chunk-BPFSYA37.js";import{A as B,D as G,E as K,H,K as z,N as Y,P as $,Q,R as X,T as Z,_ as ee,ca as te,da as ne,g as N,h as V,i as A,r as W,t as q,w as J,x as U}from"./chunk-FEXPC4HW.js";import{$b as _,Aa as g,Cc as E,Ec as w,Fc as T,Gc as y,Ge as j,Nc as F,Sb as v,Tb as h,Ub as L,Vb as P,Wb as M,Xb as k,Yb as f,Zb as n,_b as i,f as O,gc as b,ic as m,kc as u,lb as c,ta as C,uc as x,wb as D,za as d,zc as o}from"./chunk-H5OPY2IR.js";var le=()=>({standalone:!1});function se(r,p){r&1&&(n(0,"div"),o(1,' Writing to the server requires "Login to Server" authentication or a Device token '),i())}function ce(r,p){if(r&1){let e=b();n(0,"div")(1,"mat-form-field",31)(2,"mat-label"),o(3,"Scope"),i(),n(4,"mat-select",32),y("ngModelChange",function(t){d(e);let a=u();return T(a.saveConfigScope,t)||(a.saveConfigScope=t),g(t)}),n(5,"mat-option",33),o(6," Global "),i(),n(7,"mat-option",34),o(8," User "),i()()(),n(9,"mat-form-field",35)(10,"mat-label"),o(11,"Configuration Name"),i(),n(12,"input",36),y("ngModelChange",function(t){d(e);let a=u();return T(a.saveConfigName,t)||(a.saveConfigName=t),g(t)}),i()(),v(13,se,2,0,"div"),i()}if(r&2){let e=u();c(4),w("ngModel",e.saveConfigScope),c(8),w("ngModel",e.saveConfigName),f("ngModelOptions",F(4,le)),c(),h(e.hasToken?-1:13)}}function de(r,p){r&1&&(n(0,"div",10)(1,"p"),o(2,"Server authentication or Device Token required"),i()())}function ge(r,p){if(r&1&&(n(0,"mat-option",39),o(1),i()),r&2){let e=p.$implicit;f("value",e),c(),E(" ",e.scope," / ",e.name," ")}}function pe(r,p){if(r&1){let e=b();n(0,"div")(1,"mat-form-field",37)(2,"mat-label"),o(3,"Configuration"),i(),n(4,"mat-select",38),y("ngModelChange",function(t){d(e);let a=u();return T(a.deleteConfigItem,t)||(a.deleteConfigItem=t),g(t)}),M(5,ge,2,3,"mat-option",39,P),i()()()}if(r&2){let e=u();c(4),w("ngModel",e.deleteConfigItem),c(),k(e.serverConfigList)}}function me(r,p){r&1&&(n(0,"div",10)(1,"p"),o(2,"Authentication or Device Token required"),i()())}function fe(r,p){if(r&1&&(n(0,"mat-option",39),o(1),i()),r&2){let e=p.$implicit;f("value",e),c(),E(" ",e.scope," / ",e.name," ")}}function ue(r,p){if(r&1&&(n(0,"div")(1,"mat-form-field",37)(2,"mat-label"),o(3,"Configuration"),i(),n(4,"mat-select",40),M(5,fe,2,3,"mat-option",39,L),i()()()),r&2){let e=u();c(5),k(e.serverConfigList)}}function Ce(r,p){r&1&&(n(0,"div",10)(1,"p"),o(2,"Authentication or Device Token required"),i()())}var Ne=(()=>{class r{appSettingsService=C(A);storageSvc=C(V);appService=C(R);auth=C(N);fb=C($);pageTitle="Configurations";hasToken=!1;isTokenTypeDevice=!1;tokenSub;supportApplicationData=!1;serverConfigList=[];serverUpgradableConfigList=[];copyConfigForm;storageLocation=null;locations=["Local Storage","Server Storage"];saveConfigName=null;saveConfigScope=null;deleteConfigItem;jsonData=null;ngOnInit(){this.tokenSub=this.auth.authToken$.subscribe(e=>{e&&e.token?(this.hasToken=!0,this.isTokenTypeDevice=e.isDeviceAccessToken,e.isDeviceAccessToken?this.saveConfigScope="global":this.saveConfigScope="user"):this.hasToken=!1}),this.copyConfigForm=this.fb.group({sourceTarget:[{value:"",disabled:!1},q.required]}),this.supportApplicationData=this.storageSvc.isAppDataSupported,this.hasToken&&this.getServerConfigList()}getServerConfigList(e){this.supportApplicationData&&this.storageSvc.listConfigs(e).then(l=>{let t=l.filter(a=>!(a.scope==="user"&&a.name==="default"));e?this.serverUpgradableConfigList=t:this.serverConfigList=t}).catch(l=>{switch(l.status){case 401:this.appService.sendSnackbarNotification("Application Storage Error: "+l.statusText+". Signal K configuration must meet the following requirements; 1) Security enabled. 2) Application Data Storage Interface: On. 3) Either Allow Readonly Access enabled, or connecting with a user.",0,!1);break;default:this.appService.sendSnackbarNotification("Error listing server configurations: "+l,3e3,!1);break}})}saveConfig(e,l,t,a,s){if(this.supportApplicationData){if(l==="user"&&t==="default"&&!s){this.appService.sendSnackbarNotification("Saving configuration with scope 'user' and name 'default' is not allowed.",5e3,!1);return}this.storageSvc.setConfig(l,t,e)?(this.appService.sendSnackbarNotification(`Configuration [${t}] saved to [${l}] storage scope`,5e3,!1),a||this.getServerConfigList()):this.appService.sendSnackbarNotification("Error saving configuration to server",0,!1)}}saveToLocalstorage(e){this.appSettingsService.replaceConfig("appConfig",e.app,!1),this.appSettingsService.replaceConfig("dashboardsConfig",e.dashboards,!1),this.appSettingsService.replaceConfig("themeConfig",e.theme,!1)}copyConfig(){return O(this,null,function*(){let e=null;try{yield this.storageSvc.getConfig(this.copyConfigForm.value.sourceTarget.scope,this.copyConfigForm.value.sourceTarget.name).then(l=>{e=l})}catch(l){this.appService.sendSnackbarNotification("Error retrieving configuration from server: "+l.statusText,3e3,!1);return}this.saveConfig(e,"user","default",!1,!0),this.appSettingsService.reloadApp()})}deleteConfig(e,l,t,a){this.storageSvc.removeItem(e,l,t),this.appService.sendSnackbarNotification(`Configuration [${l}] deleted from [${e}] storage scope`,5e3,!1),a||this.getServerConfigList()}resetConfigToDefault(){this.appSettingsService.resetSettings()}resetConnectionToDefault(){this.appSettingsService.resetConnection()}loadDemoConfig(){this.appSettingsService.loadDemoConfig()}getActiveConfig(){let e;return this.appSettingsService.useSharedConfig?e=this.getLocalConfigFromMemory():e=this.getLocalConfigFromLocalStorage(),e}getLocalConfigFromMemory(){return{app:this.appSettingsService.getAppConfig(),dashboards:this.appSettingsService.getDashboardConfig(),theme:this.appSettingsService.getThemeConfig()}}getLocalConfigFromLocalStorage(){return{app:this.appSettingsService.loadConfigFromLocalStorage("appConfig"),dashboards:this.appSettingsService.loadConfigFromLocalStorage("dashboardsConfig"),theme:this.appSettingsService.loadConfigFromLocalStorage("themeConfig")}}downloadJsonConfig(){let e=this.getActiveConfig(),l=JSON.stringify(e,null,2),t=new Blob([l],{type:"application/json"}),a=window.URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download="KipConfig.json",document.body.appendChild(s),s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(a)}uploadJsonConfig(e){let t=e.target.files?.[0];if(t&&t.type==="application/json"){let a=new FileReader;a.onload=s=>{try{this.jsonData=JSON.parse(s.target?.result),this.hasToken?this.saveConfig(this.jsonData,"user","default",!1,!0):this.saveToLocalstorage(this.jsonData),this.appSettingsService.reloadApp()}catch(S){this.appService.sendSnackbarNotification("Invalid JSON file",3e3,!1),console.error("Invalid JSON file:",S)}},a.readAsText(t)}else this.appService.sendSnackbarNotification("Please select a valid JSON file",0,!1)}ngOnDestroy(){this.tokenSub.unsubscribe()}static \u0275fac=function(l){return new(l||r)};static \u0275cmp=D({type:r,selectors:[["settings-config"]],decls:82,vars:8,consts:[["saveConfigForm","ngForm"],["deleteConfigForm","ngForm"],["fileInput",""],[3,"pageTitle"],[1,"page-content"],["routerLink","/help"],[1,"flex-container"],[1,"flex-item-rounded-card","rounded-card-color"],["name","saveConfigForm",3,"ngSubmit"],[2,"margin-bottom","16px"],[1,"no-token-notice"],[1,"formActionFooter"],[1,"formActionDivider"],["mat-flat-button","","type","submit","color","accent",3,"disabled"],["name","deleteConfigForm",3,"ngSubmit"],[3,"ngSubmit","formGroup"],[1,"flex-item-reset","rounded-card-color"],[1,"config-operation-container",2,"margin-top","20px"],[1,"download-txt"],[1,"download-btn","btn-div"],["mat-flat-button","","type","button",1,"adv-btn",3,"click"],[1,"upload-txt"],[1,"upload-btn","btn-div"],["type","file","accept",".json","hidden","",3,"change"],["mat-flat-button","",1,"adv-btn",3,"click"],[1,"demo-txt"],[1,"demo-btn","btn-div"],[1,"reset-txt"],[1,"reset-btn","btn-div"],[1,"config-txt"],[1,"config-btn","btn-div"],[2,"width","25%"],["name","serverConfiScope","required","",3,"ngModelChange","ngModel"],["value","global"],["value","user"],[2,"width","70%","padding-left","3%"],["matInput","","name","serverConfigName","placeholder","Enter a name for the configuration","required","",3,"ngModelChange","ngModel","ngModelOptions"],[2,"width","100%"],["name","selectedDeleteItem","required","",3,"ngModelChange","ngModel"],[3,"value"],["formControlName","sourceTarget"]],template:function(l,t){if(l&1){let a=b();_(0,"page-header",3),n(1,"div",4)(2,"p"),o(3," Recommended Reading: To understand configuration management and storage options, consult the "),n(4,"a",5),o(5,"Configuration Management Help"),i(),o(6," section. "),i(),n(7,"div",6)(8,"div",7)(9,"form",8,0),m("ngSubmit",function(){return d(a),g(t.saveConfig(t.getActiveConfig(),t.saveConfigScope,t.saveConfigName))}),n(11,"h2"),o(12,"Backup"),i(),n(13,"p",9),o(14," Create a backup of the current active configuration on the server. "),i(),v(15,ce,14,5,"div")(16,de,3,0,"div",10),n(17,"div",11),_(18,"mat-divider",12),n(19,"button",13),o(20," Create "),i()()()(),n(21,"div",7)(22,"form",14,1),m("ngSubmit",function(){return d(a),g(t.deleteConfig(t.deleteConfigItem.scope,t.deleteConfigItem.name))}),n(24,"h2"),o(25,"Delete"),i(),n(26,"p",9),o(27," Select a backup configuration to permanently delete from the server. "),i(),v(28,pe,7,1,"div")(29,me,3,0,"div",10),n(30,"div",11),_(31,"mat-divider",12),n(32,"button",13),o(33," Delete "),i()()()(),n(34,"div",7)(35,"form",15),m("ngSubmit",function(){return d(a),g(t.copyConfig())}),n(36,"h2"),o(37,"Restore"),i(),n(38,"p",9),o(39," Replace the current configuration with a backup from the server. "),i(),v(40,ue,7,0,"div")(41,Ce,3,0,"div",10),n(42,"div",11),_(43,"mat-divider",12),n(44,"button",13),o(45," Restore "),i()()()(),n(46,"div",16)(47,"h2"),o(48,"Advanced"),i(),n(49,"div",17)(50,"div",18)(51,"p"),o(52,"Download the active configuration to a file."),i()(),n(53,"div",19)(54,"button",20),m("click",function(){return d(a),g(t.downloadJsonConfig())}),o(55," Download "),i()(),n(56,"div",21)(57,"p"),o(58," Select a configuration file to upload. The file must be a valid KIP configuration file of JSON format. "),i()(),n(59,"div",22)(60,"input",23,2),m("change",function(S){return d(a),g(t.uploadJsonConfig(S))}),i(),n(62,"button",24),m("click",function(){d(a);let S=x(61);return g(S.click())}),o(63," Upload "),i()(),n(64,"div",25)(65,"p"),o(66," Load the demonstration configuration and connection to Signal K demo server. WARNING: This will completely reset all your settings. "),i()(),n(67,"div",26)(68,"button",20),m("click",function(){return d(a),g(t.loadDemoConfig())}),o(69," Demo "),i()(),n(70,"div",27)(71,"p"),o(72," Reset all your settings to default. The default configuration has a single Getting Started instruction widget. Your Signal K server connection settings will remain. "),i()(),n(73,"div",28)(74,"button",20),m("click",function(){return d(a),g(t.resetConfigToDefault())}),o(75," Default "),i()(),n(76,"div",29)(77,"p"),o(78," Clear the current connection configuration. This only affects Connectivity tab settings. "),i()(),n(79,"div",30)(80,"button",20),m("click",function(){return d(a),g(t.resetConnectionToDefault())}),o(81," Connection "),i()()()()()()}if(l&2){let a=x(10),s=x(23);f("pageTitle",t.pageTitle),c(15),h(t.hasToken?15:16),c(4),f("disabled",!t.hasToken||!a.valid),c(9),h(t.hasToken?28:29),c(4),f("disabled",!t.hasToken||!s.valid),c(3),f("formGroup",t.copyConfigForm),c(5),h(t.hasToken?40:41),c(4),f("disabled",!t.copyConfigForm.valid)}},dependencies:[I,Q,K,W,J,U,Y,G,B,ie,j,ee,Z,ae,oe,te,X,H,z,re,ne],styles:['[_nghost-%COMP%]{display:block;height:100%;width:100%}.page-content[_ngcontent-%COMP%]{width:100%;height:calc(100% - 63px);overflow-y:auto;scroll-behavior:smooth;padding:0 24px 10px}.flex-item-copy[_ngcontent-%COMP%]{flex:2 1 41%;padding:10px 20px;border-radius:15px}.flex-item-reset[_ngcontent-%COMP%]{flex:1 1 100%;padding:10px 20px;border-radius:15px}a[_ngcontent-%COMP%]{font-size:14px}a[_ngcontent-%COMP%]:hover{text-decoration:underline;cursor:pointer}a[_ngcontent-%COMP%]:link, a[_ngcontent-%COMP%]:visited{color:#8ab4f8;text-decoration:none}.warningText[_ngcontent-%COMP%]{padding-left:15px}.no-token-notice[_ngcontent-%COMP%]{height:58px;contain:content;text-align:center;font-style:italic}.mat-mdc-radio-button[_ngcontent-%COMP%] ~ .mat-radio-button[_ngcontent-%COMP%]{margin-right:16px;margin-left:16px}.config-column[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex-basis:100%;flex:1;margin:0 10px}.sources-radio-group[_ngcontent-%COMP%]{display:flex;flex-direction:column;margin:15px 0}.sources-radio-button[_ngcontent-%COMP%]{margin:5px;margin-left:0!important}.select-config[_ngcontent-%COMP%]{margin-left:0}.config-row[_ngcontent-%COMP%]{display:flex;flex-direction:row;flex-wrap:wrap;width:100%}.btn-div[_ngcontent-%COMP%]{align-self:center}.adv-btn[_ngcontent-%COMP%]{width:100%}.config-operation-container[_ngcontent-%COMP%]{display:grid;grid-template-columns:[col-start] auto [col1-end] min-content [col2-end];grid-template-rows:[row-start] max-content [row1-end] max-content [row2-end];grid-template-areas:"download-txt download-btn" "upload-txt upload-btn" "demo-txt demo-btn" "reset-txt reset-btn" "config-txt config-btn";row-gap:20px;column-gap:10px}.upload-txt[_ngcontent-%COMP%]{grid-area:upload-txt}.upload-btn[_ngcontent-%COMP%]{grid-area:upload-btn}.download-txt[_ngcontent-%COMP%]{grid-area:download-txt}.download-btn[_ngcontent-%COMP%]{grid-area:download-btn}.demo-txt[_ngcontent-%COMP%]{grid-area:demo-txt}.demo-btn[_ngcontent-%COMP%]{grid-area:demo-btn}.reset-txt[_ngcontent-%COMP%]{grid-area:reset-txt}.reset-btn[_ngcontent-%COMP%]{grid-area:reset-btn}.config-txt[_ngcontent-%COMP%]{grid-area:config-txt}.config-btn[_ngcontent-%COMP%]{grid-area:config-btn}']})}return r})();export{Ne as SettingsConfigComponent};