From 2071a490915cdc53ccbea1094698d8ff86f7d80b Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Thu, 10 Feb 2022 17:57:26 +0200 Subject: [PATCH] Fix locale interference with network performance page --- .../resolver/json/NetworkJSONResolver.java | 1 + .../assets/plan/web/js/network-values.js | 16 ++++++++-------- .../main/resources/assets/plan/web/network.html | 9 +++------ .../delivery/webserver/AccessControlTest.java | 16 ++++++++++------ 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/NetworkJSONResolver.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/NetworkJSONResolver.java index 3480062c8..203c9c156 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/NetworkJSONResolver.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/NetworkJSONResolver.java @@ -55,6 +55,7 @@ public class NetworkJSONResolver { .add("servers", forJSON(DataID.SERVERS, jsonFactory::serversAsJSONMaps)) .add("pingTable", forJSON(DataID.PING_TABLE, jsonFactory::pingPerGeolocation)) .add("listServers", forJSON(DataID.LIST_SERVERS, jsonFactory::listServers)) + .add("serverOptions", forJSON(DataID.LIST_SERVERS, jsonFactory::listServers)) .add("performanceOverview", networkPerformanceJSONResolver) .build(); } diff --git a/Plan/common/src/main/resources/assets/plan/web/js/network-values.js b/Plan/common/src/main/resources/assets/plan/web/js/network-values.js index 21699423f..fec870817 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/network-values.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/network-values.js @@ -253,14 +253,14 @@ function loadservers(json, error) { return; } - let navServersHtml = ''; + let navserversHtml = ''; let serversHtml = ''; for (let i = 0; i < servers.length; i++) { - navServersHtml += addserverToNav(servers[i]); + navserversHtml += addserverToNav(servers[i]); serversHtml += createnetworkserverBox(i, servers[i]); } - document.getElementById("navSrvContainer").innerHTML = navServersHtml; + document.getElementById("navSrvContainer").innerHTML = navserversHtml; document.getElementById("data_server_list").innerHTML = serversHtml; for (let i = 0; i < servers.length; i++) { @@ -450,31 +450,31 @@ function loadJoinAddressPie(json, error) { } } -function loadPerformanceServerOptions() { +function loadperformanceserverOptions() { const refreshElement = document.querySelector(`#performance .refresh-element`); refreshElement.querySelector('i').addEventListener('click', () => { if (refreshElement.querySelector('.refresh-notice').innerHTML.length) { return; } - onSelectPerformanceServers(); + onSelectperformanceservers(); refreshElement.querySelector('.refresh-notice').innerHTML = ' Updating..'; }); const selector = document.getElementById('performance-server-selector'); - jsonRequest('./v1/network/listServers', function (json, error) { + jsonRequest('./v1/network/serverOptions', function (json, error) { if (json) { let options = ``; for (let server of json.servers) { options += `${server.serverName}` } selector.innerHTML = options; - onSelectPerformanceServers(); + onSelectperformanceservers(); } else if (error) { selector.innerText = `Failed to load server list: ${error}` } }); } -async function onSelectPerformanceServers() { +async function onSelectperformanceservers() { const selector = document.getElementById('performance-server-selector'); const selectedServerUUIDs = []; diff --git a/Plan/common/src/main/resources/assets/plan/web/network.html b/Plan/common/src/main/resources/assets/plan/web/network.html index 8c00d9ac8..c1db61f04 100644 --- a/Plan/common/src/main/resources/assets/plan/web/network.html +++ b/Plan/common/src/main/resources/assets/plan/web/network.html @@ -665,12 +665,9 @@ Server selector - + @@ -1143,7 +1140,7 @@ responsive: true }); - loadPerformanceServerOptions(); + loadperformanceserverOptions(); setLoadingText('Almost done..'); openPage(); diff --git a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java index 61cbc9c51..3cea7cfaf 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/delivery/webserver/AccessControlTest.java @@ -56,7 +56,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests for limiting user access control based on permissions. */ -public class AccessControlTest { +class AccessControlTest { private static final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); @@ -124,7 +124,7 @@ public class AccessControlTest { static String login(String address, String username) throws IOException, KeyManagementException, NoSuchAlgorithmException { HttpURLConnection loginConnection = null; - String cookie = ""; + String cookie; try { loginConnection = CONNECTOR.getConnection("POST", address + "/auth/login"); loginConnection.setDoOutput(true); @@ -141,7 +141,7 @@ public class AccessControlTest { return cookie; } - @ParameterizedTest + @ParameterizedTest(name = "{0}: expecting {1}") @CsvSource({ "/,302", "/server,302", @@ -196,6 +196,7 @@ public class AccessControlTest { "/v1/errors,200", "/errors,200", "/v1/network/listServers,200", + "/v1/network/serverOptions,200", "/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],200", "/v1/version,200", "/v1/user,200", @@ -205,7 +206,7 @@ public class AccessControlTest { assertEquals(Integer.parseInt(expectedResponseCode), responseCode, () -> "User level 0, Wrong response code for " + resource + ", expected " + expectedResponseCode + " but was " + responseCode); } - @ParameterizedTest + @ParameterizedTest(name = "{0}: expecting {1}") @CsvSource({ "/,302", "/server,403", @@ -260,6 +261,7 @@ public class AccessControlTest { "/v1/errors,403", "/errors,403", "/v1/network/listServers,403", + "/v1/network/serverOptions,403", "/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403", "/v1/version,200", "/v1/user,200", @@ -269,7 +271,7 @@ public class AccessControlTest { assertEquals(Integer.parseInt(expectedResponseCode), responseCode, () -> "User level 1, Wrong response code for " + resource + ", expected " + expectedResponseCode + " but was " + responseCode); } - @ParameterizedTest + @ParameterizedTest(name = "{0}: expecting {1}") @CsvSource({ "/,302", "/server,403", @@ -324,6 +326,7 @@ public class AccessControlTest { "/v1/errors,403", "/errors,403", "/v1/network/listServers,403", + "/v1/network/serverOptions,403", "/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403", "/v1/version,200", "/v1/user,200", @@ -333,7 +336,7 @@ public class AccessControlTest { assertEquals(Integer.parseInt(expectedResponseCode), responseCode, () -> "User level 2, Wrong response code for " + resource + ", expected " + expectedResponseCode + " but was " + responseCode); } - @ParameterizedTest + @ParameterizedTest(name = "{0}: expecting {1}") @CsvSource({ "/,403", "/server,403", @@ -386,6 +389,7 @@ public class AccessControlTest { "/v1/filters,403", "/v1/query,403", "/v1/network/listServers,403", + "/v1/network/serverOptions,403", "/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403", "/v1/version,200", "/v1/user,200",