Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,56 +66,4 @@
expect(controller.selectedIds.length).toEqual(0);
});
});

describe('when loading the data with infinite scroll',
function() {
var controller, serviceControlService, root, deferred, getFailedMessageSpy;

beforeEach(inject(function ($rootScope, notifyService, $q) {
root = $rootScope;
this.notifyService = notifyService;
serviceControlService = { getExceptionGroups: function () { }, getFailedMessages: function(){ } };
deferred = $q.defer();
spyOn(serviceControlService, 'getExceptionGroups').and.callFake(function () {

return deferred.promise;
});

getFailedMessageSpy = spyOn(serviceControlService, 'getFailedMessages').and.callFake(function () {
return deferred.promise;
});

controller = $controller('failedMessagesController',
{
$scope: root,
$timeout: null,
$interval: function(){},
$location: null,
sharedDataService: { getstats: function() { return { number_of_pending_retries: 0 }; } },
notifyService: notifyService,
serviceControlService: serviceControlService,
failedMessageGroupsService: null
});
}));

it('no load happens when initial load is in progress',
function () {
expect(getFailedMessageSpy).toHaveBeenCalledTimes(1);

controller.loadMoreResults(controller.selectedExceptionGroup, true);

expect(getFailedMessageSpy).toHaveBeenCalledTimes(1);
});

it('load happens when initial load is done',
function () {
root.$apply(function () { deferred.resolve({data: []}) });
expect(getFailedMessageSpy).toHaveBeenCalledTimes(1);

controller.loadMoreResults(controller.selectedExceptionGroup, true);

expect(getFailedMessageSpy).toHaveBeenCalledTimes(2);
});

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$httpBackend.whenGET('http://localhost:33333/api/errors/queues/addresses').respond(null);
$httpBackend.whenGET('http://localhost:33333/api/redirects').respond(null);

pendingRetryService = { retryPendingRetriedMessages: function () { } };
pendingRetryService = { retryPendingRetriedMessages: function () { }, getPendingRetryMessages: function(){ return {then: function(){}}} };
controller = $controller('pendingRetriesController', {
$scope: $scope,
$timeout: null,
Expand All @@ -40,7 +40,7 @@
controller.pendingRetryMessages = [{ id: 1, submittedForRetrial: false, selected: true }, { id: 2, submittedForRetrial: false, selected: false }, { id: 3, submittedForRetrial: false, selected: true }];
controller.selectedIds = [1, 3];
controller.retrySelected();

root.$apply(function () { deferred.resolve('Remote call result') });

expect(controller.selectedIds.length).toEqual(0);
Expand All @@ -58,13 +58,13 @@
var $scope, controller, pendingRetryService, root, $httpBackend;

beforeEach(inject(function ($rootScope, $injector) {
$scope = {};
$scope = { };
root = $rootScope;
$httpBackend = $injector.get('$httpBackend');
$httpBackend.whenGET('http://localhost:33333/api/errors/queues/addresses').respond(null);
$httpBackend.whenGET('http://localhost:33333/api/redirects').respond(null);

pendingRetryService = { retryAllMessages: function () { } };
pendingRetryService = { retryAllMessages: function () { }, getPendingRetryMessages: function(){ return {then: function(){}}} };
controller = $controller('pendingRetriesController', {
$scope: $scope,
$timeout: null,
Expand Down Expand Up @@ -113,7 +113,7 @@
$httpBackend = $injector.get('$httpBackend');
$httpBackend.whenGET('http://localhost:33333/api/errors/queues/addresses').respond(null);
$httpBackend.whenGET('http://localhost:33333/api/redirects').respond(null);
pendingRetryService = { markAsResolvedMessages: function () { } };
pendingRetryService = { markAsResolvedMessages: function () { }, getPendingRetryMessages: function(){ return {then: function(){}}} };
controller = $controller('pendingRetriesController', {
$scope: $scope,
$timeout: null,
Expand Down Expand Up @@ -158,7 +158,7 @@
$httpBackend = $injector.get('$httpBackend');
$httpBackend.whenGET('http://localhost:33333/api/errors/queues/addresses').respond(null);
$httpBackend.whenGET('http://localhost:33333/api/redirects').respond(null);
pendingRetryService = { markAsResolvedAllMessages: function () { } };
pendingRetryService = { markAsResolvedAllMessages: function () { }, getPendingRetryMessages: function(){ return {then: function(){}}} };
controller = $controller('pendingRetriesController', {
$scope: $scope,
$timeout: null,
Expand Down Expand Up @@ -218,7 +218,7 @@
var message = { retried: true, number_of_processing_attempts: 1 };

var result = controller.noStatusPresent(message);

expect(result).toEqual(false);
}));

Expand Down
1 change: 0 additions & 1 deletion src/ServicePulse.Host/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'toaster',
'toastService',
'ui.bootstrap',
'infinite-scroll',
'services',
'ui.particular',
'ui.particular.reindexingstatus',
Expand Down
8 changes: 7 additions & 1 deletion src/ServicePulse.Host/app/js/views/archive/archive-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h3 class="active group-title group-message-count">{{vm.total | number}} message

<no-data ng-show="vm.archives.length === 0 && !vm.loadingData" title="message failures" message="There are currently no deleted messages"></no-data>

<div class="row" ng-show="vm.archives.length > 0" infinite-scroll="vm.loadMoreResults(vm.selectedExceptionGroup)" infinite-scroll-distance="0" infinite-scroll-listen-for-event="list:updated" infinite-scroll-disabled="vm.disableLoadingData" class="clearfix">
<div class="row" ng-show="vm.archives.length > 0" class="clearfix">

<div class="col-sm-12 no-mobile-side-padding" ng-repeat="message in vm.archives">

Expand Down Expand Up @@ -96,5 +96,11 @@ <h3 class="active group-title group-message-count">{{vm.total | number}} message
</div>
</div>
</div>
<div class="row ">
<div class="col-md-4"></div>
<div class="col-md-6">
<ul uib-pagination ng-hide="vm.pager.total <= vm.pager.perPage" items-per-page="vm.pager.perPage" total-items="vm.pager.total" ng-model="vm.pager.page" max-size="10" boundary-link-numbers="true" ng-change="vm.loadMoreResults()"></ul>
</div>
</div>
</section>
</div>
25 changes: 15 additions & 10 deletions src/ServicePulse.Host/app/js/views/archive/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@

vm.selectedArchiveGroup = { 'id': $routeParams.groupId ? $routeParams.groupId : undefined, 'title': 'All deleted messages', 'count': 0, 'initialLoad': true };

vm.pager = {
page: 1,
total: 1,
perPage: 50
};

vm.sort = {
sortby: 'modified',
direction: 'desc',
page: 1,
start: undefined,
end: undefined,
buttonText: function () {
Expand Down Expand Up @@ -66,9 +71,9 @@
return nObj;
});

vm.archives = vm.archives.concat(exgroups);
vm.selectedIds = [];
vm.archives = exgroups;
vm.allMessagesLoaded = (vm.archives.length >= vm.total);
vm.sort.page++;
}

vm.loadingData = false;
Expand All @@ -93,9 +98,9 @@

vm.configuration = sharedDataService.getConfiguration();
vm.error_retention_period = moment.duration(vm.configuration.data_retention.error_retention_period).asHours();
vm.total = 1;
vm.pager.total = 1;
vm.archives = [];
vm.sort.page = 1;
vm.pager.page = 1;

var selectedArchiveGroup = getSelectedArchiveGroup();

Expand Down Expand Up @@ -209,8 +214,8 @@
vm.selectedIds = [];
vm.archives = [];
vm.allMessagesLoaded = false;
vm.total = 1;
vm.page = 1;
vm.pager.total = 1;
vm.pager.page = 1;
vm.loadMoreResults();
};

Expand Down Expand Up @@ -258,7 +263,7 @@
};

vm.loadMoreResults = function () {
vm.allMessagesLoaded = vm.archives.length >= vm.total;
vm.allMessagesLoaded = vm.archives.length >= vm.pager.total;

if (vm.allMessagesLoaded || vm.loadingData) {
return;
Expand All @@ -269,13 +274,13 @@
archivedMessageService.getArchivedMessages(
vm.selectedArchiveGroup.id,
vm.sort.sortby,
vm.sort.page,
vm.pager.page,
vm.sort.direction,
vm.sort.start,
vm.sort.end).then(function (response) {
notifier.notify('InitialLoadComplete');

vm.total = response.total;
vm.pager.total = response.total;
processLoadedMessages(response.data);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@
serviceControlService,
notifyService) {

$scope.model = { data: [], total: 0 };
$scope.model = { data: []};
$scope.loadingData = false;
$scope.disableLoadingData = false;
$scope.reloadCount = 0;

var page = 1;
$scope.pager = {
page: 1,
total: 1,
perPage: 25
}

$scope.loadMoreResults = function () {
if ($scope.loadingData) {
return;
}

$scope.loadingData = true;
load(page++, $scope.reloadCount);
load($scope.pager.page, $scope.reloadCount);
};

$scope.dismiss = function (row) {
Expand All @@ -31,13 +34,13 @@
notifier.subscribe($scope, reloadData, 'CustomChecksUpdated');

function reloadData() {
page = 1;
$scope.pager.page = 1;
$scope.pager.total = 1;
$scope.loadingData = true;
$scope.model = { data: [], total: 0 };
$scope.disableLoadingData = false;
$scope.model = { data: [] };
$scope.reloadCount++;

load(page, $scope.reloadCount);
load($scope.pager.page, $scope.reloadCount);
}

function load(page, reloadCount) {
Expand All @@ -50,12 +53,8 @@

$scope.loadingData = false;

$scope.model.data = $scope.model.data.concat(response.data);
$scope.model.total = response.total;

if ($scope.model.data.length >= $scope.model.total) {
$scope.disableLoadingData = true;
}
$scope.model.data = response.data;
$scope.pager.total = response.total;
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ <h1>Custom checks</h1>
<section name="custom_checks">
<busy ng-show="loadingData" message="fetching more data"></busy>

<no-data ng-show="!loadingData && model.total == 0" message="No failed custom checks"></no-data>
<no-data ng-show="!loadingData && pager.total == 0" message="No failed custom checks"></no-data>

<div class="row">
<div class="col-sm-12">
<div infinite-scroll="loadMoreResults()" infinite-scroll-distance="0" infinite-scroll-disabled="disableLoadingData">
<div>
<div class="row box box-warning box-no-click" ng-repeat="item in model.data | orderBy: '-reported_at'">
<div class="col-sm-12 no-side-padding">
<div class="row">
Expand All @@ -48,6 +48,13 @@ <h1>Custom checks</h1>
</div>
</div>
</div>

<div class="row ">
<div class="col-md-4"></div>
<div class="col-md-6">
<ul uib-pagination ng-hide="pager.total <= pager.perPage" items-per-page="pager.perPage" total-items="pager.total" ng-model="pager.page" max-size="10" boundary-link-numbers="true" ng-change="loadMoreResults()"></ul>
</div>
</div>
</section>
</section>
</div>
Loading