Add warning to server list if server hasn't sent data for over 24h

The warning is demoted if data doesn't arrive in 7 days to a grey warning
And again after 30 days it changes to an archive to signify the server might be gone for good.

Affects issues:
- Close #2595
This commit is contained in:
Aurora Lahtela 2023-04-06 19:57:45 +03:00
parent 720cf4374e
commit e40793d2b8
2 changed files with 21 additions and 3 deletions

View File

@ -375,6 +375,8 @@ public enum HtmlLang implements Lang {
WARNING_NO_GAME_SERVERS("html.description.noGameServers", "Some data requires Plan to be installed on game servers."),
WARNING_NO_GEOLOCATIONS("html.description.noGeolocations", "Geolocation gathering needs to be enabled in the config (Accept GeoLite2 EULA)."),
WARNING_NO_SPONGE_CHUNKS("html.description.noSpongeChunks", "Chunks unavailable on Sponge"),
WARNING_NO_DATA_24H("html.description.noData24h", "Server has not sent data for over 24 hours"),
WARNING_NO_DATA_30D("html.description.noData30d", "Server has not sent data for over 30 days"),
EXPORTED_TITLE("html.label.exported", "Data export time");
private final String key;

View File

@ -1,7 +1,9 @@
import React from "react";
import {FontAwesomeIcon as Fa} from "@fortawesome/react-fontawesome";
import {
faBoxArchive,
faCaretSquareRight,
faExclamationTriangle,
faLineChart,
faLink,
faServer,
@ -19,9 +21,22 @@ import {NavLink} from "react-router-dom";
const ServerRow = ({server, onQuickView}) => {
const {t} = useTranslation();
const timeUtc = Date.now();
const dayMs = 86400000
let noDataWarning = '';
if (!server.playersOnline.length) {
noDataWarning = <>&nbsp;<Fa icon={faBoxArchive} title={t('html.description.noData30d')}/></>
} else if (timeUtc - server.playersOnline[server.playersOnline.length - 1][0] > dayMs) {
noDataWarning = <>&nbsp;<Fa icon={faExclamationTriangle}
className={timeUtc - server.playersOnline[server.playersOnline.length - 1][0] > dayMs * 7 ? '' : "col-deep-orange"}
title={t('html.description.noData24h')}/></>
}
return (
<tr>
<td>{server.name}</td>
<td>{server.name}{noDataWarning}</td>
<td className="p-1">
<NavLink to={"/server/" + encodeURIComponent(server.serverUUID)}
title={t('html.label.serverAnalysis') + ': ' + server.name}
@ -136,8 +151,9 @@ const ServersTable = ({servers, onSelect, sortBy, sortReversed}) => {
</tr>
</thead>
<tbody>
{sortedServers.length ? sortedServers.map((server, i) => <ServerRow key={i} server={server}
onQuickView={() => onSelect(servers.indexOf(server))}/>) :
{sortedServers.length ? sortedServers.map(server => <ServerRow key={server.serverUUID}
server={server}
onQuickView={() => onSelect(servers.indexOf(server))}/>) :
<tr>
<td>{t('html.generic.none')}</td>
<td>-</td>