dashboard-core/theme/dbd-soft-ui/pages/get/admin.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-06-22 19:36:52 +05:00
const db = require("quick.db");
2023-06-19 14:21:58 +05:00
module.exports = {
2023-06-22 19:36:52 +05:00
page: "/admin",
execute: async (req, res, app, config, themeConfig, info, database) => {
if (!req.session.user) return res.redirect("/discord?r=/admin/");
if (!config.ownerIDs?.includes(req.session.user.id)) return res.redirect("/");
if (!themeConfig.nodeactyl && themeConfig.admin?.pterodactyl?.enabled) return res.send("Unable to contact Pterodactyl, are your details correct?");
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
async function getServers() {
if (!themeConfig?.admin?.pterodactyl?.enabled) return [];
2023-06-19 14:21:58 +05:00
2023-06-22 19:36:52 +05:00
const serverData = [];
const serverUUIDS = themeConfig?.admin?.pterodactyl?.serverUUIDs;
for (const uuid of serverUUIDS) {
const dataStatus = await themeConfig?.nodeactyl?.getServerStatus(uuid);
const data = await themeConfig?.nodeactyl?.getServerDetails(uuid);
serverData.push({
name: data.name.toString(),
uuid: data.uuid.toString(),
desc: data.description.toString(),
node: data.node.toString(),
status: dataStatus.toString(),
});
}
return serverData;
}
const d = await getServers();
res.render("admin", {
req,
sData: d,
ldata: await database.get("logs"),
themeConfig: req.themeConfig,
node: themeConfig.nodeactyl,
bot: config.bot,
allFeedsUsed: (db.get("feeds.one") && db.get("feeds.two") && db.get("feeds.three")) ? true : false,
config,
require,
});
},
};