mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 09:37:54 +01:00
Translate more labels like 'Unknown' in the frontend
This commit is contained in:
parent
30a8da3c3b
commit
9886040de7
@ -158,24 +158,32 @@ public class ActivityIndex {
|
||||
return Math.abs(Math.log(other.value) - Math.log(value));
|
||||
}
|
||||
|
||||
public static String getGroup(double value) {
|
||||
public static HtmlLang getGroupLang(double value) {
|
||||
if (value >= VERY_ACTIVE) {
|
||||
return HtmlLang.INDEX_VERY_ACTIVE.getDefault();
|
||||
return HtmlLang.INDEX_VERY_ACTIVE;
|
||||
} else if (value >= ACTIVE) {
|
||||
return HtmlLang.INDEX_ACTIVE.getDefault();
|
||||
return HtmlLang.INDEX_ACTIVE;
|
||||
} else if (value >= REGULAR) {
|
||||
return HtmlLang.INDEX_REGULAR.getDefault();
|
||||
return HtmlLang.INDEX_REGULAR;
|
||||
} else if (value >= IRREGULAR) {
|
||||
return HtmlLang.INDEX_IRREGULAR.getDefault();
|
||||
return HtmlLang.INDEX_IRREGULAR;
|
||||
} else {
|
||||
return HtmlLang.INDEX_INACTIVE.getDefault();
|
||||
return HtmlLang.INDEX_INACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getGroup(double value) {
|
||||
return getGroupLang(value).getDefault();
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return getGroup(value);
|
||||
}
|
||||
|
||||
public String getGroupLang() {
|
||||
return getGroupLang(value).getKey();
|
||||
}
|
||||
|
||||
public String getGroup(Locale locale) {
|
||||
if (value >= VERY_ACTIVE) {
|
||||
return locale.getString(HtmlLang.INDEX_VERY_ACTIVE);
|
||||
|
@ -284,15 +284,15 @@ public class JSONFactory {
|
||||
server.put("unique_players", uniquePlayerCounts.getOrDefault(serverUUID, 0));
|
||||
TPSMutator tpsWeek = tpsMonth.filterDataBetween(weekAgo, now);
|
||||
double averageTPS = tpsWeek.averageTPS();
|
||||
server.put("avg_tps", averageTPS != -1 ? decimals.apply(averageTPS) : locale.get(HtmlLang.UNIT_NO_DATA).toString());
|
||||
server.put("avg_tps", averageTPS != -1 ? decimals.apply(averageTPS) : HtmlLang.UNIT_NO_DATA.getKey());
|
||||
server.put("low_tps_spikes", tpsWeek.lowTpsSpikeCount(config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED)));
|
||||
server.put("downtime", timeAmount.apply(tpsWeek.serverDownTime()));
|
||||
server.put("current_uptime", serverUptimeCalculator.getServerUptimeMillis(serverUUID).map(timeAmount)
|
||||
.orElse(locale.getString(GenericLang.UNAVAILABLE)));
|
||||
.orElse(GenericLang.UNAVAILABLE.getKey()));
|
||||
|
||||
Optional<TPS> online = tpsWeek.getLast();
|
||||
server.put("online", online.map(point -> point.getDate() >= now - TimeUnit.MINUTES.toMillis(3L) ? point.getPlayers() : "Possibly offline")
|
||||
.orElse(locale.get(HtmlLang.UNIT_NO_DATA).toString()));
|
||||
server.put("online", online.map(point -> point.getDate() >= now - TimeUnit.MINUTES.toMillis(3L) ? point.getPlayers() : HtmlLang.LABEL_POSSIBLY_OFFLINE.getKey())
|
||||
.orElse(HtmlLang.UNIT_NO_DATA.getKey()));
|
||||
servers.add(server);
|
||||
});
|
||||
return Collections.singletonMap("servers", servers);
|
||||
|
@ -23,7 +23,6 @@ import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.locale.lang.HtmlLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
@ -46,7 +45,6 @@ import java.util.concurrent.TimeUnit;
|
||||
public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String, Object>> {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private final Formatter<Double> decimals;
|
||||
@ -57,12 +55,10 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
@Inject
|
||||
public PerformanceJSONCreator(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
Formatters formatters
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
decimals = formatters.decimals();
|
||||
@ -134,15 +130,15 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
}
|
||||
|
||||
private String format(double value) {
|
||||
return value != -1 ? decimals.apply(value) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
return value != -1 ? decimals.apply(value) : GenericLang.UNAVAILABLE.getKey();
|
||||
}
|
||||
|
||||
private String formatBytes(double value) {
|
||||
return value != -1 ? byteSize.apply(value) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
return value != -1 ? byteSize.apply(value) : GenericLang.UNAVAILABLE.getKey();
|
||||
}
|
||||
|
||||
private String formatPercentage(double value) {
|
||||
return value != -1 ? percentage.apply(value / 100.0) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
return value != -1 ? percentage.apply(value / 100.0) : GenericLang.UNAVAILABLE.getKey();
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(List<TPS> tpsData) {
|
||||
@ -157,7 +153,7 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
double averageCPU = lowTPS.averageCPU();
|
||||
double averageEntities = lowTPS.averageEntities();
|
||||
double averageChunks = lowTPS.averageChunks();
|
||||
insights.put("low_tps_players", avgPlayersOnline != -1 ? decimals.apply(avgPlayersOnline) : locale.get(HtmlLang.TEXT_NO_LOW_TPS).toString());
|
||||
insights.put("low_tps_players", avgPlayersOnline != -1 ? decimals.apply(avgPlayersOnline) : HtmlLang.TEXT_NO_LOW_TPS.getKey());
|
||||
insights.put("low_tps_tps", averageTPS != -1 ? decimals.apply(averageTPS) : "-");
|
||||
insights.put("low_tps_cpu", averageCPU != -1 ? decimals.apply(averageCPU) : "-");
|
||||
insights.put("low_tps_entities", averageEntities != -1 ? decimals.apply(averageEntities) : "-");
|
||||
|
@ -38,7 +38,6 @@ import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.settings.theme.Theme;
|
||||
import com.djrapitops.plan.settings.theme.ThemeVal;
|
||||
@ -46,7 +45,6 @@ import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
import com.djrapitops.plan.storage.database.queries.containers.PlayerContainerQuery;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.storage.database.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.java.Lists;
|
||||
import com.djrapitops.plan.utilities.java.Maps;
|
||||
@ -61,7 +59,6 @@ import java.util.function.Predicate;
|
||||
public class PlayerJSONCreator {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final Theme theme;
|
||||
private final DBSystem dbSystem;
|
||||
private final Graphs graphs;
|
||||
@ -74,14 +71,12 @@ public class PlayerJSONCreator {
|
||||
@Inject
|
||||
public PlayerJSONCreator(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
Theme theme,
|
||||
DBSystem dbSystem,
|
||||
Formatters formatters,
|
||||
Graphs graphs
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.theme = theme;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
@ -92,10 +87,6 @@ public class PlayerJSONCreator {
|
||||
this.graphs = graphs;
|
||||
}
|
||||
|
||||
public long getLastSeen(UUID playerUUID) {
|
||||
return dbSystem.getDatabase().query(SessionQueries.lastSeen(playerUUID));
|
||||
}
|
||||
|
||||
public Map<String, Object> createJSONAsMap(UUID playerUUID, Predicate<WebPermission> hasPermission) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
|
||||
@ -142,7 +133,7 @@ public class PlayerJSONCreator {
|
||||
data.put("player_deaths", new PlayerKillMutator(deaths).toJSONAsMap(formatters));
|
||||
}
|
||||
if (hasPermission.test(WebPermission.PAGE_PLAYER_SERVERS)) {
|
||||
List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount, locale.getString(GenericLang.UNKNOWN)).asMaps();
|
||||
List<Map<String, Object>> serverAccordion = new ServerAccordion(player, serverNames, graphs, year, timeAmount, GenericLang.UNKNOWN.getKey()).asMaps();
|
||||
Map<ServerUUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer();
|
||||
String[] pieColors = theme.getPieColors(ThemeVal.GRAPH_WORLD_PIE);
|
||||
|
||||
@ -230,8 +221,8 @@ public class PlayerJSONCreator {
|
||||
info.put("longest_session_length", timeAmount.apply(sessions.toLongestSessionLength()));
|
||||
info.put("session_median", timeAmount.apply(sessions.toMedianSessionLength()));
|
||||
info.put("activity_index", decimals.apply(activityIndex.getValue()));
|
||||
info.put("activity_index_group", activityIndex.getGroup());
|
||||
info.put("favorite_server", perServer.favoriteServer().map(favoriteServer -> serverNames.getOrDefault(favoriteServer, favoriteServer.toString())).orElse(locale.getString(GenericLang.UNKNOWN)));
|
||||
info.put("activity_index_group", activityIndex.getGroupLang());
|
||||
info.put("favorite_server", perServer.favoriteServer().map(favoriteServer -> serverNames.getOrDefault(favoriteServer, favoriteServer.toString())).orElse(GenericLang.UNKNOWN.getKey()));
|
||||
info.put("latest_join_address", sessions.latestSession()
|
||||
.flatMap(session -> session.getExtraData(JoinAddress.class))
|
||||
.map(JoinAddress::getAddress)
|
||||
@ -240,7 +231,7 @@ public class PlayerJSONCreator {
|
||||
int worstPing = ping.max();
|
||||
int bestPing = ping.min();
|
||||
|
||||
String unavailable = locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
String unavailable = GenericLang.UNAVAILABLE.getKey();
|
||||
info.put("average_ping", averagePing != -1.0 ? decimals.apply(averagePing) + " ms" : unavailable);
|
||||
info.put("worst_ping", worstPing != -1.0 ? worstPing + " ms" : unavailable);
|
||||
info.put("best_ping", bestPing != -1.0 ? bestPing + " ms" : unavailable);
|
||||
|
@ -29,7 +29,6 @@ import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
@ -58,7 +57,6 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
|
||||
private final Formatter<Long> day;
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ServerSensor<?> serverSensor;
|
||||
@ -72,7 +70,6 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
@Inject
|
||||
public ServerOverviewJSONCreator(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
ServerSensor<?> serverSensor,
|
||||
@ -80,7 +77,6 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
Formatters formatters
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.serverSensor = serverSensor;
|
||||
@ -120,7 +116,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
sevenDays.put("new_players_retention_perc", percentage.apply(retentionPercentage7d));
|
||||
TPSMutator tpsMutator = new TPSMutator(db.query(TPSQueries.fetchTPSDataOfServer(weekAgo, now, serverUUID)));
|
||||
double averageTPS = tpsMutator.averageTPS();
|
||||
sevenDays.put("average_tps", averageTPS != -1 ? decimals.apply(averageTPS) : locale.get(GenericLang.UNAVAILABLE).toString());
|
||||
sevenDays.put("average_tps", averageTPS != -1 ? decimals.apply(averageTPS) : GenericLang.UNAVAILABLE.getKey());
|
||||
sevenDays.put("low_tps_spikes", tpsMutator.lowTpsSpikeCount(config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED)));
|
||||
sevenDays.put("downtime", timeAmount.apply(tpsMutator.serverDownTime()));
|
||||
|
||||
@ -153,7 +149,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
numbers.put("mob_kills", db.query(KillQueries.mobKillCount(0L, now, serverUUID)));
|
||||
numbers.put("deaths", db.query(KillQueries.deathCount(0L, now, serverUUID)));
|
||||
numbers.put("current_uptime", serverUptimeCalculator.getServerUptimeMillis(serverUUID).map(timeAmount)
|
||||
.orElse(locale.getString(GenericLang.UNAVAILABLE)));
|
||||
.orElse(GenericLang.UNAVAILABLE.getKey()));
|
||||
|
||||
return numbers;
|
||||
}
|
||||
@ -163,7 +159,7 @@ public class ServerOverviewJSONCreator implements ServerTabJSONCreator<Map<Strin
|
||||
? serverSensor.getOnlinePlayerCount()
|
||||
: db.query(TPSQueries.fetchLatestTPSEntryForServer(serverUUID))
|
||||
.map(TPS::getPlayers).map(Object::toString)
|
||||
.orElse(locale.get(GenericLang.UNKNOWN).toString());
|
||||
.orElse(GenericLang.UNKNOWN.getKey());
|
||||
}
|
||||
|
||||
private Map<String, Object> createWeeksMap(ServerUUID serverUUID) {
|
||||
|
@ -27,7 +27,6 @@ import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.TimeSettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
@ -53,7 +52,6 @@ public class NetworkOverviewJSONCreator implements NetworkTabJSONCreator<Map<Str
|
||||
|
||||
private final Formatter<Long> day;
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final ServerSensor<?> serverSensor;
|
||||
@ -64,7 +62,6 @@ public class NetworkOverviewJSONCreator implements NetworkTabJSONCreator<Map<Str
|
||||
@Inject
|
||||
public NetworkOverviewJSONCreator(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
ServerInfo serverInfo,
|
||||
ServerSensor<?> serverSensor,
|
||||
@ -72,7 +69,6 @@ public class NetworkOverviewJSONCreator implements NetworkTabJSONCreator<Map<Str
|
||||
Formatters formatters
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
this.serverInfo = serverInfo;
|
||||
this.serverSensor = serverSensor;
|
||||
@ -137,7 +133,7 @@ public class NetworkOverviewJSONCreator implements NetworkTabJSONCreator<Map<Str
|
||||
numbers.put("sessions", sessionCount);
|
||||
numbers.put("session_length_avg", sessionCount != 0 ? timeAmount.apply(totalPlaytime / sessionCount) : "-");
|
||||
numbers.put("current_uptime", serverUptimeCalculator.getServerUptimeMillis(serverUUID).map(timeAmount)
|
||||
.orElse(locale.getString(GenericLang.UNAVAILABLE)));
|
||||
.orElse(GenericLang.UNAVAILABLE.getKey()));
|
||||
|
||||
return numbers;
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import com.djrapitops.plan.gathering.domain.TPS;
|
||||
import com.djrapitops.plan.identification.ServerUUID;
|
||||
import com.djrapitops.plan.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.settings.config.paths.DisplaySettings;
|
||||
import com.djrapitops.plan.settings.locale.Locale;
|
||||
import com.djrapitops.plan.settings.locale.lang.GenericLang;
|
||||
import com.djrapitops.plan.storage.database.DBSystem;
|
||||
import com.djrapitops.plan.storage.database.Database;
|
||||
@ -63,7 +62,6 @@ import java.util.stream.Collectors;
|
||||
public class NetworkPerformanceJSONResolver implements Resolver {
|
||||
|
||||
private final PlanConfig config;
|
||||
private final Locale locale;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private final Formatter<Double> decimals;
|
||||
@ -75,13 +73,11 @@ public class NetworkPerformanceJSONResolver implements Resolver {
|
||||
@Inject
|
||||
public NetworkPerformanceJSONResolver(
|
||||
PlanConfig config,
|
||||
Locale locale,
|
||||
DBSystem dbSystem,
|
||||
Formatters formatters,
|
||||
Gson gson
|
||||
) {
|
||||
this.config = config;
|
||||
this.locale = locale;
|
||||
this.dbSystem = dbSystem;
|
||||
|
||||
decimals = formatters.decimals();
|
||||
@ -212,15 +208,15 @@ public class NetworkPerformanceJSONResolver implements Resolver {
|
||||
}
|
||||
|
||||
private String format(double value) {
|
||||
return value != -1 ? decimals.apply(value) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
return value != -1 ? decimals.apply(value) : GenericLang.UNAVAILABLE.getKey();
|
||||
}
|
||||
|
||||
private String formatBytes(double value) {
|
||||
return value != -1 ? byteSize.apply(value) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
return value != -1 ? byteSize.apply(value) : GenericLang.UNAVAILABLE.getKey();
|
||||
}
|
||||
|
||||
private String formatPercentage(double value) {
|
||||
return value != -1 ? percentage.apply(value / 100.0) : locale.get(GenericLang.UNAVAILABLE).toString();
|
||||
return value != -1 ? percentage.apply(value / 100.0) : GenericLang.UNAVAILABLE.getKey();
|
||||
}
|
||||
|
||||
}
|
@ -268,6 +268,7 @@ public enum HtmlLang implements Lang {
|
||||
LABEL_PROJECTION_ORTOGRAPHIC("html.label.geoProjection.ortographic", "Ortographic"),
|
||||
LABEL_SERVER_SELECTOR("html.label.serverSelector", "Server selector"),
|
||||
LABEL_APPLY("html.label.apply", "Apply"),
|
||||
LABEL_POSSIBLY_OFFLINE("html.label.serverPossiblyOffline", "Possibly offline"),
|
||||
|
||||
LABEL_TABLE_VISIBLE_COLUMNS("html.label.table.visibleColumns", "Visible columns"),
|
||||
LABEL_TABLE_SHOW_N_OF_M("html.label.table.showNofM", "Showing {{n}} of {{mn}} entries"),
|
||||
|
@ -1,15 +1,19 @@
|
||||
import {FontAwesomeIcon as Fa} from "@fortawesome/react-fontawesome";
|
||||
import React from "react";
|
||||
import End from "./layout/End";
|
||||
import {useTranslation} from "react-i18next";
|
||||
|
||||
const Datapoint = ({icon, color, name, value, valueLabel, bold, boldTitle, title, trend}) => {
|
||||
const {t} = useTranslation();
|
||||
if (value === undefined && valueLabel === undefined) return <></>;
|
||||
|
||||
const displayedValue = bold ? <b>{value}</b> : value;
|
||||
const extraLabel = typeof valueLabel === 'string' ? ` (${valueLabel})` : '';
|
||||
const colorClass = color && color.startsWith("col-") ? color : "col-" + color;
|
||||
const isTranslatable = typeof value === 'string' && (value.startsWith('html') || value.startsWith('plugin'));
|
||||
const translatedValue = isTranslatable ? t(value) : value;
|
||||
const displayedValue = bold ? <b>{translatedValue}</b> : translatedValue;
|
||||
const extraLabel = typeof valueLabel === 'string' ? ` (${t(valueLabel)})` : '';
|
||||
const colorClass = color?.startsWith("col-") ? color : "col-" + color;
|
||||
return (
|
||||
<p title={title ? title : name + " is " + value}>
|
||||
<p title={title ? title : name + ": " + translatedValue}>
|
||||
{icon && <Fa icon={icon} className={colorClass}/>} {boldTitle ? <b>{name}</b> : name}
|
||||
{value !== undefined ? <End>{displayedValue} {extraLabel}{trend}</End> : ''}
|
||||
</p>
|
||||
|
@ -12,9 +12,10 @@ import {baseAddress} from "../../service/backendConfiguration";
|
||||
import {useAuth} from "../../hooks/authenticationHook";
|
||||
|
||||
const ServerHeader = ({server}) => {
|
||||
const {t} = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<td>{server.server_name}
|
||||
<td>{t(server.server_name)}
|
||||
{server.operator ? <Fa icon={faSuperpowers} title="Operator"/> : ''}
|
||||
{server.banned ? <Fa icon={faGavel} title="Banned"/> : ''}
|
||||
</td>
|
||||
|
@ -26,8 +26,8 @@ const ConnectionsCard = ({connections}) => {
|
||||
</tr>
|
||||
</thead>
|
||||
{Boolean(connections?.length) && <tbody>
|
||||
{connections.map((connection, i) => (<tr key={JSON.stringify(connection)}>
|
||||
<td>{connection.geolocation}</td>
|
||||
{connections.map(connection => (<tr key={JSON.stringify(connection)}>
|
||||
<td>{connection.geolocation.replace('Local Machine', t('html.value.localMachine'))}</td>
|
||||
<td>{connection.date}</td>
|
||||
</tr>))}
|
||||
</tbody>}
|
||||
|
@ -25,6 +25,9 @@ const FunctionPlotGraph = ({
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.chart(id, options ? options : {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
yAxis: {
|
||||
plotLines: yPlotLines,
|
||||
plotBands: yPlotBands
|
||||
|
@ -21,7 +21,10 @@ const GeolocationBarGraph = ({series, color}) => {
|
||||
Accessibility(Highcharts);
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.chart("countryBarChart", {
|
||||
chart: {type: 'bar'},
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
type: 'bar'
|
||||
},
|
||||
title: {text: ''},
|
||||
xAxis: {
|
||||
categories: categories,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, {useEffect} from 'react';
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {useTheme} from "../../hooks/themeHook";
|
||||
import Highcharts from 'highcharts/highmaps.js';
|
||||
import Highcharts from 'highcharts/highmaps';
|
||||
import topology from '@highcharts/map-collection/custom/world.topo.json';
|
||||
import Accessibility from "highcharts/modules/accessibility";
|
||||
import NoDataDisplay from "highcharts/modules/no-data-to-display";
|
||||
@ -46,6 +46,7 @@ const GeolocationWorldMap = ({series, colors, projection}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}});
|
||||
Highcharts.mapChart('countryWorldMap', {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
map: topology,
|
||||
animation: true
|
||||
},
|
||||
|
@ -29,7 +29,10 @@ const GroupBarGraph = ({id, groups, colors, horizontal, name}) => {
|
||||
Accessibility(Highcharts);
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.chart(id, {
|
||||
chart: {type: horizontal ? 'bar' : 'column'},
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
type: horizontal ? 'bar' : 'column'
|
||||
},
|
||||
title: {text: ''},
|
||||
xAxis: {
|
||||
categories: categories,
|
||||
|
@ -31,6 +31,7 @@ const GroupPie = ({id, groups, colors, name}) => {
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.chart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
backgroundColor: 'transparent',
|
||||
plotBorderWidth: null,
|
||||
plotShadow: false,
|
||||
|
@ -40,6 +40,7 @@ const JoinAddressGraph = ({id, data, colors, stack}) => {
|
||||
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
type: "column"
|
||||
},
|
||||
rangeSelector: {
|
||||
|
@ -36,6 +36,9 @@ const LineGraph = ({
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
setGraph(Highcharts.stockChart(id, options ? options : {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: selectedRange !== undefined ? selectedRange : 2,
|
||||
buttons: linegraphButtons
|
||||
@ -71,7 +74,7 @@ const LineGraph = ({
|
||||
onSetExtremes, setGraph, selectedRange]);
|
||||
|
||||
useEffect(() => {
|
||||
if (graph && graph.xAxis && graph.xAxis.length && extremes) {
|
||||
if (graph?.xAxis?.length && extremes) {
|
||||
graph.xAxis[0].setExtremes(extremes.min, extremes.max);
|
||||
}
|
||||
}, [graph, extremes]);
|
||||
|
@ -27,6 +27,7 @@ const PlayerbaseGraph = ({data}) => {
|
||||
|
||||
Highcharts.chart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
type: "area"
|
||||
},
|
||||
xAxis: {
|
||||
|
@ -18,6 +18,7 @@ const PunchCard = ({series}) => {
|
||||
Highcharts.setOptions(graphTheming);
|
||||
setTimeout(() => Highcharts.chart('punchcard', {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
backgroundColor: 'transparent',
|
||||
plotBackgroundColor: 'transparent',
|
||||
defaultSeriesType: 'scatter'
|
||||
|
@ -28,6 +28,7 @@ const ServerPie = ({colors, series}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}});
|
||||
Highcharts.chart('server-pie', {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
backgroundColor: 'transparent',
|
||||
plotBorderWidth: null,
|
||||
plotShadow: false,
|
||||
|
@ -33,6 +33,7 @@ const StackedPlayersOnlineGraph = ({data}) => {
|
||||
buttons: linegraphButtons
|
||||
},
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
zooming: {
|
||||
type: 'xy'
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ const WorldPie = ({id, worldSeries, gmSeries}) => {
|
||||
setTimeout(() => {
|
||||
const chart = Highcharts.chart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay'),
|
||||
backgroundColor: 'transparent',
|
||||
plotBackgroundColor: 'transparent',
|
||||
plotBorderWidth: null,
|
||||
|
@ -72,7 +72,7 @@ const AllPerformanceGraph = ({id, data, dataSeries}) => {
|
||||
let chartId = chartElement?.getAttribute('data-highcharts-chart');
|
||||
const chart = chartId !== undefined ? Highcharts.charts[chartId] : undefined;
|
||||
|
||||
if (chart && chart.yAxis && chart.yAxis.length) {
|
||||
if (chart?.yAxis?.length) {
|
||||
const newWidth = window.innerWidth
|
||||
chart.yAxis[0].update({labels: {enabled: newWidth >= 900}});
|
||||
chart.yAxis[1].update({labels: {enabled: newWidth >= 900}});
|
||||
@ -158,6 +158,9 @@ const AllPerformanceGraph = ({id, data, dataSeries}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: 2,
|
||||
buttons: linegraphButtons
|
||||
|
@ -47,6 +47,9 @@ const CpuRamPerformanceGraph = ({id, data, dataSeries}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: 1, // TODO Sync range selectors state
|
||||
buttons: linegraphButtons
|
||||
|
@ -44,6 +44,9 @@ const DiskPerformanceGraph = ({id, data, dataSeries}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: 2,
|
||||
buttons: linegraphButtons
|
||||
|
@ -46,6 +46,9 @@ const PingGraph = ({id, data}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: 2,
|
||||
buttons: linegraphButtons
|
||||
|
@ -53,6 +53,9 @@ const TpsPerformanceGraph = ({id, data, dataSeries}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: 1,
|
||||
buttons: linegraphButtons
|
||||
|
@ -47,6 +47,9 @@ const WorldPerformanceGraph = ({id, data, dataSeries}) => {
|
||||
Highcharts.setOptions({lang: {noData: t('html.label.noDataToDisplay')}})
|
||||
Highcharts.setOptions(graphTheming);
|
||||
Highcharts.stockChart(id, {
|
||||
chart: {
|
||||
noData: t('html.label.noDataToDisplay')
|
||||
},
|
||||
rangeSelector: {
|
||||
selected: 2,
|
||||
buttons: linegraphButtons
|
||||
|
@ -58,9 +58,9 @@ const PerformanceAsNumbersTable = ({data, servers}) => {
|
||||
]}/>
|
||||
<TableRow icon={faTachometerAlt} color="orange" text={t('html.label.averageTps')}
|
||||
values={[
|
||||
<>{data.tps_30d} {noTPSOnProxies}</>,
|
||||
<>{data.tps_7d} {noTPSOnProxies}</>,
|
||||
<>{data.tps_24h} {noTPSOnProxies}</>
|
||||
<>{t(data.tps_30d)} {noTPSOnProxies}</>,
|
||||
<>{t(data.tps_7d)} {noTPSOnProxies}</>,
|
||||
<>{t(data.tps_24h)} {noTPSOnProxies}</>
|
||||
]}/>
|
||||
<TableRow icon={faTachometerAlt} color="amber" text={t('html.label.averageCpuUsage')}
|
||||
values={[
|
||||
@ -76,17 +76,17 @@ const PerformanceAsNumbersTable = ({data, servers}) => {
|
||||
]}/>
|
||||
<TableRow icon={faDragon} color="purple" text={t('html.label.averageEntities')}
|
||||
values={[
|
||||
<>{data.entities_30d} {noTPSOnProxies}</>,
|
||||
<>{data.entities_7d} {noTPSOnProxies}</>,
|
||||
<>{data.entities_24h} {noTPSOnProxies}</>
|
||||
<>{t(data.entities_30d)} {noTPSOnProxies}</>,
|
||||
<>{t(data.entities_7d)} {noTPSOnProxies}</>,
|
||||
<>{t(data.entities_24h)} {noTPSOnProxies}</>
|
||||
]}/>
|
||||
<TableRow icon={faMap} color="blue-grey"
|
||||
text={<>{t('html.label.averageChunks')}{' '}{data.chunks_30d === 'Unavailable' ?
|
||||
text={<>{t('html.label.averageChunks')}{' '}{data.chunks_30d === 'plugin.generic.unavailable' ?
|
||||
<Fa icon={faEye} title={t('html.description.noSpongeChunks')}/> : ''}</>}
|
||||
values={[
|
||||
<>{data.chunks_30d} {noTPSOnProxies}</>,
|
||||
<>{data.chunks_7d} {noTPSOnProxies}</>,
|
||||
<>{data.chunks_24h} {noTPSOnProxies}</>
|
||||
<>{t(data.chunks_30d)} {noTPSOnProxies}</>,
|
||||
<>{t(data.chunks_7d)} {noTPSOnProxies}</>,
|
||||
<>{t(data.chunks_24h)} {noTPSOnProxies}</>
|
||||
]}/>
|
||||
<TableRow icon={faHdd} color="green"
|
||||
text={t('html.label.maxFreeDisk')}
|
||||
|
@ -45,7 +45,7 @@ const ServerRow = ({server, onQuickView}) => {
|
||||
</NavLink>
|
||||
</td>
|
||||
<td>{server.players}</td>
|
||||
<td>{server.online}</td>
|
||||
<td>{t(server.online)}</td>
|
||||
<td className="p-1">
|
||||
<button className={'btn bg-light-blue float-right'}
|
||||
title={t('html.label.quickView') + ': ' + server.name}
|
||||
|
@ -1,14 +1,20 @@
|
||||
import {FontAwesomeIcon as Fa} from "@fortawesome/react-fontawesome";
|
||||
import React from "react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
|
||||
export const TableRow = ({icon, text, color, values, bold}) => {
|
||||
const {t} = useTranslation();
|
||||
if (!values || values.filter(value => value !== undefined).length < values.length) return <></>;
|
||||
|
||||
const label = (<><Fa icon={icon} className={'col-' + color}/> {text}</>);
|
||||
return (
|
||||
<tr>
|
||||
<td>{bold ? <b>{label}</b> : label}</td>
|
||||
{values.map((value, j) => <td key={j}>{value}</td>)}
|
||||
{values.map((value, j) => {
|
||||
const isTranslatable = typeof value === 'string' && (value.startsWith('html') || value.startsWith('plugin'));
|
||||
const translatedValue = isTranslatable ? t(value) : value;
|
||||
return <td key={j}>{translatedValue}</td>;
|
||||
})}
|
||||
</tr>
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user