Skip to content

Commit

Permalink
Added app version number to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroDogeDX committed Jul 8, 2023
1 parent dd3fb57 commit 7ced5c4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions client/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,12 @@ window.addEventListener('focus', async () => {
if (!requestInitialized) refreshButton.classList.toggle('spinner', false);
});

window.API.getVersion();

window.API.receiveVersion((appVersion) => {
document.querySelector('.navbar-version').innerHTML = `v${appVersion}`;
});

window.API.onSocketDied((_event) => promptReconnect());

applyTooltips();
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<div data-tooltip="Settings" data-page="settings" class="navbar-button material-symbols-outlined">
settings
</div>
<div class="navbar-version">####</div>
</div>
</div>
<div class="cvrx-display">
Expand Down
7 changes: 7 additions & 0 deletions client/main-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ button {
filter: drop-shadow(2.5px 2.5px 0px rgba(0, 0, 0, 0.5));
}

.navbar-version {
color: rgba(255,255,255,0.25);
font-size: 12px;
font-style: italic;
text-align: center;
}

/* Main Display Area */

.cvrx-display {
Expand Down
10 changes: 9 additions & 1 deletion server/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const dotenv = require('dotenv');
dotenv.config();

const { app, BrowserWindow, Menu } = require('electron');
const { app, BrowserWindow, Menu, ipcMain } = require('electron');

// Prevent app launching multiple times during the installation
if (require('electron-squirrel-startup')) {
Expand Down Expand Up @@ -120,6 +120,14 @@ app.whenReady().then(async () => {
await Updater.Setup(mainWindow);
});

app.on('ready', () => {
let appVersion = app.getVersion();
// Send version info to renderer process
ipcMain.on('get-app-version', (event) => {
event.sender.send('app-version', appVersion);
});
});

app.on('window-all-closed', () => app.quit());

app.on('will-quit', async () => {
Expand Down
4 changes: 4 additions & 0 deletions server/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ contextBridge.exposeInMainWorld('API', {
reconnectWebSocket: () => ipcRenderer.send('reconnect-web-socket'),
onSocketDied: (callback) => ipcRenderer.on('socket-died', callback),

// App Version
getVersion: () => ipcRenderer.send('get-app-version'),
receiveVersion: (callback) => ipcRenderer.on('app-version', (event, arg) => callback(arg)),

// Test
// closeTest: (closeCode, close) => ipcRenderer.send('close-socket-server', closeCode, close),
});

0 comments on commit 7ced5c4

Please sign in to comment.