diff --git a/frontend/app/scripts/app.js b/frontend/app/scripts/app.js index 3f9e9d6062..4d336656d8 100644 --- a/frontend/app/scripts/app.js +++ b/frontend/app/scripts/app.js @@ -241,9 +241,6 @@ angular.module('thehive', [ organisation: function($stateParams, OrganisationSrv) { return OrganisationSrv.get($stateParams.organisation); }, - users: function($stateParams, OrganisationSrv) { - return OrganisationSrv.users($stateParams.organisation); - }, templates: function($stateParams, OrganisationSrv) { return OrganisationSrv.caseTemplates($stateParams.organisation); }, diff --git a/frontend/app/scripts/components/organisation/OrgUserListCmp.js b/frontend/app/scripts/components/organisation/OrgUserListCmp.js index be4e2790af..517b323309 100644 --- a/frontend/app/scripts/components/organisation/OrgUserListCmp.js +++ b/frontend/app/scripts/components/organisation/OrgUserListCmp.js @@ -11,8 +11,7 @@ self.currentUser = AuthenticationSrv.currentUser; self.$onInit = function() { - // TODO FIX ME - self.canSetPass = true; + self.canSetPass = this.setPasswordEnabled; }; self.reload = function() { @@ -203,6 +202,7 @@ bindings: { users: '<', mfaEnabled: '<', + setPasswordEnabled: '<', onReload: '&', onEdit: '&' } diff --git a/frontend/app/scripts/controllers/admin/organisation/OrgDetailsCtrl.js b/frontend/app/scripts/controllers/admin/organisation/OrgDetailsCtrl.js index 53e44cf90b..80238ad282 100644 --- a/frontend/app/scripts/controllers/admin/organisation/OrgDetailsCtrl.js +++ b/frontend/app/scripts/controllers/admin/organisation/OrgDetailsCtrl.js @@ -2,32 +2,71 @@ 'use strict'; angular.module('theHiveControllers').controller('OrgDetailsCtrl', - function($scope, $q, $uibModal, OrganisationSrv, NotificationSrv, UserSrv, organisation, users, templates, fields, appConfig, uiConfig) { + function($scope, $q, $uibModal, FilteringSrv, PaginatedQuerySrv, OrganisationSrv, NotificationSrv, UserSrv, organisation, /*users, */templates, fields, appConfig, uiConfig) { var self = this; this.uiConfig = uiConfig; this.org = organisation; - this.users = users; + //this.users = users; this.templates = templates; this.fields = fields; this.canChangeMfa = appConfig.config.capabilities.indexOf('mfa') !== -1; + this.canSetPass = appConfig.config.capabilities.indexOf('setPassword') !== -1; this.getUserInfo = UserSrv.getCache; - this.reloadUsers = function() { - OrganisationSrv.users(self.org.name) - .then(function(users) { - self.users = users; - }) - .catch(function(err) { - NotificationSrv.error('OrgDetailsCtrl', err.data, err.status); + this.$onInit = function() { + self.filtering = new FilteringSrv('user', 'user.list', { + version: 'v1', + defaults: { + showFilters: true, + showStats: false, + pageSize: 15, + //sort: ['-flag', '-startDate'] + }, + defaultFilter: [] + }); + + self.filtering.initContext(self.org.name) + .then(function() { + self.loadUsers(); + + $scope.$watch('$vm.users.pageSize', function (newValue) { + self.filtering.setPageSize(newValue); + }); }); }; + this.loadUsers = function() { + + self.users = new PaginatedQuerySrv({ + name: 'organisation-users', + version: 'v1', + skipStream: true, + sort: self.filtering.context.sort, + loadAll: false, + pageSize: self.filtering.context.pageSize, + filter: this.filtering.buildQuery(), + operations: [{ + '_name': 'getOrganisation', + 'idOrName': self.org.name + }, + { + '_name': 'users' + } + ], + config: { + headers: { + 'X-Organisation': self.org.name + } + } + }); + }; + this.showUserDialog = function(user) { UserSrv.openModal(user, self.org.name) .then(function() { - self.reloadUsers(); + self.loadUsers(); }) .catch(function(err) { if (err && !_.isString(err)) { @@ -35,5 +74,34 @@ } }); }; + + // Filtering + this.toggleFilters = function () { + this.filtering.toggleFilters(); + }; + + this.filter = function () { + self.filtering.filter().then(this.applyFilters); + }; + + this.clearFilters = function () { + this.filtering.clearFilters() + .then(self.search); + }; + + this.removeFilter = function (index) { + self.filtering.removeFilter(index) + .then(self.search); + }; + + this.search = function () { + self.loadUsers(); + self.filtering.storeContext(); + }; + this.addFilterValue = function (field, value) { + this.filtering.addFilterValue(field, value); + this.search(); + }; + }); })(); diff --git a/frontend/app/scripts/services/common/QuerySrv.js b/frontend/app/scripts/services/common/QuerySrv.js index 3227d793dc..fbd83b143f 100644 --- a/frontend/app/scripts/services/common/QuerySrv.js +++ b/frontend/app/scripts/services/common/QuerySrv.js @@ -67,6 +67,10 @@ }; } + if(options && options.config) { + config = _.extend({}, config, options.config); + } + return self.query(version, operations, config) .then(function(response) { return $q.resolve(response.data); @@ -99,6 +103,10 @@ }; } + if(options && options.config) { + config = _.extend({}, config, options.config); + } + // Add filters operations.push({'_name': 'count'}); diff --git a/frontend/app/scripts/services/common/data/PaginatedQuerySrv.js b/frontend/app/scripts/services/common/data/PaginatedQuerySrv.js index eaa2b2d41f..ef9350a001 100644 --- a/frontend/app/scripts/services/common/data/PaginatedQuerySrv.js +++ b/frontend/app/scripts/services/common/data/PaginatedQuerySrv.js @@ -31,6 +31,7 @@ this.withStats = options.withStats || undefined; this.extraData = options.extraData || undefined; this.name = options.name || undefined; + this.config = options.config || {}; this.operations = options.operations; @@ -130,7 +131,7 @@ filter: filters, sort: self.getSort(), page: self.getPage(), - config: {}, + config: self.config, withParent: false, name: self.name }).then(function(data) { @@ -157,7 +158,7 @@ QuerySrv.count('v1', this.operations, { filter: filters, name: self.name, - config: {} + config: self.config, }).then(function(total) { self.total = total; }); diff --git a/frontend/app/views/components/alert/similar-case-list.component.html b/frontend/app/views/components/alert/similar-case-list.component.html index 67299c8f07..f0bd8bc364 100644 --- a/frontend/app/views/components/alert/similar-case-list.component.html +++ b/frontend/app/views/components/alert/similar-case-list.component.html @@ -8,7 +8,7 @@
diff --git a/frontend/app/views/components/org/user.list.html b/frontend/app/views/components/org/user.list.html index 4f439324d4..8eedbee8b7 100644 --- a/frontend/app/views/components/org/user.list.html +++ b/frontend/app/views/components/org/user.list.html @@ -2,49 +2,38 @@ Add user

--> -
+
No users defined.
-
+
- - - + + + + - + - + + + - diff --git a/frontend/app/views/partials/admin/organisation/details.html b/frontend/app/views/partials/admin/organisation/details.html index 77448a0e60..8fcfb6b51f 100644 --- a/frontend/app/views/partials/admin/organisation/details.html +++ b/frontend/app/views/partials/admin/organisation/details.html @@ -53,19 +53,37 @@

+
+ +
+
+ +
+
+ + +
- + diff --git a/frontend/app/views/partials/admin/organisation/list/filters.html b/frontend/app/views/partials/admin/organisation/list/filters.html new file mode 100644 index 0000000000..b7e40c6786 --- /dev/null +++ b/frontend/app/views/partials/admin/organisation/list/filters.html @@ -0,0 +1,38 @@ +
+
+

Filters

+
+
+
+
+ + + + +
+
+
+ +
+
+
+ +
+ + +
+
diff --git a/frontend/app/views/partials/case/case.list.html b/frontend/app/views/partials/case/case.list.html index 73110b7920..a5923b857e 100644 --- a/frontend/app/views/partials/case/case.list.html +++ b/frontend/app/views/partials/case/case.list.html @@ -39,8 +39,8 @@

List of cases ({{$vm.list.total || 0}} of {{$vm.caseStats.

-
StatusUser detailsStatusLoginFull NameProfile Password API Key MFA
{{user.locked === false ? 'Active' : 'Locked'}} {{user.login}}{{user.name}} -

- - Login: {{user.login}} -

-

- - Full name: {{user.name}} -

-
-

- - Profile: {{user.profile}} -

+ + {{user.profile}} +
@@ -93,17 +82,21 @@

- - Edit + + + - - Lock + + + - - Unlock + + + - - Remove + + +
- + + Title