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,
'error': function()
'error': function(jqXHR,textStatus,errorThrown)
{
showTab('disconnect');
$('#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)
{
@ -439,7 +440,7 @@
{
case 1: return "<span class='green'>Running</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
* @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)
{
@ -187,7 +187,7 @@
)
).append(
$('<label>').text('time').append(
$('<span>').text( formatDateLong(settings.settings.config.time) )
$('<span>').text( formatDate(settings.settings.config.time) )
)
).append(
$('<label>').text('Streams').append(
@ -298,8 +298,7 @@
var id = Number($(this).parent().parent().attr('id').replace('protocol-', ''));
var pid = pids.indexOf(id);
settings.settings.config.protocols.splice(pid, 1);
$(this).parent().parent().remove();
loadSettings();
showTab('protocols');
}
}).text('delete') ) );
@ -320,22 +319,27 @@
{
getData(function(data)
{
protocol = data.config.protocols;
for (index in protocol)
$('tbody tr').each(function()
{
var row = $('#protocol-' + index);
var status = protocol[index].online;
$(row.children()[1]).html( formatStatus(status) );
if (status == undefined)
protocolstatus = null;
pid = $(this).attr('id').split('-')[1];
if (data.config.protocols[pid] == undefined)
{
protocolstatus = 'Protocol config missing.. reloading tab';
showTab('protocol');
}
else {
if (data.config.protocols[pid].online == undefined)
{
setTimeout(function()
{
refreshProtocolStatus();
},1000);
}
protocolstatus = data.config.protocols[pid].online;
}
$(this).children()[1].innerHTML = formatStatus( protocolstatus );
});
});
}
@ -495,10 +499,21 @@
error = true;
}
});
//turn all numbers into integers
$('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()));
}
});
//check if all uints are actually uints
$('input.uint').each(function()
@ -613,18 +628,22 @@
{
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);
var status = streams[stream][0];
$(row.children()[4]).html( formatStatus(status) );
$(row.children()[5]).text(streams[stream][1]);
streamstatus = 'Stream config missing - reloading tab';
showTab('streams');
}
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)
{
//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];
$tr = $('<tr>').attr('id', 'stream-' + stream);
@ -1018,7 +1053,7 @@
case 'logs':
$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>');
if(!settings.settings.log)
@ -1041,7 +1076,7 @@
cur = settings.settings.log[i];
$tr = $('<tr>').append(
$('<td>').text(formatDateLong(cur[0]))
$('<td>').text(formatDate(cur[0]))
).append(
$('<td>').text(cur[1])
).append(

View file

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