From f905f3c879eb9798b952ff9d1c5a2c1f150e1f0c Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Fri, 26 Jul 2019 12:40:10 +0300 Subject: [PATCH] Player page plugins tabs --- .../html/pages/AnalysisPluginTabs.java | 8 +- .../utilities/html/pages/PageFactory.java | 12 +- .../plan/utilities/html/pages/PlayerPage.java | 2 +- ...ectPluginTab.java => PlayerPluginTab.java} | 37 +++--- .../utilities/html/structure/NavLink.java | 19 +++ .../resources/assets/plan/web/player.html | 108 +----------------- 6 files changed, 56 insertions(+), 130 deletions(-) rename Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/{InspectPluginTab.java => PlayerPluginTab.java} (85%) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPluginTabs.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPluginTabs.java index cb19a52be..b51094b48 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPluginTabs.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/AnalysisPluginTabs.java @@ -36,7 +36,7 @@ import java.util.*; /** * Responsible for generating /server page plugin tabs based on DataExtension API data. *

- * 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 = "

" + - "
" + Html.CARD.parse("

No Extension Data

") + - "
"; + tab = wrapInTab( + "
" + Html.CARD.parse("

No Extension Data

") + "
" + ); } else { nav = new NavLink(Icon.called("cubes").build(), "Overview").toHtml(); tab = generatePageTab(); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PageFactory.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PageFactory.java index 4bfdc5eee..f554b4a59 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PageFactory.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PageFactory.java @@ -147,16 +147,16 @@ public class PageFactory { ); } - public InspectPluginTab inspectPluginTabs(UUID playerUUID) { + public PlayerPluginTab inspectPluginTabs(UUID playerUUID) { Database database = dbSystem.get().getDatabase(); Map> 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 inspectPluginTabs = new ArrayList<>(); + List playerPluginTabs = new ArrayList<>(); for (Map.Entry 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()); } /** diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPage.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPage.java index 2ad5711a3..3c0c79196 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPage.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPage.java @@ -113,7 +113,7 @@ public class PlayerPage implements Page { replacer.put("backButton", "
  • arrow_backstorage
  • "); } - InspectPluginTab pluginTabs = pageFactory.inspectPluginTabs(playerUUID); + PlayerPluginTab pluginTabs = pageFactory.inspectPluginTabs(playerUUID); replacer.put("navPluginsTabs", pluginTabs.getNav()); replacer.put("pluginsTabs", pluginTabs.getTab()); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPluginTab.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPluginTab.java similarity index 85% rename from Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPluginTab.java rename to Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPluginTab.java index f25e9b219..2f96dadd2 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/InspectPluginTab.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/pages/PlayerPluginTab.java @@ -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 { +public class PlayerPluginTab implements Comparable { private String serverName; private List playerData; @@ -52,12 +53,12 @@ public class InspectPluginTab implements Comparable { 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 playerData, Formatters formatters @@ -89,12 +90,12 @@ public class InspectPluginTab implements Comparable { private void generate() { if (playerData.isEmpty()) { - nav = "
  • " + serverName + " (No Data)
  • "; - tab = "
    " + - "
    " + Html.CARD.parse("

    No Data (" + serverName + ")

    ") + - "
    "; + nav = NavLink.collapsed(Icon.called("cubes").build(), serverName + " (No Data)").toHtml(); + tab = wrapInTab( + "
    " + Html.CARD.parse("

    No Extension Data

    ") + "
    " + ); } else { - nav = "
  • " + serverName + "
  • "; + nav = NavLink.collapsed(Icon.called("cubes").build(), serverName).toHtml(); tab = generatePageTab(); } } @@ -126,7 +127,13 @@ public class InspectPluginTab implements Comparable { } private String wrapInTab(String content) { - return "
    " + content + "
    "; + return "
    " + + // Page heading + "
    " + + "

    ${playerName} · " + serverName + " Plugins

    " + + "
    " + + // End Page heading + "
    " + content + "
    "; } private TabsElement.Tab wrapToTabElementTab(ExtensionTabData tabData) { @@ -202,9 +209,9 @@ public class InspectPluginTab implements Comparable { private String wrapInContainer(ExtensionInformation information, String tabsElement) { String colWidth = hasWideTable ? "col-md-8 col-lg-8" : "col-md-4 col-lg-4"; - return "
    " + - "
    " + - "

    " + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "

    " + + return "
    " + + "
    " + + "
    " + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "
    " + "
    " + tabsElement + "
    "; @@ -213,8 +220,8 @@ public class InspectPluginTab implements Comparable { @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 { } @Override - public int compareTo(InspectPluginTab other) { + public int compareTo(PlayerPluginTab other) { return String.CASE_INSENSITIVE_ORDER.compare(this.serverName, other.serverName); } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/structure/NavLink.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/structure/NavLink.java index 12aed002f..fa9598ab0 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/structure/NavLink.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/structure/NavLink.java @@ -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 "" + + icon.toHtml() + ' ' + + tabName + ""; + } return "
  • " + "" + icon.toHtml() + diff --git a/Plan/common/src/main/resources/assets/plan/web/player.html b/Plan/common/src/main/resources/assets/plan/web/player.html index f940e3036..20fc38222 100644 --- a/Plan/common/src/main/resources/assets/plan/web/player.html +++ b/Plan/common/src/main/resources/assets/plan/web/player.html @@ -93,12 +93,7 @@
    - - Server 1 - - Server 2 - - Server 3 + ${navPluginsTabs}
  • @@ -422,8 +417,7 @@ - Average KDR / Player - + KDR @@ -443,7 +437,7 @@ - Average Mob KDR + Mob KDR @@ -571,101 +565,7 @@
    - -
    -
    - -
    -

    ${playerName} - · Server 1 Plugins

    - - - - - Network page - -
    -
    -
    -
    -
    -
    - AdvancedAchievements
    -
    -
    -

    Achievements9

    -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -

    ${playerName} - · Server 2 Plugins

    - - - - - Network page - -
    -
    -
    -
    -
    -
    - Towny
    -
    -
    -

    TownCayon

    -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -

    ${playerName} - · Server 3 Plugins

    - - - - - Network page - -
    -
    -
    -
    -
    -
    - No Plugins
    -
    -
    -

    Server 3 has no plugins with Plan support enabled.

    -
    -
    -
    -
    -
    -
    + ${pluginsTabs}