LSP: added server stats page and version update check
This commit is contained in:
parent
d0040e9b41
commit
b5bb288ac0
4 changed files with 200 additions and 84 deletions
|
@ -339,7 +339,7 @@
|
||||||
delete data.statistics; // same goes for the stats
|
delete data.statistics; // same goes for the stats
|
||||||
|
|
||||||
//IE breaks if the console isn't opened, so keep commented when committing
|
//IE breaks if the console isn't opened, so keep commented when committing
|
||||||
//console.log('[763] SEND', data);
|
console.log('[763] SEND', data);
|
||||||
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
|
@ -363,7 +363,7 @@
|
||||||
$('#shield').remove(); // remove loading display
|
$('#shield').remove(); // remove loading display
|
||||||
|
|
||||||
//IE breaks if the console isn't opened, so keep commented when committing
|
//IE breaks if the console isn't opened, so keep commented when committing
|
||||||
//console.log('[785] RECV', d);
|
console.log('[785] RECV', d);
|
||||||
|
|
||||||
if(d && d['authorize'] && d['authorize']['challenge'])
|
if(d && d['authorize'] && d['authorize']['challenge'])
|
||||||
{
|
{
|
||||||
|
@ -387,7 +387,7 @@
|
||||||
"version": ""
|
"version": ""
|
||||||
},
|
},
|
||||||
"streams": {},
|
"streams": {},
|
||||||
"capabilities": {},
|
"capabilities": {},
|
||||||
"log": {},
|
"log": {},
|
||||||
"statistics": {}
|
"statistics": {}
|
||||||
}, d);
|
}, d);
|
||||||
|
|
259
lsp/main.js
259
lsp/main.js
|
@ -79,6 +79,8 @@
|
||||||
// what kind of streams should be displayed? Format is [recorded, live];
|
// what kind of streams should be displayed? Format is [recorded, live];
|
||||||
var streamsdisplay = [true, true];
|
var streamsdisplay = [true, true];
|
||||||
|
|
||||||
|
// used on the overview page to decide then to ask the controller for an update check
|
||||||
|
var updatelastchecked;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
@ -172,82 +174,117 @@
|
||||||
|
|
||||||
case 'overview':
|
case 'overview':
|
||||||
|
|
||||||
$('#page').append(
|
|
||||||
$('<div>').attr('id', 'editserver').append(
|
loadSettings(function(){
|
||||||
$('<label>').attr('for', 'config-host').text('host').append(
|
|
||||||
$('<input>').attr('type', 'text').attr('placeholder', 'HOST').attr('id', 'config-host').attr('value', settings.settings.config.host)
|
$uptodate = null;
|
||||||
)
|
if (settings.settings.LTS == 1)
|
||||||
).append(
|
{
|
||||||
$('<label>').attr('for', 'config-name').text('name').append(
|
if ((settings.settings.update == undefined) || (updatelastchecked == undefined) || ((new Date()).getTime() - updatelastchecked > 3600000))
|
||||||
$('<input>').attr('type', 'text').attr('placeholder', 'NAME').attr('id', 'config-name').attr('value', settings.settings.config.name)
|
{
|
||||||
)
|
settings.settings.checkupdate = true;
|
||||||
).append(
|
settings.settings.update = {};
|
||||||
$('<label>').text('version').append(
|
updatelastchecked = (new Date()).getTime();
|
||||||
$('<span>').text(settings.settings.config.version)
|
loadSettings(function()
|
||||||
)
|
{
|
||||||
).append(
|
showTab('overview');
|
||||||
$('<label>').text('time').append(
|
});
|
||||||
$('<span>').text( formatDate(settings.settings.config.time) )
|
}
|
||||||
)
|
else
|
||||||
).append(
|
{
|
||||||
$('<label>').text('Streams').append(
|
if (settings.settings.update.uptodate == 0)
|
||||||
$('<span>').attr('id', 'cur_streams_online').text('retrieving data...')
|
{
|
||||||
)
|
$uptodate = $('<label>').text('version check').css('line-height','30px');
|
||||||
).append(
|
$uptodate.append(
|
||||||
$('<label>').text('Viewers').append(
|
$('<span>').attr('class','red').text('Outdated version!').append(
|
||||||
$('<span>').attr('id', 'cur_num_viewers').text('retrieving data...')
|
$('<button>').text('update').click(function(){
|
||||||
)
|
settings.settings.autoupdate = true;
|
||||||
)
|
loadSettings();
|
||||||
);
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#page').append(
|
||||||
|
$('<div>').attr('id', 'editserver').append(
|
||||||
|
$('<label>').attr('for', 'config-host').text('host').append(
|
||||||
|
$('<input>').attr('type', 'text').attr('placeholder', 'HOST').attr('id', 'config-host').attr('value', settings.settings.config.host)
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<label>').attr('for', 'config-name').text('name').append(
|
||||||
|
$('<input>').attr('type', 'text').attr('placeholder', 'NAME').attr('id', 'config-name').attr('value', settings.settings.config.name)
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<label>').text('version').append(
|
||||||
|
$('<span>').text(settings.settings.config.version)
|
||||||
|
).append($uptodate)
|
||||||
|
).append(
|
||||||
|
$('<label>').text('time').append(
|
||||||
|
$('<span>').text( formatDate(settings.settings.config.time) )
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<label>').text('Streams').append(
|
||||||
|
$('<span>').attr('id', 'cur_streams_online').text('retrieving data...')
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<label>').text('Viewers').append(
|
||||||
|
$('<span>').attr('id', 'cur_num_viewers').text('retrieving data...')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
function showStats()
|
function showStats()
|
||||||
{
|
{
|
||||||
getStatData(function(data)
|
getStatData(function(data)
|
||||||
{
|
{
|
||||||
$('#cur_streams_online').html('').text(data.streams[0] + ' of ' + data.streams[1] + ' online');
|
$('#cur_streams_online').html('').text(data.streams[0] + ' of ' + data.streams[1] + ' online');
|
||||||
$('#cur_num_viewers').html('').text(data.viewers);
|
$('#cur_num_viewers').html('').text(data.viewers);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// refresh the stream status + viewers
|
// refresh the stream status + viewers
|
||||||
sinterval = setInterval(function()
|
sinterval = setInterval(function()
|
||||||
{
|
{
|
||||||
showStats();
|
showStats();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
showStats();
|
showStats();
|
||||||
|
|
||||||
$('#editserver').append(
|
$('#editserver').append(
|
||||||
$('<button>').attr('class', 'floatright').click(function()
|
$('<button>').attr('class', 'floatright').click(function()
|
||||||
{
|
{
|
||||||
var host = $('#config-host').val();
|
var host = $('#config-host').val();
|
||||||
var name = $('#config-name').val();
|
var name = $('#config-name').val();
|
||||||
|
|
||||||
settings.settings.config.host = host;
|
settings.settings.config.host = host;
|
||||||
settings.settings.config.name = name;
|
settings.settings.config.name = name;
|
||||||
|
|
||||||
loadSettings(function()
|
loadSettings(function()
|
||||||
{
|
{
|
||||||
showTab('overview');
|
showTab('overview');
|
||||||
});
|
});
|
||||||
}).text( 'save' )
|
}).text( 'save' )
|
||||||
);
|
);
|
||||||
|
|
||||||
var forcesave = $('<div>').attr('id', 'forcesave');
|
var forcesave = $('<div>').attr('id', 'forcesave');
|
||||||
|
|
||||||
forcesave.append(
|
forcesave.append(
|
||||||
$('<p>').text('Click the button below to force an immediate settings save. This differs from a regular save to memory and file save on exit by saving directly to file while operating. This may slow server processes for a short period of time.')
|
$('<p>').text('Click the button below to force an immediate settings save. This differs from a regular save to memory and file save on exit by saving directly to file while operating. This may slow server processes for a short period of time.')
|
||||||
).append(
|
).append(
|
||||||
$('<button>').click(function()
|
$('<button>').click(function()
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
forceJSONSave();
|
forceJSONSave();
|
||||||
}
|
}
|
||||||
}).text( 'force save to JSON file' )
|
}).text( 'force save to JSON file' )
|
||||||
);
|
);
|
||||||
|
|
||||||
$('#page').append(forcesave);
|
$('#page').append(forcesave);
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -298,7 +335,10 @@
|
||||||
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);
|
||||||
showTab('protocols');
|
loadSettings(function()
|
||||||
|
{
|
||||||
|
showTab('protocols');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}).text('delete') ) );
|
}).text('delete') ) );
|
||||||
|
|
||||||
|
@ -338,7 +378,7 @@
|
||||||
}
|
}
|
||||||
protocolstatus = data.config.protocols[pid].online;
|
protocolstatus = data.config.protocols[pid].online;
|
||||||
}
|
}
|
||||||
$(this).children()[1].innerHTML = formatStatus( protocolstatus );
|
$(this).children(':nth-child(2)').html( formatStatus( protocolstatus ) );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -641,8 +681,8 @@
|
||||||
{
|
{
|
||||||
streamstatus = streams[stream][0];
|
streamstatus = streams[stream][0];
|
||||||
}
|
}
|
||||||
$(this).children()[4].innerHTML = formatStatus(streamstatus);
|
$(this).children(':nth-child(5)').html(formatStatus(streamstatus));
|
||||||
$(this).children()[5].innerHTML = streams[stream][1];
|
$(this).children(':nth-child(6)').html(streams[stream][1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -694,6 +734,8 @@
|
||||||
showTab('embed', sname);
|
showTab('embed', sname);
|
||||||
}) ) ); // end function, end click(), end append(), end append(). Huzzah jQuery.
|
}) ) ); // end function, end click(), end append(), end append(). Huzzah jQuery.
|
||||||
|
|
||||||
|
if ( cstr.name == undefined ) { cstr.name = ''; }
|
||||||
|
|
||||||
$tr.append( $('<td>').text( cstr.name ) );
|
$tr.append( $('<td>').text( cstr.name ) );
|
||||||
|
|
||||||
$tr.append( $('<td>').html( formatStatus( cstr.online ) ) );
|
$tr.append( $('<td>').html( formatStatus( cstr.online ) ) );
|
||||||
|
@ -1102,6 +1144,65 @@
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'server stats':
|
||||||
|
loadSettings(function(){
|
||||||
|
serverstats = settings.settings.capabilities;
|
||||||
|
|
||||||
|
console.log(serverstats); //weghalen
|
||||||
|
|
||||||
|
if (serverstats.cpu !== undefined)
|
||||||
|
{
|
||||||
|
$('#page').append(
|
||||||
|
$('<div>').attr('class','datacont').append(
|
||||||
|
$('<p>').text('CPU')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
//be careful, only works if this is the first div to be constructed
|
||||||
|
for (property in serverstats.cpu[0])
|
||||||
|
{
|
||||||
|
$('#page div.datacont').append(
|
||||||
|
$('<label>').text(property).append(
|
||||||
|
$('<span>').text(serverstats.cpu[0][property])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (serverstats.mem !== undefined)
|
||||||
|
{
|
||||||
|
$('#page').append(
|
||||||
|
$('<div>').attr('class','datacont').append(
|
||||||
|
$('<p>').text('Memory')
|
||||||
|
).append(
|
||||||
|
$('<label>').text('Physical memory').append(
|
||||||
|
$('<span>').text(serverstats.mem.used+'MiB/'+serverstats.mem.total+'MiB ('+serverstats.mem.free+'MiB available)')
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<label>').text('Swap memory').append(
|
||||||
|
$('<span>').text((serverstats.mem.swaptotal - serverstats.mem.swapfree)+'MiB/'+serverstats.mem.swaptotal+'MiB ('+serverstats.mem.swapfree+'MiB available)')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (serverstats.load !== undefined)
|
||||||
|
{
|
||||||
|
$('#page').append(
|
||||||
|
$('<div>').attr('class','datacont').append(
|
||||||
|
$('<p>').text('Load')
|
||||||
|
).append(
|
||||||
|
$('<label>').text('Memory used').append(
|
||||||
|
$('<span>').text(serverstats.load.memory+'%')
|
||||||
|
)
|
||||||
|
).append(
|
||||||
|
$('<label>').text('Loading averages').append(
|
||||||
|
$('<span>').text('1 min: '+serverstats.load.one+'%, 5 min: '+serverstats.load.five+'%, 15 min: '+serverstats.load.fifteen+'%')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'disconnect':
|
case 'disconnect':
|
||||||
showTab('login');
|
showTab('login');
|
||||||
setHeaderState('disconnected');
|
setHeaderState('disconnected');
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
<li>streams</li>
|
<li>streams</li>
|
||||||
<li>limits</li>
|
<li>limits</li>
|
||||||
<li>logs</li>
|
<li>logs</li>
|
||||||
|
<li>server stats</li>
|
||||||
<li id='logoutbutton'>disconnect</li>
|
<li id='logoutbutton'>disconnect</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ label select
|
||||||
width: 225px;
|
width: 225px;
|
||||||
}
|
}
|
||||||
|
|
||||||
label span
|
label span, label button
|
||||||
{
|
{
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
@ -290,6 +290,7 @@ th,
|
||||||
#login > button,
|
#login > button,
|
||||||
p,
|
p,
|
||||||
label,
|
label,
|
||||||
|
button,
|
||||||
#page label input,
|
#page label input,
|
||||||
#page label select,
|
#page label select,
|
||||||
#page > button,
|
#page > button,
|
||||||
|
@ -409,4 +410,17 @@ td
|
||||||
padding: 50px 0 0 0;
|
padding: 50px 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.datacont label span
|
||||||
|
{
|
||||||
|
font-weight: normal;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
.datacont label
|
||||||
|
{
|
||||||
|
padding-left: 25px;
|
||||||
|
}
|
||||||
|
.datacont p
|
||||||
|
{
|
||||||
|
margin-top: 25px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue