Add event log search and filter capabilities
Change-Id: I9dc891e0f1e30abe488d401c57e1cf4f5656c3af
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
new file mode 100644
index 0000000..bf2cc1f
--- /dev/null
+++ b/app/common/directives/log-event.html
@@ -0,0 +1,60 @@
+<div class="row column event-log__single-event"
+ ng-class="{'active': event.meta, 'selected': event.selected}">
+ <div class="row">
+ <div class="inline__confirm" ng-class="{active: event.confirm}">
+ <div class="inline__confirm-message">
+ <p class="h3"><i></i>Are you sure you want to <strong class="ng-binding">delete this
+ event</strong>?</p>
+ </div>
+ <div class="inline__confirm-buttons">
+ <button class="btn-primary" ng-click="accept()">Yes</button>
+ <button class="btn-primary" ng-click="event.confirm=false;">No</button>
+ </div>
+ </div>
+ <div class="column small-1 large-2 event-log__col-check">
+ <label class="control-check">
+ <input type="checkbox" name="events__check" ng-click="event.selected= ! event.selected"
+ ng-checked="event.selected"/>
+ <span class="control__indicator"></span>
+ </label>
+ </div>
+ <div class="column small-9 large-9 event-log__event-info"
+ ng-click="event.meta = ! event.meta">
+ <p class="inline event__priority event-resolved" ng-hide="event.Resolved == 0">Resolved</p>
+ <p class="inline event__priority med-priority" ng-class="{'low-priority': event.priority == 'Low', 'medium-priority': event.priority == 'Medium', 'high-priority': event.priority == 'High'}" ng-hide="event.Resolved == 1">{{event.priority}}</p>
+ <p class="inline event__severity">{{event.severity_code}}</p>
+ <p class="inline event__description">{{event.Severity}}</p>
+ <div>
+ <p class="inline event__id">#{{event.Id}}</p>
+ <p class="inline event__timestamp">{{event.Timestamp| date:'MM/dd/yyyy HH:mm:ss '+tmz: tmz}}</p></div>
+ </div>
+ <div class="column small-1 large-1">
+ <button class="accord-trigger" ng-class="{'active': event.meta}"
+ ng-click="event.meta = ! event.meta"></button>
+ </div>
+ </div>
+ <div class="row event__metadata-row" ng-class="{'active': event.meta}">
+ <div class="column small-1 large-1 event-log__col-check"> </div>
+ <div class="column small-11 large-11 end">
+ <div class="event__metadata">{{event.additional_data}}
+ </div>
+ <div>
+ <div class="event__actions">
+ <button class="btn-meta-copy" clipboard text="event.additional_data" on-copied="copySuccess(event)" on-error="copyfailed(err)">
+ <img class="event__icon" src="assets/images/icon-copy.svg" alt=""/><span ng-if="!event.copied">Copy</span><span ng-if="event.copied">Copied</span>
+ </button>
+ <button class="btn-delete" ng-click="event.confirm= ! event.confirm"><img
+ class="event__icon"
+ 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>
+ </div>
+ <div class="event__related" ng-show="event.related_items.length">
+ <p class="inline event__related-label">Related items:</p>
+ <p class="event__related-item" ng-repeat="item in event.related_items">{{item}}</p>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/app/common/directives/log-event.js b/app/common/directives/log-event.js
new file mode 100644
index 0000000..387ce3b
--- /dev/null
+++ b/app/common/directives/log-event.js
@@ -0,0 +1,28 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives')
+ .directive('logEvent', ['APIUtils', function (APIUtils) {
+ return {
+ 'restrict': 'E',
+ 'templateUrl': 'common/directives/log-event.html',
+ 'scope': {
+ 'event': '=',
+ 'tmz': '='
+ },
+ 'controller': ['$rootScope', '$scope','dataService', '$location', '$timeout', function($rootScope, $scope, dataService, $location, $timeout){
+ $scope.dataService = dataService;
+ $scope.copySuccess = function (event) {
+ event.copied = true;
+ $timeout(function(){
+ event.copied = false;
+ }, 5000);
+ };
+ $scope.copyFailed = function (err) {
+ console.error('Error!', err);
+ };
+ }]
+ };
+ }]);
+})(window.angular);
diff --git a/app/common/directives/log-filter.html b/app/common/directives/log-filter.html
new file mode 100644
index 0000000..c0c5a20
--- /dev/null
+++ b/app/common/directives/log-filter.html
@@ -0,0 +1,58 @@
+<section id="event-filter" class="row column">
+ <div class="inline event__severity-filter">
+ <p class="filter-label">Filter by severity</p>
+ <button class="inline first" ng-click="toggleSeverityAll()"
+ ng-class="selectedSeverity.all ? 'btn-primary' : 'btn-secondary'">All
+ </button>
+ <button class="inline " ng-click="toggleSeverity('high')"
+ ng-class="selectedSeverity.high ? 'btn-primary' : 'btn-secondary'">High
+ </button>
+ <button class="inline" ng-click="toggleSeverity('medium')"
+ ng-class="selectedSeverity.medium ? 'btn-primary' : 'btn-secondary'">Medium
+ </button>
+ <button class="inline last" ng-click="toggleSeverity('low')"
+ ng-class="selectedSeverity.low ? 'btn-primary' : 'btn-secondary'">Low
+ </button>
+ </div>
+ <div class="inline event__date-filter">
+ <p class="filter-label">Filter by date range (MM/DD/YYYY)</p>
+ <div class="inline">
+ <label for="event-filter-start-date">Start Date</label>
+ <input id="event-filter-start-date" type="date" placeholder="MM/DD/YYYY" ng-model="start_date"/>
+ </div>
+ <strong>–</strong>
+ <div class="inline">
+ <label for="event-filter-end-date">End Date</label>
+ <input id="event-filter-end-date" type="date" placeholder="MM/DD/YYYY" ng-model="end_date"/>
+ </div>
+ </div>
+ <div class="inline event__status-filter">
+ <p class="filter-label">Filter by issue status</p>
+ <!-- Status filter -->
+ <div class="dropdown__wrapper">
+ <button class="dropdown__button" ng-click="statusFilter = statusFilter == true ? false : true;"
+ ng-class="{'active' : statusFilter}" toggle-flag="statusFilter">
+ <span ng-if="selectedStatus.all">All issues</span>
+ <span ng-if="!selectedStatus.all && selectedStatus.resolved">Resolved issues</span>
+ <span ng-if="!selectedStatus.all && !selectedStatus.resolved">Unresolved issues</span>
+ </button>
+ <ul class="dropdown__list inline" ng-show="statusFilter">
+ <li>
+ <button
+ ng-click="selectedStatus.all = true; statusFilter = false;"
+ ng-class="{'active' : selectedStatus.all}">All issues</button>
+ </li>
+ <li>
+ <button
+ ng-click="selectedStatus.all = false; selectedStatus.resolved = true; statusFilter = false;"
+ ng-class="{'active' : selectedStatus.resolved}">Resolved issues</button>
+ </li>
+ <li>
+ <button
+ ng-click="selectedStatus.all = false; selectedStatus.resolved = false; statusFilter = false;"
+ ng-class="{'active' : !selectedStatus.resolved}">Unresolved issues</button>
+ </li>
+ </ul>
+ </div>
+ </div>
+</section>
\ No newline at end of file
diff --git a/app/common/directives/log-filter.js b/app/common/directives/log-filter.js
new file mode 100644
index 0000000..fcbffe4
--- /dev/null
+++ b/app/common/directives/log-filter.js
@@ -0,0 +1,39 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives')
+ .directive('logFilter', ['APIUtils', function (APIUtils) {
+ return {
+ 'restrict': 'E',
+ 'templateUrl': 'common/directives/log-filter.html',
+ 'controller': ['$rootScope', '$scope','dataService', '$location', function($rootScope, $scope, dataService, $location){
+ $scope.dataService = dataService;
+ $scope.toggleSeverityAll = function(){
+ $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
+
+ if($scope.selectedSeverity.all){
+ $scope.selectedSeverity.low = false;
+ $scope.selectedSeverity.medium = false;
+ $scope.selectedSeverity.high = false;
+ }
+ }
+
+ $scope.toggleSeverity = function(severity){
+ $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
+
+ if($scope.selectedSeverity.low &&
+ $scope.selectedSeverity.medium &&
+ $scope.selectedSeverity.high){
+ $scope.selectedSeverity.all = true;
+ $scope.selectedSeverity.low = false;
+ $scope.selectedSeverity.medium = false;
+ $scope.selectedSeverity.high = false;
+ }else{
+ $scope.selectedSeverity.all = false;
+ }
+ }
+ }]
+ };
+ }]);
+})(window.angular);
diff --git a/app/common/directives/log-search-control.html b/app/common/directives/log-search-control.html
new file mode 100644
index 0000000..03b699b
--- /dev/null
+++ b/app/common/directives/log-search-control.html
@@ -0,0 +1,5 @@
+<div class="content__search">
+ <label for="content__search-input">Event Log Search</label>
+ <input id="content__search-input" type="text" placeholder="Filter issues" ng-model="customSearch" ng-keydown="doSearchOnEnter($event)"/>
+ <input id="content__search-submit" type="submit" class="btn btn-secondary" value="Submit" ng-click="doSearchOnClick()"/>
+</div>
\ No newline at end of file
diff --git a/app/common/directives/log-search-control.js b/app/common/directives/log-search-control.js
new file mode 100644
index 0000000..1fa268c
--- /dev/null
+++ b/app/common/directives/log-search-control.js
@@ -0,0 +1,39 @@
+window.angular && (function (angular) {
+ 'use strict';
+
+ angular
+ .module('app.common.directives')
+ .directive('logSearchControl', ['APIUtils', function (APIUtils) {
+ return {
+ 'restrict': 'E',
+ 'templateUrl': 'common/directives/log-search-control.html',
+ 'controller': ['$rootScope', '$scope','dataService', '$location', function($rootScope, $scope, dataService, $location){
+ $scope.dataService = dataService;
+ $scope.doSearchOnEnter = function (event) {
+ var search = $scope.customSearch.replace(/^\s+/g,'').replace(/\s+$/g,'');
+ if (event.keyCode === 13 &&
+ search.length >= 2) {
+ $scope.clearSearchItem();
+ $scope.addSearchItem(search);
+ }else{
+ if(search.length == 0){
+ $scope.clearSearchItem();
+ }
+ }
+ };
+
+ $scope.doSearchOnClick = function() {
+ var search = $scope.customSearch.replace(/^\s+/g,'').replace(/\s+$/g,'');
+ if (search.length >= 2) {
+ $scope.clearSearchItem();
+ $scope.addSearchItem(search);
+ }else{
+ if(search.length == 0){
+ $scope.clearSearchItem();
+ }
+ }
+ }
+ }]
+ };
+ }]);
+})(window.angular);
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index 0a96f62..0c69b9e 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -348,7 +348,7 @@
severity_flags: severityFlags,
additional_data: content.data[key].AdditionalData.join("\n"),
selected: false,
- search_text: (severityCode + " " + content.data[key].Severity + " " + content.data[key].AdditionalData.join(" ")).toLowerCase(),
+ search_text: ("#" + content.data[key].Id + " " + severityCode + " " + content.data[key].Severity + " " + content.data[key].AdditionalData.join(" ")).toLowerCase(),
meta: false,
confirm: false,
related_items: relatedItems,