From c80c6714a19dbf9779623f99d852f70134d11470 Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Sat, 10 Dec 2016 00:17:23 +0100 Subject: [PATCH] add small notification to terminal if new invisible output is available --- public/themes/default/css/pterodactyl.css | 18 ++++++++++++ resources/views/server/index.blade.php | 34 ++++++++++++++++++++--- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/public/themes/default/css/pterodactyl.css b/public/themes/default/css/pterodactyl.css index 607da8d1f..739f65fb1 100755 --- a/public/themes/default/css/pterodactyl.css +++ b/public/themes/default/css/pterodactyl.css @@ -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; diff --git a/resources/views/server/index.blade.php b/resources/views/server/index.blade.php index fc296c541..5ca05e73a 100644 --- a/resources/views/server/index.blade.php +++ b/resources/views/server/index.blade.php @@ -50,6 +50,9 @@ +
@@ -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);