Browse Source

Added issue bar charts. Upgraded Xidyn library.

master
Christian P. MOMON 2 years ago
parent
commit
1aa8ee8637
  1. BIN
      lib/xidyn-1.8.1-sources.zip
  2. BIN
      lib/xidyn-1.8.1.jar
  3. 1
      src/org/april/agirstatool/core/AgirStatool.java
  4. 50
      src/org/april/agirstatool/core/AgirStatoolUtils.java
  5. 75
      src/org/april/agirstatool/core/pages/ChartBarView.java
  6. 91
      src/org/april/agirstatool/core/pages/IssueStatChartView.java
  7. 9
      src/org/april/agirstatool/core/pages/ProjectPage.java
  8. 74
      src/org/april/agirstatool/core/pages/chartBarView.xhtml
  9. 2
      src/org/april/agirstatool/core/pages/index.html
  10. 61
      src/org/april/agirstatool/core/pages/project.xhtml
  11. 2
      src/org/april/agirstatool/core/pages/projectsGroupedView.xhtml

BIN
lib/xidyn-1.8.1-sources.zip

Binary file not shown.

BIN
lib/xidyn-1.8.1.jar

Binary file not shown.

1
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"));

50
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.
*

75
src/org/april/agirstatool/core/pages/ChartBarView.java

@ -0,0 +1,75 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

91
src/org/april/agirstatool/core/pages/IssueStatChartView.java

@ -0,0 +1,91 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian.momon@devinsy.fr>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

9
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);

74
src/org/april/agirstatool/core/pages/chartBarView.xhtml

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Agir Statool</title>
<meta charset="UTF-8" />
<meta content="April" name="keywords" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="agirstatool.css" />
<script src="/commons/sorttable.js" />
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div style="width: 400px; height: 200px; text-align: center; margin: 0 0; border: 1px solid red;">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx,
{
type: 'bar',
data:
{
labels: ['New', 'Started', 'Waiting', 'Maybe', 'Resolved', 'Closed'],
datasets:
[{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor:
[
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor:
[
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options:
{
maintainAspectRatio: false,
scales:
{
xAxes:
[{
ticks:
{
beginAtZero: true
}
}],
yAxes:
[{
ticks:
{
beginAtZero: true
}
}]
}
}
});
</script>
</div>
</body>
</html>

2
src/org/april/agirstatool/core/pages/redirection.xhtml → src/org/april/agirstatool/core/pages/index.html

@ -4,7 +4,7 @@
<head>
<title>Redirection</title>
<meta charset="UTF-8" />
<meta http-equiv="Refresh" content="0;URL=/project-all.xhtml">
<meta http-equiv="Refresh" content="0;URL=index.xhtml">
</head>
<body>

61
src/org/april/agirstatool/core/pages/project.xhtml

@ -13,60 +13,13 @@
<body>
<div style="margin: 10px;">
<h1><a href="index.xhtml">Agir Statool</a> – Project <span id="projectName">n/a</span></h1>
<div style="width: 400px; height: 200px; text-align: center; margin: 0 0; border: 1px solid red;">
<canvas id="myChart" width="100%" height="100%"></canvas>
<script>
var ctx = document.getElementById('myChart');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['New', 'Started', 'Waiting', 'Maybe', 'Resolved', 'Closed'],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255, 99, 132, 1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options:
{
maintainAspectRatio: false,
scales:
{
xAxes:
[{
ticks:
{
beginAtZero: true
}
}],
yAxes:
[{
ticks:
{
beginAtZero: true
}
}]
}
}
});
</script>
</div>
<div>
<div id="issueRawChart" style="display: inline-block;">ISSUES BAR CHART</div>
<div id="issueGroupedChart" style="display: inline-block;">ISSUES BAR CHART</div>
<br/>
<div id="issueRawChartAlone" style="display: inline-block;"></div>
<div id="issueGroupedChartAlone" style="display: inline-block;"></div>
</div>
<br/>
<div>
<div style="margin: 4px;">

2
src/org/april/agirstatool/core/pages/projectsGroupedView.xhtml

@ -12,7 +12,7 @@
<body>
<table class="table_classic">
<tr>
<th rowspan="2">ID</th>
<th rowspan="2" style="width: 30px;">ID</th>
<th rowspan="2">Name</th>
<th rowspan="2">Child</th>
<th colspan="5">Issues count</th>

Loading…
Cancel
Save