lsp protocol interface fix for 23 (#17)

This commit is contained in:
That-Guy 2012-04-21 17:18:51 +02:00
parent 3e5aa21ef9
commit 5892a176a3

View file

@ -561,17 +561,7 @@ td
{ {
var ret = $.extend(true, var ret = $.extend(true,
{ {
"config":
{
"host": "",
"limits": [],
"name": "",
"protocols": {},
"status": "",
"version": ""
},
"streams": {}, "streams": {},
"log": {},
"statistics": {} "statistics": {}
}, d); }, d);
@ -672,7 +662,7 @@ td
"host": "", "host": "",
"limits": [], "limits": [],
"name": "", "name": "",
"protocols": {}, "protocols": [],
"status": "", "status": "",
"version": "" "version": ""
}, },
@ -891,7 +881,7 @@ td
{ {
if(confirmDelete('Are you sure you want to force a JSON save?') == true) if(confirmDelete('Are you sure you want to force a JSON save?') == true)
{ {
console.log('magie hier!'); // TODO FIXME console.log('magie hier!'); // TODO FIXME JARON
} }
}).text( 'force save to JSON file' ) }).text( 'force save to JSON file' )
); );
@ -911,26 +901,30 @@ td
$table.html("<thead><th>Protocol</th><th>Port</th><th>Interface</th><th></th></thead>"); $table.html("<thead><th>Protocol</th><th>Port</th><th>Interface</th><th></th></thead>");
$tbody = $('<tbody>'); $tbody = $('<tbody>');
var tr, protocol; var tr, i, protocol,
len = settings.settings.config.protocols.length;
// remove old stuff // remove old stuff
$tbody.html(''); $tbody.html('');
for(protocol in settings.settings.config.protocols) for(i = 0; i < len; i++)
{ {
tr = $('<tr>').attr('id', 'protocol-' + protocol); protocol = settings.settings.config.protocols[i]; // local copy, {}
tr.append( $('<td>').text( protocol ) ); tr = $('<tr>').attr('id', 'protocol-' + i);
tr.append( $('<td>').text( settings.settings.config.protocols[protocol].port ) );
tr.append( $('<td>').text( '_' ) ); // interface tr.append( $('<td>').text( protocol.connector ) );
tr.append( $('<td>').text( protocol.port ) );
tr.append( $('<td>').text( protocol['interface'] ) ); // interface is a reserved JS keyword :)
tr.append( $('<td>').attr('class', 'center').append( $('<button>').click(function() tr.append( $('<td>').attr('class', 'center').append( $('<button>').click(function()
{ {
if(confirmDelete('Are you sure you want to delete this protocol?') == true) if(confirmDelete('Are you sure you want to delete this protocol?') == true)
{ {
var id = $(this).parent().parent().attr('id').replace('protocol-', ''); var id = $(this).parent().parent().attr('id').replace('protocol-', '');
delete settings.settings.config.protocols[protocol]; settings.settings.config.protocols.splice(i, 1);
//delete settings.settings.config.protocols[protocol];
$(this).parent().parent().remove(); $(this).parent().parent().remove();
loadSettings(); loadSettings();
} }
@ -966,13 +960,26 @@ td
if(!settings.settings.config.protocols) if(!settings.settings.config.protocols)
{ {
settings.settings.config.protocols = {}; //settings.settings.config.protocols = {};
settings.settings.config.protocols = [];
} }
/*
settings.settings.config.protocols[$('#new-protocol-name :selected').val()] = settings.settings.config.protocols[$('#new-protocol-name :selected').val()] =
{ {
port: $('#new-protocol-val').val() port: $('#new-protocol-val').val()
}; };
*/
var nobj =
{
connector: $('#new-protocol-name :selected').val(),
port: $('#new-protocol-val').val(),
};
nobj['interface'] = $('#new-protocol-interface').val();
settings.settings.config.protocols.push(nobj);
loadSettings(function() loadSettings(function()
{ {