Skip to content

Commit

Permalink
Merge pull request #359 from Particular/load-failedmessages-from-book…
Browse files Browse the repository at this point in the history
…mark

Load failed messages if not in local storage
  • Loading branch information
WojcikMike authored Jun 16, 2016
2 parents 9b2159b + f64917d commit a562e77
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
archived: stats.number_of_archived_messages
}

$scope.viewExceptionGroup= function() {
$scope.viewExceptionGroup = function () {
sharedDataService.set(allFailedMessagesGroup);
$location.path('/failedMessages');
}
Expand Down
51 changes: 23 additions & 28 deletions src/ServicePulse.Host/app/js/services/services.service-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
(function(window, angular, $, undefined) {
'use strict';


function Service($http, scConfig, notifications, uri) {

function getVersion() {
var url = uri.join(scConfig.service_control_url);
return $http.get(url).then(function(response) {
return response.headers('X-Particular-Version');
});
};
}

function checkLicense() {
var url = uri.join(scConfig.service_control_url);
Expand All @@ -20,14 +19,14 @@
}
return true;
});
};
}

function getEventLogItems() {
var url = uri.join(scConfig.service_control_url, 'eventlogitems');
return $http.get(url).then(function(response) {
return response.data;
});
};
}

function getFailedMessages(sortBy, page, direction) {
var url = uri.join(scConfig.service_control_url, 'errors?status=unresolved&page=' + page + '&sort=' + sortBy + '&direction=' + direction);
Expand All @@ -37,7 +36,7 @@
total: response.headers('Total-Count')
};
});
};
}

function getExceptionGroups() {
var url = uri.join(scConfig.service_control_url, 'recoverability', 'groups');
Expand All @@ -46,7 +45,7 @@
data: response.data
};
});
};
}

function getFailedMessagesForExceptionGroup(groupId, sortBy, page) {
var url = uri.join(scConfig.service_control_url, 'recoverability', 'groups', groupId, 'errors?page=' + page + '&sort=' + sortBy + '&status=unresolved');
Expand All @@ -56,7 +55,7 @@
total: response.headers('Total-Count')
};
});
};
}

function getMessageBody(messageId) {
var url = uri.join(scConfig.service_control_url, 'messages', messageId, 'body');
Expand All @@ -65,7 +64,7 @@
data: response.data
};
});
};
}

function getMessageHeaders(messageId) {
var url = uri.join(scConfig.service_control_url, 'messages', 'search', messageId);
Expand All @@ -74,28 +73,28 @@
data: response.data
};
});
};
}

function getTotalExceptionGroups() {
var url = uri.join(scConfig.service_control_url, 'recoverability', 'groups');
return $http.head(url).then(function (response) {
return response.headers('Total-Count');
});
};

}

function getTotalFailedMessages() {
var url = uri.join(scConfig.service_control_url, 'errors?status=unresolved');
return $http.head(url).then(function(response) {
return response.headers('Total-Count');
});
};
}

function getTotalArchivedMessages() {
var url = uri.join(scConfig.service_control_url, 'errors?status=archived');
return $http.head(url).then(function(response) {
return response.headers('Total-Count');
});
};
}

function getConfiguration() {
var url = uri.join(scConfig.service_control_url, 'configuration');
Expand All @@ -109,7 +108,7 @@
return $http.get(url).then(function(response) {
return response.headers('Total-Count');
});
};
}

function getFailingCustomChecks(page) {
var url = uri.join(scConfig.service_control_url, 'customchecks?status=fail&page=' + page);
Expand All @@ -119,14 +118,14 @@
total: response.headers('Total-Count')
};
});
};
}

function getFailedMessageStats() {
var url = uri.join(scConfig.service_control_url, 'errors', 'summary');
return $http.get(url).then(function(response) {
return response.data;
});
};
}

function muteCustomChecks(customCheck) {
var url = uri.join(scConfig.service_control_url, 'customchecks', customCheck.id);
Expand All @@ -138,7 +137,7 @@
.error(function() {
// notifications.pushForCurrentRoute('Failed to mute "{{item.custom_check_id}}" custom check', 'danger', { item: customCheck });
});
};
}

function retryAllFailedMessages() {
var url = uri.join(scConfig.service_control_url, 'errors', 'retry', 'all');
Expand All @@ -149,7 +148,7 @@
.error(function() {
notifications.pushForCurrentRoute('Retrying all messages failed', 'danger');
});
};
}

function retryFailedMessages(selectedMessages) {
var url = uri.join(scConfig.service_control_url, 'errors', 'retry');
Expand All @@ -160,7 +159,7 @@
.error(function() {
notifications.pushForCurrentRoute('Retrying messages failed', 'danger');
});
};
}

