Fix locale interference with network performance page

This commit is contained in:
Risto Lahtela 2022-02-10 17:57:26 +02:00
parent 3fadcf65e4
commit 2071a49091
4 changed files with 22 additions and 20 deletions

View File

@ -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();
}

View File

@ -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 = '<i class="fa fa-fw fa-cog fa-spin"></i> 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 += `<option${server.proxy ? ' selected' : ''} data-plan-server-uuid="${server.serverUUID}">${server.serverName}</option>`
}
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 = [];

View File

@ -665,12 +665,9 @@
Server selector</h6>
</div>
<select class="form-control" id="performance-server-selector" multiple>
<option selected>Proxy server</option>
<option>Server 1</option>
<option>Skyblock</option>
<option>Server 3</option>
<option>Loading..</option>
</select>
<button class="btn bg-plan" onclick="onSelectPerformanceServers()">Apply</button>
<button class="btn bg-plan" onclick="onSelectperformanceservers()">Apply</button>
</div>
</div>
</div>
@ -1143,7 +1140,7 @@
responsive: true
});
loadPerformanceServerOptions();
loadperformanceserverOptions();
setLoadingText('Almost done..');
openPage();

View File

@ -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",