Fix the log view performance issues in the build history view by creating a specialized collection class that asynchronously adds the items to be displayed in a batch-like manner.
This commit is contained in:
parent
a727717add
commit
877427378d
3 changed files with 90 additions and 23 deletions
|
@ -105,6 +105,86 @@ function getMarkedDown(string) {
|
|||
quayApp = angular.module('quay', ['ngRoute', 'chieffancypants.loadingBar', 'angular-tour', 'restangular', 'angularMoment', 'angulartics', /*'angulartics.google.analytics',*/ 'angulartics.mixpanel', 'mgcrea.ngStrap', 'ngCookies', 'ngSanitize', 'angular-md5', 'pasvaz.bindonce', 'ansiToHtml', 'ngAnimate'], function($provide, cfpLoadingBarProvider) {
|
||||
cfpLoadingBarProvider.includeSpinner = false;
|
||||
|
||||
/**
|
||||
* Specialized wrapper around array which provides a toggle() method for viewing the contents of the
|
||||
* array in a manner that is asynchronously filled in over a short time period. This prevents long
|
||||
* pauses in the UI for ngRepeat's when the array is significant in size.
|
||||
*/
|
||||
$provide.factory('AngularViewArray', ['$interval', function($interval) {
|
||||
var ADDTIONAL_COUNT = 50;
|
||||
|
||||
function _ViewArray() {
|
||||
this.isVisible = false;
|
||||
this.visibleEntries = null;
|
||||
this.hasEntries = false;
|
||||
this.entries = [];
|
||||
|
||||
this.timerRef_ = null;
|
||||
this.currentIndex_ = 0;
|
||||
}
|
||||
|
||||
_ViewArray.prototype.push = function(elem) {
|
||||
this.entries.push(elem);
|
||||
this.hasEntries = true;
|
||||
|
||||
if (this.isVisible) {
|
||||
this.setVisible(true);
|
||||
}
|
||||
};
|
||||
|
||||
_ViewArray.prototype.toggle = function() {
|
||||
this.setVisible(!this.isVisible);
|
||||
};
|
||||
|
||||
_ViewArray.prototype.setVisible = function(newState) {
|
||||
this.isVisible = newState;
|
||||
|
||||
this.visibleEntries = [];
|
||||
this.currentIndex_ = 0;
|
||||
|
||||
if (newState) {
|
||||
this.showAdditionalEntries_();
|
||||
this.startTimer_();
|
||||
} else {
|
||||
this.stopTimer_();
|
||||
}
|
||||
};
|
||||
|
||||
_ViewArray.prototype.showAdditionalEntries_ = function() {
|
||||
var i = 0;
|
||||
for (i = this.currentIndex_; i < (this.currentIndex_ + ADDTIONAL_COUNT) && i < this.entries.length; ++i) {
|
||||
this.visibleEntries.push(this.entries[i]);
|
||||
}
|
||||
|
||||
this.currentIndex_ = i;
|
||||
if (this.currentIndex_ >= this.entries.length) {
|
||||
this.stopTimer_();
|
||||
}
|
||||
};
|
||||
|
||||
_ViewArray.prototype.startTimer_ = function() {
|
||||
var that = this;
|
||||
this.timerRef_ = $interval(function() {
|
||||
that.showAdditionalEntries_();
|
||||
}, 10);
|
||||
};
|
||||
|
||||
_ViewArray.prototype.stopTimer_ = function() {
|
||||
if (this.timerRef_) {
|
||||
$interval.cancel(this.timerRef_);
|
||||
this.timerRef_ = null;
|
||||
}
|
||||
};
|
||||
|
||||
var service = {
|
||||
'create': function() {
|
||||
return new _ViewArray();
|
||||
}
|
||||
};
|
||||
|
||||
return service;
|
||||
}]);
|
||||
|
||||
$provide.factory('UtilService', ['$sanitize', function($sanitize) {
|
||||
var utilService = {};
|
||||
|
||||
|
|
Reference in a new issue