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

@@ -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);