WIP
This commit is contained in:
@@ -10,7 +10,8 @@ import {
|
||||
TransformerCategory,
|
||||
} from '@grafana/data';
|
||||
import { t } from '@grafana/i18n';
|
||||
import { fieldMatchersUI, InlineField, InlineFieldRow, Select, useStyles2 } from '@grafana/ui';
|
||||
import { Checkbox, fieldMatchersUI, InlineField, InlineFieldRow, Select, useStyles2 } from '@grafana/ui';
|
||||
import { FieldNamePicker } from '@grafana/ui/internal';
|
||||
|
||||
import { getTransformationContent } from '../docs/getTransformationContent';
|
||||
import { FieldToConfigMappingEditor } from '../fieldToConfigMapping/FieldToConfigMappingEditor';
|
||||
@@ -21,6 +22,13 @@ import { getConfigFromDataTransformer, ConfigFromQueryTransformOptions } from '.
|
||||
|
||||
export interface Props extends TransformerUIProps<ConfigFromQueryTransformOptions> {}
|
||||
|
||||
const fieldNamePickerSettings = {
|
||||
editor: FieldNamePicker,
|
||||
id: '',
|
||||
name: '',
|
||||
settings: { width: 24, isClearable: false },
|
||||
};
|
||||
|
||||
export function ConfigFromQueryTransformerEditor({ input, onChange, options }: Props) {
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
@@ -41,6 +49,13 @@ export function ConfigFromQueryTransformerEditor({ input, onChange, options }: P
|
||||
});
|
||||
};
|
||||
|
||||
const onMappingChange = (value: SelectableValue<boolean>) => {
|
||||
onChange({
|
||||
...options,
|
||||
isMapping: value.value || false,
|
||||
});
|
||||
};
|
||||
|
||||
const onMatcherChange = (value: SelectableValue<string>) => {
|
||||
onChange({ ...options, applyTo: { id: value.value! } });
|
||||
};
|
||||
@@ -85,14 +100,21 @@ export function ConfigFromQueryTransformerEditor({ input, onChange, options }: P
|
||||
onChange={onMatcherConfigChange}
|
||||
/>
|
||||
</InlineField>
|
||||
<InlineField>
|
||||
<Checkbox
|
||||
label={t('transformers.config-from-query-transformer-editor.label-mapping', 'Map results')}
|
||||
onChange={onMappingChange}
|
||||
value={options.isMapping}
|
||||
/>
|
||||
</InlineField>
|
||||
</InlineFieldRow>
|
||||
<InlineFieldRow>
|
||||
{configFrame && (
|
||||
{configFrame && !options.isMapping && (
|
||||
<FieldToConfigMappingEditor
|
||||
frame={configFrame}
|
||||
mappings={options.mappings}
|
||||
onChange={(mappings) => onChange({ ...options, mappings })}
|
||||
withReducers
|
||||
withReducers={!options.isMapping}
|
||||
/>
|
||||
)}
|
||||
</InlineFieldRow>
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface ConfigFromQueryTransformOptions {
|
||||
configRefId?: string;
|
||||
mappings: FieldToConfigMapping[];
|
||||
applyTo?: MatcherConfig;
|
||||
isMapping?: boolean;
|
||||
}
|
||||
|
||||
export function extractConfigFromQuery(options: ConfigFromQueryTransformOptions, data: DataFrame[]) {
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface FieldToConfigMapping {
|
||||
reducerId?: ReducerID;
|
||||
handlerKey: string | null;
|
||||
handlerArguments?: HandlerArguments;
|
||||
sourceFieldName?: string; // for mapping
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user