diff --git a/server-rel.html b/server-rel.html index b201dacd..9a10cb4c 100644 --- a/server-rel.html +++ b/server-rel.html @@ -86,6 +86,7 @@ tbody tr:nth-child(odd) + /* login stuff */ #login @@ -270,6 +271,11 @@ label input width: 225px; } +label span +{ + float: right; +} + #editserver { @@ -278,6 +284,16 @@ label input +thead th .theadinfo +{ + color: #848484; + padding: 0 0 0 10px; + font: normal normal 9pt Arial, sans-serif; +} + + + + /* fonts */ #header-title > span, #header-connection, #header-host, @@ -413,6 +429,19 @@ td } + function TypeofResource(uri) + { + var protocol = /([a-zA-Z]+):\/\//.exec(uri); + + if(protocol === null || (protocol[1] && protocol[1] === 'file')) + { + return 'VoD'; + }else{ + return 'Live'; + } + } + + function shortToLongLimit(name) { console.log('getting the long name for the limit "' + name + '"'); @@ -537,10 +566,9 @@ td { case 'login': -//TODO fixme login creds var host = $('').attr('type', 'text').attr('placeholder', 'HTTP://LOCALHOST:4242'); - var user = $('').attr('type', 'text').attr('placeholder', 'USERNAME').attr('value', 'testaccount'); - var pass = $('').attr('type', 'password').attr('placeholder', 'PASSWORD').attr('value', 'pisvlek'); + var user = $('').attr('type', 'text').attr('placeholder', 'USERNAME'); + var pass = $('').attr('type', 'password').attr('placeholder', 'PASSWORD'); var conn = $('').click(function() { // get login info @@ -591,7 +619,42 @@ td case 'overview': - $('#page').append($('').text('TODO overview')); + $('#page').append( + $('').attr('id', 'editserver').append( + $('').attr('for', 'config-host').text('host').append( + $('').attr('type', 'text').attr('placeholder', 'HOST').attr('id', 'config-host').attr('value', settings.settings.config.host) + ) + ).append( + $('').attr('for', 'config-name').text('name').append( + $('').attr('type', 'text').attr('placeholder', 'SOURCE').attr('id', 'config-name').attr('value', settings.settings.config.name) + ) + ).append( + $('').text('version').append( + $('').text(settings.settings.config.version) + ) + ).append( + $('').text('time').append( + $('').text( formatDate(settings.settings.config.time) ) + ) + ) + ); + + $('#editserver').append( + $('').attr('class', 'floatright').click(function() + { + var host = $('#config-host').val(); + var name = $('#config-name').val(); + + settings.settings.config.host = host; + settings.settings.config.name = name; + + loadSettings(function() + { + showTab('overview'); + }); + }).text( 'save' ) + ); + break; @@ -649,6 +712,11 @@ td return; } + if(!settings.settings.config.protocols) + { + settings.settings.config.protocols = {}; + } + settings.settings.config.protocols[$('#new-protocol-name :selected').val()] = { port: $('#new-protocol-val').val() @@ -677,7 +745,7 @@ td case 'streams': $table = $(''); - $table.html("TypeNameStatus# V"); + $table.html("TypeEmbedNameStatusViewersEdit"); $tbody = $(''); var stream, cstr, $tr; @@ -690,14 +758,29 @@ td $tr = $('').attr('id', 'stream-' + stream); - $tr.append( $('').text('?') ); + + $tr.append( $('').text( TypeofResource( cstr.channel.URL ) ) ); + $tr.append( $('').append( $('').text('embed') ) ); + // TODO do something when pressed! + // FIXME need Thulinma's embed code $tr.append( $('').text(cstr.name) ); - $tr.append( $('').text(cstr.status) ); - $tr.append( $('').text(cstr.online) ); + + $tr.append( $('').text(cstr.online == 1 ? 'Running' : 'Error') ); + + + var cviewers = 0; + if(settings.settings.statistics[stream] && settings.settings.statistics[stream].curr) + { + for(viewer in settings.settings.statistics[stream].curr) + { + cviewers++; + } + } + $tr.append( $('').text( cviewers ) ); $tr.append( $('').append( $('').text('edit').click(function() @@ -743,11 +826,10 @@ td { URL: '' }, - limits: {}, + limits: [], preset: { - cmd: '', - desc:'' + cmd: '' } }; title = 'add new stream'; @@ -772,10 +854,6 @@ td $('').attr('for', 'stream-edit-preset').text('preset').append( $('').attr('type', 'text').attr('placeholder', 'PRESET').attr('id', 'stream-edit-preset').attr('value', sdata.preset.cmd) ) - ).append( - $('').attr('for', 'stream-edit-preset-descr').text('preset descr').append( - $('').attr('type', 'text').attr('placeholder', 'PRESET DESCRIPTION').attr('id', 'stream-edit-preset-descr').attr('value', sdata.preset.desc) - ) ) ); @@ -798,7 +876,35 @@ td $('#editserver').append( $('').attr('class', 'floatright').click(function() { - /// TODO settings.settings.streams[streamname] = sdata????? + var n = $('#stream-edit-name'); + var s = $('#stream-edit-source'); + var p = $('#stream-edit-preset'); + + if(n.val() == ''){ n.focus(); return; } + if(s.val() == ''){ s.focus(); return; } + if(p.val() == ''){ p.focus(); return; } + + sdata.name = n.val(); + sdata.channel.URL = s.val(); + sdata.preset.cmd = p.val(); + + if(streamname == 'new') + { + streamname = n.val().replace(' ', '-'); + } + + if(!settings.settings.streams) + { + settings.settings.streams = {}; + } + + settings.settings.streams[streamname] = sdata; + + loadSettings(function() + { + showTab('streams'); + }); + }).text('save') ); @@ -809,11 +915,29 @@ td case 'limits': $table = $(''); - $table.html("TypeHard/soft limitValue"); + $table.html("TypeHard/softValueapplies toAction"); $tbody = $(''); - var i, tr, limit, - len = settings.settings.config.limits.length; + var i, tr, limit, stream, clims, + alllimits = settings.settings.config.limits; + + for(stream in settings.settings.streams) + { + clims = settings.settings.streams[stream].limits; + + $.each(clims, function(k, v) + { + this.appliesto = stream; + this.appliesi = k; + }); + + alllimits = alllimits.concat(clims); + } + + console.log(alllimits); + + len = alllimits.length; + // remove old stuff $tbody.html(''); @@ -821,16 +945,39 @@ td for(i = 0; i < len; i++) { tr = $('').attr('id', 'limits-' + i); - limit = settings.settings.config.limits[i]; + limit = alllimits[i]; tr.append( $('').text( shortToLongLimit(limit.name) ) ); tr.append( $('').text( limit.type ) ); tr.append( $('').text( limit.val ) ); + + if(limit.appliesto) + { + tr.append( $('').text( settings.settings.streams[limit.appliesto].name ).attr('id', 'limit-at-' + limit.appliesto + '-' + limit.appliesi) ); + }else{ + tr.append( $('').text( 'server' ) ); + } + + delete limit.appliesto; + delete limit.appliesi; + tr.append( $('').attr('class', 'center').append( $('').click(function() { var id = $(this).parent().parent().attr('id').replace('limits-', ''); - settings.settings.config.limits.splice(id, 1); + var at = $($(this).parent().parent().children()[3]).attr('id'); + + if(at == undefined) + { + settings.settings.config.limits.splice(id, 1); + }else{ + var data = at.replace('limit-at-', '').split('-'); + var loc = data.pop(); + data = data.join('-'); + + settings.settings.streams[data].limits.splice(loc, 1); + } + $(this).parent().parent().remove(); loadSettings(); @@ -854,16 +1001,36 @@ td // val $nltr.append( $('').append( $('').attr('type', 'text').attr('id', 'new-limit-val') ) ); + + // appliesto + var $appliesto = $('').attr('id', 'new-limit-appliesto').append( $('').attr('value', 'server').text('Server') ); + + for(var strm in settings.settings.streams) + { + $appliesto.append( + $('').attr('value', strm).text(settings.settings.streams[strm].name) + ); + } + $nltr.append( $('').append( $appliesto ) ); + + $nltr.append( $('').attr('class', 'center').append( $('').click(function() { - settings.settings.config.limits.push( + var obj = { name: $('#new-limit-type :selected').val(), type: $('#new-limit-hs :selected').val(), val: $('#new-limit-val').val() - }); + }; + + if( $('#new-limit-appliesto').val() == 'server') + { + settings.settings.config.limits.push(obj); + }else{ + settings.settings.streams[ $('#new-limit-appliesto').val() ].limits.push(obj); + } loadSettings(function() { @@ -886,7 +1053,7 @@ td case 'logs': $table = $(''); - $table.html("DateTypeMessage"); + $table.html("Date(MM/DD/YYYY)TypeMessage"); $tbody = $(''); var i, cur, $tr,
').text('TODO overview')); + $('#page').append( + $('