2016-11-23 21:29:44 +00:00
|
|
|
import rison from 'rison-node';
|
2017-08-21 07:00:46 +00:00
|
|
|
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
|
|
|
|
import { StateProvider } from 'ui/state_management/state';
|
|
|
|
import { AggTypesBucketsIntervalOptionsProvider } from 'ui/agg_types/buckets/_interval_options';
|
2016-11-23 21:29:44 +00:00
|
|
|
|
|
|
|
var app = require('ui/modules').get('app/wazuh', [])
|
|
|
|
.directive('kbnSearchbar', [function () {
|
|
|
|
return {
|
|
|
|
restrict: 'E',
|
|
|
|
scope: {
|
|
|
|
visType: '@visType',
|
|
|
|
visIndexPattern: '@visIndexPattern',
|
|
|
|
visA: '@visA',
|
|
|
|
visG: '@visG',
|
|
|
|
visFilter: '@visFilter',
|
|
|
|
visHeight: '@visHeight',
|
|
|
|
visWidth: '@visWidth',
|
|
|
|
visSearchable: '@visSearchable',
|
|
|
|
visClickable: '@visClickable'
|
|
|
|
},
|
|
|
|
template: require('../templates/directives/kibana-searchbar-template.html')
|
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
2017-09-22 17:31:46 +00:00
|
|
|
require('ui/modules').get('app/wazuh', []).controller('kibanaSearchBar', function ($scope, $route, timefilter, AppState, $timeout, Private, $rootScope) {
|
2016-11-23 21:29:44 +00:00
|
|
|
$route.reloadOnSearch = true;
|
|
|
|
|
|
|
|
timefilter.enabled = true;
|
2017-09-20 07:04:51 +00:00
|
|
|
$scope.stateQuery = "";
|
2016-11-24 00:04:52 +00:00
|
|
|
// Set default time
|
2017-05-30 10:37:38 +00:00
|
|
|
var gParameter;
|
2017-06-20 07:43:40 +00:00
|
|
|
if($route.current.params._g){
|
|
|
|
if($route.current.params._g.startsWith("h@")){
|
|
|
|
gParameter = sessionStorage.getItem($route.current.params._g);
|
|
|
|
}else{
|
|
|
|
gParameter = $route.current.params._g;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
gParameter="()";
|
|
|
|
}
|
|
|
|
if (gParameter == "()"){
|
2016-12-05 17:32:59 +00:00
|
|
|
timefilter.time.from = "now-24h";
|
|
|
|
timefilter.time.to = "now";
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.timefilter = timefilter;
|
2016-11-24 00:04:52 +00:00
|
|
|
let $state = $scope.$state = (function initState() {
|
2017-09-07 15:32:37 +00:00
|
|
|
$state = new AppState();
|
2017-01-26 15:58:28 +00:00
|
|
|
return $state;
|
2016-11-24 00:04:52 +00:00
|
|
|
} ());
|
2016-11-23 21:29:44 +00:00
|
|
|
|
|
|
|
// Fetch / reload visualization
|
|
|
|
$scope.fetch = function ()
|
|
|
|
{
|
2017-09-20 07:04:51 +00:00
|
|
|
if (this.stateQuery == "") {
|
|
|
|
$rootScope.$broadcast('updateQuery',"(*)");
|
|
|
|
} else {
|
|
|
|
this.stateQuery = this.stateQuery == "" ? "" : this.stateQuery;
|
|
|
|
$rootScope.$broadcast('updateQuery',"(" + this.stateQuery + ")");
|
|
|
|
}
|
2016-11-23 21:29:44 +00:00
|
|
|
};
|
2017-01-26 20:28:01 +00:00
|
|
|
|
2017-01-26 15:58:28 +00:00
|
|
|
$scope.queryFilter = Private(FilterBarQueryFilterProvider);
|
2017-01-26 16:37:16 +00:00
|
|
|
|
2016-11-23 21:29:44 +00:00
|
|
|
});
|
2017-10-24 16:35:18 +00:00
|
|
|
|