Renamed client -> frontend in configuration files

Completed renaming client -> frontend
This commit is contained in:
Pax1601 2024-02-08 22:24:12 +01:00
parent 5ca6c97cbe
commit 57a700d2d2
35 changed files with 331 additions and 147933 deletions

View File

@ -24,11 +24,11 @@ jobs:
- name: Install dependencies
run: npm install
working-directory: ./client
working-directory: ./frontend/website
- name: Create the docs directory locally in CI
run: npx typedoc --out ../docs/client @types/*.d.ts src/**/*.ts
working-directory: ./client
run: npx typedoc --out ../../docs/website @types/*.d.ts src/**/*.ts
working-directory: ./frontend/website
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1

16
.gitignore vendored
View File

@ -7,12 +7,12 @@ hgt
/backend/vcpkg_installed
/client/TODO.txt
/client/public/javascripts/bundle.js
/client/public/plugins
/client/plugins/controltips/index.js
/client/public/databases/units/old
/client/plugins/databasemanager/index.js
/frontend/server/TODO.txt
/frontend/server/public/javascripts/bundle.js
/frontend/server/public/plugins
/frontend/server/plugins/controltips/index.js
/frontend/server/public/databases/units/old
/frontend/server/plugins/databasemanager/index.js
/src/html
/src/latex
@ -30,4 +30,6 @@ leaflet.nauticscale.js
leaflet.css
package-lock.json
!client/bin
!frontend/server/bin
/frontend/server/public/javascripts/bundle.js
/mock-dcs

View File

@ -36,14 +36,14 @@ INSTALLATION INSTRUCTIONS
7) Open Olympus via the shortcut and login using any username and the Game Master password set using the Manager. (NOTE: not your DCS server password).
Local installation: run the client from the provided desktop shortcut or start it using the "View and manage instances" page of the Manager.
Dedicated server: users must first start the Olympus server from the provided desktop shortcut or using the "View and manage instances" page of the Manager.
Then log in using any browser and visiting "http:\\<server IP>:<client port>" (client port is 3000 by default, but can be edited using the Manager)
Then log in using any browser and visiting "http:\\<server IP>:<frontend port>" (frontend port is 3000 by default, but can be edited using the Manager)
8) You can use the manager at any time to change the ports and/or passwords. If you do, REMEMBER TO RESTART OLYMPUS AND DCS.
NOTES:
a) when launching the Manager you will be prompted to allow Electron to create a firewall rule. This is optional and can be denied without effect on the operation of the Manager;
b) if you are using Olympus on a dedicated server with a router, you must enable port forwarding on the client port (3000 by default);
b) if you are using Olympus on a dedicated server with a router, you must enable port forwarding on the frontend port (3000 by default);
c) unlike Olympus v1.0.3, running the netsh command is no longer required. It is also no longer required to create firewall rules or port forwarding for the backend port. (Optional) If you already performed this steps in the past you can delete the firewall and netsh rules.

View File

