From 0467fc10c7ec0d623494d11c7b9feafca4272b24 Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Tue, 24 Jan 2023 18:50:53 +0100 Subject: [PATCH 1/7] When you click on a shard, a modal will open and show all the information about the shard --- views/shards.ejs | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/views/shards.ejs b/views/shards.ejs index f237ae78..c58f7eed 100644 --- a/views/shards.ejs +++ b/views/shards.ejs @@ -56,16 +56,34 @@ for(const shard in data) { let row = $(`
- -
- ${data[shard].id} -
-
+ +
+ `) $('#shardlist2').append(row.clone(true)) - $("body").tooltip({ selector: '[data-toggle=tooltip]' }); + // $("body").tooltip({ selector: '[data-toggle=tooltip]' }); } }); } From 563893185f5c5c8e96e6017c58171636ef10a14e Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Thu, 26 Jan 2023 10:54:25 +0100 Subject: [PATCH 2/7] Added BotLogs to Admin Panel. ThemeConfig: admin: { pterodactyl: { enabled: false, apiKey: "apiKey", panelLink: "https://panel.website.com", serverUUIDs: [], }, logs: { enabled: true, key: "test.123", } }, --- pages/get/admin.js | 5 +++-- pages/post/logs.js | 23 +++++++++++++++++++++++ views/admin.ejs | 17 +++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 pages/post/logs.js diff --git a/pages/get/admin.js b/pages/get/admin.js index 9a49b777..da640d09 100644 --- a/pages/get/admin.js +++ b/pages/get/admin.js @@ -3,7 +3,7 @@ const db = require('quick.db') module.exports = { page: '/admin', - execute: async (req, res, app, config, themeConfig, info) => { + execute: async (req, res, app, config, themeConfig, info, database) => { const pterodactyl = new Nodeactyl.NodeactylClient( themeConfig.admin.pterodactyl.panelLink, themeConfig.admin.pterodactyl.apiKey @@ -40,6 +40,7 @@ module.exports = { res.render('admin', { req, sData: d, + ldata: await database.get('logs'), themeConfig: req.themeConfig, node: pterodactyl, bot: config.bot, @@ -48,4 +49,4 @@ module.exports = { require }) } -} +} \ No newline at end of file diff --git a/pages/post/logs.js b/pages/post/logs.js new file mode 100644 index 00000000..a52479ff --- /dev/null +++ b/pages/post/logs.js @@ -0,0 +1,23 @@ +module.exports = { + page: '/stats/logs/update', + execute: async (req, res, app, config, themeConfig, info, db) => { + if ( + 'Bearer ' + themeConfig.admin.logs?.key !== + req.headers.authorization + ) + return res.json({ status: 'Invalid sharding key' }) + + const logs = await db.get('logs') + + let newLogs = [] + + if (!logs || !logs.length || !logs[0]) + newLogs = [req.body] + else + newLogs = [req.body, ...logs] + + await db.set('logs', newLogs) + + res.json({ status: 'Completed' }) + } +} \ No newline at end of file diff --git a/views/admin.ejs b/views/admin.ejs index a742efdc..aa158f86 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -491,6 +491,23 @@ +
+ <% } %> + <% if (themeConfig.admin.logs.enabled) { %> +
+
+
Bot Logs
+
+
+
Current Logs
+
+
+ +
+
+
+
+
<% } %>
From 27e25a9977a89cd41843fc8016c472a4c8e60cfb Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Thu, 26 Jan 2023 11:09:59 +0100 Subject: [PATCH 3/7] Fix issue where page crashes if no data has been send yet --- views/admin.ejs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/views/admin.ejs b/views/admin.ejs index aa158f86..f20b11b2 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -502,7 +502,9 @@
Current Logs
- + <% if (ldata !== undefined) { %> + + <% }%>
From 453a4adac408ff8f717e9eb4579011a97612b5ba Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Thu, 26 Jan 2023 11:13:39 +0100 Subject: [PATCH 4/7] Restore current shard status --- views/shards.ejs | 60 +++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/views/shards.ejs b/views/shards.ejs index c58f7eed..1ac66a0b 100644 --- a/views/shards.ejs +++ b/views/shards.ejs @@ -2,15 +2,11 @@ ========================================================= * Soft UI Dashboard - v1.0.3 ========================================================= - * Product Page: https://www.creative-tim.com/product/soft-ui-dashboard * Copyright 2021 Creative Tim (https://www.creative-tim.com) * Licensed under MIT (https://www.creative-tim.com/license) - * Coded by Creative Tim - ========================================================= - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. --> @@ -19,14 +15,14 @@ - <%- themeConfig?.customHtml %> + + <%- themeConfig?.customHtml %> <%- include('partials/preload.ejs') %> @@ -37,58 +33,34 @@
No shards exist! - <%- include('partials/footer.ejs') %> + <%- include('partials/footer.ejs') %>
<%- include('partials/scripts.ejs', {now: "shards"}) %> - - - + \ No newline at end of file From 417a707db50750e4eaae4d2d7107866a35ef8346 Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Thu, 26 Jan 2023 11:15:11 +0100 Subject: [PATCH 5/7] Restore current shard status --- views/shards.ejs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/views/shards.ejs b/views/shards.ejs index 1ac66a0b..f237ae78 100644 --- a/views/shards.ejs +++ b/views/shards.ejs @@ -2,11 +2,15 @@ ========================================================= * Soft UI Dashboard - v1.0.3 ========================================================= + * Product Page: https://www.creative-tim.com/product/soft-ui-dashboard * Copyright 2021 Creative Tim (https://www.creative-tim.com) * Licensed under MIT (https://www.creative-tim.com/license) + * Coded by Creative Tim + ========================================================= + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. --> @@ -15,14 +19,14 @@ - <%- themeConfig?.customHtml %> + + <%- themeConfig?.customHtml %> <%- include('partials/preload.ejs') %> @@ -33,19 +37,23 @@
No shards exist! - <%- include('partials/footer.ejs') %> + <%- include('partials/footer.ejs') %>
<%- include('partials/scripts.ejs', {now: "shards"}) %> + - \ No newline at end of file + + From 82fdbd541f24d376d4e977e0dd692e56dae3afba Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Thu, 26 Jan 2023 18:15:18 +0100 Subject: [PATCH 6/7] Show No logs found if logs not definded --- views/admin.ejs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/views/admin.ejs b/views/admin.ejs index f20b11b2..4da5ab53 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -504,7 +504,9 @@
<% if (ldata !== undefined) { %> - <% }%> + <% } else { %> + + <% } %>
From 6e455f9854ee1359e7f3592afab786446603179b Mon Sep 17 00:00:00 2001 From: mrdennis1212 Date: Thu, 26 Jan 2023 19:39:02 +0100 Subject: [PATCH 7/7] option chained logs --- views/admin.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/admin.ejs b/views/admin.ejs index 4da5ab53..235c95cc 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -493,7 +493,7 @@
<% } %> - <% if (themeConfig.admin.logs.enabled) { %> + <% if (themeConfig.admin.logs?.enabled) { %>
Bot Logs