Remove config management

Remove lib/manager/configManager.js and the config management command
line interface as well as the serverManager's web interface for config
management.  The configuration rewrite will work differently and is not
compatible with configManager.js.
This commit is contained in:
Hornwitser committed 2019-09-16 16:04:08 +02:00
1 parent dd865b42b5
commit 5f33cf4d3b
10 files changed
+4 -201

No files matched your search

-8
View File
@@ -10,7 +10,6 @@ module.exports = class remoteCommands {
this.config = mergedConfig;
this.socket = extras.socket;
const pluginManager = require("lib/manager/pluginManager.js");
const configManager = require("lib/manager/configManager.js");
// const modManager = require("lib/manager/modManager.js")(this.config);
this.socket.on("hello", () => {
this.socket.emit("registerServerManager");
@@ -23,13 +22,6 @@ module.exports = class remoteCommands {
// let mods = modManager.getMods()
// callback(mods);
});
this.socket.on("serverManagerGetConfig", async (data, callback) => {
let config = await configManager.getConfig(data.instance);
callback(config);
});
this.socket.on("serverManagerEditConfig", async (data, callback) => {
callback(configManager.editConfig(data.instance, data.entry, data.value));
});
this.socket.on("serverManagerGetPlugins", async (data, callback) => {
callback(await pluginManager.getPlugins());
});
@@ -77,48 +77,9 @@ module.exports = that => {
});
}
});
that.app.post("/api/serverManager/editConfig", async (req,res) => {
if((req.body.token || req.cookies.token)
&& req.body.instanceID
&& typeof req.body.instanceID == "string"
&& req.body.entry
&& typeof req.body.entry == "string"
&& req.body.value !== undefined
&& that.playerManager){
let perms = await that.playerManager.main.getPermissions((req.body.token || req.cookies.token));
if(perms.cluster.includes("writeConfig")
|| (perms.instance[req.body.instanceID]
&& perms.instance[req.body.instanceID].includes("writeConfig"))){
that.serverSockets[req.body.instanceID].socket.emit("serverManagerEditConfig", {
entry: req.body.entry,
value: req.body.value,
}, async resp => {
if(resp.ok){
// Retrieve the latest config from the server and store it
await updateData("config", req.body.instanceID);
}
res.send(resp);
});
} else {
res.send({
ok:false,
msg:"Insufficient permissions",
});
}
} else {
res.send({
ok:false,
msg:"Invalid request body",
});
}
});
async function updateData(type, instanceID){
// Retrieve the latest ${type} from the server and store it
if(type == "config"){
that.serverSockets[instanceID].socket.emit("serverManagerGetConfig", {}, data => {
that.serverSockets[instanceID].config = data;
});
} else if(type == "plugins"){
if(type == "plugins"){
that.serverSockets[instanceID].socket.emit("serverManagerGetPlugins", {}, data => {
that.serverSockets[instanceID].plugins = data;
});
@@ -63,9 +63,6 @@ class masterPlugin {
server.socket.emit("serverManagerGetPlugins", {}, data => {
server.plugins = data;
});
server.socket.emit("serverManagerGetConfig", {}, data => {
server.config = data;
});
}
// I can't seem to get express static pages + ejs rendering to work properly, so I write my own thing.
+1 -17
View File
@@ -26,23 +26,7 @@
if(server.plugins) server.plugins.forEach(plugin => {
html += `<li><div class="pluginStatus" style="background-color: ${plugin.enabled ? 'green' : 'red'}"></div><div style="width: calc( 100% - 50px )"><h3>${plugin.name}</h3><p>${plugin.description}</p></div></li>`
});
html += `</ul></div><div id="config">`
if(permissions && permissions.cluster && permissions.cluster.includes("readConfig")){
if(server.config){
html += `<ul>`;
server.config.forEach(setting => {
if(setting.entry[1] !== "_" && setting.entry !== "masterAuthSecret"){
html += `<li class="settingInput">
<p style="width: 50%; display:inline-block;">${setting.entry}</p>
<input style="color:black; width: calc(50% - 4px); box-sizing: border-box;" value='${setting.value}'>
</li>`
}
});
}
}
html += `</ul>
<input id="submitSettings" type="button" value="Save changes" style="color:black"/>
</div>`
html += `</ul></div>`
}
%>
<%- html %>
@@ -1,40 +1,3 @@
// Handle config editing
originalSettings = {};
let settings = document.querySelectorAll(".settingInput");
settings.forEach(setting => {
let entry = setting.children[0].innerText
originalSettings[setting.children[0].innerText] = {
entry: setting.children[0].innerText,
value: setting.children[1].value,
}
setting.children[1].addEventListener("input", ()=>{
let newValue = setting.children[1].value;
if(newValue != originalSettings[entry].value){
setting.children[1].style.backgroundColor = "lightgreen";
} else {
setting.children[1].style.backgroundColor = "";
}
});
});
let submitSettings = document.querySelector("#submitSettings");
submitSettings.addEventListener("click", async ()=>{
let settings = document.querySelectorAll(".settingInput");
for(let i = 0; i < settings.length; i++){
let setting = settings[i];
let entry = setting.children[0].innerText
if(setting.children[1].value != originalSettings[entry].value){
// upload new changes, display results somehow
let status = await postJSON("/api/serverManager/editConfig", {
entry,
value: setting.children[1].value,
instanceID: getParameterByName("instanceID"),
});
if(status.ok){
setting.children[1].style.backgroundColor = "";
}
}
}
});
// Handle plugin management
let pluginStatuses = document.querySelectorAll(".pluginStatus");
pluginStatuses.forEach(pluginStatus => {
@@ -6,10 +6,6 @@
width:calc((( 100% ) - (( 100% ) / 4))/2);
float:left;
}
#config {
width:calc((( 100% ) - (( 100% ) / 4))/2);
float:left;
}
ul {
list-style: none;
padding:0px;