Added expert settings mode

This commit is contained in:
Pax1601 2024-01-30 17:45:25 +01:00
parent be625fdca9
commit 21040da195
10 changed files with 341 additions and 161 deletions

View File

@ -1,31 +1,5 @@
<style>
#connections-page .success,
#connections-page .error {
position: absolute;
left: 320px;
display: flex;
width: 150px;
column-gap: 8px;
}
#connections-page .success {
content: url("./icons/check-solid-green.svg");
height: 20px;
width: 20px;
}
#connections-page .error img {
content: url("./icons/triangle-exclamation-solid.svg");
height: 20px;
width: 20px;
}
#connections-page .error span {
font-weight: 600;
font-size: var(--small);
color: var(--red);
height: fit-content;
}
</style>
<div id="connections-page">
<div class="instructions">
@ -42,7 +16,7 @@
</div>
</div>
<div class="wizard-inputs">
<div class="input-group client-port">
<div class="input-group client-port port-input">
<span>Client port
<img src="./icons/circle-info-solid.svg"
title="This port is used to allow access to Olympus. Be sure to allow this port through your firewall if you want people to connect remotely">
@ -56,7 +30,7 @@
</div>
</div>
</div>
<div class="input-group backend-port">
<div class="input-group backend-port port-input">
<span>Backend port
<img src="./icons/circle-info-solid.svg"
title="This port is used by Olympus to communicate with DCS. You only need to allow it through your firewall if you enable direct API connection">

View File

@ -0,0 +1,78 @@
<style>
#expert-settings .content {
display: flex;
}
</style>
<div id="expert-settings">
<div class="instructions">
<div class="title">
Edit Olympus instance
</div>
<div class="description">
Please note: you may be required to allow these ports through your firewall and modem/router via port forwarding. <br>
Otherwise, others may not be able to connect to Olympus.
</div>
</div>
<div class="content">
<div class="wizard-inputs">
<div class="input-group game-master">
<span>Game Master Password<img src="./icons/circle-info-solid.svg"
title="This password is used to access Olympus as Game Master with full privileges.">
</span>
<input type="password" minlength="8" onchange="signal('onGameMasterPasswordChanged', this.value)">
</div>
<div class="input-group blue-commander">
<span>Blue Commander Password<img src="./icons/circle-info-solid.svg"
title="This password is used to access Olympus as blue coalition Commander.">
</span>
<input type="password" minlength="8" onchange="signal('onBlueCommanderPasswordChanged', this.value)">
</div>
<div class="input-group red-commander">
<span>Red Commander Password<img src="./icons/circle-info-solid.svg"
title="This password is used to access Olympus as red coalition Commander.">
</span>
<input type="password" minlength="8" onchange="signal('onRedCommanderPasswordChanged', this.value)">
</div>
<div class="<%= activeInstance["installed"]? '': 'hide' %>" style="color: var(--offwhite); font-size: var(--normal); color: var(--lightgray);">
Note: to keep the old passwords, click <b>Next</b> without editing any value.
</div>
</div>
<div class="wizard-inputs">
<div class="input-group client-port port-input">
<span>Client port
<img src="./icons/circle-info-solid.svg"
title="This port is used to allow access to Olympus. Be sure to allow this port through your firewall if you want people to connect remotely">
</span>
<div>
<input type="number" min="1024" max="65535" value="<%= activeInstance["clientPort"] %>"
onchange="signal('onClientPortChanged', this.value)">
<img class="success hide">
<div class="error hide">
<img> <span>Port already in use</span>
</div>
</div>
</div>
<div class="input-group backend-port port-input">
<span>Backend port
<img src="./icons/circle-info-solid.svg"
title="This port is used by Olympus to communicate with DCS. You only need to allow it through your firewall if you enable direct API connection">
</span>
<div>
<input type="number" min="1024" max="65535" value="<%= activeInstance["backendPort"] %>"
onchange="signal('onBackendPortChanged', this.value)">
<img class="success hide">
<div class="error hide">
<img> <span>Port already in use</span>
</div>
</div>
</div>
<div class="input-group backend-address">
<span onclick="signal('onEnableAPIClicked')">
<div class="checkbox"></div> Enable direct backend API connection
<img src="./icons/circle-info-solid.svg"
title="Allows services to connect to Olympus directly. This is NOT NEEDED for normal Olympus operation, even for dedicated servers. Leave it unchecked if in doubt.">
</span>
</div>
</div>
</div>
</div>

