mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
Serverside rendering of /slaves for more plugin functionality
This commit is contained in:
1 parent
8518cd54c6
commit
da268d57e7
2 files changed
+50
-6
No files matched your search
+44
-2
@@ -1,7 +1,7 @@
|
|||||||
<!doctype HTML>
|
<!doctype HTML>
|
||||||
<head>
|
<head>
|
||||||
<%- include("head.html") %>
|
<%- include("head.html") %>
|
||||||
<script src="slaveDisplay.js"></script>
|
<!-- <script src="slaveDisplay.js"></script> -->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
@@ -10,7 +10,49 @@
|
|||||||
<div id="slaves">
|
<div id="slaves">
|
||||||
<h2>Slaves</h2>
|
<h2>Slaves</h2>
|
||||||
<div id="display">
|
<div id="display">
|
||||||
|
<%
|
||||||
|
function findInArray(key, value, array){
|
||||||
|
let indexes = [];
|
||||||
|
for(let i in array){
|
||||||
|
if(array[i][key] && array[i][key].includes(value)) indexes.push(i);
|
||||||
|
}
|
||||||
|
return indexes;
|
||||||
|
}
|
||||||
|
html = "<p>Current connections:</p>";
|
||||||
|
for(let id in slaves){
|
||||||
|
let slave = slaves[id];
|
||||||
|
html += `
|
||||||
|
<div id="${id}" class="slaveBox">
|
||||||
|
<a href='nodeDetails?instanceID=${id}'>
|
||||||
|
<h2>${slave.instanceName}</h2>
|
||||||
|
</a>
|
||||||
|
<p>ID: ${id}</p>
|
||||||
|
<p>Last seen: ${moment(Number(slave.time)).format("DD.MM.YY, hh:mm")}</p>
|
||||||
|
<p>Online players: ${slave.playerCount}</p>
|
||||||
|
<p>IP: ${slave.publicIP}:${slave.serverPort}</p>
|
||||||
|
<p>Host: ${slave.mac}</p>
|
||||||
|
${findInArray("modName", "remoteMap", slave.mods).length ? "<a href='/remoteMap?instanceID="+id+"'>Remote map</a>" : ""}
|
||||||
|
`
|
||||||
|
for(let o in masterPlugins){
|
||||||
|
let plug = masterPlugins[o];
|
||||||
|
if(plug.main
|
||||||
|
&& plug.main.ui
|
||||||
|
&& typeof plug.main.ui.slaveListing == "object"
|
||||||
|
&& Array.isArray(plug.main.ui.slaveListing)){
|
||||||
|
let slaveListingEntries = plug.main.ui.slaveListing;
|
||||||
|
for(let i in slaveListingEntries){
|
||||||
|
let button = slaveListingEntries[i];
|
||||||
|
if(button.getHtml && typeof button.getHtml == "function"){
|
||||||
|
html += button.getHtml({slave});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html += `
|
||||||
|
</div>`
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
<%- html %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+6
-4
@@ -15,19 +15,21 @@
|
|||||||
<%# Very ugly ejs code to hide the Players button if the playerManager plugin isn`t installed %>
|
<%# Very ugly ejs code to hide the Players button if the playerManager plugin isn`t installed %>
|
||||||
<%
|
<%
|
||||||
sidebarPluginButtonsHtml = "";
|
sidebarPluginButtonsHtml = "";
|
||||||
masterPlugins.forEach(plug => {
|
for(let o in masterPlugins){
|
||||||
|
let plug = masterPlugins[o];
|
||||||
if(plug.main
|
if(plug.main
|
||||||
&& plug.main.ui
|
&& plug.main.ui
|
||||||
&& typeof plug.main.ui.sidebar == "object"
|
&& typeof plug.main.ui.sidebar == "object"
|
||||||
&& Array.isArray(plug.main.ui.sidebar)){
|
&& Array.isArray(plug.main.ui.sidebar)){
|
||||||
let sidebarEntries = plug.main.ui.sidebar;
|
let sidebarEntries = plug.main.ui.sidebar;
|
||||||
sidebarEntries.forEach(button => {
|
for(let i in sidebarEntries){
|
||||||
|
let button = sidebarEntries[i];
|
||||||
if(button.getHtml && typeof button.getHtml == "function"){
|
if(button.getHtml && typeof button.getHtml == "function"){
|
||||||
sidebarPluginButtonsHtml += button.getHtml();
|
sidebarPluginButtonsHtml += button.getHtml();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
%>
|
%>
|
||||||
<%- sidebarPluginButtonsHtml %>
|
<%- sidebarPluginButtonsHtml %>
|
||||||
<a href="/settings"><div id="settings-menu" class="button-black menuItem">
|
<a href="/settings"><div id="settings-menu" class="button-black menuItem">
|
||||||
|
|||||||
Reference in new issue
Block a user