From 42cfb36c040f0e24e5ce9613b3f3c3431e0a0f25 Mon Sep 17 00:00:00 2001 From: Davide Passoni Date: Fri, 7 Mar 2025 14:45:01 +0100 Subject: [PATCH] Added checkbox for autoconnection when local --- frontend/react/src/interfaces.ts | 5 ++++- manager/ejs/expertsettings.ejs | 7 +++++++ manager/ejs/passwords.ejs | 7 +++++++ manager/javascripts/dcsinstance.js | 2 ++ manager/javascripts/filesystem.js | 1 + manager/javascripts/manager.js | 18 +++++++++++++++++- 6 files changed, 38 insertions(+), 2 deletions(-) diff --git a/frontend/react/src/interfaces.ts b/frontend/react/src/interfaces.ts index d8f892de..cbf4d021 100644 --- a/frontend/react/src/interfaces.ts +++ b/frontend/react/src/interfaces.ts @@ -2,6 +2,7 @@ import { LatLng } from "leaflet"; import { Coalition, MapOptions } from "./types/types"; export interface OlympusConfig { + /* Set by user */ frontend: { port: number; customAuthHeaders: { @@ -33,13 +34,15 @@ export interface OlympusConfig { WSEndpoint?: string; }; controllers: [{ type: string; coalition: Coalition; frequency: number; modulation: number; callsign: string }]; - local: boolean; profiles?: { [key: string]: ProfileOptions }; authentication?: { gameMasterPassword: string; blueCommanderPasword: string; redCommanderPassword: string; }; + + /* Set by server */ + local: boolean; } export interface SessionData { diff --git a/manager/ejs/expertsettings.ejs b/manager/ejs/expertsettings.ejs index fc44d79b..8d3b49df 100644 --- a/manager/ejs/expertsettings.ejs +++ b/manager/ejs/expertsettings.ejs @@ -80,6 +80,13 @@ title="Install the camera control plugin, which allows direct control of the DCS camera from Olympus. It is necessary even to control the camera even if Olympus is being used remotely using a browser."> +
+ +
Autoconnect when local + +
+
diff --git a/manager/ejs/passwords.ejs b/manager/ejs/passwords.ejs index c4ad8ca2..d5dcc90b 100644 --- a/manager/ejs/passwords.ejs +++ b/manager/ejs/passwords.ejs @@ -36,5 +36,12 @@
Note: to keep the old passwords, click Next without editing any value.
+
+ +
Autoconnect when local + +
+
diff --git a/manager/javascripts/dcsinstance.js b/manager/javascripts/dcsinstance.js index c5fea078..9be3aa89 100644 --- a/manager/javascripts/dcsinstance.js +++ b/manager/javascripts/dcsinstance.js @@ -149,6 +149,7 @@ class DCSInstance { gameMasterPasswordEdited = false; blueCommanderPasswordEdited = false; redCommanderPasswordEdited = false; + autoconnectWhenLocal = false; constructor(folder) { this.folder = folder; @@ -184,6 +185,7 @@ class DCSInstance { this.backendPort = config["backend"]["port"]; this.backendAddress = config["backend"]["address"]; this.gameMasterPasswordHash = config["authentication"]["gameMasterPassword"]; + this.autoconnectWhenLocal = config["frontend"]["autoconnectWhenLocal"]; this.gameMasterPasswordEdited = false; this.blueCommanderPasswordEdited = false; diff --git a/manager/javascripts/filesystem.js b/manager/javascripts/filesystem.js index 80cd7e21..7cffc58f 100644 --- a/manager/javascripts/filesystem.js +++ b/manager/javascripts/filesystem.js @@ -161,6 +161,7 @@ async function applyConfiguration(folder, instance) { /* Apply the configuration */ config["frontend"]["port"] = instance.frontendPort; + config["frontend"]["autoconnectWhenLocal"] = instance.autoconnectWhenLocal; config["backend"]["port"] = instance.backendPort; config["backend"]["address"] = instance.backendAddress; diff --git a/manager/javascripts/manager.js b/manager/javascripts/manager.js index 5f2558b1..b753c9bf 100644 --- a/manager/javascripts/manager.js +++ b/manager/javascripts/manager.js @@ -332,8 +332,10 @@ class Manager { async onInstallTypeClicked(type) { this.typePage.getElement().querySelector(`.singleplayer`).classList.toggle("selected", type === 'singleplayer'); this.typePage.getElement().querySelector(`.multiplayer`).classList.toggle("selected", type === 'multiplayer'); - if (this.getActiveInstance()) + if (this.getActiveInstance()) { this.getActiveInstance().installationType = type; + this.getActiveInstance().autoconnectWhenLocal = type === 'singleplayer'; + } else { showErrorPopup(`
A critical error occurred!
Check ${this.getLogLocation()} for more info.
`); } @@ -399,6 +401,7 @@ class Manager { this.activePage.hide(); this.connectionsPage.show(); (this.getMode() === 'basic' ? this.connectionsPage : this.expertSettingsPage).getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.getActiveInstance().backendAddress === '*') + (this.getMode() === 'basic' ? this.passwordsPage : this.expertSettingsPage).getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal) } } else { showErrorPopup(`
A critical error occurred!
Check ${this.getLogLocation()} for more info.
`) @@ -547,6 +550,19 @@ class Manager { } } + async onEnableAutoconnectClicked() { + if (this.getActiveInstance()) { + if (this.getActiveInstance().autoconnectWhenLocal) { + this.getActiveInstance().autoconnectWhenLocal = false; + } else { + this.getActiveInstance().autoconnectWhenLocal = true; + } + this.expertSettingsPage.getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal) + } else { + showErrorPopup(`
A critical error occurred!
Check ${this.getLogLocation()} for more info.
`) + } + } + /* When the "Return to manager" button is pressed */ async onReturnClicked() { await this.reload();