mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-07 04:18:26 +02:00
Player page plugins tabs
This commit is contained in:
parent
227c66961a
commit
f905f3c879
@ -36,7 +36,7 @@ import java.util.*;
|
||||
/**
|
||||
* Responsible for generating /server page plugin tabs based on DataExtension API data.
|
||||
* <p>
|
||||
* Currently very similar to {@link InspectPluginTab}.
|
||||
* Currently very similar to {@link PlayerPluginTab}.
|
||||
* This will become more complex once tables are added, since some big tables will be moved to their own tabs.
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -91,9 +91,9 @@ public class AnalysisPluginTabs {
|
||||
private void generate() {
|
||||
if (serverData.isEmpty()) {
|
||||
nav = new NavLink(Icon.called("cubes").build(), "Overview (No Data)").toHtml();
|
||||
tab = "<div class=\"tab\"><div class=\"row clearfix\">" +
|
||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<div class=\"card-body\"><p>No Extension Data</p></div>") +
|
||||
"</div></div></div>";
|
||||
tab = wrapInTab(
|
||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<div class=\"card-body\"><p>No Extension Data</p></div>") + "</div>"
|
||||
);
|
||||
} else {
|
||||
nav = new NavLink(Icon.called("cubes").build(), "Overview").toHtml();
|
||||
tab = generatePageTab();
|
||||
|
@ -147,16 +147,16 @@ public class PageFactory {
|
||||
);
|
||||
}
|
||||
|
||||
public InspectPluginTab inspectPluginTabs(UUID playerUUID) {
|
||||
public PlayerPluginTab inspectPluginTabs(UUID playerUUID) {
|
||||
Database database = dbSystem.get().getDatabase();
|
||||
|
||||
Map<UUID, List<ExtensionPlayerData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
|
||||
|
||||
if (extensionPlayerData.isEmpty()) {
|
||||
return new InspectPluginTab("No Extensions", Collections.emptyList(), formatters.get());
|
||||
return new PlayerPluginTab("", Collections.emptyList(), formatters.get());
|
||||
}
|
||||
|
||||
List<InspectPluginTab> inspectPluginTabs = new ArrayList<>();
|
||||
List<PlayerPluginTab> playerPluginTabs = new ArrayList<>();
|
||||
for (Map.Entry<UUID, Server> entry : database.query(ServerQueries.fetchPlanServerInformation()).entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
String serverName = entry.getValue().getIdentifiableName();
|
||||
@ -166,18 +166,18 @@ public class PageFactory {
|
||||
continue;
|
||||
}
|
||||
|
||||
inspectPluginTabs.add(new InspectPluginTab(serverName, ofServer, formatters.get()));
|
||||
playerPluginTabs.add(new PlayerPluginTab(serverName, ofServer, formatters.get()));
|
||||
}
|
||||
|
||||
StringBuilder navs = new StringBuilder();
|
||||
StringBuilder tabs = new StringBuilder();
|
||||
|
||||
inspectPluginTabs.stream().sorted().forEach(tab -> {
|
||||
playerPluginTabs.stream().sorted().forEach(tab -> {
|
||||
navs.append(tab.getNav());
|
||||
tabs.append(tab.getTab());
|
||||
});
|
||||
|
||||
return new InspectPluginTab(navs.toString(), tabs.toString());
|
||||
return new PlayerPluginTab(navs.toString(), tabs.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,7 +113,7 @@ public class PlayerPage implements Page {
|
||||
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>");
|
||||
}
|
||||
|
||||
InspectPluginTab pluginTabs = pageFactory.inspectPluginTabs(playerUUID);
|
||||
PlayerPluginTab pluginTabs = pageFactory.inspectPluginTabs(playerUUID);
|
||||
|
||||
replacer.put("navPluginsTabs", pluginTabs.getNav());
|
||||
replacer.put("pluginsTabs", pluginTabs.getTab());
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
import com.djrapitops.plan.utilities.html.structure.NavLink;
|
||||
import com.djrapitops.plan.utilities.html.structure.TabsElement;
|
||||
|
||||
import java.util.*;
|
||||
@ -37,7 +38,7 @@ import java.util.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
|
||||
|
||||
private String serverName;
|
||||
private List<ExtensionPlayerData> playerData;
|
||||
@ -52,12 +53,12 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
|
||||
private boolean hasWideTable;
|
||||
|
||||
public InspectPluginTab(String nav, String tab) {
|
||||
public PlayerPluginTab(String nav, String tab) {
|
||||
this.nav = nav;
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
public InspectPluginTab(
|
||||
public PlayerPluginTab(
|
||||
String serverName,
|
||||
List<ExtensionPlayerData> playerData,
|
||||
Formatters formatters
|
||||
@ -89,12 +90,12 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
|
||||
private void generate() {
|
||||
if (playerData.isEmpty()) {
|
||||
nav = "<li><a class=\"nav-button\" href=\"javascript:void(0)\">" + serverName + " (No Data)</a></li>";
|
||||
tab = "<div class=\"tab\"><div class=\"row clearfix\">" +
|
||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<p>No Data (" + serverName + ")</p>") +
|
||||
"</div></div></div>";
|
||||
nav = NavLink.collapsed(Icon.called("cubes").build(), serverName + " (No Data)").toHtml();
|
||||
tab = wrapInTab(
|
||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<div class=\"card-body\"><p>No Extension Data</p></div>") + "</div>"
|
||||
);
|
||||
} else {
|
||||
nav = "<li><a class=\"nav-button\" href=\"javascript:void(0)\">" + serverName + "</a></li>";
|
||||
nav = NavLink.collapsed(Icon.called("cubes").build(), serverName).toHtml();
|
||||
tab = generatePageTab();
|
||||
}
|
||||
}
|
||||
@ -126,7 +127,13 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
}
|
||||
|
||||
private String wrapInTab(String content) {
|
||||
return "<div class=\"tab\"><div class=\"row clearfix\">" + content + "</div></div>";
|
||||
return "<div class=\"tab\"><div class=\"container-fluid mt-4\">" +
|
||||
// Page heading
|
||||
"<div class=\"d-sm-flex align-items-center justify-content-between mb-4\">" +
|
||||
"<h1 class=\"h3 mb-0 text-gray-800\"><i class=\"sidebar-toggler fa fa-fw fa-bars\"></i>${playerName} · " + serverName + " Plugins</h1>" +
|
||||
"</div>" +
|
||||
// End Page heading
|
||||
"<div class=\"row clearfix\">" + content + "</div></div></div>";
|
||||
}
|
||||
|
||||
private TabsElement.Tab wrapToTabElementTab(ExtensionTabData tabData) {
|
||||
@ -202,9 +209,9 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
|
||||
private String wrapInContainer(ExtensionInformation information, String tabsElement) {
|
||||
String colWidth = hasWideTable ? "col-md-8 col-lg-8" : "col-md-4 col-lg-4";
|
||||
return "<div class=\"col-xs-12 col-sm-12 " + colWidth + "\"><div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>" + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "</h2>" +
|
||||
return "<div class=\"col-xs-12 col-sm-12 " + colWidth + "\"><div class=\"card shadow mb-0\">" +
|
||||
"<div class=\"card-header py-3\">" +
|
||||
"<h6 class=\"m-0 font-weight-bold col-black\">" + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "</h6>" +
|
||||
"</div>" +
|
||||
tabsElement +
|
||||
"</div></div>";
|
||||
@ -213,8 +220,8 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof InspectPluginTab)) return false;
|
||||
InspectPluginTab that = (InspectPluginTab) o;
|
||||
if (!(o instanceof PlayerPluginTab)) return false;
|
||||
PlayerPluginTab that = (PlayerPluginTab) o;
|
||||
return Objects.equals(serverName, that.serverName) &&
|
||||
Objects.equals(nav, that.nav);
|
||||
}
|
||||
@ -225,7 +232,7 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InspectPluginTab other) {
|
||||
public int compareTo(PlayerPluginTab other) {
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(this.serverName, other.serverName);
|
||||
}
|
||||
}
|
@ -27,13 +27,32 @@ public class NavLink {
|
||||
|
||||
private final Icon icon;
|
||||
private final String tabName;
|
||||
private final boolean collapsed;
|
||||
|
||||
public NavLink(Icon icon, String tabName) {
|
||||
this(icon, tabName, false);
|
||||
}
|
||||
|
||||
private NavLink(Icon icon, String tabName, boolean collapsed) {
|
||||
this.icon = icon;
|
||||
this.tabName = tabName;
|
||||
this.collapsed = collapsed;
|
||||
}
|
||||
|
||||
public static NavLink main(Icon icon, String tabName) {
|
||||
return new NavLink(icon, tabName, false);
|
||||
}
|
||||
|
||||
public static NavLink collapsed(Icon icon, String tabName) {
|
||||
return new NavLink(icon, tabName, true);
|
||||
}
|
||||
|
||||
public String toHtml() {
|
||||
if (collapsed) {
|
||||
return "<a class=\"collapse-item nav-button\" href=\"javascript:void(0)\">" +
|
||||
icon.toHtml() + ' ' +
|
||||
tabName + "</a>";
|
||||
}
|
||||
return "<li class=\"nav-item nav-button\">" +
|
||||
"<a class=\"nav-link\" href=\"javascript:void(0)\">" +
|
||||
icon.toHtml() +
|
||||
|
@ -93,12 +93,7 @@
|
||||
</a>
|
||||
<div aria-labelledby="headingPages" class="collapse" data-parent="#accordionSidebar" id="pluginsPages">
|
||||
<div class="bg-white py-2 collapse-inner rounded">
|
||||
<a class="collapse-item nav-button" href="javascript:void(0)"><i class="fas fa-fw fa-cubes"></i>
|
||||
Server 1</a>
|
||||
<a class="collapse-item nav-button" href="javascript:void(0)"><i class="fa fa-fw fa-cubes"></i>
|
||||
Server 2</a>
|
||||
<a class="collapse-item nav-button" href="javascript:void(0)"><i class="fa fa-fw fa-cubes"></i>
|
||||
Server 3</a>
|
||||
${navPluginsTabs}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@ -422,8 +417,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><b><i class="col-red fa fa-fw fa-crosshairs"></i></b> Average KDR / Player
|
||||
</td>
|
||||
<td><b><i class="col-red fa fa-fw fa-crosshairs"></i> KDR</b></td>
|
||||
<td id="data_player_kdr_total"></td>
|
||||
<td id="data_player_kdr_30d"></td>
|
||||
<td id="data_player_kdr_7d"></td>
|
||||
@ -443,7 +437,7 @@
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><b><i class="col-green fa fa-fw fa-crosshairs"></i></b> Average Mob KDR</td>
|
||||
<td><b><i class="col-green fa fa-fw fa-crosshairs"></i> Mob KDR</b></td>
|
||||
<td id="data_mob_kdr_total"></td>
|
||||
<td id="data_mob_kdr_30d"></td>
|
||||
<td id="data_mob_kdr_7d"></td>
|
||||
@ -571,101 +565,7 @@
|
||||
</div>
|
||||
</div> <!-- /.container-fluid -->
|
||||
</div> <!-- End of Servers Overview Tab-->
|
||||
<!-- Begin Server 1 Plugins Tab -->
|
||||
<div class="tab">
|
||||
<div class="container-fluid mt-4">
|
||||
<!-- Page Heading -->
|
||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800"><i
|
||||
class="sidebar-toggler fa fa-fw fa-bars"></i>${playerName}
|
||||
· Server 1 Plugins</h1>
|
||||
<a class="btn bg-plan btn-icon-split" href="network">
|
||||
<span class="icon text-white-50">
|
||||
<i class="fas fa-fw fa-arrow-left"></i><i class="fas fa-fw fa-cloud"></i>
|
||||
</span>
|
||||
<span class="text">Network page</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4 mb-4 col-sm-12">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold col-black"><i
|
||||
class="fa fa-fw fa-star col-green"></i>
|
||||
AdvancedAchievements</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><i class="far fa-fw fa-check-circle col-green"></i> Achievements<span
|
||||
class="float-right"><b>9</b></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /.container-fluid -->
|
||||
</div> <!-- End of Server 1 Plugins tab -->
|
||||
<!-- Begin Server 2 Plugins Tab -->
|
||||
<div class="tab">
|
||||
<div class="container-fluid mt-4">
|
||||
<!-- Page Heading -->
|
||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800"><i
|
||||
class="sidebar-toggler fa fa-fw fa-bars"></i>${playerName}
|
||||
· Server 2 Plugins</h1>
|
||||
<a class="btn bg-plan btn-icon-split" href="network">
|
||||
<span class="icon text-white-50">
|
||||
<i class="fas fa-fw fa-arrow-left"></i><i class="fas fa-fw fa-cloud"></i>
|
||||
</span>
|
||||
<span class="text">Network page</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4 mb-4 col-sm-12">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold col-black"><i
|
||||
class="fa fa-fw fa-university col-brown"></i>
|
||||
Towny</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><i class="fa fa-fw fa-university col-brown"></i> Town<span
|
||||
class="float-right"><b>Cayon</b></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /.container-fluid -->
|
||||
</div> <!-- End of Server 2 Plugins tab -->
|
||||
<!-- Begin Server 3 Plugins Tab -->
|
||||
<div class="tab">
|
||||
<div class="container-fluid mt-4">
|
||||
<!-- Page Heading -->
|
||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||
<h1 class="h3 mb-0 text-gray-800"><i
|
||||
class="sidebar-toggler fa fa-fw fa-bars"></i>${playerName}
|
||||
· Server 3 Plugins</h1>
|
||||
<a class="btn bg-plan btn-icon-split" href="network">
|
||||
<span class="icon text-white-50">
|
||||
<i class="fas fa-fw fa-arrow-left"></i><i class="fas fa-fw fa-cloud"></i>
|
||||
</span>
|
||||
<span class="text">Network page</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4 mb-4 col-sm-12">
|
||||
<div class="card shadow mb-4">
|
||||
<div class="card-header py-3">
|
||||
<h6 class="m-0 font-weight-bold col-black"><i
|
||||
class="far fa-fw fa-grin-beam-sweat"></i>
|
||||
No Plugins</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>Server 3 has no plugins with Plan support enabled.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /.container-fluid -->
|
||||
</div> <!-- End of Server 3 Plugins tab -->
|
||||
${pluginsTabs}
|
||||
<div class="tab"></div>
|
||||
<div class="tab"></div>
|
||||
<div class="tab"></div>
|
||||
|
Loading…
Reference in New Issue
Block a user