Skip to content

Commit c3abb32

Browse files
authored
Merge pull request pterodactyl#204 from schrej/feature/terminal-only-scroll-at-bottom
Only auto-scroll terminal on new output when at the bottom
2 parents 0472706 + d844c41 commit c3abb32

File tree

4 files changed

+89
-42
lines changed

4 files changed

+89
-42
lines changed

public/js/jquery.terminal-0.11.23.min.js

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/jquery.terminal-0.11.6.min.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

public/themes/default/css/pterodactyl.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,24 @@ li.btn.btn-default.pill:active,li.btn.btn-default.pill:focus,li.btn.btn-default.
286286
opacity: 1;
287287
}
288288

289+
#consoleNotify {
290+
position: absolute;
291+
bottom: 0;
292+
margin-right: 17px;
293+
margin-bottom: 2px;
294+
z-index: 10;
295+
background: white;
296+
right: 0;
297+
opacity: .6;
298+
padding: 5px 7px;
299+
border-radius: 5px;
300+
cursor: pointer;
301+
}
302+
303+
#consoleNotify:hover {
304+
opacity: .9;
305+
}
306+
289307
.hasFileHover {
290308
border: 2px dashed #0087F7;
291309
border-radius: 5px;

resources/views/server/index.blade.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
@parent
2828
{!! Theme::css('css/jquery.terminal.css') !!}
2929
{!! Theme::js('js/jquery.mousewheel-min.js') !!}
30-
{!! Theme::js('js/jquery.terminal-0.11.6.min.js') !!}
30+
{!! Theme::js('js/jquery.terminal-0.11.23.min.js') !!}
3131
{!! Theme::js('js/unix_formatting.js') !!}
3232
{!! Theme::js('js/vendor/chartjs/chart.min.js') !!}
3333
{!! Theme::js('js/vendor/jquery/jquery-dateFormat.min.js') !!}
@@ -50,6 +50,9 @@
5050
<div class="alert alert-info hidden" id="consoleThrottled">
5151
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.
5252
</div>
53+
<div id="consoleNotify" class="hidden">
54+
<i class="fa fa-bell"></i>
55+
</div>
5356
<div id="terminal">
5457
</div>
5558
</div>
@@ -193,10 +196,30 @@
193196
height: 400,
194197
exit: false,
195198
prompt: '{{ $server->username }}:~$ ',
199+
scrollOnEcho: false,
200+
scrollBottomOffset: 5,
196201
onBlur: function (terminal) {
197202
return false;
198203
}
199204
});
205+
206+
const $consoleNotify = $('#consoleNotify');
207+
$consoleNotify.on('click', function () {
208+
terminal.scroll_to_bottom();
209+
$consoleNotify.removeClass('hidden');
210+
});
211+
212+
terminal.on('scroll', function() {
213+
if (terminal.is_bottom()) {
214+
$consoleNotify.addClass('hidden');
215+
}
216+
})
217+
218+
function terminalNotifyOutput() {
219+
if (!terminal.is_bottom()) {
220+
$consoleNotify.removeClass('hidden');
221+
}
222+
}
200223
201224
var ctc = $('#chart_cpu');
202225
var timeLabels = [];
@@ -326,10 +349,13 @@ function pushOutputQueue()
326349
$('#consoleThrottled').addClass('hidden');
327350
}
328351
329-
for (var i = 0; i < {{ env('CONSOLE_PUSH_COUNT', 10) }} && outputQueue.length > 0; i++)
330-
{
331-
terminal.echo(outputQueue[0]);
332-
outputQueue.shift();
352+
if (outputQueue.length > 0) {
353+
for (var i = 0; i < {{ env('CONSOLE_PUSH_COUNT', 10) }} && outputQueue.length > 0; i++)
354+
{
355+
terminal.echo(outputQueue[0]);
356+
outputQueue.shift();
357+
}
358+
terminalNotifyOutput();
333359
}
334360
}
335361
@@ -347,8 +373,10 @@ function pushOutputQueue()
347373
timeout: 10000
348374
}).done(function(data) {
349375
terminal.echo(data);
376+
terminalNotifyOutput();
350377
}).fail(function() {
351378
terminal.error('Unable to load initial server log, try reloading the page.');
379+
terminalNotifyOutput();
352380
});
353381
}
354382
updateServerPowerControls(data.status);

0 commit comments

Comments
 (0)