Commit 179608e9 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

project distribution graph ok

parent 1c4bfd06
......@@ -693,7 +693,12 @@ class tx_nG6_eid {
$role = trim(t3lib_div::_GP('role'));
$by = trim(t3lib_div::_GP('by'));
print json_encode(tx_nG6_db::select_projects_repartition($role, $by));
}
} elseif($type == 'project_distribution') {
$values = split(",", trim(t3lib_div::_GP('values')));
$by = trim(t3lib_div::_GP('by'));
$role = trim(t3lib_div::_GP('role'));
print json_encode(tx_nG6_db::select_projects_distribution($values, $by, $role));
}
}
/**
......
......@@ -245,6 +245,48 @@ class tx_nG6_db {
}
}
function select_projects_distribution($values, $by, $role) {
$from = "" ;
$where = "" ;
if ($by == "organism" || $by == "location") {
$by = "tx_nG6_".$by;
}
if ($role == "create_user") {
$from = 'tx_nG6_project '
.' INNER JOIN fe_users ON tx_nG6_project.cruser_id=fe_users.uid '
.' INNER JOIN fe_groups ON fe_groups.uid=fe_users.usergroup ' ;
} else if ($role == "manager") {
$from = 'tx_nG6_project '
.' INNER JOIN fe_rights ON tx_nG6_project.uid=fe_rights.project_id '
.' INNER JOIN fe_users ON fe_rights.fe_user_id=fe_users.uid '
.' INNER JOIN fe_groups ON fe_groups.uid=fe_users.usergroup ';
$where = "fe_rights.right_id=1" ;
}
$queryParts = array(
'SELECT' => 'fe_groups.'.$by.', count(fe_groups.'.$by.') nb',
'FROM' => $from,
'WHERE' => $where,
'GROUPBY' => 'fe_groups.'.$by,
'ORDERBY' => '',
'LIMIT' => ''
);
$results = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$others = 0 ;
while($res_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if( in_array($res_row[$by], $values) ) {
$results[] = array($res_row[$by], $res_row["nb"]);
} else {
$others += $res_row["nb"] ;
}
}
if ($others != 0) {
$results[] = array("OTHERS", $others);
}
return $results;
}
/*
* Project functions
*------------------------------------------------------------*/
......
......@@ -36,15 +36,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="sub-content sc-bottom">
<ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#wf_monitoring" data-toggle="tab">Workflows monitoring</a></li>
<li><a href="#statistics" data-toggle="tab">Statistics</a></li>
<li class="active"><a href="#statistics" data-toggle="tab">Statistics</a></li>
<li><a href="#wf_monitoring" data-toggle="tab">Workflows monitoring</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="wf_monitoring"></div>
<div class="tab-pane fade" id="statistics">
<div class="tab-pane fade in active" id="statistics">
<div id="stat_menu">
<legend>1. Which users should be considered ?</legend>
......@@ -115,16 +113,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<div class="row">
<div class="span2 offset9">
<div class="btn-group" data-toggle="buttons-radio">
<button type="button" id="distribution" class="btn btn-primary"> <i class="icon-certificate icon-white"></i> distribution</button>
<button type="button" id="evolution" class="btn"><i class="icon-random"></i> evolution</button>
<button type="button" id="project_distribution" class="multiple-selection-btn btn btn-primary"> <i class="icon-certificate icon-white"></i> distribution</button>
<button type="button" id="project_evolution" class="multiple-selection-btn btn"><i class="icon-random"></i> evolution</button>
</div>
</div>
</div>
</div>
<div id="project_graph"> </div>
<div id="highcharts_graph"> </div>
</div>
<div class="tab-pane fade" id="wf_monitoring"></div>
</div>
</div>
......
......@@ -29,35 +29,11 @@
$(function () {
$('#myTab').tab();
redraw_chart();
// Init tables
var stat_tables = initStatMenuDataTable();
// group list
$("select[id=group_list]").change(function(){
redraw_chart();
});
// get analyzes ?
$("#chk_get_analyzes").change(function(){
redraw_chart();
});
// get cumulatives ?
$("#chk_get_cumulative").change(function(){
redraw_chart();
});
updateButtons();
// statistics menu handling
$(':radio[id=select_cruser]').attr('checked','checked');
......@@ -77,10 +53,28 @@ $(function () {
$(":radio[id^=select_]").change(function(){
refreshTable(stat_tables);
});
$("[id^=chk_all_]").change(function(){
var type = $(this).attr("id").split("_")[2];
var chk_status = $(this).attr("checked") == "checked" ? true : false ;
$("#data_table_"+type).find(":checkbox").each(function(){
$(this).attr("checked", chk_status);
})
})
$(":checkbox").change(function(){
updateButtons();
})
Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
};
});
......@@ -92,66 +86,11 @@ $(function () {
Highcharts.getOptions().colors = Highcharts.map(Highcharts.getOptions().colors, function(color) {
return {
radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
};
});
$.ajax({
url: "index.php?eID=tx_nG6&type=project_repartition&role=create_user",
dataType: "json",
success: function(data) {
$('#project_graph').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
width: 930
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['Firefox', 45.0],
['IE', 26.8],
{
name: 'Chrome',
y: 12.8,
sliced: true,
selected: true
},
['Safari', 8.5],
['Opera', 6.2],
['Others', 0.7]
]
}]
});
}
});
......@@ -164,8 +103,21 @@ $(function () {
/*
redraw_chart();
// group list
$("select[id=group_list]").change(function(){
redraw_chart();
});
// get analyzes ?
$("#chk_get_analyzes").change(function(){
redraw_chart();
});
// get cumulatives ?
$("#chk_get_cumulative").change(function(){
redraw_chart();
});
// lock/unlock chart options fields when ajax request is sent
function lock_fields(lock){
if(lock==1){
......@@ -180,7 +132,6 @@ $(function () {
$("#chart_options").removeAttr('disabled');
}
}
function get_octet_string_representation (size, round) {
var octets_link = new Array("bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb"),
p = parseInt(Math.ceil(parseFloat(size.toString().length)/parseFloat(3) - parseFloat(1))),
......@@ -196,7 +147,6 @@ $(function () {
value = value + " " + octets_link[p];
return value;
}
// redraw chart
function redraw_chart(){
......@@ -264,7 +214,7 @@ $(function () {
lock_fields(0);
}
});
}
}*/
$("#wf_monitoring").activewf({
serverURL: $("#server_url").val()
......@@ -281,6 +231,86 @@ $(function () {
});
function projectDistributionHandler() {
$("table[id^=data_table_]").each(function(){
if ($(this).parent('div.dataTables_wrapper').first().css("display") != 'none') {
var group_by = $("[name=group_by]:checked").val();
var real_group = "laboratories";
if (group_by == "organism") {
real_group = "organizations";
} else if (group_by == "location") {
real_group = "locations";
}
var role = $("[name=users_to_consider]:checked").val();
var values = new Array();
$(this).find(":checked").each(function(){
values.push($(this).val());
});
$.ajax({
url: "index.php?eID=tx_nG6&type=project_distribution&by="+group_by+"&role="+role+"&values="+values.join(","),
dataType: 'json',
success: function(val, status, xhr) {
// reformat the data with values to integer
for (var i=0; i <val.length; i++ ) {
val[i][1] = parseInt(val[i][1]);
}
$('#highcharts_graph').highcharts({
chart: {
width: 930
},
title: {
text: 'Number of projects gathered by ' + real_group
},
tooltip: {
pointFormat: '<b>{point.percentage:.1f}%</b>'
},
credits: { enabled: false },
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function() {
return '<b>'+ this.point.name + '</b>';
}
}
}
},
series: [{
type: 'pie',
data: val
}]
});
}
});
}
});
}
function updateButtons () {
$('.multiple-selection-btn').each(function(){
if ($("[type='checkbox']:checked").size() == 0) {
// Add tooltip
$(this).attr('rel', 'tooltip');
// Disable button
$(this).attr('data-title', 'Select one or more element(s)');
$(this).tooltip({container: 'body'});
$(this).addClass("disabled").attr("rel", "tooltip");
$("#project_distribution").unbind("click", projectDistributionHandler);
} else {
// Enable
$(this).removeClass("disabled").attr("rel", null);
// Remove tooltip
$(this).removeAttr('rel');
$(this).removeAttr('data-title');
$(this).tooltip('destroy');
$("#project_distribution").bind("click", projectDistributionHandler);
}
});
}
function initStatMenuDataTable () {
var stat_tables = {};
......@@ -316,6 +346,10 @@ function refreshTable(stat_tables) {
var role = $("[name=users_to_consider]:checked").val();
var by = $("[name=group_by]:checked").val();
var r_by = $("[name=group_by]:checked").attr("id").split("_")[1];
$(":checkbox:checked").each(function(){
$(this).attr("checked", false);
})
updateButtons();
$.ajax({
url: "index.php?eID=tx_nG6&type=project_data_repartition&role="+role+"&by="+by,
dataType: 'json',
......@@ -334,6 +368,9 @@ function refreshTable(stat_tables) {
}
}
oTable.parents('div.dataTables_wrapper').first().show();
$(":checkbox").change(function(){
updateButtons();
})
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment