$(document).ready(setTimeout(function(){
var tunerstatus = {}
var schedstatus = []
var expire = 0
function getDashboardStatus(){
return $.getJSON("/api/dashstatus.json").then(function(json){
return json;
});
}
function populateDashboard() {
getDashboardStatus().then(function(json_dashboard) {
tunerstatus = json_dashboard['tunerstatus']
schedstatus = json_dashboard['schedstatus']
tuner_active = populateTuner(tunerstatus);
sched_active = populateSchedule(schedstatus);
if ( tuner_active || sched_active ) {
expire = 1000;
} else if (expire < 30000) {
expire = expire + 3000;
}
setTimeout(function(){
if($("#dashboard").length !== 0) {
populateDashboard();
}
}, expire);
});
}
function populateTuner(tuner_data) {
$('#dashboard').html('
Tuner Status
');
$('#tuners').append(''
+ ''
+ ''
+ ''
+ ''
+ '
'
);
var active = false;
if ( tuner_data === null ) {
$('#tuners').append('Tuner Status is Down, check 5004 process |
');
} else {
$.each(tuner_data, function(key1, list_value) {
if(list_value !== null) {
if (typeof list_value === 'object' ) {
$.each(list_value, function(key2, tuner_status) {
if (typeof tuner_status === 'object' ) {
$('#tuners').append('' + tuner_status.status +' | ' + key1 + ' | tuner' + key2 + ' | ' + tuner_status.instance + ' | ' + tuner_status.ch + ' | ' + tuner_status.mux + ' |
');
active = true;
console.log(tuner_status);
}
});
}
}
});
}
return active;
}
function populateSchedule(sched_data) {
$('#dashboard').append('
Scheduler Status
');
$('#sched').append(''
+ ''
+ ''
+ ''
+ '
'
);
var active = false;
$.each(sched_data, function(key1, dict_value) {
if(dict_value !== null) {
$('#sched').append('Running | ' + dict_value.area + ' | ' + dict_value.title + ' | ' + dict_value.namespace + ' | ' + dict_value.instance + ' |
');
active = true
}
});
return active;
}
populateDashboard();
}, 1000));