Commit b252feb9 authored by Nabil Adouani's avatar Nabil Adouani

#894 Debounce the navigation to search page when coming from dashboard items

parent db4d011a
(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: {
......@@ -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) {
......
(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: {
......@@ -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: {
......
......@@ -18,7 +18,7 @@
var cfg = this.restore();
return cfg[entity] || {};
}
};
this.restore = function() {
return localStorageService.get('search-section') || {
......@@ -55,7 +55,7 @@
return {
operator: 'any',
list: [{text: value.id, label:value.name}]
}
};
} else {
switch(fieldDef.type) {
case 'number':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment