Finalizing Server webUI

Still needed:
- Way to update clients' versions
- Way to delete nodes
- working dashboard
- working search function
This commit is contained in:
Logan Cusano
2023-07-22 01:19:54 -04:00
parent 75156d059e
commit ace762fc76
18 changed files with 327 additions and 67 deletions

View File

@@ -3,6 +3,7 @@ const { DebugBuilder } = require("../utilities/debugBuilder.js");
const log = new DebugBuilder("client", "updateConfig");
// Modules
const replace = require('replace-in-file');
const { getFullConfig } = require("./configHandler.js");
class Options {
constructor(key, updatedValue) {
@@ -23,6 +24,56 @@ exports.updateId = (updatedId) => {
this.updateConfig('CLIENT_ID', updatedId);
}
/**
* Wrapper to update any or all keys in the client config
*
* @param {*} configObject Object with what keys you wish to update (node object format, will be converted)
* @returns
*/
exports.updateClientConfig = (configObject) => {
const runningConfig = getFullConfig();
var updatedKeys = []
const configKeys = Object.keys(configObject);
if (configKeys.includes("id")) {
if (runningConfig.id != configObject.id) {
this.updateConfig('CLIENT_ID', configObject.id);
updatedKeys.push({'CLIENT_ID': configObject.id});
log.DEBUG("Updated ID to: ", configObject.id);
}
}
if (configKeys.includes("name")) {
if (runningConfig.name != configObject.name) {
this.updateConfig('CLIENT_NAME', configObject.name);
updatedKeys.push({'CLIENT_NAME': configObject.name});
log.DEBUG("Updated name to: ", configObject.name);
}
}
if (configKeys.includes("ip")) {
if (runningConfig.ip != configObject.ip) {
this.updateConfig('CLIENT_IP', configObject.ip);
updatedKeys.push({'CLIENT_IP': configObject.ip});
log.DEBUG("Updated ip to: ", configObject.ip);
}
}
if (configKeys.includes("port")) {
if (runningConfig.port != configObject.port) {
this.updateConfig('CLIENT_PORT', configObject.port);
updatedKeys.push({'CLIENT_PORT': configObject.port});
log.DEBUG("Updated port to: ", configObject.port);
}
}
if (configKeys.includes("location")) {
if (runningConfig.location != configObject.location) {
this.updateConfig('CLIENT_LOCATION', configObject.location);
updatedKeys.push({'CLIENT_LOCATION': configObject.location});
log.DEBUG("Updated location to: ", configObject.location);
}
}
return updatedKeys;
}
/**
*
* @param {string} key The config file key to update with the value
@@ -37,7 +88,6 @@ exports.updateConfig = function updateConfig(key, value) {
})
}
/**
* Wrapper to write changes to the file
* @param options An instance of the Objects class specified to the key being updated