From b7f4123946cdf360f7f6a0c312e066320887dee4 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 30 Jul 2024 22:56:53 +1200 Subject: [PATCH] add buttons in electron to show rns config and meshchat database files in containing folder --- electron/main.js | 11 ++++++++--- electron/preload.js | 5 +++++ public/index.html | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/electron/main.js b/electron/main.js index 223fcf3..c2a591f 100644 --- a/electron/main.js +++ b/electron/main.js @@ -1,4 +1,4 @@ -const { app, BrowserWindow, dialog, ipcMain, systemPreferences } = require('electron'); +const { app, BrowserWindow, dialog, ipcMain, shell, systemPreferences } = require('electron'); const electronPrompt = require('electron-prompt'); const { spawn } = require('child_process'); const fs = require('fs'); @@ -11,7 +11,7 @@ var mainWindow = null; var exeChildProcess = null; // allow fetching app version via ipc -ipcMain.handle('app-version', async() => { +ipcMain.handle('app-version', () => { return app.getVersion(); }); @@ -36,11 +36,16 @@ ipcMain.handle('prompt', async(event, message) => { }); // allow relaunching app via ipc -ipcMain.handle('relaunch', async() => { +ipcMain.handle('relaunch', () => { app.relaunch(); app.exit(); }); +// allow showing a file path in os file manager +ipcMain.handle('showPathInFolder', (event, path) => { + shell.showItemInFolder(path); +}); + function log(message) { // make sure main window exists diff --git a/electron/preload.js b/electron/preload.js index 74854cf..8abc460 100644 --- a/electron/preload.js +++ b/electron/preload.js @@ -25,4 +25,9 @@ contextBridge.exposeInMainWorld('electron', { return await ipcRenderer.invoke('relaunch'); }, + // allow showing a file path in os file manager + showPathInFolder: async function(path) { + return await ipcRenderer.invoke('showPathInFolder', path); + }, + }); diff --git a/public/index.html b/public/index.html index 486ec4b..26dafe7 100644 --- a/public/index.html +++ b/public/index.html @@ -1298,13 +1298,27 @@
Version
v{{ appInfo.version }}
-
-
Reticulum Config Path
-
{{ appInfo.reticulum_config_path }}
+
+
+
Reticulum Config Path
+
{{ appInfo.reticulum_config_path }}
+
+
+ +
-
-
Database Path
-
{{ appInfo.database_path }}
+
+
+
Database Path
+
{{ appInfo.database_path }}
+
+
+ +
Database File Size
@@ -3136,6 +3150,16 @@ window.electron.relaunch(); } }, + showReticulumConfigFile() { + if(window.electron && this.appInfo.reticulum_config_path){ + window.electron.showPathInFolder(this.appInfo.reticulum_config_path); + } + }, + showDatabaseFile() { + if(window.electron && this.appInfo.database_path){ + window.electron.showPathInFolder(this.appInfo.database_path); + } + }, isInterfaceEnabled: function(iface) { const rawValue = iface.enabled ?? iface.interface_enabled; const value = rawValue?.toLowerCase();