@ -9,7 +9,7 @@
# DCS Olympus
![alt text](https://github.com/Pax1601/DCSOlympus/blob/main/client/sample.png?raw=true)
![alt text](https://github.com/Pax1601/DCSOlympus/blob/main/frontend/website/sample.png?raw=true)
### What is this?
DCS: Olympus is a free and open-source mod for DCS that enables dynamic real-time control through a map interface. The user is able to spawn units/groups, deploy a variety of effects such as smoke, flares, or explosions, and waypoints/tasks can be given to AI units in real-time in a way similar to a classic RTS game.

124
frontend/server/bin/demo Normal file
View File

@ -0,0 +1,124 @@
const yargs = require('yargs');
var fs = require('fs');
/* Define configuration parameter */
yargs.alias('c', 'config').describe('c', 'olympus.json config location').string('rp');
args = yargs.argv;
console.log('\x1b[36m%s\x1b[0m', "*********************************************************************");
console.log('\x1b[36m%s\x1b[0m', "* _____ _____ _____ ____ _ *");
console.log('\x1b[36m%s\x1b[0m', "* | __ \\ / ____|/ ____| / __ \\| | *");
console.log('\x1b[36m%s\x1b[0m', "* | | | | | | (___ | | | | |_ _ _ __ ___ _ __ _ _ ___ *");
console.log('\x1b[36m%s\x1b[0m', "* | | | | | \\___ \\ | | | | | | | | '_ ` _ \\| '_ \\| | | / __| *");
console.log('\x1b[36m%s\x1b[0m', "* | |__| | |____ ____) | | |__| | | |_| | | | | | | |_) | |_| \\__ \\ *");
console.log('\x1b[36m%s\x1b[0m', "* |_____/ \\_____|_____/ \\____/|_|\\__, |_| |_| |_| .__/ \\__,_|___/ *");
console.log('\x1b[36m%s\x1b[0m', "* __/ | | | *");
console.log('\x1b[36m%s\x1b[0m', "* |___/ |_| *");
console.log('\x1b[36m%s\x1b[0m', "*********************************************************************");
console.log('\x1b[36m%s\x1b[0m', "");
console.log("Please wait while DCS Olympus DEMO Backend Server starts up...");
console.log(`Config location: ${args["config"]}`)
var fs = require('fs');
let rawdata = fs.readFileSync(args["config"]);
let config = JSON.parse(rawdata);
/**
* Module dependencies.
*/
var app = require('../demo')(args["config"]);
var debug = require('debug')('client:server');
var http = require('http');
/**
* Get port from environment and store in Express.
*/
var configPort = null;
if (config["server"] != undefined && config["server"]["port"] != undefined) {
configPort = config["server"]["port"];
}
var port = normalizePort(configPort || '3000');
app.set('port', port);
console.log("Express server listening on port: " + port)
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/**
* Normalize a port into a number, string, or false.
*/
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
/**
* Event listener for HTTP server "error" event.
*/
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/**
* Event listener for HTTP server "listening" event.
*/
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
console.log("DCS Olympus DEMO Backend Server {{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}} started correctly!")
console.log("Waiting for connections...")
process.title = `DCS Olympus DEMO Backend Server {{OLYMPUS_VERSION_NUMBER}} (${port})`;

102
frontend/server/bin/www Normal file
View File

@ -0,0 +1,102 @@
const yargs = require('yargs');
var fs = require('fs');
/* Define configuration parameter */
yargs.alias('c', 'config').describe('c', 'olympus.json config location').string('rp');
args = yargs.argv;
console.log('\x1b[36m%s\x1b[0m', "*********************************************************************");
console.log('\x1b[36m%s\x1b[0m', "* _____ _____ _____ ____ _ *");
console.log('\x1b[36m%s\x1b[0m', "* | __ \\ / ____|/ ____| / __ \\| | *");
console.log('\x1b[36m%s\x1b[0m', "* | | | | | | (___ | | | | |_ _ _ __ ___ _ __ _ _ ___ *");
console.log('\x1b[36m%s\x1b[0m', "* | | | | | \\___ \\ | | | | | | | | '_ ` _ \\| '_ \\| | | / __| *");
console.log('\x1b[36m%s\x1b[0m', "* | |__| | |____ ____) | | |__| | | |_| | | | | | | |_) | |_| \\__ \\ *");
console.log('\x1b[36m%s\x1b[0m', "* |_____/ \\_____|_____/ \\____/|_|\\__, |_| |_| |_| .__/ \\__,_|___/ *");
console.log('\x1b[36m%s\x1b[0m', "* __/ | | | *");
console.log('\x1b[36m%s\x1b[0m', "* |___/ |_| *");
console.log('\x1b[36m%s\x1b[0m', "*********************************************************************");
console.log('\x1b[36m%s\x1b[0m', "");
console.log("Please wait while DCS Olympus Server starts up...");
console.log(`Config location: ${args["config"]}`)
/* Load the configuration file */
var frontendPort = 0;
if (fs.existsSync(args["config"])) {
var json = JSON.parse(fs.readFileSync(args["config"], 'utf-8'));
frontendPort = json["frontend"]["port"];
} else {
console.log("Failed to read config, aborting!");
return;
}
/* Load the dependencies. The app is loaded providing the configuration file location */
var app = require('../app')(args["config"]);
var debug = require('debug')('client:server');
var http = require('http');
/* Normalize port */
var port = normalizePort(frontendPort);
app.set('port', port);
console.log("Express server listening on port: " + port)
/* Create HTTP server */
var server = http.createServer(app);
/* Listen on provided port, on all network interfaces. */
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
/* Normalize a port into a number, string, or false. */
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
return val;
}
if (port >= 0) {
return port;
}
return false;
}
/* Event listener for HTTP server "error" event. */
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;
/* Handle specific listen errors with friendly messages */
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
/* Event listener for HTTP server "listening" event. */
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
/* Final user friendly printing */
console.log("DCS Olympus server {{OLYMPUS_VERSION_NUMBER}}.{{OLYMPUS_COMMIT_HASH}} started correctly!")
console.log("Waiting for connections...")
process.title = `DCS Olympus server {{OLYMPUS_VERSION_NUMBER}} (${port})`;

