Skip to content

Commit

Permalink
add buttons in electron to show rns config and meshchat database file…
Browse files Browse the repository at this point in the history
…s in containing folder
  • Loading branch information
liamcottle committed Jul 30, 2024
1 parent 5c4d342 commit b7f4123
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
11 changes: 8 additions & 3 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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();
});

Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions electron/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},

});
36 changes: 30 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1298,13 +1298,27 @@
<div>Version</div>
<div class="text-sm text-gray-700">v{{ appInfo.version }}</div>
</div>
<div class="p-1">
<div>Reticulum Config Path</div>
<div class="text-sm text-gray-700">{{ appInfo.reticulum_config_path }}</div>
<div class="flex p-1">
<div class="mr-auto">
<div>Reticulum Config Path</div>
<div class="text-sm text-gray-700">{{ appInfo.reticulum_config_path }}</div>
</div>
<div v-if="isElectron" class="mx-2 my-auto">
<button @click="showReticulumConfigFile" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500">
Show in Folder
</button>
</div>
</div>
<div class="p-1">
<div>Database Path</div>
<div class="text-sm text-gray-700">{{ appInfo.database_path }}</div>
<div class="flex p-1">
<div class="mr-auto">
<div>Database Path</div>
<div class="text-sm text-gray-700">{{ appInfo.database_path }}</div>
</div>
<div v-if="isElectron" class="mx-2 my-auto">
<button @click="showDatabaseFile" type="button" class="my-auto inline-flex items-center gap-x-1 rounded-md bg-gray-500 px-2 py-1 text-sm font-semibold text-white shadow-sm hover:bg-gray-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-gray-500">
Show in Folder
</button>
</div>
</div>
<div class="p-1">
<div>Database File Size</div>
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b7f4123

Please sign in to comment.