diff --git a/manager/ejs/connections.ejs b/manager/ejs/connections.ejs index cc8df545..da915406 100644 --- a/manager/ejs/connections.ejs +++ b/manager/ejs/connections.ejs @@ -1,31 +1,5 @@
@@ -42,7 +16,7 @@
-
+
Client port @@ -56,7 +30,7 @@
-
+
Backend port diff --git a/manager/ejs/expertsettings.ejs b/manager/ejs/expertsettings.ejs new file mode 100644 index 00000000..40c50302 --- /dev/null +++ b/manager/ejs/expertsettings.ejs @@ -0,0 +1,78 @@ + +
+
+
+ Edit Olympus instance +
+
+ Please note: you may be required to allow these ports through your firewall and modem/router via port forwarding.
+ Otherwise, others may not be able to connect to Olympus. +
+
+
+
+
+ Game Master Password + + +
+
+ Blue Commander Password + + +
+
+ Red Commander Password + + +
+
" style="color: var(--offwhite); font-size: var(--normal); color: var(--lightgray);"> + Note: to keep the old passwords, click Next without editing any value. +
+
+
+
+ Client port + + +
+ " + onchange="signal('onClientPortChanged', this.value)"> + +
+ Port already in use +
+
+
+
+ Backend port + + +
+ " + onchange="signal('onBackendPortChanged', this.value)"> + +
+ Port already in use +
+
+
+
+ +
Enable direct backend API connection + +
+
+
+
+
diff --git a/manager/ejs/instances.ejs b/manager/ejs/instances.ejs index 4d0236f8..fcee3e9d 100644 --- a/manager/ejs/instances.ejs +++ b/manager/ejs/instances.ejs @@ -3,12 +3,35 @@
-
"> -
Olympus settings updated for <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
-
-
"> -
An error occurred while updating Olympus settings for <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
-
+ <% if (operation === 'INSTALL') { %> +
"> +
Olympus installed successfully in + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+
+
"> +
An error occurred while installing Olympus in + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+
+ <% } else if (operation === 'EDIT') {%> +
"> +
Olympus settings updated for + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+
+
"> +
An error occurred while updating Olympus settings for + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+
+ <% } else {%> +
"> +
Olympus removed successfully from + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+
+
"> +
An error occurred while removing Olympus settings from + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+
+ <% } %> +
diff --git a/manager/ejs/passwords.ejs b/manager/ejs/passwords.ejs index d592a7c6..58c6899f 100644 --- a/manager/ejs/passwords.ejs +++ b/manager/ejs/passwords.ejs @@ -19,19 +19,19 @@ Game Master Password - "> +
Blue Commander Password - "> +
Red Commander Password - "> +
" style="color: var(--offwhite); font-size: var(--normal); color: var(--lightgray);"> Note: to keep the old passwords, click Next without editing any value. diff --git a/manager/ejs/settings.ejs b/manager/ejs/settings.ejs index b8183302..45f187d1 100644 --- a/manager/ejs/settings.ejs +++ b/manager/ejs/settings.ejs @@ -5,12 +5,25 @@
Back to menu
-
"> -
Olympus settings updated for <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
-
-
"> -
An error occurred while updating Olympus settings for <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
-
+ <% if (operation === 'EDIT') {%> +
"> +
Olympus settings updated for + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+
+
"> +
An error occurred while updating Olympus settings for + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+
+ <% } else {%> +
"> +
Olympus removed successfully from + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+
+
"> +
An error occurred while removing Olympus settings from + <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+
+ <% } %>
diff --git a/manager/ejs/wizard.ejs b/manager/ejs/wizard.ejs index 7267bdd7..cb162f38 100644 --- a/manager/ejs/wizard.ejs +++ b/manager/ejs/wizard.ejs @@ -71,7 +71,7 @@
- Cancel install + <%= operation === 'INSTALL'? "Cancel install": "Cancel editing" %>
diff --git a/manager/javascripts/dcsinstance.js b/manager/javascripts/dcsinstance.js index 1b85250c..05c71361 100644 --- a/manager/javascripts/dcsinstance.js +++ b/manager/javascripts/dcsinstance.js @@ -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(`
A critical error has occurred while reading your Olympus configuration file.
Please, manually reinstall olympus in ${this.folder}.
`) 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`) + getManager().options.mode === "basic"? getManager().settingsPage.show(): getManager().instancesPage.show(); } } @@ -487,6 +501,7 @@ class DCSInstance { async install() { showWaitLoadingPopup(`Please wait while Olympus is being installed in ${this.name}`); 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(`
Are you sure you want to remove Olympus from ${this.name}?
This will only remove Olympus for this particular DCS instance.
`, async () => { + showConfirmPopup(`
Are you sure you want to remove Olympus from ${this.name}?
This will only remove Olympus for this particular DCS instance.
`, async () => { try { + getManager().activePage.hide(); logger.log(`Uninstalling Olympus from ${this.folder}`) await sleep(300); showWaitLoadingPopup(`Please wait while Olympus is being removed from ${this.name}`); @@ -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.

You can find more info in ${path.join(__dirname, "..", "manager.log")}`, () => { - location.reload(); + showErrorPopup(`
An error has occurred while uninstalling the Olympus instance.
Make sure Olympus and DCS are not running.
You can find more info in ${path.join(__dirname, "..", "manager.log")}
`, () => { + if (getManager().options.mode === 'basic') + getManager().settingsPage.show(); + else + getManager().instancesPage.show(); }); } }); diff --git a/manager/javascripts/manager.js b/manager/javascripts/manager.js index fea015d2..1defc079 100644 --- a/manager/javascripts/manager.js +++ b/manager/javascripts/manager.js @@ -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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`) } } @@ -99,7 +101,7 @@ class Manager { return instance.installed && instance.error; })) { /* Ask the user for confirmation */ - showConfirmPopup("
One or more of your Olympus instances are not up to date!
If you have just updated Olympus this is normal. Press Accept and the Manager will update your instances for you.
Press Close to update your instances manually using the Installation Wizard", async () => { + showConfirmPopup("
One or more of your Olympus instances are not up to date!
If you have just updated Olympus this is normal.

Press Accept and the Manager will update your instances for you.
Press Close to update your instances manually using the Installation Wizard
", 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.

You can find more info in ${this.options.logLocation}`); + showErrorPopup(`
An error occurred while trying to fix your installations. Please reinstall Olympus manually.
You can find more info in ${this.options.logLocation}
`); } }) } @@ -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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`) } } @@ -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("
Olympus is already installed in this instance!
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?
", + showConfirmPopup("
Olympus is already installed in this instance!
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?
", () => { 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`); } } @@ -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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`); } } /* 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("
Olympus is already installed in this instance!
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?
", + showConfirmPopup("
Olympus is already installed in this instance!
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?
", () => { 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`) } } 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`); } 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`); } 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`); } /* 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(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`) } } /* 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(`
Please, make sure both the client and backend ports are free!
If ports are already in use, Olympus will not be able to communicated correctly.
`); + 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(`
Please, make sure all passwords are set!
The role users will fulfill depends on the password they enter at login.
`); + return false; + } else if (!this.options.activeInstance.arePasswordsDifferent()) { + showErrorPopup(`
Please, set different passwords!
The role users will fulfill depends on the password they enter at login.
`); + return false; + } else { + return true; + } + } + } else { + showErrorPopup(`
A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`) + 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("
Error, the selected Olympus instance is currently active
Please stop Olympus before editing it!
") } 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("
Error, the selected Olympus instance is currently active
Please stop Olympus before removing it!
") 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) { diff --git a/manager/javascripts/preload.js b/manager/javascripts/preload.js index 564016cd..1261e297 100644 --- a/manager/javascripts/preload.js +++ b/manager/javascripts/preload.js @@ -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?
Note: DCS and Olympus MUST be stopped before proceeding.
`, + showConfirmPopup(`
You are currently running DCS Olympus ${VERSION}, but ${res["version"]} is available.
Do you want to update DCS Olympus automatically?
Note: DCS and Olympus MUST be stopped before proceeding.
`, () => { updateOlympusRelease(); }, () => { @@ -71,10 +71,10 @@ async function updateOlympusBeta() { const date1 = new Date(artifact.updated_at); const date2 = fs.statSync(".").mtime; if (date1 > date2) { - showConfirmPopup(`Looks like you are running a beta version of Olympus!Latest beta artifact timestamp of: ${date1.toLocaleString()}
Your installation timestamp: ${date2.toLocaleString()}

Do you want to update to the newest beta version?
`, () => { + showConfirmPopup(`
Looks like you are running a beta version of Olympus!
Latest beta artifact timestamp of: ${date1.toLocaleString()}
Your installation timestamp: ${date2.toLocaleString()}

Do you want to update to the newest beta version?
`, () => { /* 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(`
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.
`, () => { /* 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("
Please wait while Olympus is being updated.
The Manager will be closed and reopened automatically when updating is completed.
") /* 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.

You can find more info in ${path.join(__dirname, "..", "manager.log")}`, () => { + 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.

You can find more info in ${path.join(__dirname, "..", "manager.log")}
`, () => { exec(`start https://github.com/Pax1601/DCSOlympus/releases`, () => { ipcRenderer.send('window:close'); }) diff --git a/manager/stylesheets/style.css b/manager/stylesheets/style.css index 9174ddd6..322baebc 100644 --- a/manager/stylesheets/style.css +++ b/manager/stylesheets/style.css @@ -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 */ /************************************************/