View File

@ -3,12 +3,35 @@
</style>
<div class="dashboard">
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus settings updated for <i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while updating Olympus settings for <i><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% if (operation === 'INSTALL') { %>
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["error"] && activeInstance["installed"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus installed successfully in
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && (activeInstance["error"] || !activeInstance["installed"]))? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while installing Olympus in
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% } else if (operation === 'EDIT') {%>
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus settings updated for
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while updating Olympus settings for
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% } else {%>
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["installed"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus removed successfully from
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && activeInstance["installed"])? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while removing Olympus settings from
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% } %>
<div class="content">
<div class="instructions">
<span class="title">

View File

@ -19,19 +19,19 @@
<span>Game Master Password<img src="./icons/circle-info-solid.svg"
title="This password is used to access Olympus as Game Master with full privileges.">
</span>
<input type="password" minlength="8" onchange="signal('onGameMasterPasswordChanged', this.value)" value="<%= activeInstance["installed"]? 'This is a long string so that users know this is not actually their password. Hi Tony!': '' %>">
<input type="password" minlength="8" onchange="signal('onGameMasterPasswordChanged', this.value)">
</div>
<div class="input-group blue-commander">
<span>Blue Commander Password<img src="./icons/circle-info-solid.svg"
title="This password is used to access Olympus as blue coalition Commander.">
</span>
<input type="password" minlength="8" onchange="signal('onBlueCommanderPasswordChanged', this.value)" value="<%= activeInstance["installed"]? 'This is a long string so that users know this is not actually their password. Hi Tony!': '' %>">
<input type="password" minlength="8" onchange="signal('onBlueCommanderPasswordChanged', this.value)">
</div>
<div class="input-group red-commander">
<span>Red Commander Password<img src="./icons/circle-info-solid.svg"
title="This password is used to access Olympus as red coalition Commander.">
</span>
<input type="password" minlength="8" onchange="signal('onRedCommanderPasswordChanged', this.value)" value="<%= activeInstance["installed"]? 'This is a long string so that users know this is not actually their password. Hi Tony!': '' %>">
<input type="password" minlength="8" onchange="signal('onRedCommanderPasswordChanged', this.value)">
</div>
<div class="<%= activeInstance["installed"]? '': 'hide' %>" style="color: var(--offwhite); font-size: var(--normal); color: var(--lightgray);">
Note: to keep the old passwords, click <b>Next</b> without editing any value.

View File

@ -5,12 +5,25 @@
<div class="cancel" style="font-size: var(--normal); font-weight: 600; color: var(--offwhite); display: flex; align-items: center; column-gap: 10px; cursor: pointer; text-decoration: underline; " onclick="signal('onCancelClicked')">
<img src="./icons/chevron-left-solid.svg" style=" height: 14px;">Back to menu
</div>
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus settings updated for <i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while updating Olympus settings for <i><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% if (operation === 'EDIT') {%>
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus settings updated for
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && activeInstance["error"])? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while updating Olympus settings for
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% } else {%>
<div class="result-summary success <%= (typeof activeInstance !== 'undefined' && !activeInstance["installed"])? "": "hide" %>">
<div class="title"><img src="./icons/check-solid-background.svg">Olympus removed successfully from
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i>!</div>
</div>
<div class="result-summary error <%= (typeof activeInstance !== 'undefined' && activeInstance["installed"])? "": "hide" %>">
<div class="title"><img src="./icons/triangle-exclamation-solid-background.svg">An error occurred while removing Olympus settings from
<i style="margin-left: 3px"><%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %></i></div>
</div>
<% } %>
<div class="content">
<div class="instructions">
<span class="title">

View File

