[add data] added auto type and target field to convert processor

This commit is contained in:
Jim Unger 2016-04-08 09:49:17 -05:00
parent 3fe7dd9adc
commit 61dd02ee5d
6 changed files with 32 additions and 8 deletions

View file

@ -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);
}
};
});

View file

@ -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'
};
}
};

View file

@ -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>

View file

@ -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]
}
};
}

View file

@ -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()
});

View file

@ -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: {}