mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
Adding implicit filters and AppState management to the integrations
This commit is contained in:
parent
3e5a98bb15
commit
9553f6eed7
@ -3,11 +3,11 @@ import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
|
||||
|
||||
const app = require('ui/modules').get('apps/webinar_app', []);
|
||||
|
||||
app.controller('kibanaSearchbar', function ($scope, timefilter, AppState, $timeout, Private, $rootScope, savedVisualizations) {
|
||||
app.controller('kibanaSearchbar', function ($scope, timefilter, AppState, $timeout, Private, $rootScope, savedVisualizations, getAppState) {
|
||||
const filterBar = Private(FilterBarQueryFilterProvider);
|
||||
timefilter.enabled = true;
|
||||
let visualizeLoader = null;
|
||||
let currentAppState = null;
|
||||
let currentAppState = getAppState();
|
||||
$scope.indexPattern = [];
|
||||
|
||||
savedVisualizations.get('Alert-level-evolution').then(savedObj => {
|
||||
@ -16,6 +16,8 @@ app.controller('kibanaSearchbar', function ($scope, timefilter, AppState, $timeo
|
||||
// Configure AppState. Get App State, if there is no App State create new one
|
||||
if (!currentAppState) {
|
||||
$scope.state = new AppState(getStateDefaults());
|
||||
} else {
|
||||
$scope.state = currentAppState;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -9,8 +9,11 @@ var app = require('ui/modules').get('apps/webinar_app', [])
|
||||
visID: '=visId',
|
||||
},
|
||||
controller: function VisController($scope, savedVisualizations) {
|
||||
|
||||
$scope.implicitFilter = '';
|
||||
// Listen for changes
|
||||
var updateSearchSource = $scope.$on('updateVis', function (event, query, filters) {
|
||||
if ($scope.implicitFilter !== '') query.query = $scope.implicitFilter + ' AND ' + query.query;
|
||||
$scope.savedObj.searchSource.set('query', query);
|
||||
$scope.savedObj.searchSource.set('filter', filters);
|
||||
});
|
||||
@ -18,6 +21,8 @@ var app = require('ui/modules').get('apps/webinar_app', [])
|
||||
// Initializing the visualization
|
||||
getVisualizeLoader().then(loader => {
|
||||
savedVisualizations.get($scope.visID).then(savedObj => {
|
||||
if ($scope.implicitFilter.endsWith("AND ")) $scope.implicitFilter = $scope.implicitFilter.substring(0, $scope.implicitFilter.indexOf("AND "));
|
||||
$scope.implicitFilter = savedObj.searchSource.get('query')['query'];
|
||||
$scope.savedObj = savedObj;
|
||||
loader.embedVisualizationWithSavedObject($("#"+$scope.visID), $scope.savedObj, {})
|
||||
.then(handler => {
|
||||
|
Loading…
Reference in New Issue
Block a user