diff --git a/src/org/april/agirstatool/core/pages/ChartPolarView.java b/src/org/april/agirstatool/core/pages/ChartPolarView.java new file mode 100644 index 0000000..11bb089 --- /dev/null +++ b/src/org/april/agirstatool/core/pages/ChartPolarView.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 ChartPolarView +{ + private static Logger logger = LoggerFactory.getLogger(ChartPolarView.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 polar chart view…"); + + String source = XidynUtils.load(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/chartPolarView.xhtml")); + String code = XidynUtils.extractBodyContent(source); + + code = code.replaceAll("myChart", "myChart_" + DigestUtils.md5Hex(title + "chartPolar")); + 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/ProjectPage.java b/src/org/april/agirstatool/core/pages/ProjectPage.java index 78681c0..50fdfbe 100644 --- a/src/org/april/agirstatool/core/pages/ProjectPage.java +++ b/src/org/april/agirstatool/core/pages/ProjectPage.java @@ -56,14 +56,19 @@ public class ProjectPage TagDataManager data = new TagDataManager(); data.setContent("projectName", project.getName()); + data.setAttribute("agirLink", "href", "https://agir.april.org/projects/" + project.getIdentifier() + "/issues"); data.setContent("issueRawChart", IssueStatChartView.build("Issue Raw Count", project)); data.setContent("issueGroupedChart", IssueStatChartView.buildGrouped("Issue Grouped Count", project)); + data.setContent("unassignedRawChart", UnassignedPolarChartView.build("Unassigned Raw Count", project)); + data.setContent("unassignedGroupedChart", UnassignedPolarChartView.buildGrouped("Unassigned Grouped Count", project)); if (project.hasChild()) { data.setContent("issueRawChartAlone", IssueStatChartView.build("Issue Raw Count", project.subProjects().get(0))); data.setContent("issueGroupedChartAlone", IssueStatChartView.buildGrouped("Issue Grouped Count", project.subProjects().get(0))); + data.setContent("unassignedRawChartAlone", UnassignedPolarChartView.build("Unassigned Raw Count", project.subProjects().get(0))); + data.setContent("unassignedGroupedChartAlone", UnassignedPolarChartView.buildGrouped("Unassigned Grouped Count", project.subProjects().get(0))); } String projectsRawView = ProjectsRawView.build(project); diff --git a/src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java b/src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java new file mode 100644 index 0000000..a8815f2 --- /dev/null +++ b/src/org/april/agirstatool/core/pages/UnassignedPolarChartView.java @@ -0,0 +1,96 @@ +/* + * 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.april.agirstatool.core.Project; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.strings.StringList; + +/** + * The Class projectsRawPageBuilder. + */ +public class UnassignedPolarChartView +{ + private static Logger logger = LoggerFactory.getLogger(UnassignedPolarChartView.class); + + /** + * Builds the grouped. + * + * @param stats + * the stats + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String build(final String title, final Project project) throws AgirStatoolException + { + String result; + + logger.info("Building issue stat chart view…"); + + StringList labels = new StringList("Confirmed", "Ongoing", "Waiting", "Resolved", "Rejected", "Closed"); + StringList values = new StringList(); + IssueStats stats = project.issueStats(); + values.append(stats.getUnassignedConfirmedCount()); + values.append(stats.getUnassignedOngoingCount()); + values.append(stats.getUnassignedWaitingCount()); + values.append(stats.getUnassignedResolvedCount()); + values.append(stats.getUnassignedRejectedCount()); + values.append(stats.getUnassignedClosedCount()); + + String targetTitle = title + " – " + project.getName(); + result = ChartPolarView.build(targetTitle, targetTitle, labels, values); + + // + return result; + } + + /** + * Builds the. + * + * @param projects + * the projects + * @return the string + * @throws AgirStatoolException + * the agir statool exception + */ + public static String buildGrouped(final String title, final Project project) throws AgirStatoolException + { + String result; + + logger.info("Building issue stat chart view…"); + + StringList labels = new StringList("Started", "Resolved", "Concluded"); + StringList values = new StringList(); + IssueStats stats = project.issueStats(); + values.append(stats.getUnassignedStartedCount()); + values.append(stats.getUnassignedResolvedCount()); + values.append(stats.getUnassignedConcludedCount()); + + String targetTitle = title + " – " + project.getName(); + result = ChartPolarView.build(targetTitle, targetTitle, labels, values); + + // + return result; + } +} diff --git a/src/org/april/agirstatool/core/pages/chartLineView.xhtml b/src/org/april/agirstatool/core/pages/chartLineView.xhtml new file mode 100644 index 0000000..9d75d14 --- /dev/null +++ b/src/org/april/agirstatool/core/pages/chartLineView.xhtml @@ -0,0 +1,74 @@ + + + + + Agir Statool + + + + + + + +
+ + +
+ + diff --git a/src/org/april/agirstatool/core/pages/chartPolarView.xhtml b/src/org/april/agirstatool/core/pages/chartPolarView.xhtml new file mode 100644 index 0000000..9297017 --- /dev/null +++ b/src/org/april/agirstatool/core/pages/chartPolarView.xhtml @@ -0,0 +1,67 @@ + + + + + Agir Statool + + + + + + + +
+ + +
+ + diff --git a/src/org/april/agirstatool/core/pages/project.xhtml b/src/org/april/agirstatool/core/pages/project.xhtml index fd847ee..6b0f8a1 100644 --- a/src/org/april/agirstatool/core/pages/project.xhtml +++ b/src/org/april/agirstatool/core/pages/project.xhtml @@ -12,13 +12,17 @@
-

Agir Statool – Project n/a

+

Agir StatoolProject n/a

ISSUES BAR CHART
ISSUES BAR CHART
+
+

+
+