Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#849: Log plugin - Add option to turn auto scroll on|off. And fixed a…
…uto scroll when desc sorting.
  • Loading branch information
davsclaus committed Dec 15, 2013
1 parent 164315a commit fa5def7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
10 changes: 10 additions & 0 deletions hawtio-web/src/main/webapp/app/core/html/preferences.html
Expand Up @@ -184,6 +184,16 @@
</div>
</form>

<form class="form-horizontal">
<label class="control-label">Auto Scroll</label>
<div class="control-group">
<div class="controls">
<input type="checkbox" ng-model="logAutoScroll">
<span class="help-block">Whether to automatic scroll window when new log lines is added</span>
</div>
</div>
</form>

<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="logCacheSize" title="The number of log messages to keep in the browser">Log
Expand Down
4 changes: 3 additions & 1 deletion hawtio-web/src/main/webapp/app/core/js/preferences.ts
Expand Up @@ -111,6 +111,7 @@ module Core {
var defaults = {
logCacheSize: 1000,
logSortAsc: true,
logAutoScroll: true,
fabricAlwaysPrompt: false,
fabricEnableMaps: true,
camelIgnoreIdForLabel: false,
Expand All @@ -121,6 +122,7 @@ module Core {
var converters = {
logCacheSize: parseInt,
logSortAsc: parseBooleanValue,
logAutoScroll: parseBooleanValue,
fabricAlwaysPrompt: parseBooleanValue,
fabricEnableMaps: parseBooleanValue,
camelIgnoreIdForLabel: parseBooleanValue,
Expand Down Expand Up @@ -148,7 +150,7 @@ module Core {
});

var names = ["showWelcomePage", "gitUserName", "gitUserEmail", "activemqUserName", "activemqPassword",
"logCacheSize", "logSortAsc", "fabricAlwaysPrompt", "fabricEnableMaps", "camelIgnoreIdForLabel", "camelMaximumLabelWidth",
"logCacheSize", "logSortAsc", "logAutoScroll", "fabricAlwaysPrompt", "fabricEnableMaps", "camelIgnoreIdForLabel", "camelMaximumLabelWidth",
"camelMaximumTraceOrDebugBodyLength"];

angular.forEach(names, (name) => {
Expand Down
22 changes: 15 additions & 7 deletions hawtio-web/src/main/webapp/app/log/js/logs.ts
Expand Up @@ -19,8 +19,11 @@ module Log {
if (angular.isString(value)) {
$scope.sortAsc = "true" === value;
}

log.info("Sorting from preference is " + $scope.sortAsc)
$scope.autoScroll = true;
var value = localStorage["logAutoScroll"];
if (angular.isString(value)) {
$scope.autoScroll = "true" === value;
}

$scope.logs = [];
$scope.branding = Branding.enabled;
Expand Down Expand Up @@ -217,9 +220,14 @@ module Log {
scrollToTopOrBottom = true;
}

var pos = window.scrollTop() + window.height();
var threshold = Core.getDocHeight() - 100;
if ( (pos) > (threshold) ) {
if ($scope.sortAsc) {
var pos = window.scrollTop() + window.height();
var threshold = Core.getDocHeight() - 100;
} else {
var pos = window.scrollTop() + window.height();
var threshold = 100;
}
if ( pos > threshold ) {
// page is scrolled near the bottom
scrollToTopOrBottom = true;
}
Expand Down Expand Up @@ -269,7 +277,7 @@ module Log {
}
}
if (counter) {
if (scrollToTopOrBottom) {
if ($scope.autoScroll && scrollToTopOrBottom) {
setTimeout(() => {
var pos = 0;
if ($scope.sortAsc) {
Expand Down Expand Up @@ -306,6 +314,6 @@ module Log {
});

scopeStoreJolokiaHandle($scope, jolokia, jolokia.register(callback, $scope.queryJSON));

}

}

0 comments on commit fa5def7

Please sign in to comment.