LSP: more bugfixes - related to rapid deletion of protocols, status display, backwards compatibility

This commit is contained in:
cat 2013-01-11 15:34:47 +01:00 committed by Thulinma
parent 2f9ccf366f
commit 3533187ed8
3 changed files with 88 additions and 51 deletions

View file

@ -352,10 +352,11 @@
'timeout': 5000, 'timeout': 5000,
'error': function() 'error': function(jqXHR,textStatus,errorThrown)
{ {
showTab('disconnect'); showTab('disconnect');
$('#shield').remove(); // remove loading display $('#shield').remove(); // remove loading display
alert('O dear! An error occurred while attempting to communicatie with the MistServer.\n\n'+textStatus+'\n'+errorThrown);
}, },
'success': function(d) 'success': function(d)
{ {
@ -439,7 +440,7 @@
{ {
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='green'>" + status + "</span>"; break; default: return "<span class='red'>" + status + "</span>"; break;
} }
} }

View file

@ -83,7 +83,7 @@
/** /**
* 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
* @param name the name of the tab * @param name the name of the tab
* @param streamname only used when editing streams, the name of the edited (or new) stream. Also used with the 'embed' tab * @param streamname only used when editing streams or protocols, the name of the edited (or new) stream/protocol. Also used with the 'embed' tab
*/ */
function showTab(name, streamname) function showTab(name, streamname)
{ {
@ -187,7 +187,7 @@
) )
).append( ).append(
$('<label>').text('time').append( $('<label>').text('time').append(
$('<span>').text( formatDateLong(settings.settings.config.time) ) $('<span>').text( formatDate(settings.settings.config.time) )
) )
).append( ).append(
$('<label>').text('Streams').append( $('<label>').text('Streams').append(
@ -298,8 +298,7 @@
var id = Number($(this).parent().parent().attr('id').replace('protocol-', '')); var id = Number($(this).parent().parent().attr('id').replace('protocol-', ''));
var pid = pids.indexOf(id); var pid = pids.indexOf(id);
settings.settings.config.protocols.splice(pid, 1); settings.settings.config.protocols.splice(pid, 1);
$(this).parent().parent().remove(); showTab('protocols');
loadSettings();
} }
}).text('delete') ) ); }).text('delete') ) );
@ -320,22 +319,27 @@
{ {
getData(function(data) getData(function(data)
{ {
protocol = data.config.protocols; $('tbody tr').each(function()
for (index in protocol)
{ {
var row = $('#protocol-' + index); protocolstatus = null;
var status = protocol[index].online; pid = $(this).attr('id').split('-')[1];
if (data.config.protocols[pid] == undefined)
$(row.children()[1]).html( formatStatus(status) ); {
protocolstatus = 'Protocol config missing.. reloading tab';
if (status == undefined) showTab('protocol');
}
else {
if (data.config.protocols[pid].online == undefined)
{ {
setTimeout(function() setTimeout(function()
{ {
refreshProtocolStatus(); refreshProtocolStatus();
},1000); },1000);
} }
protocolstatus = data.config.protocols[pid].online;
} }
$(this).children()[1].innerHTML = formatStatus( protocolstatus );
});
}); });
} }
@ -495,10 +499,21 @@
error = true; error = true;
} }
}); });
//turn all numbers into integers
$('input[type="number"]').each(function() $('input[type="number"]').each(function()
{ {
//make sure this is a number
if (isNaN($(this).val()))
{
$(this).focus();
$(this).parent().addClass('red');
error = true;
}
else
{
//turn all numbers into integers
$(this).val(Math.floor($(this).val())); $(this).val(Math.floor($(this).val()));
}
}); });
//check if all uints are actually uints //check if all uints are actually uints
$('input.uint').each(function() $('input.uint').each(function()
@ -613,18 +628,22 @@
{ {
getStreamsData(function(streams) getStreamsData(function(streams)
{ {
for(stream in streams) $('tbody#streams-list-tbody tr').each(function()
{ {
if( $('stream-' + stream) ) streamstatus = null;
stream = $(this).attr('id').split('-')[1];
if (streams[stream] == undefined)
{ {
var row = $('#stream-' + stream); streamstatus = 'Stream config missing - reloading tab';
var status = streams[stream][0]; showTab('streams');
$(row.children()[4]).html( formatStatus(status) );
$(row.children()[5]).text(streams[stream][1]);
} }
else
{
streamstatus = streams[stream][0];
} }
$(this).children()[4].innerHTML = formatStatus(streamstatus);
$(this).children()[5].innerHTML = streams[stream][1];
});
}); });
}; };
@ -645,6 +664,22 @@
for(stream in settings.settings.streams) for(stream in settings.settings.streams)
{ {
//if sid does not yet exist, create it
if (settings.settings.streams[stream].sid == undefined)
{
sid = 0;
for (strm in settings.settings.streams)
{
if (settings.settings.streams[strm].sid != undefined)
{
sid = Math.max(sid,settings.settings.streams[strm].sid);
}
}
sid += 1;
settings.settings.streams[stream].sid = sid;
}
var cstr = settings.settings.streams[stream]; var cstr = settings.settings.streams[stream];
$tr = $('<tr>').attr('id', 'stream-' + stream); $tr = $('<tr>').attr('id', 'stream-' + stream);
@ -1018,7 +1053,7 @@
case 'logs': case 'logs':
$table = $('<table>'); $table = $('<table>');
$table.html("<thead><th>Date<span class='theadinfo'>(MMM DD YYYY)</span></th><th>Type</th><th>Message</th></thead>"); $table.html("<thead><th>Date<span class='theadinfo'>(MM/DD/YYYY)</span></th><th>Type</th><th>Message</th></thead>");
$tbody = $('<tbody>'); $tbody = $('<tbody>');
if(!settings.settings.log) if(!settings.settings.log)
@ -1041,7 +1076,7 @@
cur = settings.settings.log[i]; cur = settings.settings.log[i];
$tr = $('<tr>').append( $tr = $('<tr>').append(
$('<td>').text(formatDateLong(cur[0])) $('<td>').text(formatDate(cur[0]))
).append( ).append(
$('<td>').text(cur[1]) $('<td>').text(cur[1])
).append( ).append(

View file

@ -13,7 +13,8 @@ body
#page #page
{ {
overflow: hidden; overflow-y: hidden;
overflow-x:auto;
/*margin: 10px -170px 0 230px; */ /*margin: 10px -170px 0 230px; */
padding: 0; padding: 0;