Skip to content

Commit

Permalink
Added a export data module to save Data and settings files as a zip f…
Browse files Browse the repository at this point in the history
…ile easy, also bumped version number. Added a shortcuts enabled indicator in moduleView, it also acts as a toggle button so the one in settings is kinda useless? And made ping pong lifeCycle timer 3 > 7 seconds to counter reloading window
  • Loading branch information
VilleOlof committed Apr 30, 2023
1 parent 6938ecc commit f630176
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 18 deletions.
10 changes: 5 additions & 5 deletions AppSettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"PluginID": "com.villeolof.toolbox",
"Version": "1.0.2",
"Version": "1.0.3",
"DataCollection": true,
"Debug": false,
"DisableShortcut-Keybind": "F1",
Expand All @@ -9,12 +9,12 @@
"UpdateLoop_DelaySeconds": 4
},
"WindowSize": {
"width": 1558,
"height": 816
"width": 1275,
"height": 824
},
"WindowPosition": {
"x": 2811,
"y": 368
"x": 300,
"y": 121
},
"AlwaysOnTop": false,
"MirrorFlipped": false
Expand Down
14 changes: 7 additions & 7 deletions Electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ ipcMain.handle('keybind:unsetAll', (event) => {
globalShortcut.unregisterAll();
});

let oldTimeout = null;
ipcMain.handle('lifeCycle:ping', (event) => {
clearTimeout(oldTimeout);
// let oldTimeout = null;
// ipcMain.handle('lifeCycle:ping', (event) => {
// clearTimeout(oldTimeout);

oldTimeout = setTimeout(() => {
app.quit();
}, 7000);
});
// oldTimeout = setTimeout(() => {
// app.quit();
// }, 7000);
// });

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
Expand Down
5 changes: 2 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ And list of priorities.
## High Priority

- Improve Dev Version (And make it public)
- Export/Import AppSettings/Data/Settings *(Move to own folder?)*
- Updater.js (Check for updates, and update source files)
- Import AppSettings/Data/Settings *(Move to own folder?)*
- Update DataStore to be more like Settings in terms of data loading.
- Add an indicator in moduleView that shortcuts are enabled/disabled.
- Fix lifeCycle / Electron ping pong to make it not close on dialogs and such.

## Other Stuff

Expand Down
28 changes: 28 additions & 0 deletions src/Components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,33 @@
AppSettings.SetSetting('MirrorFlipped', !MirrorFlipped);
}
let DisableKeybindTextPrefix = AppSettings.GetSetting("DisabledShortcuts", false) ? "Enable" : "Disable";
const ExportDataToZIP = () => {
const filesToZIP = ["Data.json", "Settings.json"];
const AdmZip = Common.GetAdmZipModule();
const zip = new AdmZip();
//prompt user for save location
const saveLocation = Common.IO.Dialog({
title: "Save Location",
defaultPath: `${__dirname}../`,
buttonLabel: "Save",
properties: ['openDirectory']
})[0];
if (!saveLocation) return;
//add files to zip
for (const file of filesToZIP) {
const filePath = path.join(__dirname, '..', file);
zip.addLocalFile(filePath);
}
//write zip to disk
if (AppSettings.GetSetting('Debug')) console.log(`Writing zip to ${saveLocation}`);
zip.writeZip(path.join(saveLocation, 'ToolboxData.zip'));
}
// ------------
function GetSettingInstances(): {[key: string]: Settings} {
const settingInstances: {[key: string]: Settings} = {};
Expand Down Expand Up @@ -305,6 +332,7 @@
<button class="btnStyle" on:click={ClearColumns}>Clear All Columns</button>
<button class="btnStyle" on:click={OpenModuleFolder}>Open Modules Folder</button>
<button class="btnStyle" on:click={() => { DisableKeybindTextPrefix = Common.Electron.DisableAllShortcutsAction() }}>{DisableKeybindTextPrefix} Shortcuts</button>
<button class="btnStyle" on:click={ExportDataToZIP}>Export Data</button>
</div>
</div>

Expand Down
9 changes: 9 additions & 0 deletions src/Lib/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,4 +559,13 @@ export namespace Common {
export function GetOSModule(): typeof os {
return os;
}

/**
* Gets the adm-zip node module.
*
* @returns the adm-zip node module
*/
export function GetAdmZipModule() {
return require('adm-zip');
}
}
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { GlobalSettings } from './Lib/Settings'
GlobalSettings.LoadGlobalSettings();

//Keeping the plugin, otherwise we close the plugin.
setInterval(async () => {
await Common.Electron.GetElectron().ipcRenderer.invoke('lifeCycle:ping');
}, 1000);
// setInterval(async () => {
// await Common.Electron.GetElectron().ipcRenderer.invoke('lifeCycle:ping');
// }, 1000);

//This specific line is somehow always complaining.
//but it still works and its the default svelte app template.
Expand Down

0 comments on commit f630176

Please sign in to comment.