|
|
|
@ -14,8 +14,9 @@ import { |
|
|
|
|
ConvertFieldTypeOptions, |
|
|
|
|
ConvertFieldTypeTransformerOptions, |
|
|
|
|
} from '@grafana/data/src/transformations/transformers/convertFieldType'; |
|
|
|
|
import { Button, InlineField, InlineFieldRow, Input, Select } from '@grafana/ui'; |
|
|
|
|
import { Button, InlineField, InlineFieldRow, Input, Select, getFieldTypeIconName } from '@grafana/ui'; |
|
|
|
|
import { FieldNamePicker } from '@grafana/ui/src/components/MatchersUI/FieldNamePicker'; |
|
|
|
|
import { findField } from 'app/features/dimensions'; |
|
|
|
|
|
|
|
|
|
const fieldNamePickerSettings: StandardEditorsRegistryItem<string, FieldNamePickerConfigSettings> = { |
|
|
|
|
settings: { width: 24, isClearable: false }, |
|
|
|
@ -27,11 +28,11 @@ export const ConvertFieldTypeTransformerEditor = ({ |
|
|
|
|
onChange, |
|
|
|
|
}: TransformerUIProps<ConvertFieldTypeTransformerOptions>) => { |
|
|
|
|
const allTypes: Array<SelectableValue<FieldType>> = [ |
|
|
|
|
{ value: FieldType.number, label: 'Numeric' }, |
|
|
|
|
{ value: FieldType.string, label: 'String' }, |
|
|
|
|
{ value: FieldType.time, label: 'Time' }, |
|
|
|
|
{ value: FieldType.boolean, label: 'Boolean' }, |
|
|
|
|
{ value: FieldType.other, label: 'JSON' }, |
|
|
|
|
{ value: FieldType.number, label: 'Number', icon: getFieldTypeIconName(FieldType.number) }, |
|
|
|
|
{ value: FieldType.string, label: 'String', icon: getFieldTypeIconName(FieldType.string) }, |
|
|
|
|
{ value: FieldType.time, label: 'Time', icon: getFieldTypeIconName(FieldType.time) }, |
|
|
|
|
{ value: FieldType.boolean, label: 'Boolean', icon: getFieldTypeIconName(FieldType.boolean) }, |
|
|
|
|
{ value: FieldType.other, label: 'JSON', icon: getFieldTypeIconName(FieldType.other) }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const onSelectField = useCallback( |
|
|
|
@ -122,6 +123,11 @@ export const ConvertFieldTypeTransformerEditor = ({ |
|
|
|
|
<Input value={c.dateFormat} placeholder={'e.g. YYYY-MM-DD'} onChange={onInputFormat(idx)} width={24} /> |
|
|
|
|
</InlineField> |
|
|
|
|
)} |
|
|
|
|
{c.destinationType === FieldType.string && (c.dateFormat || findField(input?.[0], c.targetField)) && ( |
|
|
|
|
<InlineField label="Date format" tooltip="Specify the output format."> |
|
|
|
|
<Input value={c.dateFormat} placeholder={'e.g. YYYY-MM-DD'} onChange={onInputFormat(idx)} width={24} /> |
|
|
|
|
</InlineField> |
|
|
|
|
)} |
|
|
|
|
<Button |
|
|
|
|
size="md" |
|
|
|
|
icon="trash-alt" |
|
|
|
|