@ -71,7 +71,7 @@
</style>
<div class="wizard-page">
<div class="cancel" style="font-size: var(--normal); font-weight: 600; color: var(--offwhite); display: flex; align-items: center; column-gap: 10px; cursor: pointer; text-decoration: underline;" onclick="signal('onCancelClicked')">
<img src="./icons/chevron-left-solid.svg" style=" height: 14px;">Cancel install
<img src="./icons/chevron-left-solid.svg" style=" height: 14px;"><%= operation === 'INSTALL'? "Cancel install": "Cancel editing" %>
</div>
<div class="content">

View File

@ -22,12 +22,22 @@ class DCSInstance {
*
* @returns The list of DCS instances
*/
static async getInstances() {
if (this.instances === null)
static async getInstances(force = false) {
if (this.instances === null || force)
DCSInstance.instances = this.findInstances();
return DCSInstance.instances;
}
static async reloadInstances() {
var instances = await this.getInstances();
console.log(instances);
for (let instance of instances) {
await instance.checkInstallation();
console.log(instance.installed);
}
return true;
}
/** Static asynchronous method to find all existing DCS instances
*
* @returns The list of found DCS instances
@ -149,7 +159,7 @@ class DCSInstance {
this.backendAddress = config["server"]["address"];
this.gameMasterPasswordHash = config["authentication"]["gameMasterPassword"];
} catch (err) {
showErrorPopup(`A critical error has occurred while reading your Olympus configuration file. Please, manually reinstall olympus in ${this.folder}.`)
showErrorPopup(`<div class='main-message'>A critical error has occurred while reading your Olympus configuration file. </div><div class='sub-message'> Please, manually reinstall olympus in ${this.folder}. </div>`)
logger.error(err)
}
@ -184,6 +194,9 @@ class DCSInstance {
} else {
getManager().setLoadingProgress(`No differences found in ${this.folder}`);
}
} else {
this.installed = false;
this.error = false;
}
return this.error;
}
@ -476,8 +489,9 @@ class DCSInstance {
} catch (err) {
logger.log(`An error occurred during editing: ${err}`);
getManager().getActiveInstance().error = true;
hidePopup();
showErrorPopup(`A critical error occurred, check ${getManager().options.logLocation} for more info.`)
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`)
getManager().options.mode === "basic"? getManager().settingsPage.show(): getManager().instancesPage.show();
}
}
@ -487,6 +501,7 @@ class DCSInstance {
async install() {
showWaitLoadingPopup(`<span>Please wait while Olympus is being installed in <i>${this.name}</i></span>`);
try {
getManager().activePage.hide();
setPopupLoadingProgress("Installing hook scripts...", 0);
await sleep(100);
await installHooks(getManager().getActiveInstance().folder);
@ -511,26 +526,36 @@ class DCSInstance {
await sleep(500);
logger.log(`Installation completed successfully`);
hidePopup();
getManager().resultPage.show();
getManager().resultPage.getElement().querySelector(".result-summary.success").classList.remove("hide");
getManager().resultPage.getElement().querySelector(".result-summary.error").classList.add("hide");
getManager().resultPage.getElement().querySelector(".instructions-group").classList.remove("hide");
if (getManager().options.mode === 'basic') {
getManager().resultPage.show();
getManager().resultPage.getElement().querySelector(".result-summary.success").classList.remove("hide");
getManager().resultPage.getElement().querySelector(".result-summary.error").classList.add("hide");
getManager().resultPage.getElement().querySelector(".instructions-group").classList.remove("hide");
} else {
await getManager().reload();
getManager().instancesPage.show();
}
} catch (err) {
logger.log(`An error occurred during installation: ${err}`);
hidePopup();
getManager().resultPage.show();
getManager().resultPage.getElement().querySelector(".result-summary.success").classList.add("hide");
getManager().resultPage.getElement().querySelector(".result-summary.error").classList.remove("hide");
if (getManager().options.mode === 'basic') {
getManager().resultPage.show();
getManager().resultPage.getElement().querySelector(".result-summary.success").classList.add("hide");
getManager().resultPage.getElement().querySelector(".result-summary.error").classList.remove("hide");
} else {
await getManager().reload();
getManager().instancesPage.show();
}
}
}
/** Uninstall this instance
*
*/
async uninstall() {
showConfirmPopup(`<div style='max-width: 100%; font-size: var(--big);'> Are you sure you want to remove Olympus from ${this.name}? </div> <div style="font-weight: normal;">This will only remove Olympus for this particular DCS instance.</div>`, async () => {
showConfirmPopup(`<div class='main-message'> Are you sure you want to remove Olympus from ${this.name}? </div> <div class='sub-message'>This will only remove Olympus for this particular DCS instance.</div>`, async () => {
try {
getManager().activePage.hide();
logger.log(`Uninstalling Olympus from ${this.folder}`)
await sleep(300);
showWaitLoadingPopup(`<span>Please wait while Olympus is being removed from <i>${this.name}</i></span>`);
@ -553,12 +578,21 @@ class DCSInstance {
await sleep(500);
setPopupLoadingProgress("Instance removed!", 100);
logger.log(`Olympus removed from ${this.folder}`)
location.reload();
hidePopup();
await getManager().reload();
if (getManager().options.mode === 'basic')
getManager().settingsPage.show();
else
getManager().instancesPage.show();
return true;
} catch (err) {
logger.error(err)
showErrorPopup(`An error has occurred while uninstalling the Olympus instance. Make sure Olympus and DCS are not running. <br><br> You can find more info in ${path.join(__dirname, "..", "manager.log")}`, () => {
location.reload();
showErrorPopup(`<div class='main-message'>An error has occurred while uninstalling the Olympus instance. </div><div class='sub-message'> Make sure Olympus and DCS are not running. </div><div class='sub-message'>You can find more info in ${path.join(__dirname, "..", "manager.log")} </div>`, () => {
if (getManager().options.mode === 'basic')
getManager().settingsPage.show();
else
getManager().instancesPage.show();
});
}
});

View File

@ -14,7 +14,8 @@ const { sleep } = require("./utils");
class Manager {
options = {
logLocation: path.join(__dirname, "..", "manager.log"),
configLoaded: false
configLoaded: false,
operation: 'NONE'
};
activePage = null;
@ -27,6 +28,7 @@ class Manager {
passwordsPage = null;
resultPage = null;
instancesPage = null;
expertSettingsPage = null;
constructor() {
/* Simple framework to define callbacks to events directly in the .ejs files. When an event happens, e.g. a button is clicked, the signal function is called with the function
@ -56,7 +58,7 @@ class Manager {
this.options.configLoaded = true;
} catch (e) {
logger.error(`An error occurred while reading the options.json file: ${e}`);
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`)
}
}
@ -99,7 +101,7 @@ class Manager {
return instance.installed && instance.error;
})) {
/* Ask the user for confirmation */
showConfirmPopup("<div style='font-size: var(--very-large); max-width: 100%;'>One or more of your Olympus instances are not up to date! </div> If you have just updated Olympus this is normal. Press Accept and the Manager will update your instances for you. <br> Press Close to update your instances manually using the Installation Wizard", async () => {
showConfirmPopup("<div class='main-message'> One or more of your Olympus instances are not up to date! </div><div class='sub-message'> If you have just updated Olympus this is normal.<br><br> Press <b>Accept</b> and the Manager will update your instances for you. <br> Press <b>Close</b> to update your instances manually using the Installation Wizard</div>", async () => {
try {
await sleep(300);
await DCSInstance.fixInstances();
@ -107,7 +109,7 @@ class Manager {
} catch (err) {
logger.error(err);
await sleep(300);
showErrorPopup(`An error occurred while trying to fix your installations. Please reinstall Olympus manually. <br><br> You can find more info in ${this.options.logLocation}`);
showErrorPopup(`<div class='main-message'>An error occurred while trying to fix your installations. Please reinstall Olympus manually. </div><div class='sub-message'> You can find more info in ${this.options.logLocation} </div>`);
}
})
}
@ -130,6 +132,7 @@ class Manager {
this.passwordsPage = new WizardPage(this, "./ejs/passwords.ejs");
this.resultPage = new ManagerPage(this, "./ejs/result.ejs");
this.instancesPage = new ManagerPage(this, "./ejs/instances.ejs");
this.expertSettingsPage = new WizardPage(this, "./ejs/expertsettings.ejs");
/* Force the setting of the ports whenever the page is shown */
this.connectionsPage.options.onShow = () => {
@ -138,6 +141,16 @@ class Manager {
this.setPort('backend', this.options.activeInstance.backendPort);
}
}
this.expertSettingsPage.options.onShow = () => {
if (this.options.activeInstance) {
this.setPort('client', this.options.activeInstance.clientPort);
this.setPort('backend', this.options.activeInstance.backendPort);
}
}
this.instancesPage.options.onShow = () => {
this.updateInstances();
}
if (this.options.mode === "basic") {
/* In basic mode no dashboard is shown */
@ -172,7 +185,7 @@ class Manager {
location.reload();
} catch (err) {
logger.log(err);
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`)
}
}
@ -209,7 +222,7 @@ class Manager {
*
*/
onInstallMenuClicked() {
this.options.install = true;
this.options.operation = 'INSTALL';
if (this.options.instances.length == 0) {
// TODO: show error
@ -222,7 +235,7 @@ class Manager {
this.activePage.hide()
this.typePage.show();
} else {
showConfirmPopup("<div style='font-size: var(--large); max-width: 100%;'> Olympus is already installed in this instance! </div> <div style='font-weight: normal'>If you click Accept, it will be installed again and all changes, e.g. custom databases or mods support, will be lost. Are you sure you want to continue?</div>",
showConfirmPopup("<div class='main-message'> Olympus is already installed in this instance! </div> <div class='sub-message'>If you click Accept, it will be installed again and all changes, e.g. custom databases or mods support, will be lost. Are you sure you want to continue?</div>",
() => {
this.activePage.hide()
this.typePage.show();
@ -241,7 +254,8 @@ class Manager {
*/
onEditMenuClicked() {
this.activePage.hide()
this.options.install = false;
this.options.operation = 'EDIT';
delete this.options.activeInstance;
this.settingsPage.show();
}
@ -268,7 +282,7 @@ class Manager {
if (this.options.activeInstance)
this.options.activeInstance.installationType = type;
else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`);
}
}
@ -279,16 +293,16 @@ class Manager {
if (this.options.activeInstance)
this.options.activeInstance.connectionsType = type;
else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`);
}
}
/* When the next button of a wizard page is clicked */
onNextClicked() {
async onNextClicked() {
/* Choose which page to show depending on the active page */
if (this.activePage == this.folderPage) {
if (this.options.activeInstance.installed) {
showConfirmPopup("<div style='font-size: var(--large); max-width: 100%;'> Olympus is already installed in this instance! </div> <div style='font-weight: normal'>If you click Accept, it will be installed again and all changes, e.g. custom databases or mods support, will be lost. Are you sure you want to continue?</div>",
showConfirmPopup("<div class='main-message'> Olympus is already installed in this instance! </div> <div class='sub-message'>If you click Accept, it will be installed again and all changes, e.g. custom databases or mods support, will be lost. Are you sure you want to continue?</div>",
() => {
this.activePage.hide()
this.typePage.show();
@ -310,48 +324,25 @@ class Manager {
else {
this.activePage.hide();
this.connectionsPage.show();
this.connectionsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
(this.options.mode === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
}
} else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`)
}
} else if (this.activePage == this.connectionsPage) {
this.options.activeInstance.checkClientPort().then(
(portFree) => {
if (portFree) {
return this.options.activeInstance.checkBackendPort();
} else {
return Promise.reject('Port not free');
}
}).then((portFree) => {
if (portFree) {
this.activePage.hide();
this.passwordsPage.show();
} else {
return Promise.reject('Port not free');
}
}).catch(() => {
showErrorPopup('Please, make sure both the client and backend ports are free!');
}
);
if (await this.checkPorts()) {
this.activePage.hide();
this.passwordsPage.show();
}
} else if (this.activePage == this.passwordsPage) {
if (this.options.activeInstance) {
if (this.options.activeInstance.installed && !this.options.activeInstance.arePasswordsEdited()) {
this.activePage.hide();
this.options.install ? this.options.activeInstance.install() : this.options.activeInstance.edit();
}
else {
if (!this.options.activeInstance.arePasswordsSet()) {
showErrorPopup('Please, make sure all passwords are set!');
} else if (!this.options.activeInstance.arePasswordsDifferent()) {
showErrorPopup('Please, set different passwords for the Game Master, Blue Commander, and Red Commander roles!');
} else {
this.activePage.hide();
this.options.install ? this.options.activeInstance.install() : this.options.activeInstance.edit();
}
}
} else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
if (await this.checkPasswords()) {
this.activePage.hide();
this.options.operation === 'INSTALL' ? this.options.activeInstance.install() : this.options.activeInstance.edit();
}
} else if (this.activePage == this.expertSettingsPage) {
if (await this.checkPorts() && await this.checkPasswords()) {
this.activePage.hide();
this.options.operation === 'INSTALL' ? this.options.activeInstance.install() : this.options.activeInstance.edit();
}
}
}
@ -380,42 +371,24 @@ class Manager {
}
onGameMasterPasswordChanged(value) {
if (this.options.activeInstance) {
if (this.options.activeInstance)
this.options.activeInstance.setGameMasterPassword(value);
if (!this.options.activeInstance.blueCommanderPasswordEdited)
this.passwordsPage.getElement().querySelector(".blue-commander input").value = "";
if (!this.options.activeInstance.redCommanderPasswordEdited)
this.passwordsPage.getElement().querySelector(".red-commander input").value = "";
}
else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
}
else
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`);
}
onBlueCommanderPasswordChanged(value) {
if (this.options.activeInstance) {
if (this.options.activeInstance)
this.options.activeInstance.setBlueCommanderPassword(value);
if (!this.options.activeInstance.gameMasterPasswordEdited)
this.passwordsPage.getElement().querySelector(".game-master input").value = "";
if (!this.options.activeInstance.redCommanderPasswordEdited)
this.passwordsPage.getElement().querySelector(".red-commander input").value = "";
}
else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
}
else
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`);
}
onRedCommanderPasswordChanged(value) {
if (this.options.activeInstance) {
if (this.options.activeInstance)
this.options.activeInstance.setRedCommanderPassword(value);
if (!this.options.activeInstance.gameMasterPasswordEdited)
this.passwordsPage.getElement().querySelector(".game-master input").value = "";
if (!this.options.activeInstance.blueCommanderPasswordEdited)
this.passwordsPage.getElement().querySelector(".blue-commander input").value = "";
}
else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
}
else
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`);
}
/* When the client port input value is changed */
@ -436,16 +409,22 @@ class Manager {
} else {
this.options.activeInstance.backendAddress = 'localhost';
}
this.connectionsPage.getElement().querySelector(".note.warning").classList.toggle("hide", this.options.activeInstance.backendAddress !== '*')
this.connectionsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
if (this.options.mode === 'basic') {
this.connectionsPage.getElement().querySelector(".note.warning").classList.toggle("hide", this.options.activeInstance.backendAddress !== '*')
this.connectionsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
} else {
this.expertSettingsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
}
} else {
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`)
}
}
/* When the "Return to manager" button is pressed */
onReturnClicked() {
location.reload();
async onReturnClicked() {
await this.reload();
this.activePage.hide();
this.menuPage.show();
}
/* When the "Close manager" button is pressed */
@ -453,6 +432,39 @@ class Manager {
document.querySelector('.close').click();
}
async checkPorts() {
var clientPortFree = await this.options.activeInstance.checkClientPort();
var backendPortFree = await this.options.activeInstance.checkBackendPort();
if (clientPortFree && backendPortFree) {
return true;
} else {
showErrorPopup(`<div class='main-message'> Please, make sure both the client and backend ports are free!</div><div class='sub-message'>If ports are already in use, Olympus will not be able to communicated correctly.</div>`);
return false;
}
}
async checkPasswords() {
if (this.options.activeInstance) {
if (this.options.activeInstance.installed && !this.options.activeInstance.arePasswordsEdited()) {
return true;
}
else {
if (!this.options.activeInstance.arePasswordsSet()) {
showErrorPopup(`<div class='main-message'>Please, make sure all passwords are set!</div><div class='sub-message'>The role users will fulfill depends on the password they enter at login. </div>`);
return false;
} else if (!this.options.activeInstance.arePasswordsDifferent()) {
showErrorPopup(`<div class='main-message'>Please, set different passwords! </div><div class='sub-message'>The role users will fulfill depends on the password they enter at login. </div>`);
return false;
} else {
return true;
}
}
} else {
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${getManager().options.logLocation} for more info. </div>`)
return false;
}
}
async onStartServerClicked(name) {
var div = await this.getClickedInstanceDiv(name);
div.querySelector(".collapse").classList.add("loading")
@ -480,29 +492,31 @@ class Manager {
async onEditClicked(name) {
var instance = await this.getClickedInstance(name);
if (instance.webserverOnline || instance.backendOnline) {
showErrorPopup("Error, the selected Olympus instance is currently active, please stop Olympus before editing it!")
showErrorPopup("<div class='main-message'>Error, the selected Olympus instance is currently active </div><div class='sub-message'> Please stop Olympus before editing it! </div>")
} else {
this.options.activeInstance = instance;
this.options.install = false;
this.options.operation = 'EDIT';
this.activePage.hide();
this.typePage.show();
(this.options.mode === 'basic'? this.typePage: this.expertSettingsPage).show();
}
}
async onInstallClicked(name) {
var instance = await this.getClickedInstance(name);
this.options.activeInstance = instance;
this.options.install = true;
this.options.operation = 'INSTALL';
this.options.singleInstance = false;
this.activePage.hide();
this.typePage.show();
(this.options.mode === 'basic'? this.typePage: this.expertSettingsPage).show();
}
async onUninstallClicked(name) {
var instance = await this.getClickedInstance(name);
this.options.activeInstance = instance;
this.options.operation = 'UNINSTALL';
if (instance.webserverOnline || instance.backendOnline)
showErrorPopup("Error, the selected Olympus instance is currently active, please stop Olympus before uninstalling it!")
showErrorPopup("<div class='main-message'>Error, the selected Olympus instance is currently active </div><div class='sub-message'> Please stop Olympus before removing it! </div>")
else
await instance.uninstall();
}
@ -543,11 +557,11 @@ class Manager {
this.options.activeInstance.setBackendPort(value);
}
var successEls = this.connectionsPage.getElement().querySelector(`.${port}-port`).querySelectorAll(".success");
var successEls = (this.options.mode === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(`.${port}-port`).querySelectorAll(".success");
for (let i = 0; i < successEls.length; i++) {
successEls[i].classList.toggle("hide", !success);
}
var errorEls = this.connectionsPage.getElement().querySelector(`.${port}-port`).querySelectorAll(".error");
var errorEls = (this.options.mode === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(`.${port}-port`).querySelectorAll(".error");
for (let i = 0; i < errorEls.length; i++) {
errorEls[i].classList.toggle("hide", success);
}
@ -596,8 +610,11 @@ class Manager {
}
}
reload() {
this.activePage.show();
async reload() {
await DCSInstance.reloadInstances();
this.options.installEnabled = true;
this.options.editEnabled = this.options.instances.find(instance => instance.installed);
}
setLoadingProgress(message, percent) {

View File

@ -34,7 +34,7 @@ function checkVersion() {
/* If a newer version is available update Olympus in Release mode */
if (reg1[0] > reg2[0] || (reg1[0] == reg2[0] && reg1[1] > reg2[1]) || (reg1[0] == reg2[0] && reg1[1] == reg2[1] && reg1[2] > reg2[2])) {
logger.log(`New version available: ${res["version"]}`);
showConfirmPopup(`You are currently running DCS Olympus ${VERSION}, but ${res["version"]} is available. Do you want to update DCS Olympus automatically? <div style="max-width: 100%; color: orange">Note: DCS and Olympus MUST be stopped before proceeding.</div>`,
showConfirmPopup(`<div class='main-message'>You are currently running DCS Olympus ${VERSION}, but ${res["version"]} is available. </div><div class='sub-message'> Do you want to update DCS Olympus automatically? </div> <div style="max-width: 100%; color: orange">Note: DCS and Olympus MUST be stopped before proceeding.</div>`,
() => {
updateOlympusRelease();
}, () => {
@ -71,10 +71,10 @@ async function updateOlympusBeta() {
const date1 = new Date(artifact.updated_at);
const date2 = fs.statSync(".").mtime;
if (date1 > date2) {
showConfirmPopup(`<span style="font-size: var(--very-large); max-width: 100%; margin-bottom: 15px;">Looks like you are running a beta version of Olympus!</span><span>Latest beta artifact timestamp of: <i style="color: orange">${date1.toLocaleString()}</i> <br> Your installation timestamp: <i style="color: orange">${date2.toLocaleString()}</i> <br><br> Do you want to update to the newest beta version?</span>`, () => {
showConfirmPopup(`<div class='main-message'> Looks like you are running a beta version of Olympus!</div><div class='sub-message'> Latest beta artifact timestamp of: <b style="color: orange">${date1.toLocaleString()}</b> <br> Your installation timestamp: <b style="color: orange">${date2.toLocaleString()}</b> <br><br> Do you want to update to the newest beta version?</div>`, () => {
/* Run the browser and download the artifact */ //TODO: try and directly download the file from code rather than using the browser
exec(`start https://github.com/Pax1601/DCSOlympus/actions/runs/${artifact.workflow_run.id}/artifacts/${artifact.id}`)
showConfirmPopup('A browser window was opened to download the beta artifact. Please wait for the download to complete, then press "Accept" and select the downloaded beta artifact.',
showConfirmPopup(`<div class='main-message'> A browser window was opened to download the beta artifact. </div><div class='sub-message'> Please wait for the download to complete, then press "Accept" and select the downloaded beta artifact.</div>`,
() => {
/* Ask the user to select the downloaded file */
var input = document.createElement('input');
@ -117,7 +117,7 @@ async function updateOlympusRelease() {
}
function updateOlympus(location) {
showWaitPopup("Please wait while Olympus is being updated. The Manager will be closed and reopened automatically when updating is completed.")
showWaitPopup("<div class='main-message'>Please wait while Olympus is being updated. </div><div class='sub-message'> The Manager will be closed and reopened automatically when updating is completed.</div>")
/* If the location is a string, it is interpreted as a download url. Else, it is interpreted as a File (on disk)*/
if (typeof location === "string") {
@ -202,7 +202,7 @@ function extractAndCopy(folder) {
*
*/
function failUpdate() {
showErrorPopup(`An error has occurred while updating Olympus. Please delete Olympus and update it manually. A browser window will open automatically on the download page. <br><br> You can find more info in ${path.join(__dirname, "..", "manager.log")}`, () => {
showErrorPopup(`<div class='main-message'>An error has occurred while updating Olympus. </div><div class='sub-message'> Please delete Olympus and update it manually. A browser window will open automatically on the download page. <br><br> You can find more info in ${path.join(__dirname, "..", "manager.log")}</div>`, () => {
exec(`start https://github.com/Pax1601/DCSOlympus/releases`, () => {
ipcRenderer.send('window:close');
})

View File

@ -106,7 +106,7 @@ body {
align-items: center;
color: #F2F2F2;
font-weight: bold;
font-size: var(--normal);
font-size: var(--big);
padding: 20px 20px 20px 20px;
column-gap: 10px;
background-color: var(--background-dark);
@ -135,7 +135,7 @@ body {
font-weight: normal;
text-decoration: underline;
cursor: pointer;
font-size: var(--normal);
font-size: var(--big);
}
.link.first {
@ -298,6 +298,15 @@ body {
background-color: var(--offwhite);
}
#popup .main-message {
font-size: var(--large);
max-width: 100%;
}
#popup .sub-message {
font-weight: normal;
}
/************************************************/
/* Inputs */
/************************************************/
@ -465,6 +474,38 @@ input {
border-bottom: 2px solid var(--offwhite);
}
/************************************************/
/* Port checks */
/************************************************/
.port-input .success,
.port-input .error {
position: absolute;
left: 320px;
display: flex;
width: 150px;
column-gap: 8px;
}
.port-input .success {
content: url("../icons/check-solid-green.svg");
height: 20px;
width: 20px;
}
.port-input .error img {
content: url("../icons/triangle-exclamation-solid.svg");
height: 20px;
width: 20px;
}
.port-input .error span {
font-weight: 600;
font-size: var(--small);
color: var(--red);
height: fit-content;
}
/************************************************/
/* Dashboard */
/************************************************/