add small notification to terminal if new invisible output is available

This commit is contained in:
Jakob Schrettenbrunner 2016-12-10 00:17:23 +01:00
parent 96462a119f
commit c80c6714a1
2 changed files with 48 additions and 4 deletions

View file

@ -286,6 +286,24 @@ li.btn.btn-default.pill:active,li.btn.btn-default.pill:focus,li.btn.btn-default.
opacity: 1;
}
#consoleNotify {
position: absolute;
bottom: 0;
margin-right: 17px;
margin-bottom: 2px;
z-index: 10;
background: white;
right: 0;
opacity: .6;
padding: 5px 7px;
border-radius: 5px;
cursor: pointer;
}
#consoleNotify:hover {
opacity: .9;
}
.hasFileHover {
border: 2px dashed #0087F7;
border-radius: 5px;

View file

@ -50,6 +50,9 @@
<div class="alert alert-info hidden" id="consoleThrottled">
The console is currently being throttled due to the speed at which data is being sent. Messages are being queued and will appear as the queue is worked through.
</div>
<div id="consoleNotify" class="hidden">
<i class="fa fa-bell"></i>
</div>
<div id="terminal">
</div>
</div>
@ -198,6 +201,24 @@ $(window).load(function () {
return false;
}
});
const $consoleNotify = $('#consoleNotify');
$consoleNotify.on('click', function () {
terminal.scroll_to_bottom();
$consoleNotify.removeClass('hidden');
});
terminal.on('scroll', function() {
if (terminal.is_bottom()) {
$consoleNotify.addClass('hidden');
}
})
function terminalNotifyOutput() {
if (!terminal.is_bottom()) {
$consoleNotify.removeClass('hidden');
}
}
var ctc = $('#chart_cpu');
var timeLabels = [];
@ -327,10 +348,13 @@ $(window).load(function () {
$('#consoleThrottled').addClass('hidden');
}
for (var i = 0; i < {{ env('CONSOLE_PUSH_COUNT', 10) }} && outputQueue.length > 0; i++)
{
terminal.echo(outputQueue[0]);
outputQueue.shift();
if (outputQueue.length > 0) {
for (var i = 0; i < {{ env('CONSOLE_PUSH_COUNT', 10) }} && outputQueue.length > 0; i++)
{
terminal.echo(outputQueue[0]);
outputQueue.shift();
}
terminalNotifyOutput();
}
}
@ -348,8 +372,10 @@ $(window).load(function () {
timeout: 10000
}).done(function(data) {
terminal.echo(data);
terminalNotifyOutput();
}).fail(function() {
terminal.error('Unable to load initial server log, try reloading the page.');
terminalNotifyOutput();
});
}
updateServerPowerControls(data.status);