Skip to content

Commit

Permalink
#894 Debounce the navigation to search page when coming from dashboar…
Browse files Browse the repository at this point in the history
…d items
  • Loading branch information
nadouani committed Feb 22, 2019
1 parent db4d011 commit b252feb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
22 changes: 12 additions & 10 deletions ui/app/scripts/directives/dashboard/counter.js
@@ -1,6 +1,6 @@
(function() {
'use strict';
angular.module('theHiveDirectives').directive('dashboardCounter', function($http, $state, DashboardSrv, NotificationSrv, GlobalSearchSrv) {
angular.module('theHiveDirectives').directive('dashboardCounter', function($q, $http, $state, DashboardSrv, NotificationSrv, GlobalSearchSrv) {
return {
restrict: 'E',
scope: {
Expand Down Expand Up @@ -66,17 +66,19 @@
};

scope.openSearch = function(item) {
if(scope.mode === 'edit') {
return;
}
if(scope.mode === 'edit') {
return;
}

var filters = (scope.options.filters || []).concat(item.serie.filters || []);
var filters = (scope.options.filters || []).concat(item.serie.filters || []);

$q.resolve(GlobalSearchSrv.saveSection(scope.options.entity, {
search: filters.length === 0 ? '*' : null,
filters: filters
})).then(function() {
$state.go('app.search');
});

GlobalSearchSrv.saveSection(scope.options.entity, {
search: filters.length === 0 ? '*' : null,
filters: filters
});
$state.go('app.search');
};

if (scope.autoload === true) {
Expand Down
11 changes: 7 additions & 4 deletions ui/app/scripts/directives/dashboard/donut.js
@@ -1,6 +1,6 @@
(function() {
'use strict';
angular.module('theHiveDirectives').directive('dashboardDonut', function(StatSrv, $state, DashboardSrv, NotificationSrv, GlobalSearchSrv) {
angular.module('theHiveDirectives').directive('dashboardDonut', function($q, StatSrv, $state, DashboardSrv, NotificationSrv, GlobalSearchSrv) {
return {
restrict: 'E',
scope: {
Expand Down Expand Up @@ -93,11 +93,14 @@
value: GlobalSearchSrv.buildDefaultFilterValue(fieldDef, d)
};

GlobalSearchSrv.saveSection(scope.options.entity, {
var filters = (scope.options.filters || []).concat([data]);

$q.resolve(GlobalSearchSrv.saveSection(scope.options.entity, {
search: null,
filters: scope.options.filters.concat([data])
filters: filters
})).then(function() {
$state.go('app.search');
});
$state.go('app.search');
}
},
donut: {
Expand Down
4 changes: 2 additions & 2 deletions ui/app/scripts/services/GlobalSearchSrv.js
Expand Up @@ -18,7 +18,7 @@
var cfg = this.restore();

return cfg[entity] || {};
}
};

this.restore = function() {
return localStorageService.get('search-section') || {
Expand Down Expand Up @@ -55,7 +55,7 @@
return {
operator: 'any',
list: [{text: value.id, label:value.name}]
}
};
} else {
switch(fieldDef.type) {
case 'number':
Expand Down

0 comments on commit b252feb

Please sign in to comment.