Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
b3654c62bc
22 changed files with 524 additions and 152 deletions
|
@ -11,6 +11,23 @@ function popup(mylink){
|
|||
return false;
|
||||
}
|
||||
|
||||
function convertSecondsToDaysHoursMinutesSeconds(seconds){
|
||||
if (seconds < 0)
|
||||
seconds = 0;
|
||||
|
||||
seconds = parseInt(seconds, 10);
|
||||
|
||||
var days = parseInt(seconds / 86400);
|
||||
seconds -= days*86400;
|
||||
|
||||
var hours = parseInt(seconds / 3600);
|
||||
seconds -= hours*3600;
|
||||
|
||||
var minutes = parseInt(seconds / 60);
|
||||
seconds -= minutes*60;
|
||||
|
||||
return {days:days, hours:hours, minutes:minutes, seconds:seconds};
|
||||
}
|
||||
|
||||
/* Takes an input parameter of milliseconds and converts these into
|
||||
* the format HH:MM:SS */
|
||||
|
|
|
@ -381,6 +381,9 @@ function setAddShowEvents() {
|
|||
}else{
|
||||
duration = '0m';
|
||||
}
|
||||
if(isNaN(duration)){
|
||||
duration = '1h';
|
||||
}
|
||||
$('#add_show_duration').val(duration);
|
||||
}
|
||||
|
||||
|
|
66
airtime_mvc/public/js/airtime/status/status.js
Normal file
66
airtime_mvc/public/js/airtime/status/status.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
function generatePartitions(partitions){
|
||||
|
||||
var rowTemplate =
|
||||
'<tr class="partition-info">'+
|
||||
'<td><span class="strong">Disk #%s</span>'+
|
||||
'<ul id="watched-dir-list-%s">'+
|
||||
'</ul>'+
|
||||
'</td>'+
|
||||
'<td>%sGB of %sGB</td>'+
|
||||
'<td colspan="3">'+
|
||||
'<div class="big">'+
|
||||
'<div class="diskspace" style="width:%s%%;">'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div>%s%% in use</div>'+
|
||||
'</td>'+
|
||||
'</tr>';
|
||||
|
||||
$(".partition-info").remove();
|
||||
var lastElement = $('#partitions');
|
||||
for (var i=0; i<partitions.length; i++){
|
||||
var spaceUsed = partitions[i].totalSpace-partitions[i].totalFreeSpace;
|
||||
var totalSpace = partitions[i].totalSpace;
|
||||
var percUsed = sprintf("%01.1f", spaceUsed/totalSpace*100);
|
||||
|
||||
var spaceUsedGb = sprintf("%01.1f", spaceUsed/Math.pow(10, 9));
|
||||
var totalSpaceGb = sprintf("%01.1f", totalSpace/Math.pow(10, 9));
|
||||
|
||||
var row = sprintf(rowTemplate, i, i, spaceUsedGb, totalSpaceGb, percUsed, percUsed);
|
||||
var tr = $(row);
|
||||
lastElement.after(tr);
|
||||
|
||||
var watched_dirs_ul = $('#watched-dir-list-'+i);
|
||||
for (var j=0; j<partitions[i].dirs.length; j++){
|
||||
watched_dirs_ul.append('<li>'+partitions[i].dirs[j]+'</li>');
|
||||
}
|
||||
lastElement = tr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function success(data, textStatus, jqXHR){
|
||||
var services = data.status.services;
|
||||
|
||||
for (var key in services){
|
||||
var s = services[key];
|
||||
var children = $("#"+s.name).children();
|
||||
$(children[0]).text(s.name);
|
||||
$($(children[1]).children()[0]).attr("class", s.status ? "checked-icon": "not-available-icon");
|
||||
$(children[2]).text(sprintf('%(days)sd %(hours)sh %(minutes)sm %(seconds)ss', convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds)));
|
||||
$(children[3]).text(s.cpu_perc);
|
||||
$(children[4]).text(sprintf('%01.1fMB (%s)', parseInt(s.memory_kb)/1000, s.memory_perc));
|
||||
}
|
||||
|
||||
generatePartitions(data.status.partitions);
|
||||
}
|
||||
|
||||
function updateStatus(){
|
||||
$.getJSON( "api/status/format/json", null, success);
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
updateStatus();
|
||||
setInterval(updateStatus, 5000);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue