mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
The masterPlugins array should not be a global. The ejs templates already have it provided through locals.masterPlugins and plugins get it through onLoadFinish. Make masterPlugins local to master.js again and fix the ejs templates to use locals.masterPlugins.
71 lines
2.6 KiB
HTML
71 lines
2.6 KiB
HTML
<!doctype HTML>
|
|
<head>
|
|
<%- include("head.html") %>
|
|
<!-- <script src="slaveDisplay.js"></script> -->
|
|
</head>
|
|
|
|
<body>
|
|
<%- include("nav.html") %>
|
|
<div id="body" class="container">
|
|
<div class="page-header mt-2 row" id="banner">
|
|
<div class="col-lg-8 col-md-7 col-sm-6">
|
|
<h2>Connected Nodes</h2>
|
|
</div>
|
|
</div>
|
|
<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;
|
|
}
|
|
let html = ""
|
|
for(let id in slaves){
|
|
let slave = slaves[id];
|
|
html += `
|
|
<div id="${id}" class="slaveBox card mb-3">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><a href='nodeDetails?instanceID=${id}'>
|
|
<h2>${slave.instanceName}</h2>
|
|
</a></h5>
|
|
</div>
|
|
<ul class="list-group list-group-flush">
|
|
<li class="list-group-item">ID: ${id}</li>
|
|
<li class="list-group-item">Last seen: ${moment(Number(slave.time)).format("DD.MM.YY, hh:mm")}</li>
|
|
<li class="list-group-item">Online players: ${slave.playerCount}</li>
|
|
<li class="list-group-item">IP: ${slave.publicIP}:${slave.serverPort}</li>
|
|
<li class="list-group-item">Host: ${slave.mac}</li>
|
|
</ul>
|
|
${findInArray("modName", "remoteMap", slave.mods).length ? "<a href='/remoteMap?instanceID="+id+"'>Remote map</a>" : ""}
|
|
`
|
|
for(let o in locals.masterPlugins){
|
|
let plug = locals.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 += "<div class=\"plugin-link\">"
|
|
html += button.getHtml({slave});
|
|
html += "</div>"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
html += `
|
|
</div>
|
|
`
|
|
}
|
|
%>
|
|
<%- html %>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$('.plugin-link a').addClass('btn btn-primary')
|
|
</script>
|
|
</body> |