View File

@ -8,10 +8,10 @@ yargs.alias('c', 'config').describe('c', 'olympus.json config location').string(
args = yargs.argv;
console.log(`Config location: ${args["config"]}`)
var clientPort = 3000;
var frontendPort = 3000;
if (fs.existsSync(args["config"])) {
var json = JSON.parse(fs.readFileSync(args["config"], 'utf-8'));
clientPort = json["client"]["port"];
frontendPort = json["frontend"]["port"];
} else {
console.log("Failed to read config, trying default port");
}
@ -21,7 +21,7 @@ function createWindow() {
icon: "./../img/olympus.ico"
})
win.loadURL(`http://localhost:${clientPort}`);
win.loadURL(`http://localhost:${frontendPort}`);
win.setMenuBarVisibility(false);
win.maximize();
}

File diff suppressed because one or more lines are too long

View File

@ -8,10 +8,10 @@ let rawdata = fs.readFileSync('../../olympus.json');
let config = JSON.parse(rawdata);
var tileset = null;
if (config["client"] === undefined || config["client"]["elevationProvider"] === undefined)
if (config["frontend"] === undefined || config["frontend"]["elevationProvider"] === undefined)
tileset = new TileSet('./hgt');
else
tileset = new TileSet('./hgt', {downloader: new SRTMElevationDownloader('./hgt', config["client"]["elevationProvider"])});
tileset = new TileSet('./hgt', {downloader: new SRTMElevationDownloader('./hgt', config["frontend"]["elevationProvider"])});
router.get( "/:lat/:lng", ( req, res ) => {
tileset.getElevation([req.params.lat, req.params.lng], function(err, elevation) {

View File

@ -16,14 +16,14 @@
</div>
</div>
<div class="wizard-inputs">
<div class="input-group client-port port-input">
<span>Client port
<div class="input-group frontend-port port-input">
<span>Frontend 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)">
<input type="number" min="1024" max="65535" value="<%= activeInstance["frontendPort"] %>"
onchange="signal('onFrontendPortChanged', this.value)">
<img class="success hide">
<div class="error hide">
<img> <span>Port already in use</span>

View File

@ -38,14 +38,14 @@
</div>
</div>
<div class="wizard-inputs">
<div class="input-group client-port port-input">
<span>Client port
<div class="input-group frontend-port port-input">
<span>Frontend 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)">
<input type="number" min="1024" max="65535" value="<%= activeInstance["frontendPort"] %>"
onchange="signal('onFrontendPortChanged', this.value)">
<img class="success hide">
<div class="error hide">
<img> <span>Port already in use</span>

View File

@ -81,8 +81,8 @@
<div class="summary">
<div class="info">
<div>Client port</div>
<div> <%= instances[i].installed? instances[i].clientPort: "N/A" %> </div>
<div>Frontend port</div>
<div> <%= instances[i].installed? instances[i].frontendPort: "N/A" %> </div>
</div>
<div class="info">
<div>Backend port</div>

View File

@ -82,7 +82,7 @@
</div>
</div>
<div style="font-size: var(--normal);">
Alternatively, you can run the <b>Olympus Server</b> instead and visit <div class="link" onclick="signal('onLinkClicked', 'http://localhost:<%= activeInstance["clientPort"] %>')" >http://localhost:<%= activeInstance["clientPort"] %></div> in a web browser (Google Chrome recommended) to replace the first step above.
Alternatively, you can run the <b>Olympus Server</b> instead and visit <div class="link" onclick="signal('onLinkClicked', 'http://localhost:<%= activeInstance["frontendPort"] %>')" >http://localhost:<%= activeInstance["frontendPort"] %></div> in a web browser (Google Chrome recommended) to replace the first step above.
</div>
<% } else { %>
<div class="usage-instructions">
@ -96,7 +96,7 @@
<div>
<img src="./icons/chrome.svg">
<div>
To access Olympus remotely visit <div class="link" onclick="signal('onLinkClicked', 'http://<%= IP %>:<%= activeInstance["clientPort"] %>')">http://<%= IP %>:<%= activeInstance["clientPort"] %></div> <b>in a web browser</b> (Google Chrome recommended).
To access Olympus remotely visit <div class="link" onclick="signal('onLinkClicked', 'http://<%= IP %>:<%= activeInstance["frontendPort"] %>')">http://<%= IP %>:<%= activeInstance["frontendPort"] %></div> <b>in a web browser</b> (Google Chrome recommended).
</div>
</div>
<img src="./icons/arrow-right-solid.svg">
@ -108,7 +108,7 @@
</div>
</div>
<div style="font-size: var(--normal);">
<b>To access Olympus from this PC</b>, you need to visit <div class="link" onclick="signal('onLinkClicked', 'http://localhost:<%= activeInstance["clientPort"] %>')">http://localhost:<%= activeInstance["clientPort"] %></div> in a web browser (Google Chrome recommended) instead.
<b>To access Olympus from this PC</b>, you need to visit <div class="link" onclick="signal('onLinkClicked', 'http://localhost:<%= activeInstance["frontendPort"] %>')">http://localhost:<%= activeInstance["frontendPort"] %></div> in a web browser (Google Chrome recommended) instead.
</div>
<% } %>
</div>

View File

@ -58,8 +58,8 @@
</span>
<div class="summary">
<div class="info">
<div>Client port</div>
<div> <%= instances[i].installed? instances[i].clientPort: "N/A" %> </div>
<div>Frontend port</div>
<div> <%= instances[i].installed? instances[i].frontendPort: "N/A" %> </div>
</div>
<div class="info">
<div>Backend port</div>

View File

@ -113,7 +113,7 @@ class DCSInstance {
folder = "";
name = "";
clientPort = 3000;
frontendPort = 3000;
backendPort = 3001;
backendAddress = "localhost";
gameMasterPassword = "";
@ -137,7 +137,7 @@ class DCSInstance {
this.folder = folder;
this.name = path.basename(folder);
/* Periodically "ping" Olympus to check if either the client or the backend are active */
/* Periodically "ping" Olympus to check if either the frontend or the backend are active */
window.setInterval(async () => {
await this.getData();
getManager().updateInstances();
@ -162,7 +162,7 @@ class DCSInstance {
try {
/* Read the olympus.json */
var config = JSON.parse(fs.readFileSync(path.join(this.folder, "Config", "olympus.json")));
this.clientPort = config["client"]["port"];
this.frontendPort = config["frontend"]["port"];
this.backendPort = config["server"]["port"];
this.backendAddress = config["server"]["address"];
this.gameMasterPasswordHash = config["authentication"]["gameMasterPassword"];
@ -214,13 +214,13 @@ class DCSInstance {
return this.error;
}
/** Set the client port
/** Set the frontend port
*
* @param {Number} newPort The new client port to set
* @param {Number} newPort The new frontend port to set
*/
setClientPort(newPort) {
logger.log(`Instance ${this.folder} client port set to ${newPort}`)
this.clientPort = newPort;
setFrontendPort(newPort) {
logger.log(`Instance ${this.folder} frontend port set to ${newPort}`)
this.frontendPort = newPort;
}
/** Set the backend port
@ -291,26 +291,26 @@ class DCSInstance {
return !(getManager().getActiveInstance().gameMasterPassword === getManager().getActiveInstance().blueCommanderPassword || getManager().getActiveInstance().gameMasterPassword === getManager().getActiveInstance().redCommanderPassword || getManager().getActiveInstance().blueCommanderPassword === getManager().getActiveInstance().redCommanderPassword);
}
/** Asynchronously check if the client port is free
/** Asynchronously check if the frontend port is free
*
* @param {Number | undefined} port The port to check. If not set, the current clientPort will be checked
* @returns true if the client port is free
* @param {Number | undefined} port The port to check. If not set, the current frontendPort will be checked
* @returns true if the frontend port is free
*/
async checkClientPort(port) {
port = port ?? this.clientPort;
async checkFrontendPort(port) {
port = port ?? this.frontendPort;
logger.log(`Checking client port ${port}`);
logger.log(`Checking frontend port ${port}`);
var portFree = await checkPort(port);
if (portFree) {
portFree = !(await DCSInstance.getInstances()).some((instance) => {
if (instance !== this && instance.installed) {
if (instance.clientPort === port || instance.backendPort === port) {
logger.log(`Client port ${port} already selected by other instance`);
if (instance.frontendPort === port || instance.backendPort === port) {
logger.log(`Frontend port ${port} already selected by other instance`);
return true;
}
} else {
if (instance.backendPort === port) {
logger.log(`Client port ${port} equal to backend port`);
logger.log(`Frontend port ${port} equal to backend port`);
return true;
}
}
@ -318,7 +318,7 @@ class DCSInstance {
})
}
else {
logger.log(`Client port ${port} currently in use`);
logger.log(`Frontend port ${port} currently in use`);
}
return portFree;
}
@ -336,13 +336,13 @@ class DCSInstance {
if (portFree) {
portFree = !(await DCSInstance.getInstances()).some((instance) => {
if (instance !== this && instance.installed) {
if (instance.clientPort === port || instance.backendPort === port) {
if (instance.frontendPort === port || instance.backendPort === port) {
logger.log(`Backend port ${port} already selected by other instance`);
return true;
}
} else {
if (instance.clientPort === port) {
logger.log(`Backend port ${port} equal to client port`);
if (instance.frontendPort === port) {
logger.log(`Backend port ${port} equal to frontend port`);
return true;
}
}
@ -354,30 +354,30 @@ class DCSInstance {
return portFree;
}
/** Asynchronously find free client and backend ports. If the old ports are free, it will keep them.
/** Asynchronously find free frontend and backend ports. If the old ports are free, it will keep them.
*
*/
async findFreePorts() {
logger.log(`Looking for free ports`);
if (await this.checkClientPort() && await this.checkBackendPort()) {
if (await this.checkFrontendPort() && await this.checkBackendPort()) {
logger.log("Old ports are free, keeping them")
} else {
logger.log(`Finding new free ports`);
const instances = await DCSInstance.getInstances();
const firstPort = instances.map((instance) => { return instance.clientPort; }).concat(instances.map((instance) => { return instance.backendPort; })).sort().at(-1) + 1;
const firstPort = instances.map((instance) => { return instance.frontendPort; }).concat(instances.map((instance) => { return instance.backendPort; })).sort().at(-1) + 1;
var clientPort = await getFreePort(firstPort);
if (clientPort === false)
rej("Unable to find a free client port");
logger.log(`Found free client port ${clientPort}`);
var frontendPort = await getFreePort(firstPort);
if (frontendPort === false)
rej("Unable to find a free frontend port");
logger.log(`Found free frontend port ${frontendPort}`);
var backendPort = await getFreePort(clientPort + 1);
var backendPort = await getFreePort(frontendPort + 1);
if (backendPort === false)
rej("Unable to find a free backend port");
logger.log(`Found free backend port ${backendPort}`);
this.clientPort = clientPort;
this.frontendPort = frontendPort;
this.backendPort = backendPort;
}
}
@ -387,7 +387,7 @@ class DCSInstance {
*/
async getData() {
if (this.installed) {
fetchWithTimeout(`http://localhost:${this.clientPort}`, { timeout: 250 })
fetchWithTimeout(`http://localhost:${this.frontendPort}`, { timeout: 250 })
.then(async (response) => {
this.webserverOnline = (await response.text()).includes("Olympus");
}, () => {
@ -432,7 +432,7 @@ class DCSInstance {
const err = fs.openSync(`./${this.name}.log`, 'a');
const sub = spawn('cscript.exe', ['server.vbs', path.join(this.folder, "Config", "olympus.json")], {
detached: true,
cwd: "../client",
cwd: "../frontend",
stdio: ['ignore', out, err]
});
@ -448,7 +448,7 @@ class DCSInstance {
const err = fs.openSync(`./${this.name}.log`, 'a');
const sub = spawn('cscript.exe', ['client.vbs', path.join(this.folder, "Config", "olympus.json")], {
detached: true,
cwd: "../client",
cwd: "../frontend",
stdio: ['ignore', out, err]
});
@ -459,7 +459,7 @@ class DCSInstance {
*
*/
stop() {
find('port', this.clientPort)
find('port', this.frontendPort)
.then((list) => {
if (list.length !== 1) {
list.length === 0 ? logger.error("No processes found on the specified port") : logger.error("Too many processes found on the specified port");

View File

@ -158,7 +158,7 @@ async function applyConfiguration(folder, instance) {
}
/* Apply the configuration */
config["client"]["port"] = instance.clientPort;
config["frontend"]["port"] = instance.frontendPort;
config["server"]["port"] = instance.backendPort;
config["server"]["address"] = instance.backendAddress;
config["authentication"]["gameMasterPassword"] = sha256(instance.gameMasterPassword);

View File

@ -149,13 +149,13 @@ class Manager {
/* 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('frontend', this.getActiveInstance().frontendPort);
this.setPort('backend', this.getActiveInstance().backendPort);
}
}
this.expertSettingsPage.options.onShow = () => {
if (this.getActiveInstance()) {
this.setPort('client', this.getActiveInstance().clientPort);
this.setPort('frontend', this.getActiveInstance().frontendPort);
this.setPort('backend', this.getActiveInstance().backendPort);
}
}
@ -270,7 +270,7 @@ class Manager {
this.typePage.show();
} else {
if (this.getActiveInstance().webserverOnline || this.getActiveInstance().backendOnline) {
showErrorPopup("<div class='main-message'>The selected Olympus instance is currently active </div><div class='sub-message'> Please stop DCS and Olympus Server/Client before editing it! </div>");
showErrorPopup("<div class='main-message'>The selected Olympus instance is currently active </div><div class='sub-message'> Please stop DCS and Olympus Server/Frontend before editing it! </div>");
} else {
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>",
() => {
@ -456,9 +456,9 @@ class Manager {
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`);
}
/* When the client port input value is changed */
async onClientPortChanged(value) {
this.setPort('client', Number(value));
/* When the frontend port input value is changed */
async onFrontendPortChanged(value) {
this.setPort('frontend', Number(value));
}
/* When the backend port input value is changed */
@ -498,12 +498,12 @@ class Manager {
}
async checkPorts() {
var clientPortFree = await this.getActiveInstance().checkClientPort();
var frontendPortFree = await this.getActiveInstance().checkFrontendPort();
var backendPortFree = await this.getActiveInstance().checkBackendPort();
if (clientPortFree && backendPortFree) {
if (frontendPortFree && 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>`);
showErrorPopup(`<div class='main-message'> Please, make sure both the frontend 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;
}
}
@ -546,7 +546,7 @@ class Manager {
async onOpenBrowserClicked(name) {
var instance = await this.getClickedInstance(name);
exec(`start http://localhost:${instance.clientPort}`)
exec(`start http://localhost:${instance.frontendPort}`)
}
async onStopClicked(name) {
@ -611,9 +611,9 @@ class Manager {
/* Set the selected port to the dcs instance */
async setPort(port, value) {
var success;
if (port === 'client') {
success = await this.getActiveInstance().checkClientPort(value);
this.getActiveInstance().setClientPort(value);
if (port === 'frontend') {
success = await this.getActiveInstance().checkFrontendPort(value);
this.getActiveInstance().setFrontendPort(value);
}
else {
success = await this.getActiveInstance().checkBackendPort(value);

View File

@ -1,19 +0,0 @@
{
"server": {
"address": "localhost",
"port": 3001
},
"authentication": {
"gameMasterPassword": "4b8823ed9e5c2392ab4a791913bb8ce41956ea32e308b760eefb97536746dd33",
"blueCommanderPassword": "b0ea4230c1558c5313165eda1bdb7fced008ca7f2ca6b823fb4d26292f309098",
"redCommanderPassword": "302bcbaf2a3fdcf175b689bf102d6cdf9328f68a13d4096101bba806482bfed9"
},
"client": {
"port": 3000,
"elevationProvider": {
"provider": "https://srtm.fasma.org/{lat}{lng}.SRTMGL3S.hgt.zip",
"username": null,
"password": null
}
}
}

View File

@ -8,7 +8,7 @@
"blueCommanderPassword": "b0ea4230c1558c5313165eda1bdb7fced008ca7f2ca6b823fb4d26292f309098",
"redCommanderPassword": "302bcbaf2a3fdcf175b689bf102d6cdf9328f68a13d4096101bba806482bfed9"
},
"client": {
"frontend": {
"port": 3000,
"elevationProvider": {
"provider": "https://srtm.fasma.org/{lat}{lng}.SRTMGL3S.hgt.zip",

View File

@ -23,7 +23,7 @@ echo D|xcopy /Y /S /E .\databases .\package\mod\databases
REM copy the backend dll
echo F|xcopy /Y /I .\build\backend\bin\*.dll .\package\mod\bin
REM copy the client
REM copy the frontend
echo D|xcopy /Y /S /E .\build\frontend .\package\frontend
REM copy the manager

View File

@ -26,13 +26,13 @@ mismatched_ids = {
# The database file on which to operate is the first standard argument of the call
if len(sys.argv) > 1:
if (sys.argv[1] == "aircraft"):
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
filename = '..\\..\\databases\\units\\aircraftdatabase.json'
elif (sys.argv[1] == "helicopter"):
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
filename = '..\\..\\databases\\units\\helicopterdatabase.json'
elif (sys.argv[1] == "groundunit"):
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
filename = '..\\..\\databases\\units\\groundunitdatabase.json'
elif (sys.argv[1] == "navyunit"):
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
filename = '..\\..\\databases\\units\\navyunitdatabase.json'
# Loads the database
with open(filename, encoding="utf-8") as f:

View File

@ -104,13 +104,13 @@ def find_weapon_name(clsid):
# The database file on which to operate is the first standard argument of the call
if len(sys.argv) > 1:
if (sys.argv[1] == "aircraft"):
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
filename = '..\\..\\databases\\units\\aircraftdatabase.json'
elif (sys.argv[1] == "helicopter"):
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
filename = '..\\..\\databases\\units\\helicopterdatabase.json'
elif (sys.argv[1] == "groundunit"):
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
filename = '..\\..\\databases\\units\\groundunitdatabase.json'
elif (sys.argv[1] == "navyunit"):
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
filename = '..\\..\\databases\\units\\navyunitdatabase.json'
# Loads the database
with open(filename, encoding="utf-8") as f:

View File

@ -16,16 +16,16 @@ from dcs.helicopters import *
# The database file on which to operate is the first standard argument of the call
if len(sys.argv) > 1:
if (sys.argv[1] == "aircraft"):
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
filename = '..\\..\\databases\\units\\aircraftdatabase.json'
units_map = plane_map
elif (sys.argv[1] == "helicopter"):
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
filename = '..\\..\\databases\\units\\helicopterdatabase.json'
units_map = helicopter_map
elif (sys.argv[1] == "groundunit"):
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
filename = '..\\..\\databases\\units\\groundunitdatabase.json'
units_map = vehicle_map
elif (sys.argv[1] == "navyunit"):
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
filename = '..\\..\\databases\\units\\navyunitdatabase.json'
units_map = ship_map
# Loads the database

View File

@ -16,13 +16,13 @@ from dcs.helicopters import *
# The database file on which to operate is the first standard argument of the call
if len(sys.argv) > 1:
if (sys.argv[1] == "aircraft"):
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
filename = '..\\..\\databases\\units\\aircraftdatabase.json'
elif (sys.argv[1] == "helicopter"):
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
filename = '..\\..\\databases\\units\\helicopterdatabase.json'
elif (sys.argv[1] == "groundunit"):
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
filename = '..\\..\\databases\\units\\groundunitdatabase.json'
elif (sys.argv[1] == "navyunit"):
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
filename = '..\\..\\databases\\units\\navyunitdatabase.json'
# Loads the database
with open(filename) as f:

View File

@ -6,13 +6,13 @@ import re
# The database file on which to operate is the first standard argument of the call
if len(sys.argv) > 1:
if (sys.argv[1] == "aircraft"):
filename = '..\\..\\client\\public\\databases\\units\\aircraftdatabase.json'
filename = '..\\..\\databases\\units\\aircraftdatabase.json'
elif (sys.argv[1] == "helicopter"):
filename = '..\\..\\client\\public\\databases\\units\\helicopterdatabase.json'
filename = '..\\..\\databases\\units\\helicopterdatabase.json'
elif (sys.argv[1] == "groundunit"):
filename = '..\\..\\client\\public\\databases\\units\\groundunitdatabase.json'
filename = '..\\..\\databases\\units\\groundunitdatabase.json'
elif (sys.argv[1] == "navyunit"):
filename = '..\\..\\client\\public\\databases\\units\\navyunitdatabase.json'
filename = '..\\..\\databases\\units\\navyunitdatabase.json'
# Loads the database
with open(filename) as f:

View File

@ -1,53 +0,0 @@
import json
base = '..\\..\\client\\public\\databases\\units\\'
filenames = [f'{base}aircraftdatabase.json', f'{base}helicopterdatabase.json', f'{base}groundunitdatabase.json', f'{base}navyunitdatabase.json']
lines = []
for filename in filenames:
# Loads the database
with open(filename, encoding="utf8") as f:
database = json.load(f)
for key in database:
acquisition_range = ""
engagement_range = ""
abilities = ""
description = ""
unit_type = ""
database_type = ""
if filename == f'{base}aircraftdatabase.json':
unit_type = "Aircraft"
database_type = "Aircraft"
elif filename == f'{base}helicopterdatabase.json':
unit_type = "Helicopter"
database_type = "Helicopter"
elif filename == f'{base}groundunitdatabase.json':
unit_type = database[key]["type"]
database_type = "Ground Unit"
else:
unit_type = database[key]["type"]
database_type = "Navy Unit"
if "acquisitionRange" in database[key]:
acquisition_range = database[key]["acquisitionRange"]
if "engagementRange" in database[key]:
engagement_range = database[key]["engagementRange"]
if "abilities" in database[key]:
abilities = database[key]["abilities"]
if "description" in database[key]:
description = database[key]["description"]
line = f"{database[key]['name']}\t{database_type}\t{unit_type}\t{database[key]['label']}\t{database[key]['shortLabel']}\t{database[key]['coalition']}\t{database[key]['era']}\t{acquisition_range}\t{engagement_range}\t{description}\t{abilities}\n"
lines.append(line)
with open("new.csv", "w") as f:
f.writelines(lines)
print("Done!")

View File

@ -1,59 +0,0 @@
import csv
import sys
import json
# Read CSV file
with open("data.csv") as fp:
reader = csv.reader(fp, delimiter=",", quotechar='"')
data_read = [row for row in reader]
base = '..\\..\\client\\public\\databases\\units\\'
filenames = [f'{base}aircraftdatabase.json', f'{base}helicopterdatabase.json', f'{base}groundunitdatabase.json', f'{base}navyunitdatabase.json']
lines = []
for filename in filenames:
# Loads the database
with open(filename, encoding="utf8") as f:
database = json.load(f)
for row in data_read:
if row[0] in database:
name = row[0]
if row[1] == "yes":
database[name]["enabled"] = True
else:
database[name]["enabled"] = False
database[name]["type"] = row[3]
database[name]["label"] = row[4]
database[name]["shortLabel"] = row[5]
database[name]["coalition"] = row[6]
database[name]["era"] = row[7]
if row[8] == "yes":
database[name]["canTargetPoint"] = True
else:
database[name]["canTargetPoint"] = False
if row[9] == "yes":
database[name]["canRearm"] = True
else:
database[name]["canRearm"] = False
if row[10] != "":
database[name]["acquisitionRange"] = int(row[10])
if row[11] != "":
database[name]["engagementRange"] = int(row[11])
database[name]["description"] = row[12]
database[name]["abilities"] = row[13]
# Dump everything in the database
with open(filename, "w") as f:
json.dump(database, f, indent=2)
# Done!
print("Done!")