wazuh-kibana-app/public/kibana-integrations/kibanaSearchbarDirective.js

67 lines
1.9 KiB
JavaScript
Raw Normal View History

import rison from 'rison-node';
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
import { StateProvider } from 'ui/state_management/state';
import { AggTypesBucketsIntervalOptionsProvider } from 'ui/agg_types/buckets/_interval_options';
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) {
$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
var gParameter;
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
} ());
// 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 + ")");
}
};
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
});