LSP bugfixes - mostly about status displays for protocols and streams

This commit is contained in:
cat 2013-01-16 12:17:04 +01:00 committed by Thulinma
parent b5bb288ac0
commit eb57d6f4a4
4 changed files with 198 additions and 185 deletions

View file

@ -187,7 +187,7 @@
for(var stream in data.streams) for(var stream in data.streams)
{ {
streams[stream] = [data.streams[stream].online, 0]; streams[stream] = [data.streams[stream].online, 0, data.streams[stream].error];
cnt++; cnt++;
} }
@ -339,7 +339,7 @@
delete data.statistics; // same goes for the stats delete data.statistics; // same goes for the stats
//IE breaks if the console isn't opened, so keep commented when committing //IE breaks if the console isn't opened, so keep commented when committing
console.log('[763] SEND', data); //console.log('[763] SEND', data);
$.ajax( $.ajax(
{ {
@ -363,7 +363,7 @@
$('#shield').remove(); // remove loading display $('#shield').remove(); // remove loading display
//IE breaks if the console isn't opened, so keep commented when committing //IE breaks if the console isn't opened, so keep commented when committing
console.log('[785] RECV', d); //console.log('[785] RECV', d);
if(d && d['authorize'] && d['authorize']['challenge']) if(d && d['authorize'] && d['authorize']['challenge'])
{ {
@ -435,12 +435,12 @@
{ {
return "<span>Unknown, checking...</span>"; return "<span>Unknown, checking...</span>";
} }
switch(status) switch(status)
{ {
case 1: return "<span class='green'>Running</span>"; break; case 1: return "<span class='green'>Running</span>"; break;
case 0: return "<span class='red'>Offline</span>"; break; case 0: return "<span class='red'>Offline</span>"; break;
default: return "<span class='red'>" + status + "</span>"; break; case -1: return "<span>Unknown, checking...</span>"; break;
default: return "<span class='green'>" + status + "</span>"; break;
} }
} }

View file

@ -79,8 +79,8 @@
// what kind of streams should be displayed? Format is [recorded, live]; // what kind of streams should be displayed? Format is [recorded, live];
var streamsdisplay = [true, true]; var streamsdisplay = [true, true];
// used on the overview page to decide then to ask the controller for an update check // used on the overview page to decide then to ask the controller for an update check
var updatelastchecked; var updatelastchecked;
/** /**
* Display a certain page. It contains a (giant) switch-statement, that builds a page depending on the tab requested * Display a certain page. It contains a (giant) switch-statement, that builds a page depending on the tab requested
@ -174,117 +174,117 @@
case 'overview': case 'overview':
loadSettings(function(){
$uptodate = null;
if (settings.settings.LTS == 1)
{
if ((settings.settings.update == undefined) || (updatelastchecked == undefined) || ((new Date()).getTime() - updatelastchecked > 3600000))
{
settings.settings.checkupdate = true;
settings.settings.update = {};
updatelastchecked = (new Date()).getTime();
loadSettings(function()
{
showTab('overview');
});
}
else
{
if (settings.settings.update.uptodate == 0)
{
$uptodate = $('<label>').text('version check').css('line-height','30px');
$uptodate.append(
$('<span>').attr('class','red').text('Outdated version!').append(
$('<button>').text('update').click(function(){
settings.settings.autoupdate = true;
loadSettings();
})
)
);
}
}
}
$('#page').append(
$('<div>').attr('id', 'editserver').append(
$('<label>').attr('for', 'config-host').text('host').append(
$('<input>').attr('type', 'text').attr('placeholder', 'HOST').attr('id', 'config-host').attr('value', settings.settings.config.host)
)
).append(
$('<label>').attr('for', 'config-name').text('name').append(
$('<input>').attr('type', 'text').attr('placeholder', 'NAME').attr('id', 'config-name').attr('value', settings.settings.config.name)
)
).append(
$('<label>').text('version').append(
$('<span>').text(settings.settings.config.version)
).append($uptodate)
).append(
$('<label>').text('time').append(
$('<span>').text( formatDate(settings.settings.config.time) )
)
).append(
$('<label>').text('Streams').append(
$('<span>').attr('id', 'cur_streams_online').text('retrieving data...')
)
).append(
$('<label>').text('Viewers').append(
$('<span>').attr('id', 'cur_num_viewers').text('retrieving data...')
)
)
);
function showStats() loadSettings(function(){
{
getStatData(function(data) $uptodate = null;
{ if (settings.settings.LTS == 1)
$('#cur_streams_online').html('').text(data.streams[0] + ' of ' + data.streams[1] + ' online'); {
$('#cur_num_viewers').html('').text(data.viewers); if ((settings.settings.update == undefined) || (updatelastchecked == undefined) || ((new Date()).getTime() - updatelastchecked > 3600000))
}); {
} settings.settings.checkupdate = true;
settings.settings.update = {};
// refresh the stream status + viewers updatelastchecked = (new Date()).getTime();
sinterval = setInterval(function() loadSettings(function()
{ {
showStats(); showTab('overview');
}, 10000); });
}
showStats(); else
{
$('#editserver').append( if (settings.settings.update.uptodate == 0)
$('<button>').attr('class', 'floatright').click(function() {
{ $uptodate = $('<label>').text('version check').css('line-height','30px');
var host = $('#config-host').val(); $uptodate.append(
var name = $('#config-name').val(); $('<span>').attr('class','red').text('Outdated version!').append(
$('<button>').text('update').click(function(){
settings.settings.config.host = host; settings.settings.autoupdate = true;
settings.settings.config.name = name; loadSettings();
})
loadSettings(function() )
{ );
showTab('overview'); }
}); }
}).text( 'save' ) }
);
$('#page').append(
var forcesave = $('<div>').attr('id', 'forcesave'); $('<div>').attr('id', 'editserver').append(
$('<label>').attr('for', 'config-host').text('host').append(
forcesave.append( $('<input>').attr('type', 'text').attr('placeholder', 'HOST').attr('id', 'config-host').attr('value', settings.settings.config.host)
$('<p>').text('Click the button below to force an immediate settings save. This differs from a regular save to memory and file save on exit by saving directly to file while operating. This may slow server processes for a short period of time.') )
).append( ).append(
$('<button>').click(function() $('<label>').attr('for', 'config-name').text('name').append(
{ $('<input>').attr('type', 'text').attr('placeholder', 'NAME').attr('id', 'config-name').attr('value', settings.settings.config.name)
if(confirmDelete('Are you sure you want to force a JSON save?') == true) )
{ ).append(
forceJSONSave(); $('<label>').text('version').append(
} $('<span>').text(settings.settings.config.version)
}).text( 'force save to JSON file' ) ).append($uptodate)
); ).append(
$('<label>').text('time').append(
$('#page').append(forcesave); $('<span>').text( formatDate(settings.settings.config.time) )
}); )
).append(
$('<label>').text('Streams').append(
$('<span>').attr('id', 'cur_streams_online').text('retrieving data...')
)
).append(
$('<label>').text('Viewers').append(
$('<span>').attr('id', 'cur_num_viewers').text('retrieving data...')
)
)
);
function showStats()
{
getStatData(function(data)
{
$('#cur_streams_online').html('').text(data.streams[0] + ' of ' + data.streams[1] + ' online');
$('#cur_num_viewers').html('').text(data.viewers);
});
}
// refresh the stream status + viewers
sinterval = setInterval(function()
{
showStats();
}, 10000);
showStats();
$('#editserver').append(
$('<button>').attr('class', 'floatright').click(function()
{
var host = $('#config-host').val();
var name = $('#config-name').val();
settings.settings.config.host = host;
settings.settings.config.name = name;
loadSettings(function()
{
showTab('overview');
});
}).text( 'save' )
);
var forcesave = $('<div>').attr('id', 'forcesave');
forcesave.append(
$('<p>').text('Click the button below to force an immediate settings save. This differs from a regular save to memory and file save on exit by saving directly to file while operating. This may slow server processes for a short period of time.')
).append(
$('<button>').click(function()
{
if(confirmDelete('Are you sure you want to force a JSON save?') == true)
{
forceJSONSave();
}
}).text( 'force save to JSON file' )
);
$('#page').append(forcesave);
});
break; break;
@ -580,6 +580,7 @@
$('input').each(function(){ $('input').each(function(){
newprotocol[$(this).attr('id').split('-')[2]] = $(this).val();; newprotocol[$(this).attr('id').split('-')[2]] = $(this).val();;
}); });
newprotocol.online = -1;
if (streamname == 'new') { if (streamname == 'new') {
settings.settings.config.protocols.push(newprotocol); settings.settings.config.protocols.push(newprotocol);
}else{ }else{
@ -679,7 +680,14 @@
} }
else else
{ {
streamstatus = streams[stream][0]; if (streams[stream][2])
{
streamstatus = streams[stream][2];
}
else
{
streamstatus = streams[stream][0];
}
} }
$(this).children(':nth-child(5)').html(formatStatus(streamstatus)); $(this).children(':nth-child(5)').html(formatStatus(streamstatus));
$(this).children(':nth-child(6)').html(streams[stream][1]); $(this).children(':nth-child(6)').html(streams[stream][1]);
@ -734,10 +742,15 @@
showTab('embed', sname); showTab('embed', sname);
}) ) ); // end function, end click(), end append(), end append(). Huzzah jQuery. }) ) ); // end function, end click(), end append(), end append(). Huzzah jQuery.
if ( cstr.name == undefined ) { cstr.name = ''; } if ( cstr.name == undefined ) { cstr.name = ''; }
$tr.append( $('<td>').text( cstr.name ) ); $tr.append( $('<td>').text( cstr.name ) );
if (cstr.error)
{
cstr.online = cstr.error;
}
$tr.append( $('<td>').html( formatStatus( cstr.online ) ) ); $tr.append( $('<td>').html( formatStatus( cstr.online ) ) );
var cviewers = 0; var cviewers = 0;
@ -894,6 +907,8 @@
sdata.name = newname; sdata.name = newname;
sdata.channel.URL = s.val(); sdata.channel.URL = s.val();
sdata.preset.cmd = p.val(); sdata.preset.cmd = p.val();
sdata.online = -1;
sdata.error = null;
if(streamname == 'new') if(streamname == 'new')
{ {
@ -1144,65 +1159,63 @@
break; break;
case 'server stats': case 'server stats':
loadSettings(function(){ loadSettings(function(){
serverstats = settings.settings.capabilities; serverstats = settings.settings.capabilities;
console.log(serverstats); //weghalen if (serverstats.cpu !== undefined)
{
if (serverstats.cpu !== undefined) $('#page').append(
{ $('<div>').attr('class','datacont').append(
$('#page').append( $('<p>').text('CPU')
$('<div>').attr('class','datacont').append( )
$('<p>').text('CPU') );
) //be careful, only works if this is the first div to be constructed
); for (property in serverstats.cpu[0])
//be careful, only works if this is the first div to be constructed {
for (property in serverstats.cpu[0]) $('#page div.datacont').append(
{ $('<label>').text(property).append(
$('#page div.datacont').append( $('<span>').text(serverstats.cpu[0][property])
$('<label>').text(property).append( )
$('<span>').text(serverstats.cpu[0][property]) );
) }
); }
} if (serverstats.mem !== undefined)
} {
if (serverstats.mem !== undefined) $('#page').append(
{ $('<div>').attr('class','datacont').append(
$('#page').append( $('<p>').text('Memory')
$('<div>').attr('class','datacont').append( ).append(
$('<p>').text('Memory') $('<label>').text('Physical memory').append(
).append( $('<span>').text(serverstats.mem.used+'MiB/'+serverstats.mem.total+'MiB ('+serverstats.mem.free+'MiB available)')
$('<label>').text('Physical memory').append( )
$('<span>').text(serverstats.mem.used+'MiB/'+serverstats.mem.total+'MiB ('+serverstats.mem.free+'MiB available)') ).append(
) $('<label>').text('Swap memory').append(
).append( $('<span>').text((serverstats.mem.swaptotal - serverstats.mem.swapfree)+'MiB/'+serverstats.mem.swaptotal+'MiB ('+serverstats.mem.swapfree+'MiB available)')
$('<label>').text('Swap memory').append( )
$('<span>').text((serverstats.mem.swaptotal - serverstats.mem.swapfree)+'MiB/'+serverstats.mem.swaptotal+'MiB ('+serverstats.mem.swapfree+'MiB available)') )
) );
) }
); if (serverstats.load !== undefined)
} {
if (serverstats.load !== undefined) $('#page').append(
{ $('<div>').attr('class','datacont').append(
$('#page').append( $('<p>').text('Load')
$('<div>').attr('class','datacont').append( ).append(
$('<p>').text('Load') $('<label>').text('Memory used').append(
).append( $('<span>').text(serverstats.load.memory+'%')
$('<label>').text('Memory used').append( )
$('<span>').text(serverstats.load.memory+'%') ).append(
) $('<label>').text('Loading averages').append(
).append( $('<span>').text('1 min: '+serverstats.load.one+'%, 5 min: '+serverstats.load.five+'%, 15 min: '+serverstats.load.fifteen+'%')
$('<label>').text('Loading averages').append( )
$('<span>').text('1 min: '+serverstats.load.one+'%, 5 min: '+serverstats.load.five+'%, 15 min: '+serverstats.load.fifteen+'%') )
) );
) }
); });
}
}); break;
break;
case 'disconnect': case 'disconnect':
showTab('login'); showTab('login');
setHeaderState('disconnected'); setHeaderState('disconnected');

View file

@ -40,7 +40,7 @@
<li>streams</li> <li>streams</li>
<li>limits</li> <li>limits</li>
<li>logs</li> <li>logs</li>
<li>server stats</li> <li>server stats</li>
<li id='logoutbutton'>disconnect</li> <li id='logoutbutton'>disconnect</li>
</ul> </ul>

View file

@ -412,15 +412,15 @@ td
.datacont label span .datacont label span
{ {
font-weight: normal; font-weight: normal;
text-transform: none; text-transform: none;
} }
.datacont label .datacont label
{ {
padding-left: 25px; padding-left: 25px;
} }
.datacont p .datacont p
{ {
margin-top: 25px; margin-top: 25px;
margin-bottom: 0px; margin-bottom: 0px;
} }