From 8fbb3679dd72a5f51bdc292b02ec2d2ea5167e8e Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 6 Sep 2017 14:58:29 +0300 Subject: [PATCH] Fixed WorldPie for sessions --- .../info/parsing/InspectPageParser.java | 4 ++- .../plan/utilities/html/HtmlStructure.java | 32 ++++++++++--------- .../html/graphs/WorldPieCreator.java | 5 ++- Plan/src/main/resources/Placeholders.txt | 1 + Plan/src/main/resources/html/player.html | 1 + Plan/src/main/resources/js/worldPie.js | 2 +- .../utilities/html/HtmlStructureTest.java | 6 ++-- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index c2e3ec16a..1cf3f57e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -90,7 +90,9 @@ public class InspectPageParser extends PageParser { .sorted(new SessionStartComparator()) .collect(Collectors.toList()); - addValue("contentSessions", HtmlStructure.createSessionsTabContent(sessions, allSessions)); + String[] sessionsTabContent = HtmlStructure.createSessionsTabContent(sessions, allSessions); + addValue("contentSessions", sessionsTabContent[0]); + addValue("sessionTabGraphViewFunctions", sessionsTabContent[1]); addValue("contentServerOverview", HtmlStructure.createServerOverviewColumn(sessions)); long now = MiscUtils.getTime(); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java index 34727cb83..79843f832 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/HtmlStructure.java @@ -84,7 +84,7 @@ public class HtmlStructure { return builder.toString(); } - public static String createSessionsTabContent(Map> sessions, List allSessions) throws FileNotFoundException { + public static String[] createSessionsTabContent(Map> sessions, List allSessions) throws FileNotFoundException { Map serverNameIDRelationMap = new HashMap<>(); for (Map.Entry> entry : sessions.entrySet()) { @@ -95,7 +95,8 @@ public class HtmlStructure { } } - StringBuilder builder = new StringBuilder(); + StringBuilder html = new StringBuilder(); + StringBuilder viewScript = new StringBuilder(); int i = 0; for (Session session : allSessions) { if (i >= 50) { @@ -109,7 +110,7 @@ public class HtmlStructure { String dotSeparated = separateWithDots(sessionStart, sessionLength); // Session-column starts & header. - builder.append("
") + html.append("
") .append("
") .append("
") .append("

").append(dotSeparated).append("

") @@ -120,57 +121,58 @@ public class HtmlStructure { String serverName = serverNameIDRelationMap.get(session.getSessionID()); // Left side of Session box - builder.append("
") + html.append("
") .append("
") // .append("
"); // Left side header - builder.append("
") + html.append("
") .append("

") .append(sessionStart) .append("

") .append("
"); // Left side content - builder.append("
") + html.append("
") .append("

Session Length: ").append(sessionLength).append("
") .append("Session Ended: ").append(sessionEnd).append("
") .append("Server: ").append(serverName).append("

") .append("Mob Kills: ").append(session.getMobKills()).append("
") .append("Deaths: ").append(session.getDeaths()).append("

"); - builder.append(KillsTableCreator.createTable(session.getPlayerKills())) + html.append(KillsTableCreator.createTable(session.getPlayerKills())) .append("
"); // Left Side content ends // Left side ends & Right side starts - builder.append("
") + html.append("
") .append("
"); String id = "worldPie" + session.getSessionStart(); - builder.append("
"); + html.append("
"); String[] worldData = WorldPieCreator.createSeriesData(session.getWorldTimes()); - builder.append(""); + + viewScript.append("worldPie(") .append(id).append(", ") .append(id).append("series, ") .append(id).append("gmseries") - .append(");})") - .append(""); + .append(");"); // Session-col, Row, Session-Content, Session-column ends. - builder.append("
") + html.append("
") .append("
") .append("
") .append("
"); i++; } - return builder.toString(); + return new String[]{html.toString(), viewScript.toString()}; } public static String createInspectPageTabContent(String serverName, List plugins, Map replaceMap) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java index 6031e370e..b5eb2950d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java @@ -52,9 +52,10 @@ public class WorldPieCreator { Map gmTimesMap = worldTimes.getWorldTimes(); if (gmTimesMap.isEmpty()) { - return "{[]}"; + return "[{[]}]"; } int size = gmTimesMap.size(); + drilldownBuilder.append("["); for (Map.Entry world : gmTimesMap.entrySet()) { drilldownBuilder.append("{name:'").append(world.getKey()) .append("', id:'").append(world.getKey()) @@ -68,6 +69,7 @@ public class WorldPieCreator { } i++; } + drilldownBuilder.append("]"); return drilldownBuilder.toString(); } @@ -78,6 +80,7 @@ public class WorldPieCreator { for (Map.Entry entry : gmTimes.entrySet()) { Long time = entry.getValue(); if (time == 0) { + j++; continue; } drilldownBuilder.append("['") diff --git a/Plan/src/main/resources/Placeholders.txt b/Plan/src/main/resources/Placeholders.txt index b5655498f..e2fc5c674 100644 --- a/Plan/src/main/resources/Placeholders.txt +++ b/Plan/src/main/resources/Placeholders.txt @@ -32,6 +32,7 @@ ${sessionLengthLongestDay} timeamount ${sessionLengthLongestWeek} timeamount ${contentSessions} See example page +${sessionTabGraphViewFunctions} function calls that call the graphs to be viewed. ${contentServerOverview} See example page ${tabContentPlugins} See example page diff --git a/Plan/src/main/resources/html/player.html b/Plan/src/main/resources/html/player.html index 9a67ab356..705f38281 100644 --- a/Plan/src/main/resources/html/player.html +++ b/Plan/src/main/resources/html/player.html @@ -225,6 +225,7 @@ worldPie('worldPie', worldSeries, gmSeries); punchCard('punchcard', punchcardSeries); + ${sessionTabGraphViewFunctions} openFunc(slideIndex)(); diff --git a/Plan/src/main/resources/js/worldPie.js b/Plan/src/main/resources/js/worldPie.js index f587f2f8a..3d72cc926 100644 --- a/Plan/src/main/resources/js/worldPie.js +++ b/Plan/src/main/resources/js/worldPie.js @@ -27,7 +27,7 @@ function worldPie(id, worldSeries, gmSeries) { }, series: [worldSeries], drilldown: { - series: [gmSeries] + series: gmSeries } }); } diff --git a/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java b/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java index bef397335..8ae475356 100644 --- a/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java +++ b/Plan/test/main/java/com/djrapitops/plan/utilities/html/HtmlStructureTest.java @@ -52,10 +52,10 @@ public class HtmlStructureTest { @Test public void createSessionsTabContent() throws Exception { List allSessions = sessions.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); - String sessionsTab = HtmlStructure.createSessionsTabContent(sessions, allSessions); + String[] sessionsTab = HtmlStructure.createSessionsTabContent(sessions, allSessions); - int opened = StringUtils.countMatches(sessionsTab, "