Skip to content

Commit

Permalink
Merge pull request #12 from cernops/v6.8.0
Browse files Browse the repository at this point in the history
Migrating the cluster to 6.8.0
  • Loading branch information
schwicke committed Aug 8, 2019
2 parents ef6b1f4 + 2aad011 commit d33e263
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 41 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "relational_filter",
"version": "6.2.4",
"description": "Visualization with the possibility to create filters based on relations between different documents"
"name": "relational_filter",
"version": "6.8.0",
"description": "Visualization with the possibility to create filters based on relations between different documents"
}

46 changes: 25 additions & 21 deletions public/relationalFilterController.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,14 @@ module.controller('relationalFilterController', function($scope, Private) {
let alias, field, internal_query, a, b;
alias = $scope.vis.aggs.bySchemaName['filterDisplay'][0]['params']['field']['name'].replace(".keyword", "");
field = $scope.vis.aggs.bySchemaName['filterValue'][0]['params']['field']['name'];
console.log(field);
console.log(tag);
console.log($scope.vis.params.emptyValue);
console.log("AM I HERE???");

filter = {'meta':{'type':'query'}};
filter[alias] = tag.label;

internal_query = {
"terms": {}
};
internal_query["terms"][field] = tag.value.split(",");
internal_query["terms"][field] = tag['values'];

if ($scope.vis.params.emptyValue) {
console.log("Doing the boolean query");
Expand Down Expand Up @@ -91,7 +87,6 @@ module.controller('relationalFilterController', function($scope, Private) {

$scope.filter_menu = function() {
console.log("INSIDE THE FILTER_MENU");
console.log($scope.my_filter);
$scope.create_filter(JSON.parse($scope.my_filter));

};
Expand All @@ -102,7 +97,7 @@ module.controller('relationalFilterController', function($scope, Private) {
let my_object;
my_tag = {
"label": "",
"value": ""
"values": [],
};

if (typeof $scope.my_filter === 'undefined' || !$scope.my_filter) {
Expand All @@ -113,12 +108,11 @@ module.controller('relationalFilterController', function($scope, Private) {
for (var i = 0; i < $scope.my_filter.length; i++) {
my_object = JSON.parse($scope.my_filter[i]);
my_tag['label'] += my_object['label'] + ",";
my_tag['value'] += my_object['value'] + ",";
my_tag['values'] = my_tag['values'].concat(my_object['values']);
}

// Remove the last ,
my_tag['label'] = my_tag['label'].slice(0, -1);
my_tag['value'] = my_tag['value'].slice(0, -1);

console.log("AND NOW");
console.log("my tag: " + my_tag);
Expand Down Expand Up @@ -148,21 +142,31 @@ module.controller('relationalFilterController', function($scope, Private) {
if (!$scope.vis.aggs.bySchemaName['filterDisplay'] || !$scope.vis.aggs.bySchemaName['filterValue']) {
return;
}

console.log('Creating the filter');
var displayId = $scope.vis.aggs.bySchemaName['filterDisplay'][0].id;
var valuesId = $scope.vis.aggs.bySchemaName['filterValue'][0].id;
var buckets = resp.aggregations[displayId].buckets;
var buckets = resp.rows;
$scope.filter_display = $scope.vis.aggs.bySchemaName['filterDisplay'][0]['params']['field']['name'].replace(".keyword", "");
$scope.filter_entries = buckets.map(function(bucket) {
var subbucket = bucket[valuesId].buckets;
var all_values = subbucket.map(function(subbucket) {
return subbucket.key;
});
return {
label: bucket.key,
value: all_values.join()
}
});
var current_display = '';
$scope.filter_entries = [];
var current_values = [];
buckets.forEach(function (item, index) {
var display= item['col-0-1'];
var value = item['col-1-2'];
if (current_display == display) {
current_values.push(value);
} else {
if (current_display!= '') {
$scope.filter_entries.push({'label': current_display, 'values':current_values});
}
current_values = [value];
current_display = display;
}
});
if (current_display!= '') {
$scope.filter_entries.push({'label': current_display, 'values':current_values});
}

console.log('Filter_entries created');
// console.log($scope.filter_entries);

Expand Down
41 changes: 24 additions & 17 deletions public/relational_filter.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
require('plugins/relational_filter/relationalFilterController');

//import { VisController } from './vis_controller';
import { CATEGORY } from 'ui/vis/vis_category';
import { Status } from 'ui/vis/update_status';
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { VisTypesRegistryProvider } from 'ui/registry/vis_types';
import { VisSchemasProvider } from 'ui/vis/editors/default/schemas';
import { Schemas } from 'ui/vis/editors/default/schemas';
import optionsTemplate from 'plugins/relational_filter/filter_options.html';
import visTemplate from 'plugins/relational_filter/relational_filter.html';

// The provider function, which must return our new visualization type
//function RelationalFilterProvider(Private) {
const RelationalFilterProvider = (Private) => {
VisTypesRegistryProvider.register( function (Private) {
const VisFactory = Private(VisFactoryProvider);
const Schemas = Private(VisSchemasProvider);
return VisFactory.createAngularVisualization({
type: 'relationalFilter',
name: 'trRelationalFilter',
title: 'Relational Filter',
icon: 'fa-cloud',
icon: 'gear',
description: 'Kibana Relational Filter',
category: CATEGORY.OTHER,
visConfig: {
template: visTemplate,
defaults: {
outputFormat: 'table',
filterTypes: []
filterTypes: [],
totalFunc: 'sum'

}
},
// requestHandler: 'none',
responseHandler: 'none',

editorConfig: {
optionsTemplate: optionsTemplate,
schemas: new Schemas([
{
group: 'metrics',
name: 'metric',
title: 'My metric',
aggFilter: ['!geo_centroid', '!geo_bounds'],
min: 1,
max: 1,
defaults: [
{ type: 'count', schema: 'metric' }
]
},

{
group: 'buckets',
name: 'filterDisplay',
Expand All @@ -49,10 +59,7 @@ const RelationalFilterProvider = (Private) => {
aggFilter: [ 'terms'],
type: 'string',
},
]),
}
]),
}
});
}

// Define the aggregation your visualization accepts
VisTypesRegistryProvider.register(RelationalFilterProvider);
});

0 comments on commit d33e263

Please sign in to comment.