diff --git a/lib/xidyn-1.8.1-sources.zip b/lib/xidyn-1.8.1-sources.zip new file mode 100644 index 0000000..b22f9ea Binary files /dev/null and b/lib/xidyn-1.8.1-sources.zip differ diff --git a/lib/xidyn-1.8.1.jar b/lib/xidyn-1.8.1.jar new file mode 100644 index 0000000..cc8e8ed Binary files /dev/null and b/lib/xidyn-1.8.1.jar differ diff --git a/src/org/april/agirstatool/core/AgirStatool.java b/src/org/april/agirstatool/core/AgirStatool.java index b93b728..bc06ec2 100644 --- a/src/org/april/agirstatool/core/AgirStatool.java +++ b/src/org/april/agirstatool/core/AgirStatool.java @@ -184,6 +184,7 @@ public class AgirStatool try { // Copy CSS file. + FileUtils.copyURLToFile(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/index.html"), new File(this.targetDirectory, "index.html")); FileUtils.copyURLToFile(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/agirstatool.css"), new File(this.targetDirectory, "agirstatool.css")); FileUtils.copyURLToFile(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/Chart.bundle.min.js"), new File(this.targetDirectory, "Chart.bundle.min.js")); diff --git a/src/org/april/agirstatool/core/AgirStatoolUtils.java b/src/org/april/agirstatool/core/AgirStatoolUtils.java index 03a8aad..2ab54f9 100644 --- a/src/org/april/agirstatool/core/AgirStatoolUtils.java +++ b/src/org/april/agirstatool/core/AgirStatoolUtils.java @@ -25,6 +25,9 @@ import java.util.Date; import org.apache.commons.lang3.math.NumberUtils; +import fr.devinsy.strings.StringList; +import fr.devinsy.strings.StringsUtils; + /** * The Class AgirStatoolUtils. */ @@ -198,6 +201,53 @@ public class AgirStatoolUtils return result; } + /** + * To Json numbers. + * + * @param source + * the source + * @return the string + */ + public static String toJSonNumbers(final StringList source) + { + String result; + + result = StringsUtils.toString(source, "[", ",", "]"); + + // + return result; + } + + /** + * To Json strings. + * + * @param source + * the source + * @return the string + */ + public static String toJSonStrings(final StringList source) + { + String result; + + StringList target = new StringList(); + + target.append("["); + for (String string : source) + { + target.append("'"); + target.append(string); + target.append("'"); + target.append(","); + } + target.removeLast(); + target.append("]"); + + result = target.toString(); + + // + return result; + } + /** * To date time. * diff --git a/src/org/april/agirstatool/core/pages/ChartBarView.java b/src/org/april/agirstatool/core/pages/ChartBarView.java new file mode 100644 index 0000000..20ab2fd --- /dev/null +++ b/src/org/april/agirstatool/core/pages/ChartBarView.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of AgirStatool, simple key value database. + * + * AgirStatool is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * AgirStatool is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with AgirStatool. If not, see . + */ +package org.april.agirstatool.core.pages; + +import java.io.IOException; + +import org.apache.commons.codec.digest.DigestUtils; +import org.april.agirstatool.core.AgirStatool; +import org.april.agirstatool.core.AgirStatoolException; +import org.april.agirstatool.core.AgirStatoolUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; +import fr.devinsy.xidyn.utils.XidynUtils; + +/** + * The Class projectsRawPageBuilder. + */ +public class ChartBarView +{ + private static Logger logger = LoggerFactory.getLogger(ChartBarView.class); + + /** + * Builds the. + * + * @param projects + * the projects + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final String labelTitle, final StringList labels, final StringList values) throws AgirStatoolException + { + String result; + + try + { + logger.info("Building chartBar view…"); + + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartBarView.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title)); + code = code.replace("# of Votes", labelTitle); + code = code.replaceAll("labels: \\[.*\\]", "labels: " + AgirStatoolUtils.toJSonStrings(labels)); + code = code.replaceAll("data: \\[.*\\]", "data: " + AgirStatoolUtils.toJSonNumbers(values)); + + result = code.toString(); + } + catch (IOException exception) + { + throw new AgirStatoolException("Error building ProjectsRaw view: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/org/april/agirstatool/core/pages/IssueStatChartView.java b/src/org/april/agirstatool/core/pages/IssueStatChartView.java new file mode 100644 index 0000000..dbbf13f --- /dev/null +++ b/src/org/april/agirstatool/core/pages/IssueStatChartView.java @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of AgirStatool, simple key value database. + * + * AgirStatool is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * AgirStatool is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with AgirStatool. If not, see . + */ +package org.april.agirstatool.core.pages; + +import org.april.agirstatool.core.AgirStatoolException; +import org.april.agirstatool.core.IssueStats; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; + +/** + * The Class projectsRawPageBuilder. + */ +public class IssueStatChartView +{ + private static Logger logger = LoggerFactory.getLogger(IssueStatChartView.class); + + /** + * Builds the. + * + * @param projects + * the projects + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final IssueStats stats) throws AgirStatoolException + { + String result; + + logger.info("Building issue stat chart view…"); + + StringList labels = new StringList("Maybe", "New", "Confirmed", "Ongoing", "Waiting", "Resolved"); + StringList values = new StringList(); + values.append(stats.getMaybeCount()); + values.append(stats.getNewCount()); + values.append(stats.getConfirmedCount()); + values.append(stats.getOngoingCount()); + values.append(stats.getWaitingCount()); + values.append(stats.getResolvedCount()); + + result = ChartBarView.build(title, title, labels, values); + + // + return result; + } + + /** + * Builds the grouped. + * + * @param stats + * the stats + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String buildGrouped(final String title, final IssueStats stats) throws AgirStatoolException + { + String result; + + logger.info("Building issue stat chart view…"); + + StringList labels = new StringList("Maybe", "Active", "Resolved"); + StringList values = new StringList(); + values.append(stats.getMaybeCount()); + values.append(stats.getActiveCount()); + values.append(stats.getResolvedCount()); + + result = ChartBarView.build(title, title, labels, values); + + // + return result; + } +} diff --git a/src/org/april/agirstatool/core/pages/ProjectPage.java b/src/org/april/agirstatool/core/pages/ProjectPage.java index b17adc6..528588b 100644 --- a/src/org/april/agirstatool/core/pages/ProjectPage.java +++ b/src/org/april/agirstatool/core/pages/ProjectPage.java @@ -57,6 +57,15 @@ public class ProjectPage data.setContent("projectName", project.getName()); + data.setContent("issueRawChart", IssueStatChartView.build("Issue Raw Count", project.issueStats())); + data.setContent("issueGroupedChart", IssueStatChartView.buildGrouped("Issue Grouped Count", project.issueStats())); + + if (project.hasChild()) + { + data.setContent("issueRawChartAlone", IssueStatChartView.build("Issue Raw Count (#)", project.subProjects().get(0).issueStats())); + data.setContent("issueGroupedChartAlone", IssueStatChartView.buildGrouped("Issue Grouped Count (#)", project.subProjects().get(0).issueStats())); + } + String projectsRawView = ProjectsRawView.build(project); data.setContent("projectsRawView", projectsRawView); diff --git a/src/org/april/agirstatool/core/pages/chartBarView.xhtml b/src/org/april/agirstatool/core/pages/chartBarView.xhtml new file mode 100644 index 0000000..ffd86e2 --- /dev/null +++ b/src/org/april/agirstatool/core/pages/chartBarView.xhtml @@ -0,0 +1,74 @@ + + + + + Agir Statool + + + + + + + +
+ + +
+ + diff --git a/src/org/april/agirstatool/core/pages/redirection.xhtml b/src/org/april/agirstatool/core/pages/index.html similarity index 76% rename from src/org/april/agirstatool/core/pages/redirection.xhtml rename to src/org/april/agirstatool/core/pages/index.html index f4bd1a2..5692654 100644 --- a/src/org/april/agirstatool/core/pages/redirection.xhtml +++ b/src/org/april/agirstatool/core/pages/index.html @@ -4,7 +4,7 @@ Redirection - + diff --git a/src/org/april/agirstatool/core/pages/project.xhtml b/src/org/april/agirstatool/core/pages/project.xhtml index baac400..fd847ee 100644 --- a/src/org/april/agirstatool/core/pages/project.xhtml +++ b/src/org/april/agirstatool/core/pages/project.xhtml @@ -13,60 +13,13 @@

Agir Statool – Project n/a

-
- - -
+
+
ISSUES BAR CHART
+
ISSUES BAR CHART
+
+
+
+

diff --git a/src/org/april/agirstatool/core/pages/projectsGroupedView.xhtml b/src/org/april/agirstatool/core/pages/projectsGroupedView.xhtml index e77a6c8..8667874 100644 --- a/src/org/april/agirstatool/core/pages/projectsGroupedView.xhtml +++ b/src/org/april/agirstatool/core/pages/projectsGroupedView.xhtml @@ -12,7 +12,7 @@ - +
IDID Name Child Issues count