mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Removed visTimestamp from visualization directive
This commit is contained in:
parent
5b5c1b0ec0
commit
a7c4be4329
@ -39,59 +39,58 @@ const app = modules.get('apps/webinar_app', [])
|
||||
if(!visualization && !rendered && !renderInProgress) { // There's no visualization object -> create it with proper filters
|
||||
renderInProgress = true;
|
||||
|
||||
if ($rootScope.visTimestamp) {
|
||||
const rawVis = raw.filter(item => item.id === $scope.visID + "-" + $rootScope.visTimestamp);
|
||||
wzsavedVisualizations.get($scope.visID + "-" + $rootScope.visTimestamp,rawVis[0]).then(savedObj => {
|
||||
originalImplicitFilter = savedObj.searchSource.get('query')['query'];
|
||||
visTitle = savedObj.vis.title;
|
||||
visualization = savedObj;
|
||||
const rawVis = raw.filter(item => item.id === $scope.visID);
|
||||
wzsavedVisualizations.get($scope.visID,rawVis[0]).then(savedObj => {
|
||||
originalImplicitFilter = savedObj.searchSource.get('query')['query'];
|
||||
visTitle = savedObj.vis.title;
|
||||
visualization = savedObj;
|
||||
|
||||
// There's an original filter
|
||||
if (originalImplicitFilter.length > 0 ) {
|
||||
// And also a pending one -> concatenate them
|
||||
if ($rootScope.discoverPendingUpdates && typeof $rootScope.discoverPendingUpdates[0].query === 'string' && $rootScope.discoverPendingUpdates[0].query.length > 0) {
|
||||
implicitFilter = originalImplicitFilter + ' AND ' + $rootScope.discoverPendingUpdates[0].query;
|
||||
} else {
|
||||
// Only the original filter
|
||||
implicitFilter = originalImplicitFilter;
|
||||
}
|
||||
// There's an original filter
|
||||
if (originalImplicitFilter.length > 0 ) {
|
||||
// And also a pending one -> concatenate them
|
||||
if ($rootScope.discoverPendingUpdates && typeof $rootScope.discoverPendingUpdates[0].query === 'string' && $rootScope.discoverPendingUpdates[0].query.length > 0) {
|
||||
implicitFilter = originalImplicitFilter + ' AND ' + $rootScope.discoverPendingUpdates[0].query;
|
||||
} else {
|
||||
// Other case, use the pending one, if it is empty, it won't matter
|
||||
implicitFilter = $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[0].query : '';
|
||||
// Only the original filter
|
||||
implicitFilter = originalImplicitFilter;
|
||||
}
|
||||
} else {
|
||||
// Other case, use the pending one, if it is empty, it won't matter
|
||||
implicitFilter = $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[0].query : '';
|
||||
}
|
||||
|
||||
if (visTitle !== 'Wazuh App Overview General Agents status') { // We don't want to filter that visualization as it uses another index-pattern
|
||||
visualization.searchSource
|
||||
.query({ language: 'lucene', query: implicitFilter })
|
||||
.set('filter', $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[1] : {});
|
||||
}
|
||||
if (visTitle !== 'Wazuh App Overview General Agents status') { // We don't want to filter that visualization as it uses another index-pattern
|
||||
visualization.searchSource
|
||||
.query({ language: 'lucene', query: implicitFilter })
|
||||
.set('filter', $rootScope.discoverPendingUpdates ? $rootScope.discoverPendingUpdates[1] : {});
|
||||
}
|
||||
|
||||
let params = {};
|
||||
let params = {};
|
||||
|
||||
if ($scope.specificTimeRange) {
|
||||
const timeRange = {
|
||||
from: 'now-1d/d',
|
||||
to: 'now'
|
||||
};
|
||||
params = {timeRange: timeRange}
|
||||
}
|
||||
$(`[vis-id="'${$scope.visID}'"]`).on('renderStart', () => {
|
||||
//$("#"+$scope.visID).on('renderStart', () => {
|
||||
// TBD: Use renderStart to couple it with renderComplete?
|
||||
});
|
||||
|
||||
visHandler = loader.embedVisualizationWithSavedObject($(`[vis-id="'${$scope.visID}'"]`), visualization, params);
|
||||
|
||||
$rootScope.ownHandlers.push(visHandler);
|
||||
visHandler.addRenderCompleteListener(renderComplete);
|
||||
}).catch(error => {
|
||||
if(error && error.message && error.message.includes('not locate that index-pattern-field')){
|
||||
errorHandler.handle(`${error.message}, please restart Kibana and refresh this page once done`,'Visualize')
|
||||
} else {
|
||||
errorHandler.handle(error,'Visualize')
|
||||
}
|
||||
});
|
||||
}
|
||||
if ($scope.specificTimeRange) {
|
||||
const timeRange = {
|
||||
from: 'now-1d/d',
|
||||
to: 'now'
|
||||
};
|
||||
params = {timeRange: timeRange}
|
||||
}
|
||||
$(`[vis-id="'${$scope.visID}'"]`).on('renderStart', () => {
|
||||
//$("#"+$scope.visID).on('renderStart', () => {
|
||||
// TBD: Use renderStart to couple it with renderComplete?
|
||||
});
|
||||
|
||||
visHandler = loader.embedVisualizationWithSavedObject($(`[vis-id="'${$scope.visID}'"]`), visualization, params);
|
||||
|
||||
$rootScope.ownHandlers.push(visHandler);
|
||||
visHandler.addRenderCompleteListener(renderComplete);
|
||||
}).catch(error => {
|
||||
if(error && error.message && error.message.includes('not locate that index-pattern-field')){
|
||||
errorHandler.handle(`${error.message}, please restart Kibana and refresh this page once done`,'Visualize')
|
||||
} else {
|
||||
errorHandler.handle(error,'Visualize')
|
||||
}
|
||||
});
|
||||
|
||||
} else if (rendered) { // There's a visualization object -> just update its filters
|
||||
|
||||
// There's an original filter
|
||||
@ -133,10 +132,6 @@ const app = modules.get('apps/webinar_app', [])
|
||||
|
||||
if (currentCompleted >= 100) {
|
||||
|
||||
if ($rootScope.visTimestamp) {
|
||||
$rootScope.visTimestamp = null;
|
||||
}
|
||||
|
||||
if (!visTitle !== 'Wazuh App Overview General Agents status') $rootScope.rendered = true;
|
||||
// Forcing a digest cycle
|
||||
if(!$rootScope.$$phase) $rootScope.$digest();
|
||||
|
Loading…
Reference in New Issue
Block a user