LSP: more bugfixes - related to rapid deletion of protocols, status display, backwards compatibility
This commit is contained in:
parent
2f9ccf366f
commit
3533187ed8
3 changed files with 88 additions and 51 deletions
|
@ -27,13 +27,13 @@
|
|||
('00' + d.getSeconds()).slice(-2)
|
||||
].join(':');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
/**
|
||||
* Format a date to mmm dd /yyyy hh:mm:ss format
|
||||
* @param date the date to format (timestamp)
|
||||
*/
|
||||
months = Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
|
||||
months = Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
|
||||
function formatDateLong(date)
|
||||
{
|
||||
var d = new Date(date * 1000);
|
||||
|
@ -48,10 +48,10 @@
|
|||
('00' + d.getSeconds()).slice(-2)
|
||||
].join(':');
|
||||
}
|
||||
function nameMonth(monthNum)
|
||||
{
|
||||
months = Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
|
||||
}
|
||||
function nameMonth(monthNum)
|
||||
{
|
||||
months = Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@
|
|||
var ret = $.extend(true,
|
||||
{
|
||||
"streams": {},
|
||||
"capabilities": {},
|
||||
"capabilities": {},
|
||||
"statistics": {}
|
||||
}, d);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
113
lsp/main.js
113
lsp/main.js
|
@ -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)
|
||||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
refreshProtocolStatus();
|
||||
},1000);
|
||||
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 );
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -436,13 +440,13 @@
|
|||
if ((fieldname != 'connector') && (fieldname != 'online'))
|
||||
{
|
||||
$('#protocol-parameter-'+fieldname).val(currentdata[fieldname]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loadSettings(function()
|
||||
{
|
||||
{
|
||||
if (streamname == 'new') { t = 'add new protocol'; }
|
||||
else { t = 'edit protocol'; }
|
||||
|
||||
|
@ -473,7 +477,7 @@
|
|||
);
|
||||
|
||||
$('#page').append( $div );
|
||||
$('#editprotocol').append( $('<div>').attr('id','protocoldesc') );
|
||||
$('#editprotocol').append( $('<div>').attr('id','protocoldesc') );
|
||||
$('#editprotocol').append( $('<div>').attr('id', 'protocolfields') );
|
||||
$('#editprotocol').append(
|
||||
$('<button>').text('cancel').addClass('floatright').click(function()
|
||||
|
@ -495,10 +499,21 @@
|
|||
error = true;
|
||||
}
|
||||
});
|
||||
//turn all numbers into integers
|
||||
|
||||
$('input[type="number"]').each(function()
|
||||
{
|
||||
$(this).val(Math.floor($(this).val()));
|
||||
//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()
|
||||
|
@ -611,21 +626,25 @@
|
|||
// refresh every streams' data (status and viewer count)
|
||||
function refreshStreams()
|
||||
{
|
||||
getStreamsData(function(streams)
|
||||
{
|
||||
for(stream in streams)
|
||||
{
|
||||
if( $('stream-' + stream) )
|
||||
getStreamsData(function(streams)
|
||||
{
|
||||
$('tbody#streams-list-tbody tr').each(function()
|
||||
{
|
||||
var row = $('#stream-' + stream);
|
||||
var status = streams[stream][0];
|
||||
|
||||
$(row.children()[4]).html( formatStatus(status) );
|
||||
|
||||
$(row.children()[5]).text(streams[stream][1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
streamstatus = null;
|
||||
stream = $(this).attr('id').split('-')[1];
|
||||
if (streams[stream] == undefined)
|
||||
{
|
||||
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];
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
sinterval = setInterval(function()
|
||||
|
@ -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(
|
||||
|
|
|
@ -13,7 +13,8 @@ body
|
|||
|
||||
#page
|
||||
{
|
||||
overflow: hidden;
|
||||
overflow-y: hidden;
|
||||
overflow-x:auto;
|
||||
/*margin: 10px -170px 0 230px; */
|
||||
padding: 0;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue