added log reader to server.html and fixed stream group bug (#17, done, 0.5h)

This commit is contained in:
That-Guy 2012-03-18 21:27:28 +01:00
parent ff15e6c1a6
commit 5c2623ae48

View file

@ -25,7 +25,7 @@
h2 h2
{ {
margin: 0 0 10px 0; margin: 0 0 10px 0;
background-color: #000; background-color: #333;
color: #fff; color: #fff;
font-size: 1.2em; font-size: 1.2em;
padding: 5px; padding: 5px;
@ -52,13 +52,13 @@
width: 25%; width: 25%;
} }
#stream-limit-table #stream-limit-table, #logs table
{ {
width: 100%; width: 100%;
margin: 10px 0 20px 15px; margin: 10px 0 20px 15px;
} }
#stream-limit-table th #stream-limit-table th, #logs th, #limits-table th
{ {
text-align: left; text-align: left;
} }
@ -69,12 +69,6 @@
width: 100%; width: 100%;
} }
#limits-table th
{
text-align: left;
}
#limits p, #protocols p #limits p, #protocols p
{ {
margin: 20px 0 5px 15px; margin: 20px 0 5px 15px;
@ -307,6 +301,24 @@
</div> </div>
<div id='logs'>
<h2>Logs</h2>
<table>
<thead>
<th>Date</th>
<th>Type</th>
<th>Message</th>
</thead>
<tbody id='log-list'>
</tbody>
</table>
</div>
<script> <script>
@ -347,7 +359,7 @@
} }
} }
return 'error'; return '[error] name "' + name + '" has no entry in rep (@350)!';
} }
@ -501,6 +513,9 @@
// streams // streams
fillStreams(); fillStreams();
// log
fillLogs();
} }
@ -598,7 +613,7 @@
cur = settings.settings.streams[stream]; cur = settings.settings.streams[stream];
li.append( $('<div>').text('Name:').append( li.append( $('<div>').text('Name: ').append(
$('<input>').attr('type', 'text').attr('id', 'stream-name-' + stream).attr('value', cur.name) $('<input>').attr('type', 'text').attr('id', 'stream-name-' + stream).attr('value', cur.name)
).append( ).append(
$('<span>').text('<save>').click(function(x) $('<span>').text('<save>').click(function(x)
@ -615,7 +630,23 @@
li.append($('<div>').text('Group: ' + cur.group)); //li.append($('<div>').text('Group: ' + cur.group));
li.append( $('<div>').text('Group: ').append(
$('<input>').attr('type', 'text').attr('id', 'stream-group-' + stream).attr('value', cur.group)
).append(
$('<span>').text('<save>').click(function(x)
{
return function()
{
var group = $('#stream-group-' + x).val();
settings.settings.streams[x].group = group;
loadSettings(fillStreams);
}
}(stream))
) );
@ -805,7 +836,7 @@
// new stream // new stream
var nspreset = $('<div>').attr('id', 'new-stream').text('New stream').append( var nspreset = $('<div>').attr('id', 'new-stream').text('New stream').append(
$('<div>').text('ID:').append( $('<div>').text('Name: ').append(
$('<input>').attr('id', 'new-stream-name').attr('type', 'text') $('<input>').attr('id', 'new-stream-name').attr('type', 'text')
).append( ).append(
$('<button>').text('create').click(function() $('<button>').text('create').click(function()
@ -818,7 +849,7 @@
"channel": {"URL": "", "account": ""}, "channel": {"URL": "", "account": ""},
"group": "", "group": "",
"limits": [], "limits": [],
"name": "", "name": $('#new-stream-name').val(),
"preset": {"cmd": "", "name": "", "desc": ""}, "preset": {"cmd": "", "name": "", "desc": ""},
"status": "" "status": ""
} }
@ -834,6 +865,32 @@
} }
function fillLogs()
{
var i, cur, tr,
tbody = $('#log-list'),
logs = settings.settings.log.reverse(),
len = logs.length;
for(i = 0; i < len; i++)
{
cur = settings.settings.log[i];
tr = $('<tr>').append(
$('<td>').text(new Date(cur[0] * 1000).toUTCString())
).append(
$('<td>').text(cur[1])
).append(
$('<td>').text(cur[2])
);
tbody.append(tr);
}
}
</script> </script>
</body> </body>