From ecb40ee2ec798d9be0897020e332a3a95834e86e Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 5 Nov 2023 11:09:57 -0500 Subject: [PATCH 1/3] Retain tab when navigating back to server_details --- app/classes/controllers/servers_controller.py | 1 + app/classes/web/panel_handler.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/app/classes/controllers/servers_controller.py b/app/classes/controllers/servers_controller.py index c0bae7b0..99151a32 100644 --- a/app/classes/controllers/servers_controller.py +++ b/app/classes/controllers/servers_controller.py @@ -36,6 +36,7 @@ class ServersController(metaclass=Singleton): self.management_helper = management_helper self.servers_list = [] self.stats = Stats(self.helper, self) + self.server_subpage = {} # ********************************************************************************** # Generic Servers Methods diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index e1d21f03..e8643aa7 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -481,6 +481,12 @@ class PanelHandler(BaseHandler): subpage = nh3.clean(self.get_argument("subpage", "")) server_id = self.check_server_id() + # load page the user was on last + server_subpage = self.controller.servers.server_subpage.get(server_id, "") + if subpage == "" and server_subpage != "": + subpage = self.controller.servers.server_subpage.get(server_id, "") + else: + self.controller.servers.server_subpage[server_id] = subpage if server_id is None: return if not self.failed_server: From a5f4a68c49776b971004e615b6fcbeac7471f6e2 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sun, 5 Nov 2023 12:06:57 -0500 Subject: [PATCH 2/3] Add badge to server detail pages --- app/frontend/templates/base.html | 3 ++ .../templates/panel/parts/details_stats.html | 28 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html index 40ee757b..cca5ef3b 100755 --- a/app/frontend/templates/base.html +++ b/app/frontend/templates/base.html @@ -82,6 +82,9 @@ +     + + {% include notify.html %} diff --git a/app/frontend/templates/panel/parts/details_stats.html b/app/frontend/templates/panel/parts/details_stats.html index 47fa501d..ad190bc3 100644 --- a/app/frontend/templates/panel/parts/details_stats.html +++ b/app/frontend/templates/panel/parts/details_stats.html @@ -248,12 +248,38 @@ $("#player-body").html(text); } - + //used to get cookies from browser - this is part of tornados xsrf protection - it's for extra security + function getCookie(name) { + var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); + return r ? r[1] : undefined; + } + const token = getCookie("_xsrf") $(window).ready(function () { console.log("ready!"); //if (webSocket) { webSocket.on('update_server_details', update_server_details); + add_server_name(); //} }); + async function add_server_name(){ + let res = await fetch(`/api/v2/servers/${serverId}`, { + method: 'GET', + headers: { + 'X-XSRFToken': token + }, + }); + let responseData = await res.json(); + if (responseData.status === "ok") { + console.log(responseData) + $("#server-name-nav").html(`${responseData.data['server_name']}`) + $("#server-name-nav").show(); + } else { + + bootbox.alert({ + title: responseData.error, + message: responseData.error_data + }); + } + } \ No newline at end of file From 437bc1525cc9cbb8c5377fde9a36b4deb6600b77 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 25 Nov 2023 19:17:52 +0000 Subject: [PATCH 3/3] Update changelog !667 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a5c492..917cc3a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ TBD - Remove webhook `custom` option from webook provider list as it's not currently an option ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/664)) ### Tweaks - Homogenize Panel logos/branding ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/666)) +- Retain previous tab when revisiting server details page (#272)([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/667)) +- Add server name tag in panel header (#272)([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/667)) ### Lang TBD