mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 08:47:12 -06:00
32 lines
805 B
TypeScript
32 lines
805 B
TypeScript
import { VisualizationSuggestionsBuilder } from '@grafana/data';
|
|
import { checkFields } from '@grafana/flamegraph';
|
|
import { SuggestionName } from 'app/types/suggestions';
|
|
|
|
export class FlameGraphSuggestionsSupplier {
|
|
getListWithDefaults(builder: VisualizationSuggestionsBuilder) {
|
|
return builder.getListAppender<{}, {}>({
|
|
name: SuggestionName.FlameGraph,
|
|
pluginId: 'flamegraph',
|
|
});
|
|
}
|
|
|
|
getSuggestionsForData(builder: VisualizationSuggestionsBuilder) {
|
|
if (!builder.data) {
|
|
return;
|
|
}
|
|
|
|
const dataFrame = builder.data.series[0];
|
|
if (!dataFrame) {
|
|
return;
|
|
}
|
|
const wrongFields = checkFields(dataFrame);
|
|
if (wrongFields) {
|
|
return;
|
|
}
|
|
|
|
this.getListWithDefaults(builder).append({
|
|
name: SuggestionName.FlameGraph,
|
|
});
|
|
}
|
|
}
|