Added delete and mark as resolved in event log page

Change-Id: Ia1f8e630cecef38bc546bdcde867685a99dd936b
Signed-off-by: Iftekharul Islam <iislam@us.ibm.com>
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 @@
                     $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 @@
     '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 @@
               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 @@
               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 @@
               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 @@
                     }
                 });
               },
+              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 @@
                     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 @@
                     Warning: 'Medium'
                 },
                 PAGINATION: {
-                    LOG_ITEMS_PER_PAGE: 4
+                    LOG_ITEMS_PER_PAGE: 25
                 },
                 HARDWARE: {
                   component_key_filter: '/xyz/openbmc_project/inventory/system',