Skip to content

Commit

Permalink
Fix logs scrolling (#1451)
Browse files Browse the repository at this point in the history
  • Loading branch information
juankaromo authored and Jesús Ángel committed May 17, 2019
1 parent 4b8736f commit f458b2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion public/controllers/management/logs.js
Expand Up @@ -53,7 +53,8 @@ export class LogsController {
this.$scope.XMLContent = this.parseLogsToText(parameters.items) || '';

this.$scope.$broadcast('XMLContentReady', {
data: this.$scope.XMLContent
data: this.$scope.XMLContent,
logs: true
});
this.$scope.$applyAsync();
this.$scope.$broadcast('doRefresh', { type: 'xml' });
Expand Down
22 changes: 13 additions & 9 deletions public/directives/wz-config-viewer/wz-config-viewer.js
Expand Up @@ -69,16 +69,17 @@ class WzConfigViewer {
bindXmlListener();
};

$(window).on('resize', function() {
$(window).on('resize', function () {
dynamicHeight();
});

const dynamicHeight = () => {
setTimeout(function() {
setTimeout(function () {
const editorContainer = $('.configViewer');
const windows = $(window).height();
const offsetTop = getPosition(editorContainer[0]).y;
editorContainer.height(windows - (offsetTop + 20));
const bottom = $scope.isLogs ? 75 : 20;
editorContainer.height(windows - (offsetTop + bottom));
}, 1);
};

Expand All @@ -89,25 +90,28 @@ class WzConfigViewer {
}
if ($scope.jsoncontent != false) {
$scope.jsonCodeBox.setValue($scope.jsoncontent.replace(/\\\\/g, '\\'));
setTimeout(function() {
setTimeout(function () {
$scope.jsonCodeBox.refresh();
$scope.$applyAsync();
window.dispatchEvent(new Event('resize')); // eslint-disable-line
}, 200);
}
};

const refreshXmlBox = xml => {
const refreshXmlBox = (xml, isLogs) => {
$scope.isLogs = isLogs;
$scope.xmlcontent = xml;
if (!$scope.xmlCodeBox) {
setXmlBox();
}
if ($scope.xmlcontent != false) {
$scope.xmlCodeBox.setValue($scope.xmlcontent);
setTimeout(function() {
setTimeout(function () {
$scope.xmlCodeBox.refresh();
$scope.$applyAsync();
window.dispatchEvent(new Event('resize')); // eslint-disable-line
$scope.isLogs
? dynamicHeight()
: window.dispatchEvent(new Event('resize'));
}, 200);
}
};
Expand All @@ -121,12 +125,12 @@ class WzConfigViewer {
});

$scope.$on('XMLContentReady', (ev, params) => {
refreshXmlBox(params.data);
refreshXmlBox(params.data, params.logs);
});

const bindXmlListener = () => {
var scrollElement = $scope.xmlCodeBox.getScrollerElement();
$(scrollElement).bind('scroll', function(e) {
$(scrollElement).bind('scroll', function (e) {
var element = $(e.currentTarget)[0];
if (element.scrollHeight - element.scrollTop === element.clientHeight) {
$scope.$emit('scrolledToBottom', {
Expand Down

0 comments on commit f458b2e

Please sign in to comment.