mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Format String Transformation: Add applicability function (#87777)
* Add applicability function * Prettier
This commit is contained in:
parent
aae6b5312a
commit
e4db00903b
@ -1,7 +1,7 @@
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { DataFrame, Field, FieldType } from '../../types';
|
import { DataFrame, Field, FieldType } from '../../types';
|
||||||
import { DataTransformerInfo, FieldMatcher } from '../../types/transformations';
|
import { DataTransformerInfo, FieldMatcher, TransformationApplicabilityLevels } from '../../types/transformations';
|
||||||
import { fieldMatchers } from '../matchers';
|
import { fieldMatchers } from '../matchers';
|
||||||
import { FieldMatcherID } from '../matchers/ids';
|
import { FieldMatcherID } from '../matchers/ids';
|
||||||
|
|
||||||
@ -69,6 +69,19 @@ export const formatStringTransformer: DataTransformerInfo<FormatStringTransforme
|
|||||||
name: 'Format string',
|
name: 'Format string',
|
||||||
description: 'Manipulate string fields formatting',
|
description: 'Manipulate string fields formatting',
|
||||||
defaultOptions: { stringField: '', outputFormat: FormatStringOutput.UpperCase },
|
defaultOptions: { stringField: '', outputFormat: FormatStringOutput.UpperCase },
|
||||||
|
isApplicable: (data: DataFrame[]) => {
|
||||||
|
// Search for a string field
|
||||||
|
// if there is one then we can use this transformation
|
||||||
|
for (const frame of data) {
|
||||||
|
for (const field of frame.fields) {
|
||||||
|
if (field.type === 'string') {
|
||||||
|
return TransformationApplicabilityLevels.Applicable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TransformationApplicabilityLevels.NotApplicable;
|
||||||
|
},
|
||||||
operator: (options) => (source) =>
|
operator: (options) => (source) =>
|
||||||
source.pipe(
|
source.pipe(
|
||||||
map((data) => {
|
map((data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user