Fix error log resolve
logging/entry/<entryId>/attr/Resolved is a boolean as such
send true when resolving.
Before the function was always returning successful, fixed this
and log to the console when it fails.
Tested: Resolved multiple error logs and see the fail in the
console on a fail.
Change-Id: I60496f30f9241ffb6b6b73cf87b7481bea10b24f
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/common/directives/log-event.js b/app/common/directives/log-event.js
index cf8c41b..e179389 100644
--- a/app/common/directives/log-event.js
+++ b/app/common/directives/log-event.js
@@ -22,11 +22,16 @@
console.error('Error!', err);
};
$scope.resolveEvent = function(event) {
- APIUtils.resolveLogs([{Id: event.Id}]).then(function() {
- event.Resolved = 1;
- });
+ APIUtils.resolveLogs([{Id: event.Id}])
+ .then(
+ function(data) {
+ event.Resolved = 1;
+ },
+ function(error) {
+ // TODO: Show error to user
+ console.log(JSON.stringify(error));
+ });
};
-
$scope.accept = function() {
$scope.event.selected = true;
$timeout(function() {
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 89b2c71..840db8e 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -1707,13 +1707,8 @@
return defer.promise;
},
resolveLogs: function(logs) {
- var defer = $q.defer();
var promises = [];
- function finished() {
- defer.resolve();
- }
-
logs.forEach(function(item) {
promises.push($http({
method: 'PUT',
@@ -1721,13 +1716,10 @@
'/xyz/openbmc_project/logging/entry/' + item.Id +
'/attr/Resolved',
withCredentials: true,
- data: JSON.stringify({'data': '1'})
+ data: JSON.stringify({'data': true})
}));
});
-
- $q.all(promises).then(finished);
-
- return defer.promise;
+ return $q.all(promises);
},
getPowerConsumption: function() {
return $http({
diff --git a/app/server-health/controllers/log-controller.js b/app/server-health/controllers/log-controller.js
index a604126..ae873fb 100644
--- a/app/server-health/controllers/log-controller.js
+++ b/app/server-health/controllers/log-controller.js
@@ -173,11 +173,16 @@
if (!events.length) return;
- APIUtils.resolveLogs(events).then(function() {
- events.forEach(function(item) {
- item.Resolved = 1;
- });
- });
+ APIUtils.resolveLogs(events).then(
+ function(data) {
+ events.forEach(function(item) {
+ item.Resolved = 1;
+ });
+ },
+ function(error) {
+ // TODO: Show error to user
+ console.log(JSON.stringify(error));
+ });
};
$scope.$watch('logs', function() {