function archiveFailedMessages(selectedMessages) {
var url = uri.join(scConfig.service_control_url, 'errors', 'archive');
Expand All @@ -176,7 +175,7 @@
.error(function() {
notifications.pushForCurrentRoute('Archiving messages failed', 'danger');
});
};
}

function archiveExceptionGroup(id, successText) {
var url = uri.join(scConfig.service_control_url, 'recoverability', 'groups', id, 'errors', 'archive');
Expand All @@ -187,7 +186,7 @@
.error(function() {
notifications.pushForCurrentRoute('Archiving messages failed', 'danger');
});
};
}

function retryExceptionGroup(id, successText) {

Expand All @@ -199,14 +198,14 @@
.error(function() {
notifications.pushForCurrentRoute('Retrying messages failed', 'danger');
});
};
}

function getHeartbeatStats() {
var url = uri.join(scConfig.service_control_url, 'heartbeats', 'stats');
return $http.get(url).then(function(response) {
return response.data;
});
};
}

function getEndpointsWithSla() {
return this
Expand All @@ -223,8 +222,7 @@

return results;
});
};

}

var service = {
getVersion: getVersion,
Expand Down Expand Up @@ -252,13 +250,10 @@
};

return service;

}

Service.$inject = ['$http', 'scConfig', 'notifications', 'uri'];


angular.module('services.serviceControlService', [])
.service('serviceControlService', Service);

}(window, window.angular, window.jQuery));
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
}

vm.archiveExceptionGroup = function (group) {

group.workflow_state = { status: 'working', message: 'working' };
var response = failedMessageGroupsService.archiveGroup(group.id, 'Archive Group Request Enqueued', 'Archive Group Request Rejected')
.then(function (message) {
Expand Down
39 changes: 16 additions & 23 deletions src/ServicePulse.Host/app/js/views/failed_messages/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@

var notifier = notifyService();
vm.selectedExceptionGroup = sharedDataService.get();

if (!vm.selectedExceptionGroup) {
vm.selectedExceptionGroup = { 'id': undefined, 'title': 'All Failed Messages', 'count': 0, 'initialLoad': true };
}

if (!vm.selectedExceptionGroup.hasOwnProperty('title')) {
$location.path('/failedGroups');
}
Expand Down Expand Up @@ -66,7 +71,6 @@
vm.loadMoreResults(vm.selectedExceptionGroup);
}


var markMessage = function (property) {
for (var i = 0; i < vm.failedMessages.length; i++) {
vm.failedMessages[i][property] = true;
Expand Down Expand Up @@ -112,7 +116,6 @@
}
};


vm.retrySelected = function () {
serviceControlService.retryFailedMessages(vm.selectedIds);
vm.selectedIds = [];
Expand All @@ -138,8 +141,6 @@
};

vm.archiveExceptionGroup = function (group) {


var response = failedMessageGroupsService.archiveGroup(group.id, 'Archive Group Request Enqueued', 'Archive Group Request Rejected')
.then(function (message) {
notifier.notify('ArchiveGroupRequestAccepted', group);
Expand Down Expand Up @@ -170,8 +171,7 @@

});
}



vm.debugInServiceInsight = function (index) {
var messageId = vm.failedMessages[index].message_id;
var dnsName = scConfig.service_control_url.toLowerCase();
Expand Down Expand Up @@ -210,35 +210,28 @@
selectGroupInternal(group, sort, direction, true);
};




vm.loadMoreResults = function (group) {
vm.allMessagesLoaded = vm.failedMessages.length >= group.count;

if (vm.allMessagesLoaded || vm.loadingData) {
if (!group.initialLoad && (vm.allMessagesLoaded || vm.loadingData)) {
return;
}

vm.loadingData = true;
delete group.initialLoad;

var allExceptionsGroupSelected = (!group || !group.id);

var loadPromise;
if (allExceptionsGroupSelected) {
serviceControlService.getFailedMessages(
vm.sort,
vm.page,
vm.direction).then(function (response) {
processLoadedMessages(response.data);
});
loadPromise = serviceControlService.getFailedMessages(vm.sort, vm.page, vm.direction)
} else {
serviceControlService.getFailedMessagesForExceptionGroup(
group.id,
vm.sort,
vm.page,
vm.direction).then(function (response) {
processLoadedMessages(response.data);
});
loadPromise = serviceControlService.getFailedMessagesForExceptionGroup(group.id, vm.sort, vm.page, vm.direction);
}

loadPromise.then(function (response) {
processLoadedMessages(response.data);
});
}

init();
Expand Down

0 comments on commit a562e77

Please sign in to comment.