Commit 36eeee39 authored by Eduardo L. Buratti's avatar Eduardo L. Buratti

web: Make use of the error and warning blocks in chart views

Signed-off-by: Eduardo L. Buratti's avatarEduardo L. Buratti <elb09@c3sl.ufpr.br>
parent 004c1612
......@@ -56,7 +56,7 @@
<div class="span6" id="piechart"></div>
</div>
<div class="row-fluid">
<div class="row-fluid bar-chart-help">
<div class="span5 offset1 alert alert-info align-center">Clique nas barras acima para visualizar os dados no próximo nível.</div>
</div>
......
......@@ -56,7 +56,7 @@
<div class="span6" id="piechart"></div>
</div>
<div class="row-fluid">
<div class="row-fluid bar-chart-help">
<div class="span5 offset1 alert alert-info align-center">Clique nas barras acima para visualizar os dados no próximo nível.</div>
</div>
......
......@@ -56,7 +56,7 @@
<div class="span6" id="piechart"></div>
</div>
<div class="row-fluid">
<div class="row-fluid bar-chart-help">
<div class="span5 offset1 alert alert-info align-center">Clique nas barras acima para visualizar os dados no próximo nível.</div>
</div>
......
......@@ -51,7 +51,7 @@
<div class="span8 offset2" id="barchart"></div>
</div>
<div class="row-fluid">
<div class="row-fluid bar-chart-help">
<div class="span6 offset3 alert alert-info align-center">Clique nas barras acima para visualizar os dados no próximo nível.</div>
</div>
<br/>
......
......@@ -29,7 +29,7 @@
<div class="span8 offset2" id="barchart"></div>
</div>
<div class="row-fluid">
<div class="row-fluid bar-chart-help">
<div class="span6 offset3 alert alert-info align-center">Clique nas barras acima para visualizar os dados no próximo nível.</div>
</div>
<br/>
......
......@@ -64,6 +64,12 @@ Charts.load = function(project, region, state) {
data: '{"type": "sub", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if (data.hd.length == 0) {
Charts.barChart.hideLoading();
Charts.noData(Charts.barChart);
return;
}
Charts.barChart.xAxis[0].setCategories(data.categories);
Charts.barChart.addSeries({
......@@ -83,10 +89,10 @@ Charts.load = function(project, region, state) {
Charts.barChart.redraw();
Charts.barChart.hideLoading();
$('.bar-chart-help').fadeIn('slow');
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* PIE CHART */
......@@ -95,6 +101,13 @@ Charts.load = function(project, region, state) {
data: '{"type": "current", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if ( ((data.hd[0] == 0) &&
(data.mem[0] == 0)) || (data.hd.length == 0) ) {
Charts.pieChart.hideLoading();
Charts.noData(Charts.pieChart);
return;
}
Charts.pieChart.addSeries({
name: 'Número de Máquinas',
data: [
......@@ -105,9 +118,7 @@ Charts.load = function(project, region, state) {
Charts.pieChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* HIST CHART */
......@@ -116,21 +127,11 @@ Charts.load = function(project, region, state) {
data: '{"type": "historical", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
var formatDate = function (date) {
var now = new Date(date),
date = now.getDate(),
month = now.getMonth() + 1, // +1 because its zero based
year = now.getFullYear();
if (date < 10) date = '0' + date;
if (month < 10) month = '0' + month;
return month + '/' + year;
};
/*for (var i = 0; i < data.categories.length; i++)
data.categories[i] = formatDate(data.categories[i]);*/
if (data.hd.length == 0) {
Charts.histChart.hideLoading();
Charts.noData(Charts.histChart);
return;
}
Charts.histChart.xAxis[0].setCategories(data.categories);
......@@ -148,8 +149,6 @@ Charts.load = function(project, region, state) {
Charts.histChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
};
......@@ -64,6 +64,12 @@ Charts.load = function(project, region, state) {
data: '{"type": "sub", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if (data.installed.length == 0) {
Charts.barChart.hideLoading();
Charts.noData(Charts.barChart);
return;
}
Charts.barChart.xAxis[0].setCategories(data.categories);
Charts.barChart.addSeries({
......@@ -83,10 +89,10 @@ Charts.load = function(project, region, state) {
Charts.barChart.redraw();
Charts.barChart.hideLoading();
$('.bar-chart-help').fadeIn('slow');
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* PIE CHART */
......@@ -95,6 +101,13 @@ Charts.load = function(project, region, state) {
data: '{"type": "current", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if ( ((data.installed[0] == 0) &&
(data.notInstalled[0] == 0)) || (data.installed.length == 0) ) {
Charts.pieChart.hideLoading();
Charts.noData(Charts.pieChart);
return;
}
Charts.pieChart.addSeries({
name: 'Número de Máquinas',
data: [
......@@ -105,9 +118,7 @@ Charts.load = function(project, region, state) {
Charts.pieChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* HIST CHART */
......@@ -116,21 +127,11 @@ Charts.load = function(project, region, state) {
data: '{"type": "historical", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
var formatDate = function (date) {
var now = new Date(date),
date = now.getDate(),
month = now.getMonth() + 1, // +1 because its zero based
year = now.getFullYear();
if (date < 10) date = '0' + date;
if (month < 10) month = '0' + month;
return month + '/' + year;
};
/*for (var i = 0; i < data.categories.length; i++)
data.categories[i] = formatDate(data.categories[i]);*/
if (data.installed.length == 0) {
Charts.histChart.hideLoading();
Charts.noData(Charts.histChart);
return;
}
Charts.histChart.xAxis[0].setCategories(data.categories);
......@@ -148,8 +149,6 @@ Charts.load = function(project, region, state) {
Charts.histChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
};
......@@ -62,6 +62,12 @@ Charts.load = function(project, region, state) {
data: '{"type": "sub", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if (data.green.length == 0) {
Charts.barChart.hideLoading();
Charts.noData(Charts.barChart);
return;
}
Charts.barChart.xAxis[0].setCategories(data.categories);
Charts.barChart.addSeries({
......@@ -86,10 +92,10 @@ Charts.load = function(project, region, state) {
Charts.barChart.redraw();
Charts.barChart.hideLoading();
$('.bar-chart-help').fadeIn('slow');
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* PIE CHART */
......@@ -98,6 +104,14 @@ Charts.load = function(project, region, state) {
data: '{"type": "current", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if ( ((data.green[0] == 0) &&
(data.yellow[0] == 0) &&
(data.red[0] == 0)) || (data.green.length == 0) ) {
Charts.pieChart.hideLoading();
Charts.noData(Charts.pieChart);
return;
}
Charts.pieChart.addSeries({
name: 'Número de Máquinas',
data: [
......@@ -109,9 +123,7 @@ Charts.load = function(project, region, state) {
Charts.pieChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* HIST CHART */
......@@ -120,21 +132,11 @@ Charts.load = function(project, region, state) {
data: '{"type": "historical", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
var formatDate = function (date) {
var now = new Date(date),
date = now.getDate(),
month = now.getMonth() + 1, // +1 because its zero based
year = now.getFullYear();
if (date < 10) date = '0' + date;
if (month < 10) month = '0' + month;
return month + '/' + year;
};
/*for (var i = 0; i < data.categories.length; i++)
data.categories[i] = formatDate(data.categories[i]);*/
if (data.green.length == 0) {
Charts.histChart.hideLoading();
Charts.noData(Charts.histChart);
return;
}
Charts.histChart.xAxis[0].setCategories(data.categories);
......@@ -157,8 +159,6 @@ Charts.load = function(project, region, state) {
Charts.histChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
};
......@@ -194,6 +194,28 @@ var Charts = {
getRoute: function(category) {
return null;
}
},
error: function(err) {
console.log(err);
$('#error').fadeIn('slow');
Charts.barChart.destroy();
Charts.pieChart.destroy();
Charts.histChart.destroy();
},
noDataCount: 0,
noData: function(chart) {
this.noDataCount++;
if (typeof chart !== 'undefined') {
chart.destroy();
}
if (this.noDataCount >= 3) {
$('#no-data').fadeIn('slow');
}
}
};
......@@ -53,12 +53,21 @@ Charts.load = function(project, region, state) {
this.barChart.showLoading("Carregando...");
this.histChart.showLoading("Carregando...");
// pie chart doesnt exist, so we call noData to increase the noData counter
Charts.noData();
/* BAR CHART */
jsRoutes.controllers.Data.inventory().ajax({
contentType: "application/json",
data: '{"type": "sub", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
if (data.total.length == 0) {
Charts.barChart.hideLoading();
Charts.noData(Charts.barChart);
return;
}
Charts.barChart.xAxis[0].setCategories(data.categories);
Charts.barChart.addSeries({
......@@ -73,10 +82,10 @@ Charts.load = function(project, region, state) {
Charts.barChart.redraw();
Charts.barChart.hideLoading();
$('.bar-chart-help').fadeIn('slow');
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* HIST CHART */
......@@ -85,21 +94,11 @@ Charts.load = function(project, region, state) {
data: '{"type": "historical", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'"}',
success: function(data) {
var formatDate = function (date) {
var now = new Date(date),
date = now.getDate(),
month = now.getMonth() + 1, // +1 because its zero based
year = now.getFullYear();
if (date < 10) date = '0' + date;
if (month < 10) month = '0' + month;
return month + '/' + year;
};
/*for (var i = 0; i < data.categories.length; i++)
data.categories[i] = formatDate(data.categories[i]);*/
if (data.total.length == 0) {
Charts.histChart.hideLoading();
Charts.noData(Charts.histChart);
return;
}
Charts.histChart.xAxis[0].setCategories(data.categories);
......@@ -110,8 +109,6 @@ Charts.load = function(project, region, state) {
Charts.histChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
};
......@@ -77,12 +77,22 @@ Charts.load = function(project, region, state, city) {
this.barChart.showLoading("Carregando...");
this.histChart.showLoading("Carregando...");
// pie chart doesnt exist, so we call noData to increase the noData counter
Charts.noData();
/* BAR CHART */
jsRoutes.controllers.Data.inventory().ajax({
contentType: "application/json",
data: '{"type": "sub", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'", "city": "'+city+'"}',
success: function(data) {
if (data.total.length == 0) {
Charts.barChart.hideLoading();
Charts.noData(Charts.barChart);
return;
}
Charts.barChart.xAxis[0].setCategories(data.categories);
Charts.barChart.addSeries({
......@@ -100,10 +110,10 @@ Charts.load = function(project, region, state, city) {
Charts.barChart.redraw();
Charts.barChart.hideLoading();
$('.bar-chart-help').fadeIn('slow');
},
error: function(err) {
console.log(err);
}
error: this.error
});
/* HIST CHART */
......@@ -112,6 +122,12 @@ Charts.load = function(project, region, state, city) {
data: '{"type": "historical", "level": "'+level+'", "project": "'+
project + '", "region": "'+region+'", "state": "'+state+'", "city": "'+city+'"}',
success: function(data) {
if (data.total.length == 0) {
Charts.histChart.hideLoading();
Charts.noData(Charts.histChart);
return;
}
Charts.histChart.xAxis[0].setCategories(data.categories);
Charts.histChart.addSeries({
......@@ -121,8 +137,6 @@ Charts.load = function(project, region, state, city) {
Charts.histChart.hideLoading();
},
error: function(err) {
console.log(err);
}
error: this.error
});
};
......@@ -463,3 +463,7 @@ h2.title {
.placeholder {
color: #aaa;
}
.bar-chart-help {
display: none;
}
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