From 0e794f975f7f604d49d872536ac573f97cf68e70 Mon Sep 17 00:00:00 2001 From: NovaFox161 Date: Mon, 3 Aug 2020 04:14:48 -0500 Subject: [PATCH] Add version info in status tracking since we may end up having multiple versions out across the network for testing --- .../network/discal/ConnectedClient.java | 30 +++++++++++++++++++ .../object/network/discal/NetworkInfo.java | 11 +++++++ .../resources/templates/various/status.html | 16 ++++++++++ 3 files changed, 57 insertions(+) diff --git a/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/ConnectedClient.java b/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/ConnectedClient.java index 9c4a5bf6..1567faca 100644 --- a/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/ConnectedClient.java +++ b/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/ConnectedClient.java @@ -1,5 +1,6 @@ package org.dreamexposure.discal.core.object.network.discal; +import org.dreamexposure.discal.core.utils.GlobalConst; import org.json.JSONObject; import java.text.SimpleDateFormat; @@ -16,6 +17,9 @@ import java.util.Date; public class ConnectedClient { private int clientIndex; + private String version; + private String d4jVersion; + private int connectedServers; private long lastKeepAlive; private String uptime; @@ -29,6 +33,9 @@ public class ConnectedClient { ConnectedClient() { this.clientIndex = -1; + this.version = GlobalConst.version; + this.d4jVersion = GlobalConst.d4jVersion; + this.connectedServers = 0; this.lastKeepAlive = System.currentTimeMillis(); @@ -39,6 +46,9 @@ public class ConnectedClient { public ConnectedClient(final int _clientIndex) { this.clientIndex = _clientIndex; + this.version = GlobalConst.version; + this.d4jVersion = GlobalConst.d4jVersion; + this.connectedServers = 0; this.lastKeepAlive = System.currentTimeMillis(); @@ -51,6 +61,14 @@ public class ConnectedClient { return this.clientIndex; } + public String getVersion() { + return this.version; + } + + public String getD4JVersion() { + return this.d4jVersion; + } + public int getConnectedServers() { return this.connectedServers; } @@ -90,6 +108,14 @@ public class ConnectedClient { this.clientIndex = clientIndex; } + public void setVersion(final String version) { + this.version = version; + } + + public void setD4JVersion(final String d4jVersion) { + this.d4jVersion = d4jVersion; + } + public void setConnectedServers(final int _connectedServers) { this.connectedServers = _connectedServers; } @@ -122,6 +148,8 @@ public class ConnectedClient { final JSONObject json = new JSONObject(); json.put("index", this.clientIndex); + json.put("version", this.version); + json.put("d4j_version", this.d4jVersion); json.put("guilds", this.connectedServers); json.put("keep_alive", this.lastKeepAlive); json.put("uptime", this.uptime); @@ -132,6 +160,8 @@ public class ConnectedClient { public ConnectedClient fromJson(final JSONObject json) { this.clientIndex = json.getInt("index"); + this.version = json.getString("version"); + this.d4jVersion = json.getString("d4j_version"); this.connectedServers = json.getInt("guilds"); this.lastKeepAlive = json.getLong("keep_alive"); this.uptime = json.getString("uptime"); diff --git a/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/NetworkInfo.java b/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/NetworkInfo.java index fcf5b011..0c477a57 100644 --- a/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/NetworkInfo.java +++ b/core/src/main/java/org/dreamexposure/discal/core/object/network/discal/NetworkInfo.java @@ -4,6 +4,7 @@ import org.dreamexposure.discal.core.database.DatabaseManager; import org.dreamexposure.discal.core.logger.LogFeed; import org.dreamexposure.discal.core.logger.object.LogObject; import org.dreamexposure.discal.core.object.BotSettings; +import org.dreamexposure.discal.core.utils.GlobalConst; import org.joda.time.Interval; import org.joda.time.Period; import org.json.JSONArray; @@ -89,6 +90,14 @@ public class NetworkInfo { } } + public String getVersion() { + return GlobalConst.version; + } + + public String getD4JVersion() { + return GlobalConst.d4jVersion; + } + public int getTotalGuildCount() { int count = 0; for (final ConnectedClient cc : this.clients) { @@ -150,6 +159,8 @@ public class NetworkInfo { public JSONObject toJson() { final JSONObject json = new JSONObject(); + json.put("api_version", this.getVersion()); + json.put("d4j_version", this.getD4JVersion()); json.put("api_uptime", this.getUptimeLatest()); json.put("api_pid", this.getPid()); json.put("announcements", this.getAnnouncementCount()); diff --git a/web/src/main/resources/templates/various/status.html b/web/src/main/resources/templates/various/status.html index 35861562..207ed384 100644 --- a/web/src/main/resources/templates/various/status.html +++ b/web/src/main/resources/templates/various/status.html @@ -231,6 +231,14 @@

Server

+

+

+ +

+

+

@@ -295,6 +303,14 @@

+

+

+ +

+

+