mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-22 17:18:40 +01:00
Fix locale interference with network performance page
This commit is contained in:
parent
3fadcf65e4
commit
2071a49091
@ -55,6 +55,7 @@ public class NetworkJSONResolver {
|
|||||||
.add("servers", forJSON(DataID.SERVERS, jsonFactory::serversAsJSONMaps))
|
.add("servers", forJSON(DataID.SERVERS, jsonFactory::serversAsJSONMaps))
|
||||||
.add("pingTable", forJSON(DataID.PING_TABLE, jsonFactory::pingPerGeolocation))
|
.add("pingTable", forJSON(DataID.PING_TABLE, jsonFactory::pingPerGeolocation))
|
||||||
.add("listServers", forJSON(DataID.LIST_SERVERS, jsonFactory::listServers))
|
.add("listServers", forJSON(DataID.LIST_SERVERS, jsonFactory::listServers))
|
||||||
|
.add("serverOptions", forJSON(DataID.LIST_SERVERS, jsonFactory::listServers))
|
||||||
.add("performanceOverview", networkPerformanceJSONResolver)
|
.add("performanceOverview", networkPerformanceJSONResolver)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -253,14 +253,14 @@ function loadservers(json, error) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let navServersHtml = '';
|
let navserversHtml = '';
|
||||||
let serversHtml = '';
|
let serversHtml = '';
|
||||||
for (let i = 0; i < servers.length; i++) {
|
for (let i = 0; i < servers.length; i++) {
|
||||||
navServersHtml += addserverToNav(servers[i]);
|
navserversHtml += addserverToNav(servers[i]);
|
||||||
serversHtml += createnetworkserverBox(i, servers[i]);
|
serversHtml += createnetworkserverBox(i, servers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("navSrvContainer").innerHTML = navServersHtml;
|
document.getElementById("navSrvContainer").innerHTML = navserversHtml;
|
||||||
document.getElementById("data_server_list").innerHTML = serversHtml;
|
document.getElementById("data_server_list").innerHTML = serversHtml;
|
||||||
|
|
||||||
for (let i = 0; i < servers.length; i++) {
|
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`);
|
const refreshElement = document.querySelector(`#performance .refresh-element`);
|
||||||
refreshElement.querySelector('i').addEventListener('click', () => {
|
refreshElement.querySelector('i').addEventListener('click', () => {
|
||||||
if (refreshElement.querySelector('.refresh-notice').innerHTML.length) {
|
if (refreshElement.querySelector('.refresh-notice').innerHTML.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onSelectPerformanceServers();
|
onSelectperformanceservers();
|
||||||
refreshElement.querySelector('.refresh-notice').innerHTML = '<i class="fa fa-fw fa-cog fa-spin"></i> Updating..';
|
refreshElement.querySelector('.refresh-notice').innerHTML = '<i class="fa fa-fw fa-cog fa-spin"></i> Updating..';
|
||||||
});
|
});
|
||||||
const selector = document.getElementById('performance-server-selector');
|
const selector = document.getElementById('performance-server-selector');
|
||||||
jsonRequest('./v1/network/listServers', function (json, error) {
|
jsonRequest('./v1/network/serverOptions', function (json, error) {
|
||||||
if (json) {
|
if (json) {
|
||||||
let options = ``;
|
let options = ``;
|
||||||
for (let server of json.servers) {
|
for (let server of json.servers) {
|
||||||
options += `<option${server.proxy ? ' selected' : ''} data-plan-server-uuid="${server.serverUUID}">${server.serverName}</option>`
|
options += `<option${server.proxy ? ' selected' : ''} data-plan-server-uuid="${server.serverUUID}">${server.serverName}</option>`
|
||||||
}
|
}
|
||||||
selector.innerHTML = options;
|
selector.innerHTML = options;
|
||||||
onSelectPerformanceServers();
|
onSelectperformanceservers();
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
selector.innerText = `Failed to load server list: ${error}`
|
selector.innerText = `Failed to load server list: ${error}`
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSelectPerformanceServers() {
|
async function onSelectperformanceservers() {
|
||||||
const selector = document.getElementById('performance-server-selector');
|
const selector = document.getElementById('performance-server-selector');
|
||||||
const selectedServerUUIDs = [];
|
const selectedServerUUIDs = [];
|
||||||
|
|
||||||
|
@ -665,12 +665,9 @@
|
|||||||
Server selector</h6>
|
Server selector</h6>
|
||||||
</div>
|
</div>
|
||||||
<select class="form-control" id="performance-server-selector" multiple>
|
<select class="form-control" id="performance-server-selector" multiple>
|
||||||
<option selected>Proxy server</option>
|
<option>Loading..</option>
|
||||||
<option>Server 1</option>
|
|
||||||
<option>Skyblock</option>
|
|
||||||
<option>Server 3</option>
|
|
||||||
</select>
|
</select>
|
||||||
<button class="btn bg-plan" onclick="onSelectPerformanceServers()">Apply</button>
|
<button class="btn bg-plan" onclick="onSelectperformanceservers()">Apply</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1143,7 +1140,7 @@
|
|||||||
responsive: true
|
responsive: true
|
||||||
});
|
});
|
||||||
|
|
||||||
loadPerformanceServerOptions();
|
loadperformanceserverOptions();
|
||||||
|
|
||||||
setLoadingText('Almost done..');
|
setLoadingText('Almost done..');
|
||||||
openPage();
|
openPage();
|
||||||
|
@ -56,7 +56,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
/**
|
/**
|
||||||
* Tests for limiting user access control based on permissions.
|
* 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);
|
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 {
|
static String login(String address, String username) throws IOException, KeyManagementException, NoSuchAlgorithmException {
|
||||||
HttpURLConnection loginConnection = null;
|
HttpURLConnection loginConnection = null;
|
||||||
String cookie = "";
|
String cookie;
|
||||||
try {
|
try {
|
||||||
loginConnection = CONNECTOR.getConnection("POST", address + "/auth/login");
|
loginConnection = CONNECTOR.getConnection("POST", address + "/auth/login");
|
||||||
loginConnection.setDoOutput(true);
|
loginConnection.setDoOutput(true);
|
||||||
@ -141,7 +141,7 @@ public class AccessControlTest {
|
|||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest(name = "{0}: expecting {1}")
|
||||||
@CsvSource({
|
@CsvSource({
|
||||||
"/,302",
|
"/,302",
|
||||||
"/server,302",
|
"/server,302",
|
||||||
@ -196,6 +196,7 @@ public class AccessControlTest {
|
|||||||
"/v1/errors,200",
|
"/v1/errors,200",
|
||||||
"/errors,200",
|
"/errors,200",
|
||||||
"/v1/network/listServers,200",
|
"/v1/network/listServers,200",
|
||||||
|
"/v1/network/serverOptions,200",
|
||||||
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],200",
|
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],200",
|
||||||
"/v1/version,200",
|
"/v1/version,200",
|
||||||
"/v1/user,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);
|
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({
|
@CsvSource({
|
||||||
"/,302",
|
"/,302",
|
||||||
"/server,403",
|
"/server,403",
|
||||||
@ -260,6 +261,7 @@ public class AccessControlTest {
|
|||||||
"/v1/errors,403",
|
"/v1/errors,403",
|
||||||
"/errors,403",
|
"/errors,403",
|
||||||
"/v1/network/listServers,403",
|
"/v1/network/listServers,403",
|
||||||
|
"/v1/network/serverOptions,403",
|
||||||
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403",
|
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403",
|
||||||
"/v1/version,200",
|
"/v1/version,200",
|
||||||
"/v1/user,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);
|
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({
|
@CsvSource({
|
||||||
"/,302",
|
"/,302",
|
||||||
"/server,403",
|
"/server,403",
|
||||||
@ -324,6 +326,7 @@ public class AccessControlTest {
|
|||||||
"/v1/errors,403",
|
"/v1/errors,403",
|
||||||
"/errors,403",
|
"/errors,403",
|
||||||
"/v1/network/listServers,403",
|
"/v1/network/listServers,403",
|
||||||
|
"/v1/network/serverOptions,403",
|
||||||
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403",
|
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403",
|
||||||
"/v1/version,200",
|
"/v1/version,200",
|
||||||
"/v1/user,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);
|
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({
|
@CsvSource({
|
||||||
"/,403",
|
"/,403",
|
||||||
"/server,403",
|
"/server,403",
|
||||||
@ -386,6 +389,7 @@ public class AccessControlTest {
|
|||||||
"/v1/filters,403",
|
"/v1/filters,403",
|
||||||
"/v1/query,403",
|
"/v1/query,403",
|
||||||
"/v1/network/listServers,403",
|
"/v1/network/listServers,403",
|
||||||
|
"/v1/network/serverOptions,403",
|
||||||
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403",
|
"/v1/network/performanceOverview?servers=[" + TestConstants.SERVER_UUID_STRING + "],403",
|
||||||
"/v1/version,200",
|
"/v1/version,200",
|
||||||
"/v1/user,200",
|
"/v1/user,200",
|
||||||
|
Loading…
Reference in New Issue
Block a user