mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-07 04:18:26 +02:00
Version information to the pages
This commit is contained in:
parent
3027de6327
commit
b895bd1a8a
@ -47,7 +47,7 @@ public class APFModule {
|
||||
@Named("currentVersion")
|
||||
@Singleton
|
||||
String provideCurrentVersion(IPlugin plugin) {
|
||||
return plugin.getVersion();
|
||||
return plugin.getVersion().replace("%buildNumber%", "?");
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -103,10 +103,45 @@ public class VersionCheckSystem implements SubSystem {
|
||||
return Optional.ofNullable(newVersionAvailable);
|
||||
}
|
||||
|
||||
public Optional<String> getUpdateHtml() {
|
||||
public Optional<String> getUpdateButton() {
|
||||
return getNewVersionAvailable()
|
||||
.map(v -> v.isTrusted() ? "<a href=\"" + v.getChangeLogUrl() + "\" target=\"_blank\">" +
|
||||
"<h4 class=\"col-green\"><i class=\"" + (v.isRelease() ? "fa fa-download" : "fab fa-dev") + "\"></i> v" + v.getVersion().getVersionString() + " available!</h4></a>" : "");
|
||||
.filter(VersionInfo::isTrusted)
|
||||
.map(v -> "<button class=\"btn bg-white col-plan\" data-target=\"#updateModal\" data-toggle=\"modal\" type=\"button\">" +
|
||||
"<i class=\"fa fa-fw fa-download\"></i> v." + v.getVersion().getVersionString() +
|
||||
"</button>"
|
||||
);
|
||||
}
|
||||
|
||||
public String getCurrentVersionButton() {
|
||||
return "<button class=\"btn bg-plan\" data-target=\"#updateModal\" data-toggle=\"modal\" type=\"button\">" +
|
||||
"v." + getCurrentVersion() +
|
||||
"</button>";
|
||||
}
|
||||
|
||||
public String getUpdateModal() {
|
||||
return getNewVersionAvailable()
|
||||
.filter(VersionInfo::isTrusted)
|
||||
.map(v -> "<div class=\"modal-header\">" +
|
||||
"<h5 class=\"modal-title\" id=\"updateModalLabel\">" +
|
||||
"<i class=\"fa fa-fw fa-download\"></i> Version " + v.getVersion().getVersionString() + " is Available!" +
|
||||
"</h5><button aria-label=\"Close\" class=\"close\" data-dismiss=\"modal\" type=\"button\"><span aria-hidden=\"true\">×</span></button>" +
|
||||
"</div>" + // Close modal-header
|
||||
"<div class=\"modal-body\">" +
|
||||
"<p>A new version has been released and is now available for download." +
|
||||
(v.isRelease() ? "" : "<br>This version is a DEV release.") + "</p>" +
|
||||
"<a class=\"btn col-plan\" href=\"" + v.getChangeLogUrl() + "\" rel=\"noopener noreferrer\" target=\"_blank\">" +
|
||||
"<i class=\"fa fa-fw fa-list\"></i> View Changelog</a>" +
|
||||
"<a class=\"btn col-plan\" href=\"" + v.getDownloadUrl() + "\" rel=\"noopener noreferrer\" target=\"_blank\">" +
|
||||
"<i class=\"fa fa-fw fa-download\"></i> Download Plan-4.6.2.jar</a>" +
|
||||
"</div>") // Close modal-body
|
||||
.orElse("<div class=\"modal-header\">" +
|
||||
"<h5 class=\"modal-title\" id=\"updateModalLabel\">" +
|
||||
"<i class=\"far fa-fw fa-check-circle\"></i> You have version " + getCurrentVersion() + "" +
|
||||
"</h5><button aria-label=\"Close\" class=\"close\" data-dismiss=\"modal\" type=\"button\"><span aria-hidden=\"true\">×</span></button>" +
|
||||
"</div>" + // Close modal-header
|
||||
"<div class=\"modal-body\">" +
|
||||
"<p>You are running the latest version.</p>" +
|
||||
"</div>"); // Close modal-body
|
||||
}
|
||||
|
||||
public String getCurrentVersion() {
|
||||
|
@ -48,15 +48,15 @@ public class ErrorResponse extends PageResponse {
|
||||
}
|
||||
|
||||
public void replacePlaceholders() {
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("title", title);
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("title", title);
|
||||
String[] split = title.split(">", 3);
|
||||
placeHolders.put("titleText", split.length == 3 ? split[2] : title);
|
||||
placeHolders.put("paragraph", paragraph);
|
||||
placeHolders.put("version", versionCheckSystem.getCurrentVersion());
|
||||
placeHolders.put("update", versionCheckSystem.getUpdateHtml().orElse(""));
|
||||
placeholders.put("titleText", split.length == 3 ? split[2] : title);
|
||||
placeholders.put("paragraph", paragraph);
|
||||
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
|
||||
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
|
||||
|
||||
setContent(StringSubstitutor.replace(getContent(), placeHolders));
|
||||
setContent(StringSubstitutor.replace(getContent(), placeholders));
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
|
@ -85,7 +85,8 @@ public class NetworkPage implements Page {
|
||||
placeholders.put("avgPingColor", theme.getValue(ThemeVal.GRAPH_AVG_PING));
|
||||
placeholders.put("timeZone", config.getTimeZoneOffsetHours());
|
||||
|
||||
placeholders.put("update", versionCheckSystem.getUpdateHtml().orElse(""));
|
||||
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
|
||||
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
|
||||
|
||||
List<ExtensionServerData> extensionData = dbSystem.getDatabase()
|
||||
.query(new ExtensionServerDataQuery(serverUUID));
|
||||
|
@ -90,33 +90,33 @@ public class PlayerPage implements Page {
|
||||
long now = System.currentTimeMillis();
|
||||
UUID playerUUID = player.getUnsafe(PlayerKeys.UUID);
|
||||
|
||||
PlaceholderReplacer replacer = new PlaceholderReplacer();
|
||||
PlaceholderReplacer placeholders = new PlaceholderReplacer();
|
||||
|
||||
replacer.put("refresh", clockLongFormatter.apply(now));
|
||||
replacer.put("refreshFull", secondLongFormatter.apply(now));
|
||||
replacer.put("version", versionCheckSystem.getCurrentVersion());
|
||||
replacer.put("update", versionCheckSystem.getUpdateHtml().orElse(""));
|
||||
replacer.put("timeZone", config.getTimeZoneOffsetHours());
|
||||
placeholders.put("refresh", clockLongFormatter.apply(now));
|
||||
placeholders.put("refreshFull", secondLongFormatter.apply(now));
|
||||
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
|
||||
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
|
||||
placeholders.put("timeZone", config.getTimeZoneOffsetHours());
|
||||
|
||||
String playerName = player.getValue(PlayerKeys.NAME).orElse(playerUUID.toString());
|
||||
replacer.put("playerName", playerName);
|
||||
placeholders.put("playerName", playerName);
|
||||
|
||||
replacer.put("worldPieColors", theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
||||
replacer.put("gmPieColors", theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
||||
replacer.put("serverPieColors", theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
|
||||
replacer.put("firstDay", 1);
|
||||
placeholders.put("worldPieColors", theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
||||
placeholders.put("gmPieColors", theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
||||
placeholders.put("serverPieColors", theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
|
||||
placeholders.put("firstDay", 1);
|
||||
|
||||
if (serverInfo.getServer().isProxy()) {
|
||||
replacer.put("backButton", "<li><a title=\"to Network page\" href=\"/network\"><i class=\"material-icons\">arrow_back</i><i class=\"material-icons\">cloud</i></a></li>");
|
||||
placeholders.put("backButton", "<li><a title=\"to Network page\" href=\"/network\"><i class=\"material-icons\">arrow_back</i><i class=\"material-icons\">cloud</i></a></li>");
|
||||
} else {
|
||||
replacer.put("backButton", "<li><a title=\"to Server page\" href=\"/server\"><i class=\"material-icons\">arrow_back</i><i class=\"material-icons\">storage</i></a></li>");
|
||||
placeholders.put("backButton", "<li><a title=\"to Server page\" href=\"/server\"><i class=\"material-icons\">arrow_back</i><i class=\"material-icons\">storage</i></a></li>");
|
||||
}
|
||||
|
||||
PlayerPluginTab pluginTabs = pageFactory.inspectPluginTabs(playerUUID);
|
||||
|
||||
replacer.put("navPluginsTabs", pluginTabs.getNav());
|
||||
replacer.put("pluginsTabs", pluginTabs.getTab());
|
||||
placeholders.put("navPluginsTabs", pluginTabs.getNav());
|
||||
placeholders.put("pluginsTabs", pluginTabs.getTab());
|
||||
|
||||
return replacer.apply(files.getCustomizableResourceOrDefault("web/player.html").asString());
|
||||
return placeholders.apply(files.getCustomizableResourceOrDefault("web/player.html").asString());
|
||||
}
|
||||
}
|
||||
|
@ -70,22 +70,22 @@ public class PlayersPage implements Page {
|
||||
@Override
|
||||
public String toHtml() throws ParseException {
|
||||
try {
|
||||
PlaceholderReplacer placeholderReplacer = new PlaceholderReplacer();
|
||||
PlaceholderReplacer placeholders = new PlaceholderReplacer();
|
||||
|
||||
placeholderReplacer.put("version", versionCheckSystem.getCurrentVersion());
|
||||
placeholderReplacer.put("update", versionCheckSystem.getUpdateHtml().orElse(""));
|
||||
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
|
||||
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
|
||||
if (serverInfo.getServer().isProxy()) {
|
||||
placeholderReplacer.put("networkName", config.get(ProxySettings.NETWORK_NAME));
|
||||
placeholders.put("networkName", config.get(ProxySettings.NETWORK_NAME));
|
||||
} else {
|
||||
placeholderReplacer.put("networkName", config.get(PluginSettings.SERVER_NAME));
|
||||
placeholders.put("networkName", config.get(PluginSettings.SERVER_NAME));
|
||||
}
|
||||
|
||||
timings.start("Players page players table parsing");
|
||||
List<PlayerContainer> playerContainers = database.query(ContainerFetchQueries.fetchAllPlayerContainers());
|
||||
placeholderReplacer.put("playersTable", tables.playerTableForPlayersPage(playerContainers).parseHtml());
|
||||
placeholders.put("playersTable", tables.playerTableForPlayersPage(playerContainers).parseHtml());
|
||||
timings.end("Pages", "Players page players table parsing");
|
||||
|
||||
return placeholderReplacer.apply(files.getCustomizableResourceOrDefault("web/players.html").asString());
|
||||
return placeholders.apply(files.getCustomizableResourceOrDefault("web/players.html").asString());
|
||||
} catch (Exception e) {
|
||||
throw new ParseException(e);
|
||||
}
|
||||
|
@ -118,7 +118,8 @@ public class ServerPage implements Page {
|
||||
} else {
|
||||
placeholders.put("backButton", "");
|
||||
}
|
||||
placeholders.put("update", versionCheckSystem.getUpdateHtml().orElse(""));
|
||||
placeholders.put("version", versionCheckSystem.getUpdateButton().orElse(versionCheckSystem.getCurrentVersionButton()));
|
||||
placeholders.put("updateModal", versionCheckSystem.getUpdateModal());
|
||||
|
||||
List<ExtensionServerData> extensionData = dbSystem.getDatabase()
|
||||
.query(new ExtensionServerDataQuery(server.getUuid()));
|
||||
|
@ -56,9 +56,9 @@
|
||||
<button class="btn bg-plan" data-target="#informationModal" data-toggle="modal" type="button">
|
||||
<i class="fa fa-fw fa-question-circle"></i>
|
||||
</button>
|
||||
<button class="btn bg-white col-plan" data-target="#updateModal" data-toggle="modal" type="button">
|
||||
<b><i class="fa fa-fw fa-download"></i> v4.6.2</b>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-3 align-items-center justify-content-between">
|
||||
${version}
|
||||
</div>
|
||||
</ul>
|
||||
<!-- End of Sidebar -->
|
||||
@ -230,28 +230,7 @@
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="updateModalLabel"><i class="fa fa-fw fa-download"></i> Version 4.6.2
|
||||
is
|
||||
Available!
|
||||
</h5>
|
||||
<button aria-label="Close" class="close" data-dismiss="modal" type="button">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>A new version has been released and is now available for download.</p>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/tag/4.6.2-REL"
|
||||
rel="noopener noreferrer" target="_blank">
|
||||
<i class="fa fa-fw fa-list"></i> View Changelog
|
||||
</a>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/download/4.6.2-REL/Plan-4.6.2.jar"
|
||||
rel="noopener noreferrer" target="_blank">
|
||||
<i class="fa fa-fw fa-download"></i> Download Plan-4.6.2.jar
|
||||
</a>
|
||||
</div>
|
||||
${updateModal}
|
||||
<div class="modal-footer">
|
||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||
</div>
|
||||
|
@ -120,9 +120,9 @@
|
||||
<button class="btn bg-plan" data-target="#informationModal" data-toggle="modal" type="button">
|
||||
<i class="fa fa-fw fa-question-circle"></i>
|
||||
</button>
|
||||
<button class="btn bg-white col-plan" data-target="#updateModal" data-toggle="modal" type="button">
|
||||
<b><i class="fa fa-fw fa-download"></i> v4.6.2</b>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-3 align-items-center justify-content-between">
|
||||
${version}
|
||||
</div>
|
||||
</ul>
|
||||
<!-- End of Sidebar -->
|
||||
@ -801,29 +801,7 @@
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="updateModalLabel"><i class="fa fa-fw fa-download"></i> Version 4.6.2 is
|
||||
Available!
|
||||
</h5>
|
||||
<button aria-label="Close" class="close" data-dismiss="modal" type="button">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>A new version has been released and is now available for download.</p>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/tag/4.6.2-REL"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank">
|
||||
<i class="fa fa-fw fa-list"></i> View Changelog
|
||||
</a>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/download/4.6.2-REL/Plan-4.6.2.jar"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank">
|
||||
<i class="fa fa-fw fa-download"></i> Download Plan-4.6.2.jar
|
||||
</a>
|
||||
</div>
|
||||
${updateModal}
|
||||
<div class="modal-footer">
|
||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||
</div>
|
||||
|
@ -108,9 +108,9 @@
|
||||
<button class="btn bg-plan" data-target="#informationModal" data-toggle="modal" type="button">
|
||||
<i class="fa fa-fw fa-question-circle"></i>
|
||||
</button>
|
||||
<button class="btn bg-white col-plan" data-target="#updateModal" data-toggle="modal" type="button">
|
||||
<b><i class="fa fa-fw fa-download"></i> v4.6.2</b>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-3 align-items-center justify-content-between">
|
||||
${version}
|
||||
</div>
|
||||
</ul>
|
||||
<!-- End of Sidebar -->
|
||||
@ -717,28 +717,7 @@
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="updateModalLabel"><i class="fa fa-fw fa-download"></i> Version 4.6.2
|
||||
is
|
||||
Available!
|
||||
</h5>
|
||||
<button aria-label="Close" class="close" data-dismiss="modal" type="button">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>A new version has been released and is now available for download.</p>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/tag/4.6.2-REL"
|
||||
rel="noopener noreferrer" target="_blank">
|
||||
<i class="fa fa-fw fa-list"></i> View Changelog
|
||||
</a>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/download/4.6.2-REL/Plan-4.6.2.jar"
|
||||
rel="noopener noreferrer" target="_blank">
|
||||
<i class="fa fa-fw fa-download"></i> Download Plan-4.6.2.jar
|
||||
</a>
|
||||
</div>
|
||||
${updateModal}
|
||||
<div class="modal-footer">
|
||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||
</div>
|
||||
|
@ -126,9 +126,9 @@
|
||||
<button class="btn bg-plan" data-target="#informationModal" data-toggle="modal" type="button">
|
||||
<i class="fa fa-fw fa-question-circle"></i>
|
||||
</button>
|
||||
<button class="btn bg-white col-plan" data-target="#updateModal" data-toggle="modal" type="button">
|
||||
<b><i class="fa fa-fw fa-download"></i> v4.6.2</b>
|
||||
</button>
|
||||
</div>
|
||||
<div class="ml-3 align-items-center justify-content-between">
|
||||
${version}
|
||||
</div>
|
||||
</ul>
|
||||
<!-- End of Sidebar -->
|
||||
@ -1288,30 +1288,7 @@
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="updateModalLabel"><i class="fa fa-fw fa-download"></i> Version 4.6.2
|
||||
is
|
||||
Available!
|
||||
</h5>
|
||||
<button aria-label="Close" class="close" data-dismiss="modal" type="button">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>A new version has been released and is now available for download.</p>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/tag/4.6.2-REL"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank">
|
||||
<i class="fa fa-fw fa-list"></i> View Changelog
|
||||
</a>
|
||||
<a class="btn col-plan"
|
||||
href="https://github.com/Rsl1122/Plan-PlayerAnalytics/releases/download/4.6.2-REL/Plan-4.6.2.jar"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank">
|
||||
<i class="fa fa-fw fa-download"></i> Download Plan-4.6.2.jar
|
||||
</a>
|
||||
</div>
|
||||
${updateModal}
|
||||
<div class="modal-footer">
|
||||
<button class="btn bg-plan" data-dismiss="modal" type="button">OK</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user