diff options
author | Iftekharul Islam <iislam@us.ibm.com> | 2017-07-10 16:42:14 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-09-20 13:14:23 -0500 |
commit | f2d74644cbce0707897fae5d3c9d253a97a23f18 (patch) | |
tree | 9b86c073c62ee475811cb5c6551907f8cc92c58e /app | |
parent | ee27d754b273ba004e7e4c0652e9c360b551ad46 (diff) | |
download | phosphor-webui-f2d74644cbce0707897fae5d3c9d253a97a23f18.tar.gz phosphor-webui-f2d74644cbce0707897fae5d3c9d253a97a23f18.zip |
Added delete and mark as resolved in event log page
Change-Id: Ia1f8e630cecef38bc546bdcde867685a99dd936b
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
Diffstat (limited to 'app')
-rw-r--r-- | app/common/directives/log-event.html | 4 | ||||
-rw-r--r-- | app/common/directives/log-event.js | 12 | ||||
-rw-r--r-- | app/common/services/api-utils.js | 58 | ||||
-rw-r--r-- | app/common/services/constants.js | 4 | ||||
-rw-r--r-- | app/server-health/controllers/log-controller.html | 5 | ||||
-rw-r--r-- | app/server-health/controllers/log-controller.js | 22 |
6 files changed, 95 insertions, 10 deletions
diff --git a/app/common/directives/log-event.html b/app/common/directives/log-event.html index 6b8f972..18aa8b3 100644 --- a/app/common/directives/log-event.html +++ b/app/common/directives/log-event.html @@ -7,7 +7,7 @@ event</strong>?</p> </div> <div class="inline__confirm-buttons"> - <button class="btn-primary" ng-click="accept()">Yes</button> + <button class="btn-primary" ng-click="accept(event)">Yes</button> <button class="btn-primary" ng-click="event.confirm=false;">No</button> </div> </div> @@ -48,7 +48,7 @@ src="assets/images/icon-trashcan.svg" alt=""/>Delete </button> - <button class="btn-resolve"><img class="event__icon" src="assets/images/icon-checklist.svg" alt=""/>Resolved</button> + <button class="btn-resolve" ng-class="{'disabled': (event.Resolved == 1)}" ng-click="resolveEvent(event)" ng-disabled="event.Resolved == 1"><img class="event__icon" src="assets/images/icon-checklist.svg" alt=""/>Resolved</button> </div> <div class="event__related" ng-show="event.related_items.length"> <p class="inline event__related-label">Related items:</p> diff --git a/app/common/directives/log-event.js b/app/common/directives/log-event.js index 387ce3b..ae4970d 100644 --- a/app/common/directives/log-event.js +++ b/app/common/directives/log-event.js @@ -22,6 +22,18 @@ window.angular && (function (angular) { $scope.copyFailed = function (err) { console.error('Error!', err); }; + $scope.resolveEvent = function(event){ + APIUtils.resolveLogs([{Id: event.Id}]).then(function(){ + event.Resolved = 1; + }); + } + + $scope.accept = function(){ + $scope.event.selected = true; + $timeout(function(){ + $scope.$parent.accept(); + }, 10); + } }] }; }]); diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js index b044328..3b8b7e0 100644 --- a/app/common/services/api-utils.js +++ b/app/common/services/api-utils.js @@ -11,7 +11,7 @@ window.angular && (function (angular) { 'use strict'; angular .module('app.common.services') - .factory('APIUtils', ['$http', 'Constants', function($http, Constants){ + .factory('APIUtils', ['$http', 'Constants', '$q', function($http, Constants, $q){ var SERVICE = { LOGIN_CREDENTIALS: Constants.LOGIN_CREDENTIALS, API_CREDENTIALS: Constants.API_CREDENTIALS, @@ -599,7 +599,7 @@ window.angular && (function (angular) { getBMCEthernetInfo: function(callback){ $http({ method: 'GET', - url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/inventory", + url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc/ethernet", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -620,7 +620,7 @@ window.angular && (function (angular) { getBMCInfo: function(callback){ $http({ method: 'GET', - url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/inventory", + url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/inventory/system/chassis/motherboard/boxelder/bmc", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -641,7 +641,7 @@ window.angular && (function (angular) { getHardwares: function(callback){ $http({ method: 'GET', - url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/inventory/system", + url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/inventory/enumerate", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' @@ -742,6 +742,56 @@ window.angular && (function (angular) { } }); }, + deleteLogs: function(logs) { + var defer = $q.defer(); + var promises = []; + + function finished(){ + defer.resolve(); + } + + logs.forEach(function(item){ + promises.push($http({ + method: 'POST', + url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/logging/entry/"+item.Id+"/action/Delete", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + withCredentials: true, + data: JSON.stringify({"data": []}) + })); + }); + + $q.all(promises).then(finished); + + 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', + url: SERVICE.API_CREDENTIALS.host + "/xyz/openbmc_project/logging/entry/"+item.Id+"/attr/Resolved", + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + withCredentials: true, + data: JSON.stringify({"data": "1"}) + })); + }); + + $q.all(promises).then(finished); + + return defer.promise; + }, }; return SERVICE; }]); diff --git a/app/common/services/constants.js b/app/common/services/constants.js index 1445081..7d77ec0 100644 --- a/app/common/services/constants.js +++ b/app/common/services/constants.js @@ -20,7 +20,7 @@ window.angular && (function (angular) { password: "testpass", }, API_CREDENTIALS: { - host: 'https://9.3.164.177', + host: 'https://9.3.181.15', mock_host: 'http://localhost:3000' }, API_RESPONSE: { @@ -59,7 +59,7 @@ window.angular && (function (angular) { Warning: 'Medium' }, PAGINATION: { - LOG_ITEMS_PER_PAGE: 4 + LOG_ITEMS_PER_PAGE: 25 }, HARDWARE: { component_key_filter: '/xyz/openbmc_project/inventory/system', diff --git a/app/server-health/controllers/log-controller.html b/app/server-health/controllers/log-controller.html index f30fdae..59edc72 100644 --- a/app/server-health/controllers/log-controller.html +++ b/app/server-health/controllers/log-controller.html @@ -47,13 +47,14 @@ <button class="btn-primary" ng-click="confirm = false">No</button> </div> </div> - <p class="inline"><span class="event__select-count">{{filteredLogs.length}}</span> Events are logged</p> + <p class="inline" ng-show="selectedEvents.length"><span class="event__select-count">{{selectedEvents.length}}</span> Events are Selected</p> + <p class="inline" ng-hide="selectedEvents.length"><span class="event__select-count">{{filteredLogs.length}}</span> Events are Logged</p> <!-- when logs are selected, this text changes to show how many logs are checked --> <div class="event__actions"> <button class="inline btn-delete" ng-show="selectedEvents.length || all" ng-click="confirm= ! confirm"> <img class="event__icon" src="assets/images/icon-trashcan-white.svg" alt="">Delete </button> - <button class="inline btn-resolve" ng-show="selectedEvents.length || all"> + <button class="inline btn-resolve" ng-show="selectedEvents.length || all" ng-click="resolve()"> <img class="event__icon" src="assets/images/icon-checklist-white.svg" alt="">Mark as resolved </button> <a ng-href="data:text/json;charset=utf-8,{{export_data}}" class="inline btn-export" download="{{export_name}}" ng-show="selectedEvents.length || all">Export</a> diff --git a/app/server-health/controllers/log-controller.js b/app/server-health/controllers/log-controller.js index eb4ea26..cf3f248 100644 --- a/app/server-health/controllers/log-controller.js +++ b/app/server-health/controllers/log-controller.js @@ -120,6 +120,28 @@ window.angular && (function (angular) { $scope.export_data = JSON.stringify(data); } + + $scope.accept = function(){ + APIUtils.deleteLogs($scope.selectedEvents).then(function(){ + $scope.confirm = false; + $scope.loadLogs(); + }); + } + + $scope.resolve = function(){ + var events = $scope.selectedEvents.filter(function(item){ + return item.Resolved != 1; + }); + + if(!events.length) return; + + APIUtils.resolveLogs(events).then(function(){ + events.forEach(function(item){ + item.Resolved = 1; + }); + }); + } + $scope.$watch('logs', function(){ $scope.selectedEvents = $scope.logs.filter(function(item){ return item.selected; |