mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: improve some types (#95728)
* fix some typings * fix some more * more type fixes * fix some graphite types * few influx fixes
This commit is contained in:
parent
34269a03c0
commit
0fae3579e8
@ -41,8 +41,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
],
|
||||
"packages/grafana-data/src/dataframe/processDataFrame.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -69,12 +68,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "18"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "19"]
|
||||
],
|
||||
"packages/grafana-data/src/datetime/datemath.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/datetime/durationutil.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/datetime/moment_wrapper.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
@ -121,8 +114,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"]
|
||||
],
|
||||
"packages/grafana-data/src/panel/registryFactories.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
@ -150,25 +142,15 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-data/src/transformations/standardTransformersRegistry.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformDataFrame.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/nulls/nullInsertThreshold.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/reduce.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"packages/grafana-data/src/types/ScopedVars.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -188,14 +170,9 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||
],
|
||||
"packages/grafana-data/src/types/app.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"]
|
||||
],
|
||||
"packages/grafana-data/src/types/config.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
],
|
||||
"packages/grafana-data/src/types/dashboard.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -247,8 +224,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "24"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "23"]
|
||||
],
|
||||
"packages/grafana-data/src/types/explore.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -303,8 +279,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
|
||||
],
|
||||
"packages/grafana-data/src/types/plugin.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -342,23 +317,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "26"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"]
|
||||
],
|
||||
"packages/grafana-data/src/utils/Registry.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -374,9 +333,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"packages/grafana-data/src/utils/dataLinks.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/utils/datasource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
@ -601,9 +557,6 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-ui/src/components/InfoBox/InfoBox.story.tsx:5381": [
|
||||
[0, 0, 0, "\'VerticalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/InfoBox/InfoBox.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/JSONFormatter/json_explorer/json_explorer.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
@ -828,15 +781,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"packages/grafana-ui/src/utils/logger.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"packages/grafana-ui/src/utils/storybook/withTheme.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-ui/src/utils/useAsyncDependency.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
@ -896,15 +840,11 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/core/components/GraphNG/GraphNG.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "9"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"]
|
||||
],
|
||||
"public/app/core/components/LocalStorageValueProvider/index.tsx:5381": [
|
||||
[0, 0, 0, "Do not re-export imported variable (\`./LocalStorageValueProvider\`)", "0"]
|
||||
@ -2898,9 +2838,8 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/dashboard/components/TransformationsEditor/TransformationEditor.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "0"],
|
||||
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"]
|
||||
],
|
||||
"public/app/features/dashboard/components/TransformationsEditor/TransformationPicker.tsx:5381": [
|
||||
[0, 0, 0, "\'VerticalGroup\' import from \'@grafana/ui\' is restricted from being used by a pattern. Use Stack component instead.", "0"],
|
||||
@ -4533,9 +4472,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"]
|
||||
],
|
||||
"public/app/features/transformers/standardTransformers.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/features/transformers/suggestionsInput/SuggestionsInput.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
@ -5117,9 +5053,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"]
|
||||
],
|
||||
"public/app/plugins/datasource/graphite/components/helpers.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/graphite/datasource.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@ -5129,9 +5062,9 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
@ -5145,25 +5078,12 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "26"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "27"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "28"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "29"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "19"]
|
||||
],
|
||||
"public/app/plugins/datasource/graphite/gfunc.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/graphite/graphite_query.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -5176,22 +5096,12 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "16"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "10"]
|
||||
],
|
||||
"public/app/plugins/datasource/graphite/lexer.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
|
||||
],
|
||||
"public/app/plugins/datasource/graphite/migrations.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -5234,12 +5144,10 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "13"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "12"]
|
||||
],
|
||||
"public/app/plugins/datasource/influxdb/influx_query_model.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/influxdb/influx_series.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -5250,10 +5158,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
|
||||
],
|
||||
"public/app/plugins/datasource/influxdb/query_part.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
|
@ -550,8 +550,11 @@ export function parseLabelsFromField(str: string): Labels {
|
||||
* @internal // not exported in yet
|
||||
*/
|
||||
export function getLastStreamingDataFramePacket(frame: DataFrame) {
|
||||
const pi = (frame as StreamingDataFrame).packetInfo;
|
||||
return pi?.action ? pi : undefined;
|
||||
if (frame instanceof StreamingDataFrame) {
|
||||
const pi = frame.packetInfo;
|
||||
return pi.action;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// mutable circular push
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { includes, isDate } from 'lodash';
|
||||
import { isDate } from 'lodash';
|
||||
|
||||
import { TimeZone } from '../types/time';
|
||||
|
||||
@ -12,7 +12,11 @@ import {
|
||||
ISO_8601,
|
||||
} from './moment_wrapper';
|
||||
|
||||
const units: DurationUnit[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q'];
|
||||
const units: string[] = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'Q'] satisfies DurationUnit[];
|
||||
|
||||
const isDurationUnit = (value: string): value is DurationUnit => {
|
||||
return units.includes(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine if a string contains a relative date time.
|
||||
@ -169,11 +173,9 @@ export function parseDateMath(
|
||||
isFiscal = true;
|
||||
}
|
||||
|
||||
const unit = unitString as DurationUnit;
|
||||
const unit = unitString;
|
||||
|
||||
if (!includes(units, unit)) {
|
||||
return undefined;
|
||||
} else {
|
||||
if (isDurationUnit(unit)) {
|
||||
if (type === 0) {
|
||||
if (isFiscal) {
|
||||
roundToFiscal(fiscalYearStartMonth, result, unit, roundUp);
|
||||
@ -189,6 +191,8 @@ export function parseDateMath(
|
||||
} else if (type === 2) {
|
||||
result.subtract(num, unit);
|
||||
}
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { add, Duration, intervalToDuration, Interval, isAfter } from 'date-fns';
|
||||
|
||||
const durationMap: { [key in Required<keyof Duration>]: string[] } = {
|
||||
const durationMap: Record<string, string[]> = {
|
||||
years: ['y', 'Y', 'years'],
|
||||
months: ['M', 'months'],
|
||||
weeks: ['w', 'W', 'weeks'],
|
||||
@ -8,7 +8,7 @@ const durationMap: { [key in Required<keyof Duration>]: string[] } = {
|
||||
hours: ['h', 'H', 'hours'],
|
||||
minutes: ['m', 'minutes'],
|
||||
seconds: ['s', 'S', 'seconds'],
|
||||
};
|
||||
} satisfies { [key in keyof Duration]: string[] };
|
||||
|
||||
/**
|
||||
* intervalToAbbreviatedDurationString converts interval to readable duration string
|
||||
@ -26,7 +26,7 @@ export function intervalToAbbreviatedDurationString(interval: Interval, includeS
|
||||
}
|
||||
|
||||
const duration = intervalToDuration(interval);
|
||||
return (Object.entries(duration) as Array<[keyof Duration, number | undefined]>).reduce((str, [unit, value]) => {
|
||||
return Object.entries(duration).reduce((str, [unit, value]) => {
|
||||
if (value && value !== 0 && !(unit === 'seconds' && !includeSeconds && str)) {
|
||||
const padding = str !== '' ? ' ' : '';
|
||||
return str + `${padding}${value}${durationMap[unit][0]}`;
|
||||
|
@ -94,7 +94,7 @@ export type PanelOptionsSupplier<TOptions> = (
|
||||
|
||||
export class PanelPlugin<
|
||||
TOptions = any,
|
||||
TFieldConfigOptions extends object = any,
|
||||
TFieldConfigOptions extends object = {},
|
||||
> extends GrafanaPlugin<PanelPluginMeta> {
|
||||
private _defaults?: TOptions;
|
||||
private _fieldConfigDefaults: FieldConfigSource<TFieldConfigOptions> = {
|
||||
|
@ -16,7 +16,7 @@ export interface TransformerUIProps<T> {
|
||||
onChange: (options: T) => void;
|
||||
}
|
||||
|
||||
export interface TransformerRegistryItem<TOptions> extends RegistryItem {
|
||||
export interface TransformerRegistryItem<TOptions = any> extends RegistryItem {
|
||||
/**
|
||||
* Object describing transformer configuration
|
||||
*/
|
||||
@ -50,4 +50,4 @@ export enum TransformerCategory {
|
||||
* Registry of transformation options that can be driven by
|
||||
* stored configuration files.
|
||||
*/
|
||||
export const standardTransformersRegistry = new Registry<TransformerRegistryItem<any>>();
|
||||
export const standardTransformersRegistry = new Registry<TransformerRegistryItem>();
|
||||
|
@ -43,11 +43,7 @@ function filterInput(data: DataFrame[], matcher?: FrameMatcher) {
|
||||
}
|
||||
|
||||
const postProcessTransform =
|
||||
(
|
||||
before: DataFrame[],
|
||||
info: TransformerRegistryItem<any>,
|
||||
matcher?: FrameMatcher
|
||||
): MonoTypeOperatorFunction<DataFrame[]> =>
|
||||
(before: DataFrame[], info: TransformerRegistryItem, matcher?: FrameMatcher): MonoTypeOperatorFunction<DataFrame[]> =>
|
||||
(source) =>
|
||||
source.pipe(
|
||||
map((after) => {
|
||||
|
@ -88,7 +88,7 @@ function reduceSeriesToRows(
|
||||
config: {},
|
||||
});
|
||||
|
||||
const labels: KeyValue<any[]> = {};
|
||||
const labels: KeyValue<unknown[]> = {};
|
||||
if (labelsToFields) {
|
||||
for (const key of distinctLabels) {
|
||||
labels[key] = new Array(size);
|
||||
@ -101,7 +101,7 @@ function reduceSeriesToRows(
|
||||
}
|
||||
}
|
||||
|
||||
const calcs: KeyValue<any[]> = {};
|
||||
const calcs: KeyValue<unknown[]> = {};
|
||||
for (const info of calculators) {
|
||||
calcs[info.id] = new Array(size);
|
||||
fields.push({
|
||||
|
@ -59,11 +59,11 @@ interface OptionsUIRegistryBuilderAPI<
|
||||
config: OptionEditorConfig<TOptions, TSettings, TOption>
|
||||
): this;
|
||||
|
||||
addBooleanSwitch?<TSettings = any>(config: OptionEditorConfig<TOptions, TSettings, boolean>): this;
|
||||
addBooleanSwitch?<TSettings>(config: OptionEditorConfig<TOptions, TSettings, boolean>): this;
|
||||
|
||||
addUnitPicker?<TSettings = any>(config: OptionEditorConfig<TOptions, TSettings, string>): this;
|
||||
addUnitPicker?<TSettings>(config: OptionEditorConfig<TOptions, TSettings, string>): this;
|
||||
|
||||
addColorPicker?<TSettings = any>(config: OptionEditorConfig<TOptions, TSettings, string>): this;
|
||||
addColorPicker?<TSettings>(config: OptionEditorConfig<TOptions, TSettings, string>): this;
|
||||
|
||||
/**
|
||||
* Enables custom editor definition
|
||||
|
@ -82,7 +82,7 @@ export class AppPlugin<T extends KeyValue = KeyValue> extends GrafanaPlugin<AppP
|
||||
return this;
|
||||
}
|
||||
|
||||
setComponentsFromLegacyExports(pluginExports: any) {
|
||||
setComponentsFromLegacyExports(pluginExports: System.Module) {
|
||||
if (pluginExports.ConfigCtrl) {
|
||||
this.angularConfigCtrl = pluginExports.ConfigCtrl;
|
||||
}
|
||||
@ -145,7 +145,7 @@ export class AppPlugin<T extends KeyValue = KeyValue> extends GrafanaPlugin<AppP
|
||||
this.addComponent({
|
||||
targets: [extension.extensionPointId],
|
||||
...extension,
|
||||
component: extension.component as ComponentType,
|
||||
component: extension.component,
|
||||
});
|
||||
|
||||
return this;
|
||||
|
@ -208,7 +208,6 @@ export interface GrafanaConfig {
|
||||
http2Enabled: boolean;
|
||||
dateFormats?: SystemDateFormatSettings;
|
||||
grafanaJavascriptAgent: GrafanaJavascriptAgentConfig;
|
||||
customTheme?: any;
|
||||
geomapDefaultBaseLayer?: MapLayerOptions;
|
||||
geomapDisableCustomBaseLayer?: boolean;
|
||||
unifiedAlertingEnabled: boolean;
|
||||
|
@ -114,7 +114,7 @@ export class DataSourcePlugin<
|
||||
return this;
|
||||
}
|
||||
|
||||
setComponentsFromLegacyExports(pluginExports: any) {
|
||||
setComponentsFromLegacyExports(pluginExports: System.Module) {
|
||||
this.angularConfigCtrl = pluginExports.ConfigCtrl;
|
||||
|
||||
this.components.QueryCtrl = pluginExports.QueryCtrl;
|
||||
|
@ -169,7 +169,7 @@ export interface PanelMenuItem {
|
||||
type?: 'submenu' | 'divider' | 'group';
|
||||
text: string;
|
||||
iconClassName?: IconName;
|
||||
onClick?: (event: React.MouseEvent<any>) => void;
|
||||
onClick?: (event: React.MouseEvent) => void;
|
||||
shortcut?: string;
|
||||
href?: string;
|
||||
subMenu?: PanelMenuItem[];
|
||||
|
@ -30,7 +30,7 @@ import { PanelOptionsEditorConfig, PanelOptionsEditorItem } from '../types/panel
|
||||
*/
|
||||
export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder<
|
||||
TOptions,
|
||||
StandardEditorProps<any, any>,
|
||||
StandardEditorProps,
|
||||
FieldConfigPropertyItem<TOptions>
|
||||
> {
|
||||
addNumberInput<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings & NumberFieldConfigSettings, number>) {
|
||||
@ -84,7 +84,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
});
|
||||
}
|
||||
|
||||
addRadio<TOption, TSettings = any>(config: FieldConfigEditorConfig<TOptions, TSettings, TOption>) {
|
||||
addRadio<TOption, TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings, TOption>) {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -97,7 +97,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
});
|
||||
}
|
||||
|
||||
addBooleanSwitch<TSettings = any>(config: FieldConfigEditorConfig<TOptions, TSettings, boolean>) {
|
||||
addBooleanSwitch<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings, boolean>) {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -109,7 +109,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
});
|
||||
}
|
||||
|
||||
addColorPicker<TSettings = any>(config: FieldConfigEditorConfig<TOptions, TSettings, string>) {
|
||||
addColorPicker<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings, string>) {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -121,9 +121,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
});
|
||||
}
|
||||
|
||||
addUnitPicker<TSettings = any>(
|
||||
config: FieldConfigEditorConfig<TOptions, TSettings & UnitFieldConfigSettings, string>
|
||||
) {
|
||||
addUnitPicker<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings & UnitFieldConfigSettings, string>) {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -135,7 +133,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
});
|
||||
}
|
||||
|
||||
addFieldNamePicker<TSettings = any>(
|
||||
addFieldNamePicker<TSettings>(
|
||||
config: FieldConfigEditorConfig<TOptions, TSettings & FieldNamePickerConfigSettings, string>
|
||||
): this {
|
||||
return this.addCustomEditor({
|
||||
@ -149,7 +147,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
});
|
||||
}
|
||||
|
||||
addGenericEditor<TSettings = any>(
|
||||
addGenericEditor<TSettings>(
|
||||
config: FieldConfigEditorConfig<TOptions, TSettings & any>, // & any... i give up!
|
||||
editor: (props: StandardEditorProps<TSettings>) => JSX.Element
|
||||
): this {
|
||||
@ -168,7 +166,7 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
|
||||
export interface NestedValueAccess {
|
||||
getValue: (path: string) => any;
|
||||
onChange: (path: string, value: any) => void;
|
||||
getContext?: (parent: StandardEditorContext<any, any>) => StandardEditorContext<any, any>;
|
||||
getContext?: (parent: StandardEditorContext<any>) => StandardEditorContext<any>;
|
||||
}
|
||||
export interface NestedPanelOptions<TSub = any> {
|
||||
path: string;
|
||||
@ -307,7 +305,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
|
||||
});
|
||||
}
|
||||
|
||||
addBooleanSwitch<TSettings = any>(config: PanelOptionsEditorConfig<TOptions, TSettings, boolean>) {
|
||||
addBooleanSwitch<TSettings>(config: PanelOptionsEditorConfig<TOptions, TSettings, boolean>) {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -315,7 +313,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
|
||||
});
|
||||
}
|
||||
|
||||
addColorPicker<TSettings = any>(config: PanelOptionsEditorConfig<TOptions, TSettings, string>): this {
|
||||
addColorPicker<TSettings>(config: PanelOptionsEditorConfig<TOptions, TSettings, string>): this {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -324,7 +322,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
|
||||
});
|
||||
}
|
||||
|
||||
addTimeZonePicker<TSettings = any>(config: PanelOptionsEditorConfig<TOptions, TSettings, string>): this {
|
||||
addTimeZonePicker<TSettings>(config: PanelOptionsEditorConfig<TOptions, TSettings, string>): this {
|
||||
return this.addCustomEditor({
|
||||
...config,
|
||||
id: config.path,
|
||||
@ -333,7 +331,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
|
||||
});
|
||||
}
|
||||
|
||||
addUnitPicker<TSettings = any>(
|
||||
addUnitPicker<TSettings>(
|
||||
config: PanelOptionsEditorConfig<TOptions, TSettings & UnitFieldConfigSettings, string>
|
||||
): this {
|
||||
return this.addCustomEditor({
|
||||
@ -343,7 +341,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
|
||||
});
|
||||
}
|
||||
|
||||
addFieldNamePicker<TSettings = any>(
|
||||
addFieldNamePicker<TSettings>(
|
||||
config: PanelOptionsEditorConfig<TOptions, TSettings & FieldNamePickerConfigSettings, string>
|
||||
): this {
|
||||
return this.addCustomEditor({
|
||||
@ -353,7 +351,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
|
||||
});
|
||||
}
|
||||
|
||||
addDashboardPicker<TSettings = any>(
|
||||
addDashboardPicker<TSettings>(
|
||||
config: PanelOptionsEditorConfig<TOptions, TSettings & FieldNamePickerConfigSettings, string>
|
||||
): this {
|
||||
return this.addCustomEditor({
|
||||
|
@ -74,7 +74,7 @@ export function mapInternalLinkToExplore(options: LinkToExploreOptions): LinkMod
|
||||
/**
|
||||
* Generates href for internal derived field link.
|
||||
*/
|
||||
function generateInternalHref<T extends DataQuery = any>(
|
||||
function generateInternalHref<T extends DataQuery>(
|
||||
datasourceUid: string,
|
||||
query: T,
|
||||
range?: TimeRange,
|
||||
|
@ -140,7 +140,6 @@ export class GrafanaBootConfig implements GrafanaConfig {
|
||||
pluginCatalogPreinstalledPlugins: PreinstalledPlugin[] = [];
|
||||
pluginsCDNBaseURL = '';
|
||||
expressionsEnabled = false;
|
||||
customTheme?: undefined;
|
||||
awsAllowedAuthProviders: string[] = [];
|
||||
awsAssumeRoleEnabled = false;
|
||||
azure: AzureSettings = {
|
||||
|
@ -30,6 +30,8 @@ export const InfoBox = React.memo(
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
return (
|
||||
// component is deprecated so no point fixing this
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
<Alert severity={severity} className={className} {...otherProps} ref={ref} title={title as string}>
|
||||
<div>{children}</div>
|
||||
{url && (
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { throttle } from 'lodash';
|
||||
|
||||
type Args = Parameters<typeof console.log>;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* */
|
||||
const throttledLog = throttle((...t: any[]) => {
|
||||
const throttledLog = throttle((...t: Args) => {
|
||||
console.log(...t);
|
||||
}, 500);
|
||||
|
||||
@ -11,7 +13,7 @@ const throttledLog = throttle((...t: any[]) => {
|
||||
* @internal
|
||||
*/
|
||||
export interface Logger {
|
||||
logger: (...t: any[]) => void;
|
||||
logger: (...t: Args) => void;
|
||||
enable: () => void;
|
||||
disable: () => void;
|
||||
isEnabled: () => boolean;
|
||||
@ -26,7 +28,7 @@ export const createLogger = (name: string): Logger => {
|
||||
}
|
||||
|
||||
return {
|
||||
logger: (id: string, throttle = false, ...t: any[]) => {
|
||||
logger: (id: string, throttle = false, ...t: Args) => {
|
||||
if (process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test' || !loggingEnabled) {
|
||||
return;
|
||||
}
|
||||
|
@ -35,21 +35,6 @@ const ThemeableStory = ({
|
||||
);
|
||||
};
|
||||
|
||||
// Temporary solution. When we update to Storybook V5 we will be able to pass data from decorator to story
|
||||
// https://github.com/storybooks/storybook/issues/340#issuecomment-456013702
|
||||
export const renderComponentWithTheme = (component: React.ComponentType<any>, props: any) => {
|
||||
return (
|
||||
<ThemeContext.Consumer>
|
||||
{(theme) => {
|
||||
return React.createElement(component, {
|
||||
...props,
|
||||
theme,
|
||||
});
|
||||
}}
|
||||
</ThemeContext.Consumer>
|
||||
);
|
||||
};
|
||||
|
||||
export const withTheme =
|
||||
(handleSassThemeChange: SassThemeChangeHandler): Decorator =>
|
||||
// eslint-disable-next-line react/display-name
|
||||
|
@ -28,7 +28,7 @@ import { preparePlotFrame as defaultPreparePlotFrame } from './utils';
|
||||
/**
|
||||
* @internal -- not a public API
|
||||
*/
|
||||
export type PropDiffFn<T extends any = any> = (prev: T, next: T) => boolean;
|
||||
export type PropDiffFn<T extends Record<string, unknown> = {}> = (prev: T, next: T) => boolean;
|
||||
|
||||
export interface GraphNGProps extends Themeable2 {
|
||||
frames: DataFrame[];
|
||||
@ -61,7 +61,11 @@ export interface GraphNGProps extends Themeable2 {
|
||||
options?: Record<string, any>;
|
||||
}
|
||||
|
||||
function sameProps(prevProps: any, nextProps: any, propsToDiff: Array<string | PropDiffFn> = []) {
|
||||
function sameProps<T extends Record<string, unknown>>(
|
||||
prevProps: T,
|
||||
nextProps: T,
|
||||
propsToDiff: Array<string | PropDiffFn> = []
|
||||
) {
|
||||
for (const propName of propsToDiff) {
|
||||
if (typeof propName === 'function') {
|
||||
if (!propName(prevProps, nextProps)) {
|
||||
|
@ -21,7 +21,7 @@ interface TransformationEditorProps {
|
||||
debugMode?: boolean;
|
||||
index: number;
|
||||
data: DataFrame[];
|
||||
uiConfig: TransformerRegistryItem<any>;
|
||||
uiConfig: TransformerRegistryItem;
|
||||
configs: TransformationsEditorTransformation[];
|
||||
onChange: (index: number, config: DataTransformerConfig) => void;
|
||||
toggleShowDebug: () => void;
|
||||
|
@ -17,8 +17,7 @@ interface TransformationPickerProps {
|
||||
onSearchKeyDown: KeyboardEventHandler<HTMLInputElement>;
|
||||
onTransformationAdd: Function;
|
||||
suffix: ReactNode;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
xforms: Array<TransformerRegistryItem<any>>;
|
||||
xforms: TransformerRegistryItem[];
|
||||
}
|
||||
|
||||
export function TransformationPicker(props: TransformationPickerProps) {
|
||||
@ -88,8 +87,7 @@ export function TransformationPicker(props: TransformationPickerProps) {
|
||||
}
|
||||
|
||||
interface TransformationCardProps {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
transform: TransformerRegistryItem<any>;
|
||||
transform: TransformerRegistryItem;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,7 @@ interface TransformationPickerNgProps {
|
||||
onSearchKeyDown: KeyboardEventHandler<HTMLInputElement>;
|
||||
onClose?: () => void;
|
||||
noTransforms: boolean;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
xforms: Array<TransformerRegistryItem<any>>;
|
||||
xforms: TransformerRegistryItem[];
|
||||
search: string;
|
||||
suffix: ReactNode;
|
||||
data: DataFrame[];
|
||||
@ -160,8 +159,7 @@ function getTransformationPickerStyles(theme: GrafanaTheme2) {
|
||||
}
|
||||
|
||||
interface TransformationsGridProps {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
transformations: Array<TransformerRegistryItem<any>>;
|
||||
transformations: TransformerRegistryItem[];
|
||||
showIllustrations?: boolean;
|
||||
onClick: (id: string) => void;
|
||||
data: DataFrame[];
|
||||
|
@ -35,7 +35,7 @@ import { rowsToFieldsTransformRegistryItem } from './rowsToFields/RowsToFieldsTr
|
||||
import { spatialTransformRegistryItem } from './spatial/SpatialTransformerEditor';
|
||||
import { timeSeriesTableTransformRegistryItem } from './timeSeriesTable/TimeSeriesTableTransformEditor';
|
||||
|
||||
export const getStandardTransformers = (): Array<TransformerRegistryItem<any>> => {
|
||||
export const getStandardTransformers = (): TransformerRegistryItem[] => {
|
||||
return [
|
||||
reduceTransformRegistryItem,
|
||||
filterFieldsByNameTransformRegistryItem,
|
||||
|
@ -22,7 +22,7 @@ export function mapSegmentsToSelectables(segments: GraphiteSegment[]): Array<Sel
|
||||
}
|
||||
|
||||
export function mapFuncDefsToSelectables(funcDefs: FuncDefs): Array<SelectableValue<string>> {
|
||||
const categories: any = {};
|
||||
const categories: Record<string, SelectableValue<string>> = {};
|
||||
|
||||
forEach(funcDefs, (funcDef) => {
|
||||
if (!funcDef.category) {
|
||||
|
@ -55,8 +55,8 @@ describe('graphiteDatasource', () => {
|
||||
|
||||
describe('convertResponseToDataFrames', () => {
|
||||
it('should transform regular result', () => {
|
||||
const result = ctx.ds.convertResponseToDataFrames({
|
||||
data: {
|
||||
const result = ctx.ds.convertResponseToDataFrames(
|
||||
createFetchResponse({
|
||||
meta: {
|
||||
stats: {
|
||||
'executeplan.cache-hit-partial.count': 5,
|
||||
@ -105,8 +105,8 @@ describe('graphiteDatasource', () => {
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
expect(result.data.length).toBe(2);
|
||||
expect(getFrameDisplayName(result.data[0])).toBe('seriesA');
|
||||
|
@ -21,7 +21,7 @@ import {
|
||||
toDataFrame,
|
||||
getSearchFilterScopedVar,
|
||||
} from '@grafana/data';
|
||||
import { BackendSrvRequest, getBackendSrv } from '@grafana/runtime';
|
||||
import { BackendSrvRequest, FetchResponse, getBackendSrv } from '@grafana/runtime';
|
||||
import { isVersionGtOrEq, SemVersion } from 'app/core/utils/version';
|
||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { getRollupNotice, getRuntimeConsolidationNotice } from 'app/plugins/datasource/graphite/meta';
|
||||
@ -267,7 +267,7 @@ export class GraphiteDatasource
|
||||
}
|
||||
}
|
||||
|
||||
convertResponseToDataFrames = (result: any): DataQueryResponse => {
|
||||
convertResponseToDataFrames = (result: FetchResponse): DataQueryResponse => {
|
||||
const data: DataFrame[] = [];
|
||||
if (!result || !result.data) {
|
||||
return { data };
|
||||
@ -648,7 +648,7 @@ export class GraphiteDatasource
|
||||
|
||||
return lastValueFrom(
|
||||
this.doGraphiteRequest(httpOptions).pipe(
|
||||
map((results: any) => {
|
||||
map((results: FetchResponse) => {
|
||||
return _map(results.data, (metric) => {
|
||||
return {
|
||||
text: metric.text,
|
||||
@ -689,7 +689,7 @@ export class GraphiteDatasource
|
||||
|
||||
return lastValueFrom(
|
||||
this.doGraphiteRequest(httpOptions).pipe(
|
||||
map((results: any) => {
|
||||
map((results: FetchResponse) => {
|
||||
return _map(results.data.results, (metric) => {
|
||||
return {
|
||||
text: metric,
|
||||
@ -720,7 +720,7 @@ export class GraphiteDatasource
|
||||
|
||||
return lastValueFrom(
|
||||
this.doGraphiteRequest(httpOptions).pipe(
|
||||
map((results: any) => {
|
||||
map((results: FetchResponse) => {
|
||||
return _map(results.data, (tag) => {
|
||||
return {
|
||||
text: tag.tag,
|
||||
@ -750,7 +750,7 @@ export class GraphiteDatasource
|
||||
|
||||
return lastValueFrom(
|
||||
this.doGraphiteRequest(httpOptions).pipe(
|
||||
map((results: any) => {
|
||||
map((results: FetchResponse) => {
|
||||
if (results.data && results.data.values) {
|
||||
return _map(results.data.values, (value) => {
|
||||
return {
|
||||
@ -833,7 +833,7 @@ export class GraphiteDatasource
|
||||
|
||||
return lastValueFrom(
|
||||
this.doGraphiteRequest(httpOptions).pipe(
|
||||
map((results: any) => {
|
||||
map((results: FetchResponse) => {
|
||||
if (results.data) {
|
||||
const semver = new SemVersion(results.data);
|
||||
return semver.isValid() ? results.data : '';
|
||||
@ -880,7 +880,7 @@ export class GraphiteDatasource
|
||||
|
||||
return lastValueFrom(
|
||||
this.doGraphiteRequest(httpOptions).pipe(
|
||||
map((results: any) => {
|
||||
map((results: FetchResponse) => {
|
||||
// Fix for a Graphite bug: https://github.com/graphite-project/graphite-web/issues/2609
|
||||
// There is a fix for it https://github.com/graphite-project/graphite-web/pull/2612 but
|
||||
// it was merged to master in July 2020 but it has never been released (the last Graphite
|
||||
@ -950,7 +950,7 @@ export class GraphiteDatasource
|
||||
buildGraphiteParams(options: any, scopedVars?: ScopedVars): string[] {
|
||||
const graphiteOptions = ['from', 'until', 'rawData', 'format', 'maxDataPoints', 'cacheTimeout'];
|
||||
const cleanOptions = [],
|
||||
targets: any = {};
|
||||
targets: Record<string, string> = {};
|
||||
let target, targetValue, i;
|
||||
const regex = /\#([A-Z])/g;
|
||||
const intervalFormatFixRegex = /'(\d+)m'/gi;
|
||||
@ -977,7 +977,7 @@ export class GraphiteDatasource
|
||||
targets[target.refId] = targetValue;
|
||||
}
|
||||
|
||||
function nestedSeriesRegexReplacer(match: any, g1: string | number) {
|
||||
function nestedSeriesRegexReplacer(match: string, g1: string | number) {
|
||||
return targets[g1] || match;
|
||||
}
|
||||
|
||||
@ -1022,7 +1022,7 @@ function supportsFunctionIndex(version: string): boolean {
|
||||
return isVersionGtOrEq(version, '1.1');
|
||||
}
|
||||
|
||||
function mapToTags(): OperatorFunction<any, Array<{ text: string }>> {
|
||||
function mapToTags(): OperatorFunction<FetchResponse, Array<{ text: string }>> {
|
||||
return pipe(
|
||||
map((results) => {
|
||||
if (results.data) {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import gfunc, { FuncInstance } from './gfunc';
|
||||
import gfunc, { FuncDefs, FuncInstance } from './gfunc';
|
||||
|
||||
describe('gfunc', () => {
|
||||
const INDEX = {
|
||||
const INDEX: FuncDefs = {
|
||||
foo: {
|
||||
name: 'foo',
|
||||
params: [],
|
||||
defaultParams: [],
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1112,7 +1112,7 @@ export class FuncInstance {
|
||||
function createFuncInstance(
|
||||
funcDef: FuncDef | string,
|
||||
options?: { withDefaultParams: boolean },
|
||||
idx?: any
|
||||
idx?: FuncDefs | null
|
||||
): FuncInstance {
|
||||
if (isString(funcDef)) {
|
||||
funcDef = getFuncDef(funcDef, idx);
|
||||
@ -1120,14 +1120,14 @@ function createFuncInstance(
|
||||
return new FuncInstance(funcDef, options);
|
||||
}
|
||||
|
||||
function getFuncDef(name: string, idx?: any): FuncDef {
|
||||
function getFuncDef(name: string, idx?: FuncDefs | null): FuncDef {
|
||||
if (!(idx || index)[name]) {
|
||||
return { name: name, params: [{ name: '', type: '', multiple: true }], defaultParams: [''], unknown: true };
|
||||
}
|
||||
return (idx || index)[name];
|
||||
}
|
||||
|
||||
function getFuncDefs(graphiteVersion: string, idx?: any): FuncDefs {
|
||||
function getFuncDefs(graphiteVersion: string, idx?: FuncDefs | null): FuncDefs {
|
||||
const funcs: FuncDefs = {};
|
||||
forEach(idx || index, (funcDef: FuncDef) => {
|
||||
if (isVersionRelatedFunction(funcDef, graphiteVersion)) {
|
||||
|
@ -38,7 +38,7 @@ export default class GraphiteQuery {
|
||||
seriesByTagUsed = false;
|
||||
checkOtherSegmentsIndex = 0;
|
||||
removeTagValue: string;
|
||||
templateSrv: any;
|
||||
templateSrv: TemplateSrv | undefined;
|
||||
scopedVars?: ScopedVars;
|
||||
|
||||
constructor(datasource: GraphiteDatasource, target: any, templateSrv?: TemplateSrv, scopedVars?: ScopedVars) {
|
||||
@ -172,7 +172,7 @@ export default class GraphiteQuery {
|
||||
func.params.push(value);
|
||||
}
|
||||
|
||||
removeFunction(func: any) {
|
||||
removeFunction(func: FuncInstance) {
|
||||
this.functions = without(this.functions, func);
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ export default class GraphiteQuery {
|
||||
updateModelTarget(targets: any) {
|
||||
const wrapFunction = (target: string, func: FuncInstance) => {
|
||||
return func.render(target, (value: string) => {
|
||||
return this.templateSrv.replace(value, this.scopedVars);
|
||||
return this.templateSrv ? this.templateSrv.replace(value, this.scopedVars) : value;
|
||||
});
|
||||
};
|
||||
|
||||
@ -290,7 +290,7 @@ export default class GraphiteQuery {
|
||||
}
|
||||
}
|
||||
|
||||
addTag(tag: { key: any; operator: GraphiteTagOperator; value: string }) {
|
||||
addTag(tag: { key: string; operator: GraphiteTagOperator; value: string }) {
|
||||
const newTagParam = renderTagString(tag);
|
||||
this.getSeriesByTagFunc()!.params.push(newTagParam);
|
||||
this.tags.push(tag);
|
||||
@ -307,7 +307,10 @@ export default class GraphiteQuery {
|
||||
if (tag.key === this.removeTagValue) {
|
||||
this.removeTag(tagIndex);
|
||||
if (this.tags.length === 0) {
|
||||
this.removeFunction(this.getSeriesByTagFunc());
|
||||
const funcToRemove = this.getSeriesByTagFunc();
|
||||
if (funcToRemove) {
|
||||
this.removeFunction(funcToRemove);
|
||||
}
|
||||
this.checkOtherSegmentsIndex = 0;
|
||||
this.seriesByTagUsed = false;
|
||||
}
|
||||
@ -332,7 +335,7 @@ export default class GraphiteQuery {
|
||||
}
|
||||
}
|
||||
|
||||
function renderTagString(tag: { key: any; operator?: any; value?: any }) {
|
||||
function renderTagString(tag: { key: string; operator?: GraphiteTagOperator; value?: string }) {
|
||||
return tag.key + tag.operator + tag.value;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ const unicodeLetterTable = [
|
||||
177972, 177984, 177984, 178205, 178205, 194560, 195101,
|
||||
];
|
||||
|
||||
const identifierStartTable: any[] = [];
|
||||
const identifierStartTable: boolean[] = [];
|
||||
|
||||
for (let i = 0; i < 128; i++) {
|
||||
identifierStartTable[i] =
|
||||
@ -207,7 +207,7 @@ export class Lexer {
|
||||
return /^[0-9a-fA-F]$/.test(str);
|
||||
}
|
||||
|
||||
const readUnicodeEscapeSequence = bind(function (this: any) {
|
||||
const readUnicodeEscapeSequence = bind(function (this: Lexer) {
|
||||
index += 1;
|
||||
|
||||
if (this.peek(index) !== 'u') {
|
||||
@ -234,7 +234,7 @@ export class Lexer {
|
||||
return null;
|
||||
}, this);
|
||||
|
||||
const getIdentifierStart = bind(function (this: any) {
|
||||
const getIdentifierStart = bind(function (this: Lexer) {
|
||||
const chr = this.peek(index);
|
||||
const code = chr.charCodeAt(0);
|
||||
|
||||
@ -264,7 +264,7 @@ export class Lexer {
|
||||
return null;
|
||||
}, this);
|
||||
|
||||
const getIdentifierPart = bind(function (this: any) {
|
||||
const getIdentifierPart = bind(function (this: Lexer) {
|
||||
const chr = this.peek(index);
|
||||
const code = chr.charCodeAt(0);
|
||||
|
||||
|
@ -546,7 +546,7 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
|
||||
return getBackendSrv()
|
||||
.fetch(req)
|
||||
.pipe(
|
||||
map((result: any) => {
|
||||
map((result: FetchResponse) => {
|
||||
const { data } = result;
|
||||
if (data) {
|
||||
data.executedQueryString = q;
|
||||
|
@ -11,7 +11,6 @@ import { DEFAULT_POLICY, InfluxQuery, InfluxQueryTag } from './types';
|
||||
export default class InfluxQueryModel {
|
||||
target: InfluxQuery;
|
||||
selectModels: QueryPart[][] = [];
|
||||
queryBuilder: any;
|
||||
groupByParts: QueryPart[] = [];
|
||||
templateSrv: any;
|
||||
scopedVars: ScopedVars | undefined;
|
||||
|
@ -110,7 +110,7 @@ export default class InfluxSeries {
|
||||
let titleCol: any = null;
|
||||
let timeCol: any = null;
|
||||
let timeEndCol: any = null;
|
||||
const tagsCol: any = [];
|
||||
const tagsCol: string[] = [];
|
||||
let textCol: any = null;
|
||||
|
||||
each(series.columns, (column, index) => {
|
||||
@ -152,10 +152,10 @@ export default class InfluxSeries {
|
||||
// Remove empty values, then split in different tags for comma separated values
|
||||
tags: flatten(
|
||||
tagsCol
|
||||
.filter((t: any) => {
|
||||
.filter((t) => {
|
||||
return value[t];
|
||||
})
|
||||
.map((t: any) => {
|
||||
.map((t) => {
|
||||
return value[t].split(',');
|
||||
})
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user