Ping table to Geolocation tab on Server page

This commit is contained in:
Rsl1122 2018-07-16 16:23:11 +03:00
parent 236121b0e6
commit e3118c57a4
5 changed files with 67 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCre
import com.djrapitops.plan.utilities.html.structure.RecentLoginList;
import com.djrapitops.plan.utilities.html.structure.SessionAccordion;
import com.djrapitops.plan.utilities.html.tables.CommandUseTable;
import com.djrapitops.plan.utilities.html.tables.PingTable;
import com.djrapitops.plan.utilities.html.tables.PlayersTable;
import com.djrapitops.plan.utilities.html.tables.ServerSessionTable;
import com.djrapitops.plugin.api.TimeAmount;
@ -151,6 +152,12 @@ public class AnalysisContainer extends DataContainer {
putSupplier(AnalysisKeys.PLAYERS_TABLE, () ->
PlayersTable.forServerPage(getUnsafe(AnalysisKeys.PLAYERS_MUTATOR).all()).parseHtml()
);
putSupplier(AnalysisKeys.PING_TABLE, () ->
new PingTable(
getUnsafe(AnalysisKeys.PLAYERS_MUTATOR)
.getPingPerCountry(serverContainer.getUnsafe(ServerKeys.SERVER_UUID))
).parseHtml()
);
newAndUniquePlayerCounts();
}

View File

@ -52,6 +52,7 @@ public class AnalysisKeys {
public static final PlaceholderKey<String> SESSION_ACCORDION_HTML = new PlaceholderKey<>(String.class, "accordionSessions");
public static final PlaceholderKey<String> SESSION_ACCORDION_FUNCTIONS = new PlaceholderKey<>(String.class, "sessionTabGraphViewFunctions");
public static final PlaceholderKey<String> SESSION_TABLE = new PlaceholderKey<>(String.class, "tableBodySessions");
public static final PlaceholderKey<String> PING_TABLE = new PlaceholderKey<>(String.class, "tablePing");
public static final PlaceholderKey<String> RECENT_LOGINS = new PlaceholderKey<>(String.class, "listRecentLogins");
public static final PlaceholderKey<String> COMMAND_USAGE_TABLE = new PlaceholderKey<>(String.class, "tableCommandUsage");
public static final PlaceholderKey<String> HEALTH_NOTES = CommonPlaceholderKeys.HEALTH_NOTES;

View File

@ -85,7 +85,7 @@ public class AnalysisPage implements Page {
placeholderReplacer.addAllPlaceholdersFrom(analysisContainer,
SESSION_ACCORDION_HTML, SESSION_ACCORDION_FUNCTIONS,
SESSION_TABLE, RECENT_LOGINS,
COMMAND_USAGE_TABLE);
COMMAND_USAGE_TABLE, PING_TABLE);
Benchmark.stop(DEBUG, DEBUG + " Session Structures");
}

View File

@ -0,0 +1,53 @@
package com.djrapitops.plan.utilities.html.tables;
import com.djrapitops.plan.data.container.Ping;
import com.djrapitops.plan.data.element.TableContainer;
import com.djrapitops.plan.data.store.mutators.PingMutator;
import com.djrapitops.plan.utilities.FormatUtils;
import com.djrapitops.plan.utilities.html.icon.Icon;
import java.util.*;
public class PingTable extends TableContainer {
public PingTable(Map<String, List<Ping>> pingPerCountry) {
super(
Icon.called("globe") + " Country",
Icon.called("signal") + " Average Ping",
Icon.called("signal") + " Maximum Ping",
Icon.called("signal") + " Minimum Ping"
);
setColor("amber");
addRows(pingPerCountry);
}
private void addRows(Map<String, List<Ping>> pingPerCountry) {
Map<String, Double> avg = new HashMap<>();
Map<String, Integer> max = new HashMap<>();
Map<String, Integer> min = new HashMap<>();
for (Map.Entry<String, List<Ping>> entry : pingPerCountry.entrySet()) {
PingMutator pingMutator = new PingMutator(entry.getValue());
String country = entry.getKey();
avg.put(country, pingMutator.average());
max.put(country, pingMutator.max());
min.put(country, pingMutator.min());
}
List<String> sortedKeys = new ArrayList<>(avg.keySet());
Collections.sort(sortedKeys);
for (String country : sortedKeys) {
Double average = avg.get(country);
Integer maximum = max.get(country);
Integer minimum = min.get(country);
addRow(
country,
average >= 0 ? FormatUtils.cutDecimals(average) + " ms" : "-",
maximum >= 0 ? maximum + " ms" : "-",
minimum >= 0 ? minimum + " ms" : "-"
);
}
}
}

View File

@ -1062,6 +1062,11 @@
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
${tablePing}
</div>
</div>
<!-- #END# Geolocations -->
</div>
<!-- #END# Tab Geolocations -->