Merge pull request #974 from wazuh/issue-973

Fix race condition with the Wazuh filters
This commit is contained in:
Jesús Ángel 2018-10-18 10:17:18 +02:00 committed by GitHub
commit 473ceadfce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 16 deletions

View File

@ -567,7 +567,28 @@ function discoverController(
.catch(notify.error);
};
const filtersAreReady = () => {
const currentUrlPath = $location.path();
if (currentUrlPath && !currentUrlPath.includes('wazuh-discover')) {
let filters = queryFilter.getFilters();
filters = Array.isArray(filters)
? filters.filter(
item =>
item &&
item.$state &&
item.$state.store &&
item.$state.store === 'appState'
)
: [];
if (!filters || !filters.length) return false;
}
return true;
}
$scope.opts.fetch = $scope.fetch = function() {
// Wazuh filters are not ready yet
if(!filtersAreReady()) return;
// ignore requests to fetch before the app inits
if (!init.complete) return;
@ -593,20 +614,9 @@ function discoverController(
/*if ($state.query.language && $state.query.language !== query.language) {
$state.filters = [];
}*/
const currentUrlPath = $location.path();
if (currentUrlPath && !currentUrlPath.includes('wazuh-discover')) {
let filters = queryFilter.getFilters();
filters = Array.isArray(filters)
? filters.filter(
item =>
item &&
item.$state &&
item.$state.store &&
item.$state.store === 'appState'
)
: [];
if (!filters || !filters.length) return;
}
// Wazuh filters are not ready yet
if(!filtersAreReady()) return;
discoverPendingUpdates.removeAll();
discoverPendingUpdates.addItem($state.query, queryFilter.getFilters());
$rootScope.$broadcast('updateVis');

View File

@ -174,7 +174,7 @@
<!-- End Discover search bar section -->
<!-- Loading status section -->
<div layout="column" layout-align="center center" ng-if="(tab !== 'welcome') && (tab !== 'configuration') && tab !== 'syscollector'" ng-show="resultState === 'ready' && tabView === 'panels' && !rendered">
<div layout="column" layout-align="center center" ng-if="tab !== 'welcome' && tab !== 'configuration' && tab !== 'syscollector'" ng-show="resultState === 'ready' && tabView === 'panels' && !rendered">
<div class="percentage"><i class="fa fa-fw fa-spin fa-spinner" aria-hidden="true"></i></div>
<div class="percentage">{{loadingStatus}}</div>
</div>
@ -199,6 +199,6 @@
<!-- No results section -->
<!-- Loading ring -->
<div class='uil-ring-css' ng-show="load && tab !== 'configuration'">
<div class='uil-ring-css' ng-show="load && tab !== 'configuration' && tabView === 'panels'">
<div></div>
</div>