-
- View and manage installs
-
-
- The following DCS installations have been identified.
You can start an Olympus server, modify settings and uninstall below. - -
- You can start an Olympus server, modify settings and uninstall below. - -
">
- No instances detected!
+ <% if (instances.length > 0) { %>
+
+ View and manage installs
+
+
+ The following DCS installations have been identified.
You can start an Olympus server, modify settings and uninstall below. + + <% } else { %> + + No DCS installs detected + + + Please ensure you have DCS installed correctly.
+ Olympus cannot be added unless there is a DCS Saved Games folder on your computer.
+ If you are still having issues, try re-installing DCS and Olympus
+ If DCS is installed but Olympus is failing to detect it, you can add it manually.
See the troubleshooting guide for more info. + + <% } %>
+
You can start an Olympus server, modify settings and uninstall below. + + <% } else { %> + + No DCS installs detected + + + Please ensure you have DCS installed correctly.
+ Olympus cannot be added unless there is a DCS Saved Games folder on your computer.
+ If you are still having issues, try re-installing DCS and Olympus
+ If DCS is installed but Olympus is failing to detect it, you can add it manually.
See the troubleshooting guide for more info. + + <% } %>
<% for (let i = 0; i < instances.length; i++) {%>
diff --git a/manager/ejs/menu.ejs b/manager/ejs/menu.ejs
index 5c7e444a..999fb28c 100644
--- a/manager/ejs/menu.ejs
+++ b/manager/ejs/menu.ejs
@@ -84,13 +84,13 @@
-
+
Add Olympus
-
Add or update Olympus to a new DCS instance
+
Change settings
Adjust port, address and password settings
diff --git a/manager/ejs/passwords.ejs b/manager/ejs/passwords.ejs
index 58c6899f..68a52f0e 100644
--- a/manager/ejs/passwords.ejs
+++ b/manager/ejs/passwords.ejs
@@ -4,7 +4,7 @@
- Step <%= singleInstance? "4": "5" %> of <%= singleInstance? "4": "5" %>
+ Step <%= instances.length === 1? "4": "5" %> of <%= instances.length === 1? "4": "5" %>
Enter your passwords for Olympus
@@ -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/result.ejs b/manager/ejs/result.ejs
index be2d5c69..b7e60b6a 100644
--- a/manager/ejs/result.ejs
+++ b/manager/ejs/result.ejs
@@ -96,7 +96,7 @@
diff --git a/manager/ejs/settings.ejs b/manager/ejs/settings.ejs
index 70885c36..ddfcdccc 100644
--- a/manager/ejs/settings.ejs
+++ b/manager/ejs/settings.ejs
@@ -5,27 +5,28 @@
Back to menu
- <% if (operation === 'EDIT') {%>
-
- To access Olympus remotely visit
')">http://<%= ip %>:<%= activeInstance["clientPort"] %>
in a web browser (Google Chrome recommended).
+ To access Olympus remotely visit ')">http://<%= IP %>:<%= activeInstance["clientPort"] %>
in a web browser (Google Chrome recommended).
">
+ <% if (state === 'EDIT') {%>
+
- ">
Olympus settings updated for
- <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+ <%= activeInstance !== undefined? activeInstance["name"]: "" %>!
">
+
<% } else {%>
- ">
An error occurred while updating Olympus settings for
- <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+ <%= activeInstance !== undefined? activeInstance["name"]: "" %>
">
+
- ">
Olympus removed successfully from
- <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>!
+ <%= activeInstance !== undefined? activeInstance["name"]: "" %>!
">
+
<% } %>
">
An error occurred while removing Olympus settings from
- <%= typeof activeInstance !== 'undefined'? activeInstance["name"]: "" %>
+ <%= activeInstance !== undefined? activeInstance["name"]: "" %>
+ <% if (instances.some(instance => instance.installed)) { %>
Change settings
@@ -33,9 +34,15 @@
Here you can see the DCS instances on your computer that have Olympus installed.
You can edit settings and uninstall Olympus from this screen. -
- You can edit settings and uninstall Olympus from this screen. -
">
- No instances detected!
+ <% } else { %>
+
+ No Olympus installs detected
+
+
+ Use the Add Olympus option in the main manu to install Olympus in your DCS instance.
+ If you have more than one DCS instance, you will need to add Olympus to each one of them. + + <% } %>
+ If you have more than one DCS instance, you will need to add Olympus to each one of them. + + <% } %>
diff --git a/manager/ejs/type.ejs b/manager/ejs/type.ejs
index 4c6ac735..b0781fb6 100644
--- a/manager/ejs/type.ejs
+++ b/manager/ejs/type.ejs
@@ -4,7 +4,7 @@
- Step <%= singleInstance? "1": "2" %> of <%= singleInstance? "4": "5" %>
+ Step <%= instances.length === 1? "1": "2" %> of <%= instances.length === 1? "4": "5" %>
Do you want to add Olympus for singleplayer or multiplayer?
diff --git a/manager/ejs/wizard.ejs b/manager/ejs/wizard.ejs
index cb162f38..5f069df7 100644
--- a/manager/ejs/wizard.ejs
+++ b/manager/ejs/wizard.ejs
@@ -71,7 +71,7 @@
-
<%= operation === 'INSTALL'? "Cancel install": "Cancel editing" %>
+
<%= state === 'INSTALL'? "Cancel install": "Cancel editing" %>
diff --git a/manager/javascripts/dcsinstance.js b/manager/javascripts/dcsinstance.js
index 05c71361..21f67f13 100644
--- a/manager/javascripts/dcsinstance.js
+++ b/manager/javascripts/dcsinstance.js
@@ -28,14 +28,15 @@ class DCSInstance {
return DCSInstance.instances;
}
+ /** Static asynchronous method to reload all DCS instances. It will not detect any new instance, but it will determine the
+ * installation status of the existing 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
@@ -53,12 +54,12 @@ class DCSInstance {
const searchpath = result[shellFoldersKey]['values'][saveGamesKey]['value'];
var folders = fs.readdirSync(searchpath).map((folder) => {return path.join(searchpath, folder);});
var instances = [];
- folders = folders.concat(getManager().options.additionalDCSInstances);
+ folders = folders.concat(getManager().getAdditionalDCSInstances());
/* A DCS Instance is created if either the appsettings.lua or serversettings.lua file is detected */
for (let i = 0; i < folders.length; i++) {
const folder = folders[i];
- if (fs.existsSync(path.join(folder, "Config", "appsettings.lua")) || fs.existsSync(path.join(folder, "Config", "serversettings.lua")) || getManager().options.additionalDCSInstances.includes(folder)) {
+ if (fs.existsSync(path.join(folder, "Config", "appsettings.lua")) || fs.existsSync(path.join(folder, "Config", "serversettings.lua")) || getManager().getAdditionalDCSInstances().includes(folder)) {
logger.log(`Found instance in ${folder}, checking for Olympus`)
var newInstance = new DCSInstance(path.join(folder));
@@ -70,7 +71,7 @@ class DCSInstance {
}
} else {
logger.error("An error occured while trying to fetch the location of the DCS instances.")
- throw "An error occured while trying to fetch the location of the DCS instances.";
+ showErrorPopup(`
An error occured while trying to fetch the location of the DCS instances.
You can find more info in ${getManager().getLogLocation()}
`);
}
getManager().setLoadingProgress(`All DCS instances found!`, 100);
@@ -148,8 +149,15 @@ class DCSInstance {
* @returns true if the instance has any error or is outdated
*/
async checkInstallation() {
+ /* Reset values */
+ this.installed = false;
+ this.error = false;
+ this.installationType = 'singleplayer';
+ this.connectionsType = 'auto';
+
/* Check if the olympus.json file is detected. If true, Olympus is considered to be installed */
if (fs.existsSync(path.join(this.folder, "Config", "olympus.json"))) {
+
getManager().setLoadingProgress(`Olympus installed in ${this.folder}`);
try {
/* Read the olympus.json */
@@ -158,6 +166,11 @@ class DCSInstance {
this.backendPort = config["server"]["port"];
this.backendAddress = config["server"]["address"];
this.gameMasterPasswordHash = config["authentication"]["gameMasterPassword"];
+
+ this.gameMasterPasswordEdited = false;
+ this.blueCommanderPasswordEdited = false;
+ this.redCommanderPasswordEdited = false;
+
} catch (err) {
showErrorPopup(`A critical error has occurred while reading your Olympus configuration file.
Please, manually reinstall olympus in ${this.folder}.
`)
logger.error(err)
@@ -205,7 +218,6 @@ class DCSInstance {
*
* @param {Number} newPort The new client port to set
*/
-
setClientPort(newPort) {
logger.log(`Instance ${this.folder} client port set to ${newPort}`)
this.clientPort = newPort;
@@ -374,7 +386,7 @@ class DCSInstance {
*
*/
async getData() {
- if (this.installed && !this.error) {
+ if (this.installed) {
fetchWithTimeout(`http://localhost:${this.clientPort}`, { timeout: 250 })
.then(async (response) => {
this.webserverOnline = (await response.text()).includes("Olympus");
@@ -485,13 +497,13 @@ class DCSInstance {
logger.log(`Editing completed successfully`);
hidePopup();
- getManager().options.mode === "basic"? getManager().settingsPage.show(): getManager().instancesPage.show();
+ getManager().getMode() === "basic"? getManager().settingsPage.show(): getManager().instancesPage.show();
} catch (err) {
logger.log(`An error occurred during editing: ${err}`);
getManager().getActiveInstance().error = true;
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`)
- getManager().options.mode === "basic"? getManager().settingsPage.show(): getManager().instancesPage.show();
+ showErrorPopup(`A critical error occurred!
Check ${getManager().getLogLocation()} for more info.
`)
+ getManager().getMode() === "basic"? getManager().settingsPage.show(): getManager().instancesPage.show();
}
}
@@ -526,7 +538,7 @@ class DCSInstance {
await sleep(500);
logger.log(`Installation completed successfully`);
hidePopup();
- if (getManager().options.mode === 'basic') {
+ if (getManager().getMode() === 'basic') {
getManager().resultPage.show();
getManager().resultPage.getElement().querySelector(".result-summary.success").classList.remove("hide");
getManager().resultPage.getElement().querySelector(".result-summary.error").classList.add("hide");
@@ -538,7 +550,7 @@ class DCSInstance {
} catch (err) {
logger.log(`An error occurred during installation: ${err}`);
hidePopup();
- if (getManager().options.mode === 'basic') {
+ if (getManager().getMode() === 'basic') {
getManager().resultPage.show();
getManager().resultPage.getElement().querySelector(".result-summary.success").classList.add("hide");
getManager().resultPage.getElement().querySelector(".result-summary.error").classList.remove("hide");
@@ -581,7 +593,7 @@ class DCSInstance {
hidePopup();
await getManager().reload();
- if (getManager().options.mode === 'basic')
+ if (getManager().getMode() === 'basic')
getManager().settingsPage.show();
else
getManager().instancesPage.show();
@@ -589,12 +601,14 @@ class DCSInstance {
} 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")}
`, () => {
- if (getManager().options.mode === 'basic')
+ if (getManager().getMode() === 'basic')
getManager().settingsPage.show();
else
getManager().instancesPage.show();
});
- }
+ }
+ }, () => {
+ getManager().setState('IDLE');
});
}
}
diff --git a/manager/javascripts/manager.js b/manager/javascripts/manager.js
index 1defc079..589930b6 100644
--- a/manager/javascripts/manager.js
+++ b/manager/javascripts/manager.js
@@ -13,11 +13,17 @@ const { sleep } = require("./utils");
class Manager {
options = {
- logLocation: path.join(__dirname, "..", "manager.log"),
+ activeInstance: undefined,
+ additionalDCSInstances: [],
configLoaded: false,
- operation: 'NONE'
+ instances: [],
+ IP: undefined,
+ logLocation: path.join(__dirname, "..", "manager.log"),
+ mode: 'basic',
+ state: 'IDLE'
};
+ /* Manager pages */
activePage = null;
welcomePage = null;
settingsPage = null;
@@ -43,6 +49,10 @@ class Manager {
console.error(e);
}
});
+
+ window.olympus = {
+ manager: this
+ };
}
/** Asynchronously start the manager
@@ -55,14 +65,14 @@ class Manager {
/* Load the options from the json file */
try {
this.options = { ...this.options, ...JSON.parse(fs.readFileSync("options.json")) };
- this.options.configLoaded = true;
+ this.setConfigLoaded(true);
} catch (e) {
logger.error(`An error occurred while reading the options.json file: ${e}`);
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`)
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`)
}
}
- if (!this.options.configLoaded) {
+ if (!this.getConfigLoaded()) {
this.hideLoadingPage();
/* Show page to select basic vs expert mode */
@@ -73,7 +83,7 @@ class Manager {
document.getElementById("header").classList.remove("hide");
/* Initialize mode switching */
- if (this.options.mode === "basic") {
+ if (this.getMode() === "basic") {
document.getElementById("switch-mode").innerText = "Expert mode";
document.getElementById("switch-mode").onclick = () => { this.switchMode("expert"); }
}
@@ -84,108 +94,110 @@ class Manager {
/* Get the list of DCS instances */
this.setLoadingProgress("Retrieving DCS instances...", 0);
- DCSInstance.getInstances().then(async (instances) => {
- this.setLoadingProgress(`Analysis completed, starting manager...`, 100);
- await sleep(100);
+ var instances = await DCSInstance.getInstances();
+ this.setLoadingProgress(`Analysis completed, starting manager...`, 100);
+ await sleep(100);
- this.options.instances = instances;
+ this.setInstances(instances);
- /* Get my public IP */
- this.getPublicIP().then(
- (ip) => { this.options.ip = ip; },
- () => { this.options.ip = undefined; }
- )
-
- /* Check if there are corrupted or outdated instances */
- if (this.options.instances.some((instance) => {
- 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 () => {
- try {
- await sleep(300);
- await DCSInstance.fixInstances();
- location.reload();
- } catch (err) {
- logger.error(err);
- await sleep(300);
- showErrorPopup(`Press Accept and the Manager will update your instances for you.
Press Close to update your instances manually using the Installation Wizard
An error occurred while trying to fix your installations. Please reinstall Olympus manually.
You can find more info in ${this.options.logLocation}
`);
- }
- })
+ /* Get my public IP */
+ this.getPublicIP().then(
+ (IP) => { this.setIP(IP); },
+ (err) => {
+ logger.log(err)
+ this.setIP(undefined);
}
+ )
- this.options.installEnabled = true;
- this.options.editEnabled = this.options.instances.find(instance => instance.installed);
-
- /* Hide the loading page */
- this.hideLoadingPage();
-
- this.options.singleInstance = this.options.instances.length === 1;
-
- /* Create all the HTML pages */
- this.menuPage = new ManagerPage(this, "./ejs/menu.ejs");
- this.folderPage = new WizardPage(this, "./ejs/folder.ejs");
- this.settingsPage = new ManagerPage(this, "./ejs/settings.ejs");
- this.typePage = new WizardPage(this, "./ejs/type.ejs");
- this.connectionsTypePage = new WizardPage(this, "./ejs/connectionsType.ejs");
- this.connectionsPage = new WizardPage(this, "./ejs/connections.ejs");
- 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 = () => {
- if (this.options.activeInstance) {
- this.setPort('client', this.options.activeInstance.clientPort);
- this.setPort('backend', this.options.activeInstance.backendPort);
+ /* Check if there are corrupted or outdated instances */
+ if (this.getInstances().some((instance) => {
+ 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 () => {
+ try {
+ await sleep(300);
+ await DCSInstance.fixInstances();
+ location.reload();
+ } catch (err) {
+ logger.error(err);
+ await sleep(300);
+ showErrorPopup(`Press Accept and the Manager will update your instances for you.
Press Close to update your instances manually using the Installation Wizard
An error occurred while trying to fix your installations. Please reinstall Olympus manually.
You can find more info in ${this.options.logLocation}
`);
}
- }
- 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();
- }
+ /* Hide the loading page */
+ this.hideLoadingPage();
- if (this.options.mode === "basic") {
- /* In basic mode no dashboard is shown */
- this.menuPage.show();
- } else {
- /* In Expert mode we go directly to the dashboard */
- this.instancesPage.show();
- this.updateInstances();
- }
+ /* Create all the HTML pages */
+ this.menuPage = new ManagerPage(this, "./ejs/menu.ejs");
+ this.folderPage = new WizardPage(this, "./ejs/folder.ejs");
+ this.settingsPage = new ManagerPage(this, "./ejs/settings.ejs");
+ this.typePage = new WizardPage(this, "./ejs/type.ejs");
+ this.connectionsTypePage = new WizardPage(this, "./ejs/connectionsType.ejs");
+ this.connectionsPage = new WizardPage(this, "./ejs/connections.ejs");
+ 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");
- /* Send an event on manager started */
- document.dispatchEvent(new CustomEvent("managerStarted"));
- });
+ /* Force the setting of the ports whenever the page is shown */
+ this.connectionsPage.options.onShow = () => {
+ if (this.getActiveInstance()) {
+ this.setPort('client', this.getActiveInstance().clientPort);
+ this.setPort('backend', this.getActiveInstance().backendPort);
+ }
+ }
+ this.expertSettingsPage.options.onShow = () => {
+ if (this.getActiveInstance()) {
+ this.setPort('client', this.getActiveInstance().clientPort);
+ this.setPort('backend', this.getActiveInstance().backendPort);
+ }
+ }
+
+ /* Always force the IDLE state when reaching the menu page */
+ this.menuPage.options.onShow = async () => {
+ await this.setState('IDLE');
+ }
+
+ /* Update the instances when showing the dashboard */
+ this.instancesPage.options.onShow = () => {
+ this.updateInstances();
+ }
+
+ /* Reload the instances when we get to the folder page */
+ this.folderPage.options.onShow = async () => {
+ if (this.getInstances().length > 0)
+ this.setActiveInstance(this.getInstances()[0]);
+ await DCSInstance.reloadInstances();
+ }
+
+ if (this.getMode() === "basic") {
+ /* In basic mode no dashboard is shown */
+ this.menuPage.show();
+ } else {
+ /* In Expert mode we go directly to the dashboard */
+ this.instancesPage.show();
+ this.updateInstances();
+ }
+
+ /* Send an event on manager started */
+ document.dispatchEvent(new CustomEvent("managerStarted"));
}
}
- /** Get the currently active instance, i.e. the instance that is being edited/installed/removed
- *
- * @returns The active instance
- */
- getActiveInstance() {
- return this.options.activeInstance;
- }
-
/** Creates the options file. This is done only the very first time you start Olympus.
*
* @param {String} mode The mode, either Basic or Expert
*/
- createOptionsFile(mode) {
+ async createOptionsFile(mode) {
try {
fs.writeFileSync("options.json", JSON.stringify({ mode: mode, additionalDCSInstances: [] }, null, 2));
location.reload();
} catch (err) {
logger.log(err);
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`)
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`)
}
}
@@ -193,7 +205,7 @@ class Manager {
*
* @param {String} newMode The mode to switch to
*/
- switchMode(newMode) {
+ async switchMode(newMode) {
/* Change the mode in the options.json and reload the page */
var options = JSON.parse(fs.readFileSync("options.json"));
options.mode = newMode;
@@ -207,38 +219,42 @@ class Manager {
/** Switch to basic mode
*
*/
- onBasicClicked() {
+ async onBasicClicked() {
this.createOptionsFile("basic");
}
/** Switch to expert mode
*
*/
- onExpertClicked() {
+ async onExpertClicked() {
this.createOptionsFile("expert");
}
/** When the install button is clicked go the installation page
*
*/
- onInstallMenuClicked() {
- this.options.operation = 'INSTALL';
+ async onInstallMenuClicked() {
+ await this.setState('INSTALL');
- if (this.options.instances.length == 0) {
+ if (this.getInstances().length == 0) {
// TODO: show error
}
- this.options.activeInstance = this.options.instances[0];
- if (this.options.singleInstance) {
+ if (this.getInstances().length === 1) {
+ this.setActiveInstance(this.getInstances()[0]);
+
/* Show the type selection page */
- if (!this.options.activeInstance.installed) {
+ if (!this.getActiveInstance().installed) {
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?
",
() => {
- this.activePage.hide()
+ this.activePage.hide();
this.typePage.show();
+ },
+ async () => {
+ await this.setState('IDLE');
}
)
}
@@ -252,10 +268,9 @@ class Manager {
/** When the edit button is clicked go to the settings page
*
*/
- onEditMenuClicked() {
- this.activePage.hide()
- this.options.operation = 'EDIT';
- delete this.options.activeInstance;
+ async onEditMenuClicked() {
+ this.activePage.hide();
+ await this.setState('IDLE');
this.settingsPage.show();
}
@@ -271,37 +286,38 @@ class Manager {
for (let i = 0; i < instanceDivs.length; i++) {
instanceDivs[i].classList.toggle('selected', instanceDivs[i].dataset.folder === instance.folder);
if (instanceDivs[i].dataset.folder === instance.folder)
- this.options.activeInstance = instance;
+ this.setActiveInstance(instance);
}
}
/* When the installation type is selected */
- onInstallTypeClicked(type) {
+ 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.options.activeInstance)
- this.options.activeInstance.installationType = type;
+ if (this.getActiveInstance())
+ this.getActiveInstance().installationType = type;
else {
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`);
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`);
}
}
/* When the connections type is selected */
- onConnectionsTypeClicked(type) {
+ async onConnectionsTypeClicked(type) {
this.connectionsTypePage.getElement().querySelector(`.auto`).classList.toggle("selected", type === 'auto');
this.connectionsTypePage.getElement().querySelector(`.manual`).classList.toggle("selected", type === 'manual');
- if (this.options.activeInstance)
- this.options.activeInstance.connectionsType = type;
+ if (this.getActiveInstance())
+ this.getActiveInstance().connectionsType = type;
else {
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`);
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`);
}
}
/* When the next button of a wizard page is clicked */
async onNextClicked() {
/* Choose which page to show depending on the active page */
+ /* Folder selection page */
if (this.activePage == this.folderPage) {
- if (this.options.activeInstance.installed) {
+ if (this.getActiveInstance().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?
",
() => {
this.activePage.hide()
@@ -312,111 +328,128 @@ class Manager {
this.activePage.hide();
this.typePage.show();
}
+ /* Installation type page */
} else if (this.activePage == this.typePage) {
this.activePage.hide();
this.connectionsTypePage.show();
+ /* Connection type page */
} else if (this.activePage == this.connectionsTypePage) {
- if (this.options.activeInstance) {
- if (this.options.activeInstance.connectionsType === 'auto') {
+ if (this.getActiveInstance()) {
+ if (this.getActiveInstance().connectionsType === 'auto') {
this.activePage.hide();
this.passwordsPage.show();
}
else {
this.activePage.hide();
this.connectionsPage.show();
- (this.options.mode === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
+ (this.getMode() === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.getActiveInstance().backendAddress === '*')
}
} else {
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`)
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`)
}
+ /* Connection page */
} else if (this.activePage == this.connectionsPage) {
if (await this.checkPorts()) {
this.activePage.hide();
this.passwordsPage.show();
}
+ /* Passwords page */
} else if (this.activePage == this.passwordsPage) {
if (await this.checkPasswords()) {
this.activePage.hide();
- this.options.operation === 'INSTALL' ? this.options.activeInstance.install() : this.options.activeInstance.edit();
+ this.getState() === 'INSTALL' ? this.getActiveInstance().install() : this.getActiveInstance().edit();
}
+ /* Expert settings page */
} 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();
+ this.getState() === 'INSTALL' ? this.getActiveInstance().install() : this.getActiveInstance().edit();
}
}
}
/* When the back button of a wizard page is clicked */
- onBackClicked() {
+ async onBackClicked() {
this.activePage.hide();
/* If we have backed to the menu, instances or settings page, reset the active instance */
if ([this.instancesPage, this.settingsPage].includes(this.activePage.previousPage)) {
- delete this.options.activeInstance;
+ await this.setState('IDLE');
}
- this.activePage.previousPage.show(true); // Don't change the previous page
+ this.activePage.previousPage.show(true); // Don't change the previous page (or we get stuck in a loop)
this.updateInstances();
}
- onCancelClicked() {
+ async onCancelClicked() {
this.activePage.hide();
- delete this.options.activeInstance;
- if (this.options.mode === "basic")
+ await this.setState('IDLE');
+ if (this.getMode() === "basic")
this.menuPage.show(true);
else
this.instancesPage.show(true);
this.updateInstances();
}
- onGameMasterPasswordChanged(value) {
- if (this.options.activeInstance)
- this.options.activeInstance.setGameMasterPassword(value);
+ async onGameMasterPasswordChanged(value) {
+ for (let input of this.activePage.getElement().querySelectorAll("input[type='password']")) {
+ input.placeholder = "";
+ }
+
+ if (this.getActiveInstance())
+ this.getActiveInstance().setGameMasterPassword(value);
else
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`);
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`);
}
- onBlueCommanderPasswordChanged(value) {
- if (this.options.activeInstance)
- this.options.activeInstance.setBlueCommanderPassword(value);
+ async onBlueCommanderPasswordChanged(value) {
+ for (let input of this.activePage.getElement().querySelectorAll("input[type='password']")) {
+ input.placeholder = "";
+ }
+
+ if (this.getActiveInstance())
+ this.getActiveInstance().setBlueCommanderPassword(value);
else
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`);
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`);
}
- onRedCommanderPasswordChanged(value) {
- if (this.options.activeInstance)
- this.options.activeInstance.setRedCommanderPassword(value);
+ async onRedCommanderPasswordChanged(value) {
+ for (let input of this.activePage.getElement().querySelectorAll("input[type='password']")) {
+ input.placeholder = "";
+ }
+
+ if (this.getActiveInstance())
+ this.getActiveInstance().setRedCommanderPassword(value);
else
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`);
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`);
}
/* When the client port input value is changed */
- onClientPortChanged(value) {
+ async onClientPortChanged(value) {
this.setPort('client', Number(value));
}
/* When the backend port input value is changed */
- onBackendPortChanged(value) {
+ async onBackendPortChanged(value) {
this.setPort('backend', Number(value));
}
/* When the "Enable API connection" checkbox is clicked */
- onEnableAPIClicked() {
- if (this.options.activeInstance) {
- if (this.options.activeInstance.backendAddress === 'localhost') {
- this.options.activeInstance.backendAddress = '*';
+ async onEnableAPIClicked() {
+ if (this.getActiveInstance()) {
+ if (this.getActiveInstance().backendAddress === 'localhost') {
+ this.getActiveInstance().backendAddress = '*';
} else {
- this.options.activeInstance.backendAddress = 'localhost';
+ this.getActiveInstance().backendAddress = 'localhost';
}
- 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 === '*')
+ if (this.getMode() === 'basic') {
+ this.connectionsPage.getElement().querySelector(".note.warning").classList.toggle("hide", this.getActiveInstance().backendAddress !== '*')
+ this.connectionsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.getActiveInstance().backendAddress === '*')
} else {
- this.expertSettingsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.options.activeInstance.backendAddress === '*')
+ this.expertSettingsPage.getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.getActiveInstance().backendAddress === '*')
}
} else {
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`)
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`)
}
}
@@ -428,13 +461,13 @@ class Manager {
}
/* When the "Close manager" button is pressed */
- onCloseManagerClicked() {
+ async onCloseManagerClicked() {
document.querySelector('.close').click();
}
async checkPorts() {
- var clientPortFree = await this.options.activeInstance.checkClientPort();
- var backendPortFree = await this.options.activeInstance.checkBackendPort();
+ var clientPortFree = await this.getActiveInstance().checkClientPort();
+ var backendPortFree = await this.getActiveInstance().checkBackendPort();
if (clientPortFree && backendPortFree) {
return true;
} else {
@@ -444,15 +477,15 @@ class Manager {
}
async checkPasswords() {
- if (this.options.activeInstance) {
- if (this.options.activeInstance.installed && !this.options.activeInstance.arePasswordsEdited()) {
+ if (this.getActiveInstance()) {
+ if (this.getActiveInstance().installed && !this.getActiveInstance().arePasswordsEdited()) {
return true;
}
else {
- if (!this.options.activeInstance.arePasswordsSet()) {
+ if (!this.getActiveInstance().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()) {
+ } else if (!this.getActiveInstance().arePasswordsDifferent()) {
showErrorPopup(`Please, set different passwords!
The role users will fulfill depends on the password they enter at login.
`);
return false;
} else {
@@ -460,7 +493,7 @@ class Manager {
}
}
} else {
- showErrorPopup(`A critical error occurred!
Check ${getManager().options.logLocation} for more info.
`)
+ showErrorPopup(`A critical error occurred!
Check ${this.getLogLocation()} for more info.
`)
return false;
}
}
@@ -492,40 +525,38 @@ 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("The selected Olympus instance is currently active
Please stop DCS and Olympus Server/Client before editing it!
")
} else {
-
- this.options.activeInstance = instance;
- this.options.operation = 'EDIT';
+ this.setActiveInstance(instance);
+ await this.setState('EDIT');
this.activePage.hide();
- (this.options.mode === 'basic'? this.typePage: this.expertSettingsPage).show();
+ (this.getMode() === 'basic'? this.typePage: this.expertSettingsPage).show();
}
}
async onInstallClicked(name) {
var instance = await this.getClickedInstance(name);
- this.options.activeInstance = instance;
- this.options.operation = 'INSTALL';
- this.options.singleInstance = false;
+ this.setActiveInstance(instance);
+ await this.setState('INSTALL');
this.activePage.hide();
- (this.options.mode === 'basic'? this.typePage: this.expertSettingsPage).show();
+ (this.getMode() === 'basic'? this.typePage: this.expertSettingsPage).show();
}
async onUninstallClicked(name) {
var instance = await this.getClickedInstance(name);
- this.options.activeInstance = instance;
- this.options.operation = 'UNINSTALL';
+ this.setActiveInstance(instance);
+ await this.setState('UNINSTALL');
if (instance.webserverOnline || instance.backendOnline)
- showErrorPopup("Error, the selected Olympus instance is currently active
Please stop Olympus before removing it!
")
+ showErrorPopup("The selected Olympus instance is currently active
Please stop DCS and Olympus Server/Client before removing it!
")
else
await instance.uninstall();
}
- onLinkClicked(url) {
+ async onLinkClicked(url) {
exec(`start ${url}`);
}
- onTextFileClicked(path) {
+ async onTextFileClicked(path) {
exec(`notepad "${path}"`);
}
@@ -549,19 +580,19 @@ class Manager {
async setPort(port, value) {
var success;
if (port === 'client') {
- success = await this.options.activeInstance.checkClientPort(value);
- this.options.activeInstance.setClientPort(value);
+ success = await this.getActiveInstance().checkClientPort(value);
+ this.getActiveInstance().setClientPort(value);
}
else {
- success = await this.options.activeInstance.checkBackendPort(value);
- this.options.activeInstance.setBackendPort(value);
+ success = await this.getActiveInstance().checkBackendPort(value);
+ this.getActiveInstance().setBackendPort(value);
}
- var successEls = (this.options.mode === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(`.${port}-port`).querySelectorAll(".success");
+ var successEls = (this.getMode() === '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.options.mode === 'basic'? this.connectionsPage: this.expertSettingsPage).getElement().querySelector(`.${port}-port`).querySelectorAll(".error");
+ var errorEls = (this.getMode() === '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);
}
@@ -573,11 +604,11 @@ class Manager {
return data.ip;
}
- updateInstances() {
+ async updateInstances() {
var instanceDivs = this.instancesPage.getElement().querySelectorAll(`.option`);
for (let i = 0; i < instanceDivs.length; i++) {
var instanceDiv = instanceDivs[i];
- var instance = this.options.instances.find((instance) => { return instance.folder === instanceDivs[i].dataset.folder; })
+ var instance = this.getInstances().find((instance) => { return instance.folder === instanceDivs[i].dataset.folder; })
if (instance) {
instanceDiv.querySelector(".button.install").classList.toggle("hide", instance.installed);
instanceDiv.querySelector(".button.start").classList.toggle("hide", !instance.installed);
@@ -614,10 +645,10 @@ class Manager {
await DCSInstance.reloadInstances();
this.options.installEnabled = true;
- this.options.editEnabled = this.options.instances.find(instance => instance.installed);
+ this.options.editEnabled = this.getInstances().find(instance => instance.installed);
}
- setLoadingProgress(message, percent) {
+ async setLoadingProgress(message, percent) {
document.querySelector("#loader .loading-message").innerHTML = message;
if (percent) {
var style = document.querySelector('#loader .loading-bar').style;
@@ -625,13 +656,80 @@ class Manager {
}
}
- hideLoadingPage() {
+ async hideLoadingPage() {
/* Hide the loading page */
document.getElementById("loader").style.opacity = "0%";
window.setTimeout(() => {
document.getElementById("loader").classList.add("hide");
}, 250);
}
+
+ async setActiveInstance(newActiveInstance) {
+ this.options.activeInstance = newActiveInstance;
+ }
+
+ async setAdditionalDCSInstances(newAdditionalDCSInstances) {
+ this.options.additionalDCSInstances = newAdditionalDCSInstances;
+ }
+
+ async setConfigLoaded(newConfigLoaded) {
+ this.options.configLoaded = newConfigLoaded;
+ }
+
+ async setInstances(newInstances) {
+ this.options.instances = newInstances;
+ }
+
+ async setIP(newIP) {
+ this.options.IP = newIP;
+ }
+
+ async setLogLocation(newLogLocation) {
+ this.options.logLocation = newLogLocation;
+ }
+
+ async setState(newState) {
+ this.options.state = newState;
+ await DCSInstance.reloadInstances();
+ if (newState === 'IDLE')
+ this.setActiveInstance(undefined);
+ }
+
+ /** Get the currently active instance, i.e. the instance that is being edited/installed/removed
+ *
+ * @returns The active instance
+ */
+ getActiveInstance() {
+ return this.options.activeInstance;
+ }
+
+ getAdditionalDCSInstances() {
+ return this.options.additionalDCSInstances
+ }
+
+ getConfigLoaded() {
+ return this.options.configLoaded;
+ }
+
+ getInstances() {
+ return this.options.instances;
+ }
+
+ getIP() {
+ return this.options.IP;
+ }
+
+ getLogLocation() {
+ return this.options.logLocation;
+ }
+
+ getState() {
+ return this.options.state;
+ }
+
+ getMode() {
+ return this.options.mode;
+ }
}
module.exports = Manager;
\ No newline at end of file