-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6857 from BigFunger/add-data-processors-join
[add data] ingest join processor
- Loading branch information
Showing
8 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...c/settings/sections/indices/add_data_steps/pipeline_setup/directives/processor_ui_join.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import uiModules from 'ui/modules'; | ||
import _ from 'lodash'; | ||
import keysDeep from '../lib/keys_deep'; | ||
import template from '../views/processor_ui_join.html'; | ||
|
||
const app = uiModules.get('kibana'); | ||
|
||
//scope.processor, scope.pipeline are attached by the process_container. | ||
app.directive('processorUiJoin', function () { | ||
return { | ||
restrict: 'E', | ||
template: template, | ||
controller : function ($scope) { | ||
const processor = $scope.processor; | ||
const pipeline = $scope.pipeline; | ||
|
||
function consumeNewInputObject() { | ||
const allKeys = keysDeep(processor.inputObject); | ||
$scope.fields = _.filter(allKeys, (key) => { return _.isArray(_.get(processor.inputObject, key)); }); | ||
refreshFieldData(); | ||
} | ||
|
||
function refreshFieldData() { | ||
$scope.fieldData = _.get(processor.inputObject, processor.sourceField); | ||
} | ||
|
||
function processorUiChanged() { | ||
pipeline.setDirty(); | ||
} | ||
|
||
$scope.$watch('processor.inputObject', consumeNewInputObject); | ||
|
||
$scope.$watch('processor.sourceField', () => { | ||
refreshFieldData(); | ||
processorUiChanged(); | ||
}); | ||
|
||
$scope.$watch('processor.separator', processorUiChanged); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...blic/settings/sections/indices/add_data_steps/pipeline_setup/views/processor_ui_join.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="form-group"> | ||
<label>Array Field:</label> | ||
<select | ||
class="form-control" | ||
ng-options="field as field for field in fields" | ||
ng-model="processor.sourceField"> | ||
</select> | ||
</div> | ||
<div class="form-group"> | ||
<label>Field Data:</label> | ||
<pre>{{ fieldData }}</pre> | ||
</div> | ||
<div class="form-group"> | ||
<label>Separator:</label> | ||
<input type="text" class="form-control" ng-trim="false" ng-model="processor.separator"> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
define(function (require) { | ||
var Promise = require('bluebird'); | ||
var _ = require('intern/dojo/node!lodash'); | ||
var expect = require('intern/dojo/node!expect.js'); | ||
|
||
const testPipeline = { | ||
processors: [{ | ||
processor_id: 'processor1', | ||
type_id: 'join', | ||
source_field: 'foo', | ||
separator: ' ' | ||
}], | ||
input: { foo: ['value1', 'value2'] } | ||
}; | ||
|
||
return function (bdd, scenarioManager, request) { | ||
bdd.describe('simulate - join processor', () => { | ||
|
||
bdd.it('should return 400 for an invalid payload', () => { | ||
return Promise.all([ | ||
// processor requires source_field property | ||
request.post('/kibana/ingest/simulate') | ||
.send({ | ||
processors: [{ | ||
processor_id: 'processor1', | ||
type_id: 'join', | ||
source_field: 1234, | ||
separator: ' ' | ||
}], | ||
input: { foo: ['value1', 'value2'] } | ||
}) | ||
.expect(400) | ||
]); | ||
}); | ||
|
||
bdd.it('should return 200 for a valid simulate request', () => { | ||
return request.post('/kibana/ingest/simulate') | ||
.send(testPipeline) | ||
.expect(200); | ||
}); | ||
|
||
bdd.it('should return a simulated output with the correct result for the given processor', function () { | ||
return request.post('/kibana/ingest/simulate') | ||
.send(testPipeline) | ||
.expect(200) | ||
.then(function (response) { | ||
expect(response.body[0].output.foo).to.be('value1 value2'); | ||
}); | ||
}); | ||
|
||
bdd.it('should enforce snake case', () => { | ||
return request.post('/kibana/ingest/simulate') | ||
.send({ | ||
processors: [{ | ||
processorId: 'processor1', | ||
typeId: 'join', | ||
sourceField: 'foo', | ||
separator: ' ' | ||
}], | ||
input: { foo: ['value1', 'value2'] } | ||
}) | ||
.expect(400); | ||
}); | ||
|
||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters