Added issue bar charts. Upgraded Xidyn library.

This commit is contained in:
Christian P. MOMON 2020-01-19 23:33:40 +01:00
parent 17be208de5
commit 1aa8ee8637
11 changed files with 309 additions and 56 deletions

BIN
lib/xidyn-1.8.1-sources.zip Normal file

Binary file not shown.

BIN
lib/xidyn-1.8.1.jar Normal file

Binary file not shown.

View File

@ -184,6 +184,7 @@ public class AgirStatool
try try
{ {
// Copy CSS file. // 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/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")); FileUtils.copyURLToFile(AgirStatool.class.getResource("/org/april/agirstatool/core/pages/Chart.bundle.min.js"), new File(this.targetDirectory, "Chart.bundle.min.js"));

View File

@ -25,6 +25,9 @@ import java.util.Date;
import org.apache.commons.lang3.math.NumberUtils; import org.apache.commons.lang3.math.NumberUtils;
import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils;
/** /**
* The Class AgirStatoolUtils. * The Class AgirStatoolUtils.
*/ */
@ -198,6 +201,53 @@ public class AgirStatoolUtils
return result; 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. * To date time.
* *

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -57,6 +57,15 @@ public class ProjectPage
data.setContent("projectName", project.getName()); 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); String projectsRawView = ProjectsRawView.build(project);
data.setContent("projectsRawView", projectsRawView); data.setContent("projectsRawView", projectsRawView);

View File

@ -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>

View File

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

View File

@ -13,59 +13,12 @@
<body> <body>
<div style="margin: 10px;"> <div style="margin: 10px;">
<h1><a href="index.xhtml">Agir Statool</a> Project <span id="projectName">n/a</span></h1> <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;"> <div>
<canvas id="myChart" width="100%" height="100%"></canvas> <div id="issueRawChart" style="display: inline-block;">ISSUES BAR CHART</div>
<script> <div id="issueGroupedChart" style="display: inline-block;">ISSUES BAR CHART</div>
var ctx = document.getElementById('myChart'); <br/>
var myChart = new Chart(ctx, { <div id="issueRawChartAlone" style="display: inline-block;"></div>
type: 'bar', <div id="issueGroupedChartAlone" style="display: inline-block;"></div>
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>
<br/> <br/>
<div> <div>

View File

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