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)
|
('00' + d.getSeconds()).slice(-2)
|
||||||
].join(':');
|
].join(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a date to mmm dd /yyyy hh:mm:ss format
|
* Format a date to mmm dd /yyyy hh:mm:ss format
|
||||||
* @param date the date to format (timestamp)
|
* @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)
|
function formatDateLong(date)
|
||||||
{
|
{
|
||||||
var d = new Date(date * 1000);
|
var d = new Date(date * 1000);
|
||||||
|
@ -48,10 +48,10 @@
|
||||||
('00' + d.getSeconds()).slice(-2)
|
('00' + d.getSeconds()).slice(-2)
|
||||||
].join(':');
|
].join(':');
|
||||||
}
|
}
|
||||||
function nameMonth(monthNum)
|
function nameMonth(monthNum)
|
||||||
{
|
{
|
||||||
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
var ret = $.extend(true,
|
var ret = $.extend(true,
|
||||||
{
|
{
|
||||||
"streams": {},
|
"streams": {},
|
||||||
"capabilities": {},
|
"capabilities": {},
|
||||||
"statistics": {}
|
"statistics": {}
|
||||||
}, d);
|
}, d);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
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
|
* 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');
|
||||||
{
|
|
||||||
setTimeout(function()
|
|
||||||
{
|
|
||||||
refreshProtocolStatus();
|
|
||||||
},1000);
|
|
||||||
}
|
}
|
||||||
}
|
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'))
|
if ((fieldname != 'connector') && (fieldname != 'online'))
|
||||||
{
|
{
|
||||||
$('#protocol-parameter-'+fieldname).val(currentdata[fieldname]);
|
$('#protocol-parameter-'+fieldname).val(currentdata[fieldname]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSettings(function()
|
loadSettings(function()
|
||||||
{
|
{
|
||||||
if (streamname == 'new') { t = 'add new protocol'; }
|
if (streamname == 'new') { t = 'add new protocol'; }
|
||||||
else { t = 'edit protocol'; }
|
else { t = 'edit protocol'; }
|
||||||
|
|
||||||
|
@ -473,7 +477,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
$('#page').append( $div );
|
$('#page').append( $div );
|
||||||
$('#editprotocol').append( $('<div>').attr('id','protocoldesc') );
|
$('#editprotocol').append( $('<div>').attr('id','protocoldesc') );
|
||||||
$('#editprotocol').append( $('<div>').attr('id', 'protocolfields') );
|
$('#editprotocol').append( $('<div>').attr('id', 'protocolfields') );
|
||||||
$('#editprotocol').append(
|
$('#editprotocol').append(
|
||||||
$('<button>').text('cancel').addClass('floatright').click(function()
|
$('<button>').text('cancel').addClass('floatright').click(function()
|
||||||
|
@ -495,10 +499,21 @@
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//turn all numbers into integers
|
|
||||||
$('input[type="number"]').each(function()
|
$('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
|
//check if all uints are actually uints
|
||||||
$('input.uint').each(function()
|
$('input.uint').each(function()
|
||||||
|
@ -611,21 +626,25 @@
|
||||||
// refresh every streams' data (status and viewer count)
|
// refresh every streams' data (status and viewer count)
|
||||||
function refreshStreams()
|
function refreshStreams()
|
||||||
{
|
{
|
||||||
getStreamsData(function(streams)
|
getStreamsData(function(streams)
|
||||||
{
|
{
|
||||||
for(stream in streams)
|
$('tbody#streams-list-tbody tr').each(function()
|
||||||
{
|
|
||||||
if( $('stream-' + stream) )
|
|
||||||
{
|
{
|
||||||
var row = $('#stream-' + stream);
|
streamstatus = null;
|
||||||
var status = streams[stream][0];
|
stream = $(this).attr('id').split('-')[1];
|
||||||
|
if (streams[stream] == undefined)
|
||||||
$(row.children()[4]).html( formatStatus(status) );
|
{
|
||||||
|
streamstatus = 'Stream config missing - reloading tab';
|
||||||
$(row.children()[5]).text(streams[stream][1]);
|
showTab('streams');
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
});
|
{
|
||||||
|
streamstatus = streams[stream][0];
|
||||||
|
}
|
||||||
|
$(this).children()[4].innerHTML = formatStatus(streamstatus);
|
||||||
|
$(this).children()[5].innerHTML = streams[stream][1];
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
sinterval = setInterval(function()
|
sinterval = setInterval(function()
|
||||||
|
@ -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(
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue