mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[add data] added auto type and target field to convert processor
This commit is contained in:
parent
3fe7dd9adc
commit
61dd02ee5d
6 changed files with 32 additions and 8 deletions
|
@ -27,16 +27,20 @@ app.directive('processorUiConvert', function () {
|
|||
pipeline.setDirty();
|
||||
}
|
||||
|
||||
$scope.types = ['integer', 'float', 'string', 'boolean'];
|
||||
$scope.types = ['auto', 'number', 'string', 'boolean'];
|
||||
|
||||
$scope.$watch('processor.inputObject', consumeNewInputObject);
|
||||
|
||||
$scope.$watch('processor.sourceField', () => {
|
||||
if (_.isEmpty($scope.processor.targetField)) {
|
||||
$scope.processor.targetField = $scope.processor.sourceField;
|
||||
}
|
||||
refreshFieldData();
|
||||
processorUiChanged();
|
||||
});
|
||||
|
||||
$scope.$watch('processor.type', processorUiChanged);
|
||||
$scope.$watch('processor.targetField', processorUiChanged);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -48,13 +48,15 @@ export class Convert extends Processor {
|
|||
constructor(processorId) {
|
||||
super(processorId, 'convert', 'Convert');
|
||||
this.sourceField = '';
|
||||
this.type = 'string';
|
||||
this.targetField = '';
|
||||
this.type = 'auto';
|
||||
}
|
||||
|
||||
get description() {
|
||||
const source = this.sourceField || '?';
|
||||
const target = this.targetField || '?';
|
||||
const type = this.type || '?';
|
||||
return `[${source}] to ${type}`;
|
||||
return `[${source}] to ${type} -> [${target}]`;
|
||||
}
|
||||
|
||||
get model() {
|
||||
|
@ -62,7 +64,8 @@ export class Convert extends Processor {
|
|||
processorId: this.processorId,
|
||||
typeId: this.typeId,
|
||||
sourceField: this.sourceField || '',
|
||||
type: this.type || 'string'
|
||||
targetField: this.targetField || '',
|
||||
type: this.type || 'auto'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,3 +18,7 @@
|
|||
ng-model="processor.type">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Target Field:</label>
|
||||
<input type="text" class="form-control" ng-model="processor.targetField">
|
||||
</div>
|
||||
|
|
|
@ -9,11 +9,20 @@ export function append(processorApiDocument) {
|
|||
}
|
||||
|
||||
export function convert(processorApiDocument) {
|
||||
const types = {
|
||||
//<kibana type>: <ingest type>,
|
||||
auto: 'auto',
|
||||
number: 'float',
|
||||
string: 'string',
|
||||
boolean: 'boolean'
|
||||
};
|
||||
|
||||
return {
|
||||
convert: {
|
||||
tag: processorApiDocument.processor_id,
|
||||
field: processorApiDocument.source_field,
|
||||
type: processorApiDocument.type
|
||||
target_field: processorApiDocument.target_field,
|
||||
type: types[processorApiDocument.type]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ export const append = base.keys({
|
|||
export const convert = base.keys({
|
||||
type_id: Joi.string().only('convert').required(),
|
||||
source_field: Joi.string().allow(''),
|
||||
target_field: Joi.string().allow(''),
|
||||
type: Joi.string()
|
||||
});
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ define(function (require) {
|
|||
processor_id: 'processor1',
|
||||
type_id: 'convert',
|
||||
source_field: 'foo',
|
||||
type: 'integer'
|
||||
target_field: 'foo',
|
||||
type: 'auto'
|
||||
}],
|
||||
input: { foo: '1234' }
|
||||
};
|
||||
|
@ -25,8 +26,9 @@ define(function (require) {
|
|||
processors: [{
|
||||
processor_id: 'processor1',
|
||||
type_id: 'convert',
|
||||
value: 'integer',
|
||||
source_field: 42
|
||||
value: 'auto',
|
||||
source_field: 42,
|
||||
target_field: 'foo'
|
||||
}]
|
||||
})
|
||||
.expect(400)
|
||||
|
@ -55,6 +57,7 @@ define(function (require) {
|
|||
processorId: 'processor1',
|
||||
typeId: 'convert',
|
||||
sourceField: 'foo',
|
||||
targetField: 'foo',
|
||||
type: 'string'
|
||||
}],
|
||||
input: {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue