2017-11-13 15:36:31 +00:00
|
|
|
import $ from 'jquery';
|
|
|
|
import { getVisualizeLoader } from 'ui/visualize/loader';
|
2017-11-28 13:52:25 +00:00
|
|
|
import 'ui/styles/theme.less'
|
2017-11-13 15:36:31 +00:00
|
|
|
|
|
|
|
var app = require('ui/modules').get('apps/webinar_app', [])
|
|
|
|
.directive('kbnVis', [function () {
|
|
|
|
return {
|
|
|
|
restrict: 'E',
|
|
|
|
scope: {
|
|
|
|
visID: '=visId',
|
|
|
|
},
|
2017-11-17 08:58:16 +00:00
|
|
|
controller: function VisController($scope, $rootScope, savedVisualizations) {
|
2017-11-15 14:55:23 +00:00
|
|
|
|
|
|
|
$scope.implicitFilter = '';
|
2017-11-17 08:58:16 +00:00
|
|
|
$scope.visTitle = '';
|
|
|
|
$scope.fullFilter = '';
|
|
|
|
|
2017-11-13 15:36:31 +00:00
|
|
|
// Listen for changes
|
|
|
|
var updateSearchSource = $scope.$on('updateVis', function (event, query, filters) {
|
2017-11-27 10:57:47 +00:00
|
|
|
if ($scope.visTitle !== 'Wazuh App Overview General Agents status') { // We don't want to filter that visualization as it uses another index-pattern
|
|
|
|
if (query.query == '') {
|
|
|
|
$scope.fullFilter = $scope.implicitFilter;
|
2017-11-17 08:58:16 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-11-27 10:57:47 +00:00
|
|
|
if ($scope.implicitFilter != '') {
|
|
|
|
$scope.fullFilter = $scope.implicitFilter + ' AND ' + query.query;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$scope.fullFilter = query.query;
|
|
|
|
}
|
2017-11-17 08:58:16 +00:00
|
|
|
}
|
2017-11-27 10:57:47 +00:00
|
|
|
$scope.savedObj.searchSource.set('query', {
|
|
|
|
language: 'lucene',
|
|
|
|
query: $scope.fullFilter
|
|
|
|
});
|
|
|
|
$scope.savedObj.searchSource.set('filter', filters);
|
2017-11-17 08:58:16 +00:00
|
|
|
}
|
2017-11-13 15:36:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Initializing the visualization
|
|
|
|
getVisualizeLoader().then(loader => {
|
|
|
|
savedVisualizations.get($scope.visID).then(savedObj => {
|
2017-11-15 14:55:23 +00:00
|
|
|
$scope.implicitFilter = savedObj.searchSource.get('query')['query'];
|
2017-11-17 08:58:16 +00:00
|
|
|
$scope.visTitle = savedObj.vis.title;
|
2017-11-13 15:36:31 +00:00
|
|
|
$scope.savedObj = savedObj;
|
|
|
|
loader.embedVisualizationWithSavedObject($("#"+$scope.visID), $scope.savedObj, {})
|
|
|
|
.then(handler => {
|
2017-11-25 15:36:39 +00:00
|
|
|
$rootScope.loadedVisualizations++;
|
2017-11-20 11:13:37 +00:00
|
|
|
//console.log('render complete', $scope.visTitle);
|
2017-11-13 15:36:31 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-10-09 15:49:10 +00:00
|
|
|
}
|
2017-11-13 15:36:31 +00:00
|
|
|
}
|
|
|
|
}]);
|