//added data into dashproducts module

This commit is contained in:
Vincent Augagneur
2013-09-04 18:26:58 +02:00
parent 22d636f93a
commit 6b2492b62c
4 changed files with 514 additions and 81 deletions
+51 -9
View File
@@ -52,30 +52,72 @@ function refreshDashbard(module_name)
}
},
error : function(data){
alert("[TECHNICAL ERROR]");
//@TODO display errors
}
});
}
function data_value(datas)
function data_value(data)
{
for (var data_id in datas)
for (var data_id in data)
{
$('#'+data_id).html(datas[data_id]);
$('#'+data_id).html(data[data_id]);
$('#'+data_id).closest('section').removeClass('loading');
}
}
function data_trends(datas)
function data_trends(data)
{
for (var data_id in datas)
for (var data_id in data)
{
$('#'+data_id).html(datas[data_id]['value']);
if (datas[data_id]['way'] == 'down')
$('#'+data_id).html(data[data_id]['value']);
if (data[data_id]['way'] == 'down')
$('#'+data_id).parent().removeClass('dash_trend_up').addClass('dash_trend_down');
else
$('#'+data_id).parent().removeClass('dash_trend_down').addClass('dash_trend_up');
$('#'+data_id).closest('section').removeClass('loading');
}
}
function data_table(data)
{
for (var data_id in data)
{
//fill header
tr = '<tr>';
for (var header in data[data_id].header)
{
head = data[data_id].header[header];
th = '<th '+ (head.class ? ' class="'+head.class+'" ' : '' )+ ' '+(head.id ? ' id="'+head.id+'" ' : '' )+'>';
th += (head.wrapper_start ? ' '+head.wrapper_start+' ' : '' );
th += head.title;
th += (head.wrapper_stop ? ' '+head.wrapper_stop+' ' : '' );
th += '</th>';
tr += th;
}
tr += '</tr>';
$('#'+data_id+' thead').html(tr);
//fill body
$('#'+data_id+' tbody').html('');
if (data[data_id].body.length)
for (var body_content_id in data[data_id].body)
{
tr = '<tr>';
for (var body_content in data[data_id].body[body_content_id])
{
body = data[data_id].body[body_content_id][body_content];
td = '<td '+ (body.class ? ' class="'+body.class+'" ' : '' )+ ' '+(body.id ? ' id="'+body.id+'" ' : '' )+'>';
td += (body.wrapper_start ? ' '+body.wrapper_start+' ' : '' );
td += body.value;
td += (body.wrapper_stop ? ' '+body.wrapper_stop+' ' : '' );
td += '</td>';
tr += td;
}
tr += '</tr>';
$('#'+data_id+' tbody').append(tr);
}
else
$('#'+data_id+' tbody').html('<tr><td class="text-center" colspan="'+data[data_id].header.length+'">'+no_results_translation+'</td></tr>');
}
}