WebUI system logs implementation
This commit implements the webui logs page
which will show all system logs depends
on user selection( SEL or Event or Oem). This
is based out of redfish systems log services.
- View logs with pagination.
- Search filter for logs view.
- Sort option with Type, Id, Severity, Date.
- Clear logs.
- Export logs.
UnitTest:
- Existing bmcweb send the system logs of EntryType
"Event". So Loaded UI, selected Type "Event" and
validated all the above mentioned operations.
Change-Id: I0384e475f7913ca66b6db5d64831583fb382f8d5
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/app/server-health/controllers/syslog-controller.js b/app/server-health/controllers/syslog-controller.js
new file mode 100644
index 0000000..cec1d99
--- /dev/null
+++ b/app/server-health/controllers/syslog-controller.js
@@ -0,0 +1,122 @@
+/**
+ * Controller for log
+ *
+ * @module app/serverHealth
+ * @exports sysLogController
+ * @name sysLogController
+ */
+
+window.angular && (function(angular) {
+ 'use strict';
+ angular.module('app.serverHealth')
+ .config([
+ 'paginationTemplateProvider',
+ function(paginationTemplateProvider) {
+ paginationTemplateProvider.setString(
+ require('../../common/directives/dirPagination.tpl.html'));
+ }
+ ])
+ .controller('sysLogController', [
+ '$scope', 'APIUtils', 'Constants',
+ function($scope, APIUtils, Constants) {
+ $scope.itemsPerPage = Constants.PAGINATION.LOG_ITEMS_PER_PAGE;
+ $scope.loading = true;
+ $scope.sysLogs = [];
+ $scope.customSearch = '';
+ $scope.searchTerms = [];
+ $scope.sortKey = 'Id';
+ $scope.showLogDropdown = false;
+ $scope.recordTypeList =
+ ['SEL', 'Event', 'Oem']; // From Redfish specification.
+ $scope.selectedRecordType = 'SEL'; // Default Select to SEL.
+
+ $scope.selectRecordType = function(recordType) {
+ $scope.selectedRecordType = recordType;
+ $scope.showLogDropdown = false;
+ APIUtils.getSystemLogs(recordType)
+ .then(
+ function(res) {
+ $scope.sysLogs = res;
+ $scope.filterTypes.push('All');
+ $scope.sysLogs.forEach(function(log) {
+ if ($scope.filterTypes.indexOf(log.SensorType) < 0) {
+ $scope.filterTypes.push(log.SensorType);
+ }
+ });
+ },
+ function(error) {
+ console.log(JSON.stringify(error));
+ })
+ .finally(function() {
+ $scope.loading = false;
+ });
+ };
+
+ $scope.clearSystemLogEntries = function() {
+ $scope.confirm = false;
+ APIUtils.clearSystemLogs()
+ .then(
+ function(res) {
+ console.log(JSON.stringify(res));
+ },
+ function(error) {
+ console.log(JSON.stringify(error));
+ })
+ .finally(function() {
+ $scope.selectRecordType($scope.selectedRecordType);
+ });
+ };
+
+ $scope.sortBy = function(keyname, isReverse) {
+ $scope.sortKey = keyname;
+ $scope.reverse = isReverse;
+ };
+
+ $scope.clear = function() {
+ $scope.customSearch = '';
+ $scope.searchTerms = [];
+ };
+
+ $scope.doSearchOnEnter = function(event) {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (event.keyCode === 13 && search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
+ }
+ }
+ };
+
+ $scope.doSearchOnClick = function() {
+ var search =
+ $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ if (search.length >= 2) {
+ $scope.searchTerms = $scope.customSearch.split(' ');
+ } else {
+ if (search.length == 0) {
+ $scope.searchTerms = [];
+ }
+ }
+ };
+
+ $scope.filterBySearchTerms = function(log) {
+ if (!$scope.searchTerms.length) return true;
+
+ for (var i = 0, length = $scope.searchTerms.length; i < length;
+ i++) {
+ // TODO: Form it while getting data
+ var search_text = log.Id + ' ' + log.Name.toLowerCase() + ' ' +
+ log.Message.toLowerCase();
+ if (search_text.indexOf($scope.searchTerms[i].toLowerCase()) ==
+ -1)
+ return false;
+ }
+ return true;
+ };
+
+ setTimeout($scope.selectRecordType($scope.selectedRecordType), 2000);
+ }
+ ]);
+})(angular);