mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-03 01:10:17 +01: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.
|
* Responsible for generating /server page plugin tabs based on DataExtension API data.
|
||||||
* <p>
|
* <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.
|
* This will become more complex once tables are added, since some big tables will be moved to their own tabs.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
@ -91,9 +91,9 @@ public class AnalysisPluginTabs {
|
|||||||
private void generate() {
|
private void generate() {
|
||||||
if (serverData.isEmpty()) {
|
if (serverData.isEmpty()) {
|
||||||
nav = new NavLink(Icon.called("cubes").build(), "Overview (No Data)").toHtml();
|
nav = new NavLink(Icon.called("cubes").build(), "Overview (No Data)").toHtml();
|
||||||
tab = "<div class=\"tab\"><div class=\"row clearfix\">" +
|
tab = wrapInTab(
|
||||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<div class=\"card-body\"><p>No Extension Data</p></div>") +
|
"<div class=\"col-md-12\">" + Html.CARD.parse("<div class=\"card-body\"><p>No Extension Data</p></div>") + "</div>"
|
||||||
"</div></div></div>";
|
);
|
||||||
} else {
|
} else {
|
||||||
nav = new NavLink(Icon.called("cubes").build(), "Overview").toHtml();
|
nav = new NavLink(Icon.called("cubes").build(), "Overview").toHtml();
|
||||||
tab = generatePageTab();
|
tab = generatePageTab();
|
||||||
|
@ -147,16 +147,16 @@ public class PageFactory {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InspectPluginTab inspectPluginTabs(UUID playerUUID) {
|
public PlayerPluginTab inspectPluginTabs(UUID playerUUID) {
|
||||||
Database database = dbSystem.get().getDatabase();
|
Database database = dbSystem.get().getDatabase();
|
||||||
|
|
||||||
Map<UUID, List<ExtensionPlayerData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
|
Map<UUID, List<ExtensionPlayerData>> extensionPlayerData = database.query(new ExtensionPlayerDataQuery(playerUUID));
|
||||||
|
|
||||||
if (extensionPlayerData.isEmpty()) {
|
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()) {
|
for (Map.Entry<UUID, Server> entry : database.query(ServerQueries.fetchPlanServerInformation()).entrySet()) {
|
||||||
UUID serverUUID = entry.getKey();
|
UUID serverUUID = entry.getKey();
|
||||||
String serverName = entry.getValue().getIdentifiableName();
|
String serverName = entry.getValue().getIdentifiableName();
|
||||||
@ -166,18 +166,18 @@ public class PageFactory {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
inspectPluginTabs.add(new InspectPluginTab(serverName, ofServer, formatters.get()));
|
playerPluginTabs.add(new PlayerPluginTab(serverName, ofServer, formatters.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder navs = new StringBuilder();
|
StringBuilder navs = new StringBuilder();
|
||||||
StringBuilder tabs = new StringBuilder();
|
StringBuilder tabs = new StringBuilder();
|
||||||
|
|
||||||
inspectPluginTabs.stream().sorted().forEach(tab -> {
|
playerPluginTabs.stream().sorted().forEach(tab -> {
|
||||||
navs.append(tab.getNav());
|
navs.append(tab.getNav());
|
||||||
tabs.append(tab.getTab());
|
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>");
|
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("navPluginsTabs", pluginTabs.getNav());
|
||||||
replacer.put("pluginsTabs", pluginTabs.getTab());
|
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.formatting.Formatters;
|
||||||
import com.djrapitops.plan.utilities.html.Html;
|
import com.djrapitops.plan.utilities.html.Html;
|
||||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
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 com.djrapitops.plan.utilities.html.structure.TabsElement;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -37,7 +38,7 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
|
||||||
|
|
||||||
private String serverName;
|
private String serverName;
|
||||||
private List<ExtensionPlayerData> playerData;
|
private List<ExtensionPlayerData> playerData;
|
||||||
@ -52,12 +53,12 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
|||||||
|
|
||||||
private boolean hasWideTable;
|
private boolean hasWideTable;
|
||||||
|
|
||||||
public InspectPluginTab(String nav, String tab) {
|
public PlayerPluginTab(String nav, String tab) {
|
||||||
this.nav = nav;
|
this.nav = nav;
|
||||||
this.tab = tab;
|
this.tab = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InspectPluginTab(
|
public PlayerPluginTab(
|
||||||
String serverName,
|
String serverName,
|
||||||
List<ExtensionPlayerData> playerData,
|
List<ExtensionPlayerData> playerData,
|
||||||
Formatters formatters
|
Formatters formatters
|
||||||
@ -89,12 +90,12 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
|||||||
|
|
||||||
private void generate() {
|
private void generate() {
|
||||||
if (playerData.isEmpty()) {
|
if (playerData.isEmpty()) {
|
||||||
nav = "<li><a class=\"nav-button\" href=\"javascript:void(0)\">" + serverName + " (No Data)</a></li>";
|
nav = NavLink.collapsed(Icon.called("cubes").build(), serverName + " (No Data)").toHtml();
|
||||||
tab = "<div class=\"tab\"><div class=\"row clearfix\">" +
|
tab = wrapInTab(
|
||||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<p>No Data (" + serverName + ")</p>") +
|
"<div class=\"col-md-12\">" + Html.CARD.parse("<div class=\"card-body\"><p>No Extension Data</p></div>") + "</div>"
|
||||||
"</div></div></div>";
|
);
|
||||||
} else {
|
} 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();
|
tab = generatePageTab();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +127,13 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String wrapInTab(String content) {
|
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) {
|
private TabsElement.Tab wrapToTabElementTab(ExtensionTabData tabData) {
|
||||||
@ -202,9 +209,9 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
|||||||
|
|
||||||
private String wrapInContainer(ExtensionInformation information, String tabsElement) {
|
private String wrapInContainer(ExtensionInformation information, String tabsElement) {
|
||||||
String colWidth = hasWideTable ? "col-md-8 col-lg-8" : "col-md-4 col-lg-4";
|
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\">" +
|
return "<div class=\"col-xs-12 col-sm-12 " + colWidth + "\"><div class=\"card shadow mb-0\">" +
|
||||||
"<div class=\"header\">" +
|
"<div class=\"card-header py-3\">" +
|
||||||
"<h2>" + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "</h2>" +
|
"<h6 class=\"m-0 font-weight-bold col-black\">" + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "</h6>" +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
tabsElement +
|
tabsElement +
|
||||||
"</div></div>";
|
"</div></div>";
|
||||||
@ -213,8 +220,8 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (!(o instanceof InspectPluginTab)) return false;
|
if (!(o instanceof PlayerPluginTab)) return false;
|
||||||
InspectPluginTab that = (InspectPluginTab) o;
|
PlayerPluginTab that = (PlayerPluginTab) o;
|
||||||
return Objects.equals(serverName, that.serverName) &&
|
return Objects.equals(serverName, that.serverName) &&
|
||||||
Objects.equals(nav, that.nav);
|
Objects.equals(nav, that.nav);
|
||||||
}
|
}
|
||||||
@ -225,7 +232,7 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(InspectPluginTab other) {
|
public int compareTo(PlayerPluginTab other) {
|
||||||
return String.CASE_INSENSITIVE_ORDER.compare(this.serverName, other.serverName);
|
return String.CASE_INSENSITIVE_ORDER.compare(this.serverName, other.serverName);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,13 +27,32 @@ public class NavLink {
|
|||||||
|
|
||||||
private final Icon icon;
|
private final Icon icon;
|
||||||
private final String tabName;
|
private final String tabName;
|
||||||
|
private final boolean collapsed;
|
||||||
|
|
||||||
public NavLink(Icon icon, String tabName) {
|
public NavLink(Icon icon, String tabName) {
|
||||||
|
this(icon, tabName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NavLink(Icon icon, String tabName, boolean collapsed) {
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.tabName = tabName;
|
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() {
|
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\">" +
|
return "<li class=\"nav-item nav-button\">" +
|
||||||
"<a class=\"nav-link\" href=\"javascript:void(0)\">" +
|
"<a class=\"nav-link\" href=\"javascript:void(0)\">" +
|
||||||
icon.toHtml() +
|
icon.toHtml() +
|
||||||
|
@ -93,12 +93,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<div aria-labelledby="headingPages" class="collapse" data-parent="#accordionSidebar" id="pluginsPages">
|
<div aria-labelledby="headingPages" class="collapse" data-parent="#accordionSidebar" id="pluginsPages">
|
||||||
<div class="bg-white py-2 collapse-inner rounded">
|
<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>
|
${navPluginsTabs}
|
||||||
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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@ -422,8 +417,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><b><i class="col-red fa fa-fw fa-crosshairs"></i></b> Average KDR / Player
|
<td><b><i class="col-red fa fa-fw fa-crosshairs"></i> KDR</b></td>
|
||||||
</td>
|
|
||||||
<td id="data_player_kdr_total"></td>
|
<td id="data_player_kdr_total"></td>
|
||||||
<td id="data_player_kdr_30d"></td>
|
<td id="data_player_kdr_30d"></td>
|
||||||
<td id="data_player_kdr_7d"></td>
|
<td id="data_player_kdr_7d"></td>
|
||||||
@ -443,7 +437,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<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_total"></td>
|
||||||
<td id="data_mob_kdr_30d"></td>
|
<td id="data_mob_kdr_30d"></td>
|
||||||
<td id="data_mob_kdr_7d"></td>
|
<td id="data_mob_kdr_7d"></td>
|
||||||
@ -571,101 +565,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div> <!-- /.container-fluid -->
|
</div> <!-- /.container-fluid -->
|
||||||
</div> <!-- End of Servers Overview Tab-->
|
</div> <!-- End of Servers Overview Tab-->
|
||||||
<!-- Begin Server 1 Plugins Tab -->
|
${pluginsTabs}
|
||||||
<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 -->
|
|
||||||
<div class="tab"></div>
|
<div class="tab"></div>
|
||||||
<div class="tab"></div>
|
<div class="tab"></div>
|
||||||
<div class="tab"></div>
|
<div class="tab"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user