diff --git a/ui/app/scripts/controllers/case/CaseListCtrl.js b/ui/app/scripts/controllers/case/CaseListCtrl.js index 7b8c4eb46d..4fe6427ba5 100644 --- a/ui/app/scripts/controllers/case/CaseListCtrl.js +++ b/ui/app/scripts/controllers/case/CaseListCtrl.js @@ -3,7 +3,7 @@ angular.module('theHiveControllers') .controller('CaseListCtrl', CaseListCtrl); - function CaseListCtrl($scope, $q, CasesUISrv, StreamStatSrv, PSearchSrv, EntitySrv, UserInfoSrv, TagSrv, CaseResolutionStatus) { + function CaseListCtrl($scope, $q, CasesUISrv, StreamStatSrv, PSearchSrv, EntitySrv, UserInfoSrv, TagSrv, UserSrv, AuthenticationSrv, CaseResolutionStatus) { var self = this; this.showFlow = true; @@ -135,6 +135,44 @@ return TagSrv.fromCases(query); }; + this.getUsers = function(query) { + return UserSrv.list({ + _and: [ + { + status: 'Ok' + } + ] + }).then(function(data) { + return _.map(data, function(user) { + return { + label: user.name, + text: user.id + }; + }); + }).then(function(users) { + var filtered = _.filter(users, function(user) { + var regex = new RegExp(query, 'gi'); + return regex.test(user.label); + }); + + return filtered; + }); + }; + + this.filterMyCases = function() { + this.uiSrv.clearFilters() + .then(function(){ + var currentUser = AuthenticationSrv.currentUser; + self.uiSrv.activeFilters.owner = { + value: [{ + text: currentUser.id, + label: currentUser.name + }] + }; + self.filter(); + }); + }; + this.filterByStatus = function(status) { this.uiSrv.clearFilters() .then(function(){ diff --git a/ui/app/scripts/services/CasesUISrv.js b/ui/app/scripts/services/CasesUISrv.js index 0bb4cf513f..1717395f2d 100644 --- a/ui/app/scripts/services/CasesUISrv.js +++ b/ui/app/scripts/services/CasesUISrv.js @@ -30,6 +30,11 @@ type: 'list', defaultValue: [] }, + owner: { + field: 'owner', + type: 'list', + defaultValue: [] + }, tlp: { field: 'tlp', type: 'number', diff --git a/ui/app/scripts/services/TagSrv.js b/ui/app/scripts/services/TagSrv.js index fe3bd50995..2572c3097e 100644 --- a/ui/app/scripts/services/TagSrv.js +++ b/ui/app/scripts/services/TagSrv.js @@ -12,9 +12,9 @@ limit: 1000 }).then(function(response) { var tags = []; - var regex = new RegExp(query); tags = _.map(_.filter(_.keys(response.data), function(tag) { + var regex = new RegExp(query, 'gi'); return regex.test(tag); }), function(tag) { return {text: tag}; diff --git a/ui/app/scripts/services/UserSrv.js b/ui/app/scripts/services/UserSrv.js index 69c78bbbda..a11c1d7a32 100644 --- a/ui/app/scripts/services/UserSrv.js +++ b/ui/app/scripts/services/UserSrv.js @@ -35,7 +35,7 @@ angular.module('theHiveServices') } else { var ret = { 'name': login, - 'id': login + 'id': login }; res.get({ 'userId': login @@ -70,5 +70,21 @@ angular.module('theHiveServices') return defer.promise; }; + res.list = function(query) { + var defer = $q.defer(); + + var post = { + range: 'all', + query: query + }; + + $http.post('/api/user/_search', post) + .then(function(response) { + defer.resolve(response.data); + }); + + return defer.promise; + }; + return res; }); diff --git a/ui/app/views/partials/case/list/filters.html b/ui/app/views/partials/case/list/filters.html index 2a0ad417ea..964ae004c6 100644 --- a/ui/app/views/partials/case/list/filters.html +++ b/ui/app/views/partials/case/list/filters.html @@ -48,6 +48,19 @@