Display event log ID and description if present

If the Event ID and Description event log properties
are present, display the error log title as <ID>: <Desc>
and move the Message property down into the box with the
other additional data fields.

If they aren't present, or not filled in (which in the case of
the event ID is a value of 'None'), leave the title as it
currently is, which is the Message property.

Tested: Verify UI fields when the event ID is valid, when
it's still in the event data but not valid, and when it isn't
in the event data at all.

Resolves openbmc/openbmc#3056

Change-Id: I455fc257b7d3713aceee2975d5240fb226cfa87e
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/app/common/directives/log-event.html b/app/common/directives/log-event.html
index 0077a6f..6d715a1 100644
--- a/app/common/directives/log-event.html
+++ b/app/common/directives/log-event.html
@@ -26,7 +26,7 @@
              <p class="inline event__severity" ng-class="{'low-priority': event.priority == 'Low', 'medium-priority': event.priority == 'Medium', 'high-priority': event.priority == 'High'}">{{event.severity_code}}</p>
              <p class="inline event__timestamp">{{event.Timestamp| date:'MM/dd/yyyy  HH:mm:ss '+tmz: tmz}}</p></div>
              <div>
-                 <p class="inline event__description">{{event.type}}</p>
+                 <p class="inline event__description">{{getTitle(event)}}</p>
              </div>
          <div class="column small-1 large-1">
              <button class="accord-trigger" ng-class="{'active': event.meta}"
@@ -36,7 +36,7 @@
      <div class="row event__metadata-row" ng-class="{'active': event.meta}">
          <div class="column small-1 large-1 event-log__col-check">&nbsp;</div>
          <div class="column small-11 large-11 end">
-             <div class="event__metadata">{{event.additional_data}}
+             <div class="event__metadata">{{getAdditionalData(event)}}
              </div>
              <div>
                  <div class="event__actions">
diff --git a/app/common/directives/log-event.js b/app/common/directives/log-event.js
index 2a71164..29abcb9 100644
--- a/app/common/directives/log-event.js
+++ b/app/common/directives/log-event.js
@@ -33,6 +33,24 @@
                 $scope.$parent.accept();
               }, 10);
             };
+
+            $scope.getTitle = function(event) {
+              var title = event.type;
+              if ((event.eventID != 'None') && (event.description != 'None')) {
+                title = event.eventID + ': ' + event.description;
+              }
+              return title;
+            };
+
+            $scope.getAdditionalData = function(event) {
+              var data = event.additional_data;
+              // Stick the type into the additional data if it isn't
+              // already in the title.
+              if ($scope.getTitle(event).search(event.type) == -1) {
+                data += '\nMESSAGE=' + event.type;
+              }
+              return data;
+            };
           }
         ]
       };
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 077d18a..71756d4 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -565,6 +565,8 @@
                     var priority = '';
                     var health = '';
                     var relatedItems = [];
+                    var eventID = 'None';
+                    var description = 'None';
 
                     for (var key in content.data) {
                       if (content.data.hasOwnProperty(key) &&
@@ -591,6 +593,14 @@
                           relatedItems.push(item[2]);
                         });
 
+                        if (content.data[key].hasOwnProperty(['EventID'])) {
+                          eventID = content.data[key].EventID;
+                        }
+
+                        if (content.data[key].hasOwnProperty(['Description'])) {
+                          description = content.data[key].Description;
+                        }
+
                         data.push(Object.assign(
                             {
                               path: key,
@@ -612,6 +622,8 @@
                               meta: false,
                               confirm: false,
                               related_items: relatedItems,
+                              eventID: eventID,
+                              description: description,
                               data: {key: key, value: content.data[key]}
                             },
                             content.data[key]));
diff --git a/app/overview/controllers/system-overview-controller.html b/app/overview/controllers/system-overview-controller.html
index 7be7f9f..8997378 100644
--- a/app/overview/controllers/system-overview-controller.html
+++ b/app/overview/controllers/system-overview-controller.html
@@ -134,7 +134,7 @@
 							<p class="inline event__severity high-priority">{{event.severity_code}}</p>
 							<p class="inline event__timestamp">{{event.Timestamp| date:'MM/dd/yyyy  HH:mm:ss '+tmz: tmz}}</p>
 							<div>
-								<p class="inline event__description">{{event.type}}</p>
+								<p class="inline event__description">{{getEventLogTitle(event)}}</p>
 							</div>
 						</div>
 						<div class="column small-1 large-1">
diff --git a/app/overview/controllers/system-overview-controller.js b/app/overview/controllers/system-overview-controller.js
index ece0bde..a16caf6 100644
--- a/app/overview/controllers/system-overview-controller.js
+++ b/app/overview/controllers/system-overview-controller.js
@@ -146,6 +146,14 @@
             });
         $scope.loading = false;
       };
+
+      $scope.getEventLogTitle = function(event) {
+        var title = event.type;
+        if ((event.eventID != 'None') && (event.description != 'None')) {
+          title = event.eventID + ': ' + event.description;
+        }
+        return title;
+      };
     }
   ]);