mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Schema: Clean up dashboard variables schema (#76121)
* Cleanup variable schema model * minor fix * remove type ignores that are no longer type errors
This commit is contained in:
parent
69142bffe9
commit
fc0933d5f4
@ -634,21 +634,20 @@ Configured template variables
|
|||||||
A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
||||||
|
|
||||||
| Property | Type | Required | Default | Description |
|
| Property | Type | Required | Default | Description |
|
||||||
|---------------|-------------------------------------|----------|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|---------------|-------------------------------------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `hide` | integer | **Yes** | | Determine if the variable shows on dashboard<br/>Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).<br/>Possible values are: `0`, `1`, `2`. |
|
|
||||||
| `id` | string | **Yes** | `00000000-0000-0000-0000-000000000000` | Unique numeric identifier for the variable. |
|
|
||||||
| `name` | string | **Yes** | | Name of variable |
|
| `name` | string | **Yes** | | Name of variable |
|
||||||
| `skipUrlSync` | boolean | **Yes** | `false` | Whether the variable value should be managed by URL query params or not |
|
|
||||||
| `type` | string | **Yes** | | Dashboard variable type<br/>`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.<br/>`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).<br/>`constant`: Define a hidden constant.<br/>`datasource`: Quickly change the data source for an entire dashboard.<br/>`interval`: Interval variables represent time spans.<br/>`textbox`: Display a free text input field with an optional default value.<br/>`custom`: Define the variable options manually using a comma-separated list.<br/>`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables<br/>Possible values are: `query`, `adhoc`, `constant`, `datasource`, `interval`, `textbox`, `custom`, `system`. |
|
| `type` | string | **Yes** | | Dashboard variable type<br/>`query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.<br/>`adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).<br/>`constant`: Define a hidden constant.<br/>`datasource`: Quickly change the data source for an entire dashboard.<br/>`interval`: Interval variables represent time spans.<br/>`textbox`: Display a free text input field with an optional default value.<br/>`custom`: Define the variable options manually using a comma-separated list.<br/>`system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables<br/>Possible values are: `query`, `adhoc`, `constant`, `datasource`, `interval`, `textbox`, `custom`, `system`. |
|
||||||
| `allFormat` | string | No | | Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc. |
|
|
||||||
| `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. |
|
| `current` | [VariableOption](#variableoption) | No | | Option to be selected in a variable. |
|
||||||
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
|
| `datasource` | [DataSourceRef](#datasourceref) | No | | Ref to a DataSource instance |
|
||||||
| `description` | string | No | | Description of variable. It can be defined but `null`. |
|
| `description` | string | No | | Description of variable. It can be defined but `null`. |
|
||||||
|
| `hide` | integer | No | | Determine if the variable shows on dashboard<br/>Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).<br/>Possible values are: `0`, `1`, `2`. |
|
||||||
| `label` | string | No | | Optional display name |
|
| `label` | string | No | | Optional display name |
|
||||||
| `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list |
|
| `multi` | boolean | No | `false` | Whether multiple values can be selected or not from variable value list |
|
||||||
| `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. |
|
| `options` | [VariableOption](#variableoption)[] | No | | Options that can be selected for a variable. |
|
||||||
| `query` | | No | | Query used to fetch values for a variable |
|
| `query` | | No | | Query used to fetch values for a variable |
|
||||||
| `refresh` | integer | No | | Options to config when to refresh a variable<br/>`0`: Never refresh the variable<br/>`1`: Queries the data source every time the dashboard loads.<br/>`2`: Queries the data source when the dashboard time range changes.<br/>Possible values are: `0`, `1`, `2`. |
|
| `refresh` | integer | No | | Options to config when to refresh a variable<br/>`0`: Never refresh the variable<br/>`1`: Queries the data source every time the dashboard loads.<br/>`2`: Queries the data source when the dashboard time range changes.<br/>Possible values are: `0`, `1`, `2`. |
|
||||||
|
| `skipUrlSync` | boolean | No | `false` | Whether the variable value should be managed by URL query params or not |
|
||||||
|
| `sort` | integer | No | | Sort variable options<br/>Accepted values are:<br/>`0`: No sorting<br/>`1`: Alphabetical ASC<br/>`2`: Alphabetical DESC<br/>`3`: Numerical ASC<br/>`4`: Numerical DESC<br/>`5`: Alphabetical Case Insensitive ASC<br/>`6`: Alphabetical Case Insensitive DESC<br/>Possible values are: `0`, `1`, `2`, `3`, `4`, `5`, `6`. |
|
||||||
|
|
||||||
### VariableOption
|
### VariableOption
|
||||||
|
|
||||||
|
@ -183,8 +183,6 @@ lineage: schemas: [{
|
|||||||
|
|
||||||
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
||||||
#VariableModel: {
|
#VariableModel: {
|
||||||
// Unique numeric identifier for the variable.
|
|
||||||
id: string | *"00000000-0000-0000-0000-000000000000"
|
|
||||||
// Type of variable
|
// Type of variable
|
||||||
type: #VariableType
|
type: #VariableType
|
||||||
// Name of variable
|
// Name of variable
|
||||||
@ -192,17 +190,15 @@ lineage: schemas: [{
|
|||||||
// Optional display name
|
// Optional display name
|
||||||
label?: string
|
label?: string
|
||||||
// Visibility configuration for the variable
|
// Visibility configuration for the variable
|
||||||
hide: #VariableHide
|
hide?: #VariableHide
|
||||||
// Whether the variable value should be managed by URL query params or not
|
// Whether the variable value should be managed by URL query params or not
|
||||||
skipUrlSync: bool | *false
|
skipUrlSync?: bool | *false
|
||||||
// Description of variable. It can be defined but `null`.
|
// Description of variable. It can be defined but `null`.
|
||||||
description?: string
|
description?: string
|
||||||
// Query used to fetch values for a variable
|
// Query used to fetch values for a variable
|
||||||
query?: string | {...}
|
query?: string | {...}
|
||||||
// Data source used to fetch values for a variable. It can be defined but `null`.
|
// Data source used to fetch values for a variable. It can be defined but `null`.
|
||||||
datasource?: #DataSourceRef
|
datasource?: #DataSourceRef
|
||||||
// Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
|
|
||||||
allFormat?: string
|
|
||||||
// Shows current selected variable text/value on the dashboard
|
// Shows current selected variable text/value on the dashboard
|
||||||
current?: #VariableOption
|
current?: #VariableOption
|
||||||
// Whether multiple values can be selected or not from variable value list
|
// Whether multiple values can be selected or not from variable value list
|
||||||
@ -210,6 +206,8 @@ lineage: schemas: [{
|
|||||||
// Options that can be selected for a variable.
|
// Options that can be selected for a variable.
|
||||||
options?: [...#VariableOption]
|
options?: [...#VariableOption]
|
||||||
refresh?: #VariableRefresh
|
refresh?: #VariableRefresh
|
||||||
|
// Options sort order
|
||||||
|
sort?: #VariableSort
|
||||||
...
|
...
|
||||||
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
} @cuetsy(kind="interface") @grafana(TSVeneer="type") @grafanamaturity(NeedsExpertReview)
|
||||||
|
|
||||||
@ -244,10 +242,6 @@ lineage: schemas: [{
|
|||||||
// `6`: Alphabetical Case Insensitive DESC
|
// `6`: Alphabetical Case Insensitive DESC
|
||||||
#VariableSort: 0 | 1 | 2 | 3 | 4 | 5 | 6 @cuetsy(kind="enum",memberNames="disabled|alphabeticalAsc|alphabeticalDesc|numericalAsc|numericalDesc|alphabeticalCaseInsensitiveAsc|alphabeticalCaseInsensitiveDesc")
|
#VariableSort: 0 | 1 | 2 | 3 | 4 | 5 | 6 @cuetsy(kind="enum",memberNames="disabled|alphabeticalAsc|alphabeticalDesc|numericalAsc|numericalDesc|alphabeticalCaseInsensitiveAsc|alphabeticalCaseInsensitiveDesc")
|
||||||
|
|
||||||
// Loading status
|
|
||||||
// Accepted values are `NotStarted` (the request is not started), `Loading` (waiting for response), `Streaming` (pulling continuous data), `Done` (response received successfully) or `Error` (failed request).
|
|
||||||
#LoadingState: "NotStarted" | "Loading" | "Streaming" | "Done" | "Error" @cuetsy(kind="enum")
|
|
||||||
|
|
||||||
// Ref to a DataSource instance
|
// Ref to a DataSource instance
|
||||||
#DataSourceRef: {
|
#DataSourceRef: {
|
||||||
// The plugin type-id
|
// The plugin type-id
|
||||||
|
@ -48,7 +48,6 @@ export {
|
|||||||
defaultAnnotationPanelFilter,
|
defaultAnnotationPanelFilter,
|
||||||
VariableRefresh,
|
VariableRefresh,
|
||||||
VariableSort,
|
VariableSort,
|
||||||
LoadingState,
|
|
||||||
defaultDashboardLink,
|
defaultDashboardLink,
|
||||||
FieldColorModeId,
|
FieldColorModeId,
|
||||||
defaultGridPos,
|
defaultGridPos,
|
||||||
|
@ -121,10 +121,6 @@ export const defaultAnnotationQuery: Partial<AnnotationQuery> = {
|
|||||||
* A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
* A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
||||||
*/
|
*/
|
||||||
export interface VariableModel {
|
export interface VariableModel {
|
||||||
/**
|
|
||||||
* Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
|
|
||||||
*/
|
|
||||||
allFormat?: string;
|
|
||||||
/**
|
/**
|
||||||
* Shows current selected variable text/value on the dashboard
|
* Shows current selected variable text/value on the dashboard
|
||||||
*/
|
*/
|
||||||
@ -140,11 +136,7 @@ export interface VariableModel {
|
|||||||
/**
|
/**
|
||||||
* Visibility configuration for the variable
|
* Visibility configuration for the variable
|
||||||
*/
|
*/
|
||||||
hide: VariableHide;
|
hide?: VariableHide;
|
||||||
/**
|
|
||||||
* Unique numeric identifier for the variable.
|
|
||||||
*/
|
|
||||||
id: string;
|
|
||||||
/**
|
/**
|
||||||
* Optional display name
|
* Optional display name
|
||||||
*/
|
*/
|
||||||
@ -169,7 +161,11 @@ export interface VariableModel {
|
|||||||
/**
|
/**
|
||||||
* Whether the variable value should be managed by URL query params or not
|
* Whether the variable value should be managed by URL query params or not
|
||||||
*/
|
*/
|
||||||
skipUrlSync: boolean;
|
skipUrlSync?: boolean;
|
||||||
|
/**
|
||||||
|
* Options sort order
|
||||||
|
*/
|
||||||
|
sort?: VariableSort;
|
||||||
/**
|
/**
|
||||||
* Type of variable
|
* Type of variable
|
||||||
*/
|
*/
|
||||||
@ -177,7 +173,6 @@ export interface VariableModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const defaultVariableModel: Partial<VariableModel> = {
|
export const defaultVariableModel: Partial<VariableModel> = {
|
||||||
id: '00000000-0000-0000-0000-000000000000',
|
|
||||||
multi: false,
|
multi: false,
|
||||||
options: [],
|
options: [],
|
||||||
skipUrlSync: false,
|
skipUrlSync: false,
|
||||||
@ -244,18 +239,6 @@ export enum VariableSort {
|
|||||||
numericalDesc = 4,
|
numericalDesc = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loading status
|
|
||||||
* Accepted values are `NotStarted` (the request is not started), `Loading` (waiting for response), `Streaming` (pulling continuous data), `Done` (response received successfully) or `Error` (failed request).
|
|
||||||
*/
|
|
||||||
export enum LoadingState {
|
|
||||||
Done = 'Done',
|
|
||||||
Error = 'Error',
|
|
||||||
Loading = 'Loading',
|
|
||||||
NotStarted = 'NotStarted',
|
|
||||||
Streaming = 'Streaming',
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ref to a DataSource instance
|
* Ref to a DataSource instance
|
||||||
*/
|
*/
|
||||||
|
@ -45,3 +45,15 @@ export const defaultTableFieldOptions: raw.TableFieldOptions = {
|
|||||||
type: raw.TableCellDisplayMode.Auto,
|
type: raw.TableCellDisplayMode.Auto,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent panel data loading state.
|
||||||
|
* @deprecated Please use LoadingState from @grafana/data
|
||||||
|
*/
|
||||||
|
export enum LoadingState {
|
||||||
|
NotStarted = 'NotStarted',
|
||||||
|
Loading = 'Loading',
|
||||||
|
Streaming = 'Streaming',
|
||||||
|
Done = 'Done',
|
||||||
|
Error = 'Error',
|
||||||
|
}
|
||||||
|
@ -20,10 +20,8 @@ export enum VariableHide {
|
|||||||
hideVariable,
|
hideVariable,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VariableModel extends Omit<raw.VariableModel, 'hide' | 'description' | 'datasource'> {
|
export interface VariableModel extends Omit<raw.VariableModel, 'datasource'> {
|
||||||
hide: VariableHide;
|
datasource?: DataSourceRef | null;
|
||||||
description?: string | null;
|
|
||||||
datasource: DataSourceRef | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Dashboard extends Omit<raw.Dashboard, 'templating' | 'annotations' | 'panels'> {
|
export interface Dashboard extends Omit<raw.Dashboard, 'templating' | 'annotations' | 'panels'> {
|
||||||
@ -63,9 +61,6 @@ export interface DataTransformerConfig<TOptions = any> extends raw.DataTransform
|
|||||||
export const defaultDashboard = raw.defaultDashboard as Dashboard;
|
export const defaultDashboard = raw.defaultDashboard as Dashboard;
|
||||||
export const defaultVariableModel = {
|
export const defaultVariableModel = {
|
||||||
...raw.defaultVariableModel,
|
...raw.defaultVariableModel,
|
||||||
description: null,
|
|
||||||
hide: VariableHide.dontHide,
|
|
||||||
datasource: null,
|
|
||||||
} as VariableModel;
|
} as VariableModel;
|
||||||
export const defaultPanel: Partial<Panel> = raw.defaultPanel;
|
export const defaultPanel: Partial<Panel> = raw.defaultPanel;
|
||||||
export const defaultRowPanel: Partial<Panel> = raw.defaultRowPanel;
|
export const defaultRowPanel: Partial<Panel> = raw.defaultRowPanel;
|
||||||
|
@ -143,6 +143,17 @@ const (
|
|||||||
VariableRefreshN2 VariableRefresh = 2
|
VariableRefreshN2 VariableRefresh = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Defines values for VariableSort.
|
||||||
|
const (
|
||||||
|
VariableSortN0 VariableSort = 0
|
||||||
|
VariableSortN1 VariableSort = 1
|
||||||
|
VariableSortN2 VariableSort = 2
|
||||||
|
VariableSortN3 VariableSort = 3
|
||||||
|
VariableSortN4 VariableSort = 4
|
||||||
|
VariableSortN5 VariableSort = 5
|
||||||
|
VariableSortN6 VariableSort = 6
|
||||||
|
)
|
||||||
|
|
||||||
// Defines values for VariableType.
|
// Defines values for VariableType.
|
||||||
const (
|
const (
|
||||||
VariableTypeAdhoc VariableType = "adhoc"
|
VariableTypeAdhoc VariableType = "adhoc"
|
||||||
@ -900,9 +911,6 @@ type VariableHide int
|
|||||||
|
|
||||||
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
|
||||||
type VariableModel struct {
|
type VariableModel struct {
|
||||||
// Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
|
|
||||||
AllFormat *string `json:"allFormat,omitempty"`
|
|
||||||
|
|
||||||
// Option to be selected in a variable.
|
// Option to be selected in a variable.
|
||||||
Current *VariableOption `json:"current,omitempty"`
|
Current *VariableOption `json:"current,omitempty"`
|
||||||
|
|
||||||
@ -914,10 +922,7 @@ type VariableModel struct {
|
|||||||
|
|
||||||
// Determine if the variable shows on dashboard
|
// Determine if the variable shows on dashboard
|
||||||
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
|
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
|
||||||
Hide VariableHide `json:"hide"`
|
Hide *VariableHide `json:"hide,omitempty"`
|
||||||
|
|
||||||
// Unique numeric identifier for the variable.
|
|
||||||
Id string `json:"id"`
|
|
||||||
|
|
||||||
// Optional display name
|
// Optional display name
|
||||||
Label *string `json:"label,omitempty"`
|
Label *string `json:"label,omitempty"`
|
||||||
@ -941,7 +946,18 @@ type VariableModel struct {
|
|||||||
Refresh *VariableRefresh `json:"refresh,omitempty"`
|
Refresh *VariableRefresh `json:"refresh,omitempty"`
|
||||||
|
|
||||||
// Whether the variable value should be managed by URL query params or not
|
// Whether the variable value should be managed by URL query params or not
|
||||||
SkipUrlSync bool `json:"skipUrlSync"`
|
SkipUrlSync *bool `json:"skipUrlSync,omitempty"`
|
||||||
|
|
||||||
|
// Sort variable options
|
||||||
|
// Accepted values are:
|
||||||
|
// `0`: No sorting
|
||||||
|
// `1`: Alphabetical ASC
|
||||||
|
// `2`: Alphabetical DESC
|
||||||
|
// `3`: Numerical ASC
|
||||||
|
// `4`: Numerical DESC
|
||||||
|
// `5`: Alphabetical Case Insensitive ASC
|
||||||
|
// `6`: Alphabetical Case Insensitive DESC
|
||||||
|
Sort *VariableSort `json:"sort,omitempty"`
|
||||||
|
|
||||||
// Dashboard variable type
|
// Dashboard variable type
|
||||||
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
|
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
|
||||||
@ -973,6 +989,17 @@ type VariableOption struct {
|
|||||||
// `2`: Queries the data source when the dashboard time range changes.
|
// `2`: Queries the data source when the dashboard time range changes.
|
||||||
type VariableRefresh int
|
type VariableRefresh int
|
||||||
|
|
||||||
|
// Sort variable options
|
||||||
|
// Accepted values are:
|
||||||
|
// `0`: No sorting
|
||||||
|
// `1`: Alphabetical ASC
|
||||||
|
// `2`: Alphabetical DESC
|
||||||
|
// `3`: Numerical ASC
|
||||||
|
// `4`: Numerical DESC
|
||||||
|
// `5`: Alphabetical Case Insensitive ASC
|
||||||
|
// `6`: Alphabetical Case Insensitive DESC
|
||||||
|
type VariableSort int
|
||||||
|
|
||||||
// Dashboard variable type
|
// Dashboard variable type
|
||||||
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
|
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
|
||||||
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
|
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
|
||||||
|
@ -2,9 +2,9 @@ import { css } from '@emotion/css';
|
|||||||
import React, { FC, useEffect, useState } from 'react';
|
import React, { FC, useEffect, useState } from 'react';
|
||||||
import { useAsync } from 'react-use';
|
import { useAsync } from 'react-use';
|
||||||
|
|
||||||
import { PanelData, CoreApp, GrafanaTheme2 } from '@grafana/data';
|
import { PanelData, CoreApp, GrafanaTheme2, LoadingState } from '@grafana/data';
|
||||||
import { getDataSourceSrv } from '@grafana/runtime';
|
import { getDataSourceSrv } from '@grafana/runtime';
|
||||||
import { DataQuery, LoadingState } from '@grafana/schema';
|
import { DataQuery } from '@grafana/schema';
|
||||||
import { useStyles2 } from '@grafana/ui';
|
import { useStyles2 } from '@grafana/ui';
|
||||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
import { AlertQuery } from 'app/types/unified-alerting-dto';
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
import { xor } from 'lodash';
|
import { xor } from 'lodash';
|
||||||
import { ValidateResult } from 'react-hook-form';
|
import { ValidateResult } from 'react-hook-form';
|
||||||
|
|
||||||
import { DataFrame, ThresholdsConfig, ThresholdsMode, isTimeSeriesFrames, PanelData } from '@grafana/data';
|
import {
|
||||||
import { GraphTresholdsStyleMode, LoadingState } from '@grafana/schema';
|
DataFrame,
|
||||||
|
ThresholdsConfig,
|
||||||
|
ThresholdsMode,
|
||||||
|
isTimeSeriesFrames,
|
||||||
|
PanelData,
|
||||||
|
LoadingState,
|
||||||
|
} from '@grafana/data';
|
||||||
|
import { GraphTresholdsStyleMode } from '@grafana/schema';
|
||||||
import { config } from 'app/core/config';
|
import { config } from 'app/core/config';
|
||||||
import { EvalFunction } from 'app/features/alerting/state/alertDef';
|
import { EvalFunction } from 'app/features/alerting/state/alertDef';
|
||||||
import { isExpressionQuery } from 'app/features/expressions/guards';
|
import { isExpressionQuery } from 'app/features/expressions/guards';
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { map, of } from 'rxjs';
|
import { map, of } from 'rxjs';
|
||||||
|
|
||||||
import { DataSourceApi, DataQueryRequest, PanelData } from '@grafana/data';
|
import { DataSourceApi, DataQueryRequest, PanelData, LoadingState } from '@grafana/data';
|
||||||
import { LoadingState } from '@grafana/schema';
|
|
||||||
import { PublicAnnotationsDataSource } from 'app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource';
|
import { PublicAnnotationsDataSource } from 'app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource';
|
||||||
|
|
||||||
import { DashboardAnnotationsDataLayer } from './DashboardAnnotationsDataLayer';
|
import { DashboardAnnotationsDataLayer } from './DashboardAnnotationsDataLayer';
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
import { AnnotationEvent, arrayToDataFrame, DataTopic, getDefaultTimeRange, PanelData } from '@grafana/data';
|
import {
|
||||||
|
AnnotationEvent,
|
||||||
|
arrayToDataFrame,
|
||||||
|
DataTopic,
|
||||||
|
getDefaultTimeRange,
|
||||||
|
PanelData,
|
||||||
|
LoadingState,
|
||||||
|
} from '@grafana/data';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { dataLayers } from '@grafana/scenes';
|
import { dataLayers } from '@grafana/scenes';
|
||||||
import { AnnotationQuery, LoadingState } from '@grafana/schema';
|
import { AnnotationQuery } from '@grafana/schema';
|
||||||
import { PublicAnnotationsDataSource } from 'app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource';
|
import { PublicAnnotationsDataSource } from 'app/features/query/state/DashboardQueryRunner/PublicAnnotationsDataSource';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Observable, ReplaySubject, Unsubscribable } from 'rxjs';
|
import { Observable, ReplaySubject, Unsubscribable } from 'rxjs';
|
||||||
|
|
||||||
import { getDefaultTimeRange } from '@grafana/data';
|
import { getDefaultTimeRange, LoadingState } from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
SceneDataProvider,
|
SceneDataProvider,
|
||||||
SceneDataProviderResult,
|
SceneDataProviderResult,
|
||||||
@ -10,7 +10,6 @@ import {
|
|||||||
SceneObject,
|
SceneObject,
|
||||||
SceneObjectBase,
|
SceneObjectBase,
|
||||||
} from '@grafana/scenes';
|
} from '@grafana/scenes';
|
||||||
import { LoadingState } from '@grafana/schema';
|
|
||||||
import { DashboardQuery } from 'app/plugins/datasource/dashboard/types';
|
import { DashboardQuery } from 'app/plugins/datasource/dashboard/types';
|
||||||
|
|
||||||
import { getVizPanelKeyForPanelId } from '../utils/utils';
|
import { getVizPanelKeyForPanelId } from '../utils/utils';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { LoadingState } from '@grafana/data';
|
||||||
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
|
import { getPanelPlugin } from '@grafana/data/test/__mocks__/pluginMocks';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import {
|
import {
|
||||||
@ -14,7 +15,7 @@ import {
|
|||||||
SceneQueryRunner,
|
SceneQueryRunner,
|
||||||
VizPanel,
|
VizPanel,
|
||||||
} from '@grafana/scenes';
|
} from '@grafana/scenes';
|
||||||
import { DashboardCursorSync, defaultDashboard, LoadingState, Panel, RowPanel, VariableType } from '@grafana/schema';
|
import { DashboardCursorSync, defaultDashboard, Panel, RowPanel, VariableType } from '@grafana/schema';
|
||||||
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
import { DashboardModel, PanelModel } from 'app/features/dashboard/state';
|
||||||
import { createPanelJSONFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
import { createPanelJSONFixture } from 'app/features/dashboard/state/__fixtures__/dashboardFixtures';
|
||||||
import { SHARED_DASHBOARD_QUERY } from 'app/plugins/datasource/dashboard';
|
import { SHARED_DASHBOARD_QUERY } from 'app/plugins/datasource/dashboard';
|
||||||
|
@ -59,7 +59,7 @@ describe('DashboardModel', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
model = new DashboardModel({
|
model = new DashboardModel({
|
||||||
services: {
|
services: {
|
||||||
filter: { time: { from: 'now-1d', to: 'now' }, list: [{}] },
|
filter: { time: { from: 'now-1d', to: 'now' }, list: [{ name: 'server' }] },
|
||||||
},
|
},
|
||||||
pulldowns: [
|
pulldowns: [
|
||||||
{ type: 'filtering', enable: true },
|
{ type: 'filtering', enable: true },
|
||||||
@ -165,7 +165,7 @@ describe('DashboardModel', () => {
|
|||||||
|
|
||||||
it('should move time and filtering list', () => {
|
it('should move time and filtering list', () => {
|
||||||
expect(model.time.from).toBe('now-1d');
|
expect(model.time.from).toBe('now-1d');
|
||||||
expect(model.templating.list[0].allFormat).toBe('glob');
|
expect(model.templating.list[0].name).toBe('server');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('graphite panel should change name too graph', () => {
|
it('graphite panel should change name too graph', () => {
|
||||||
@ -921,58 +921,55 @@ describe('DashboardModel', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
model = new DashboardModel({
|
model = new DashboardModel({
|
||||||
|
editable: true,
|
||||||
|
graphTooltip: 0,
|
||||||
|
schemaVersion: 10,
|
||||||
templating: {
|
templating: {
|
||||||
list: [
|
list: [
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
|
name: 'server1',
|
||||||
type: 'query',
|
type: 'query',
|
||||||
hide: VariableHide.dontHide,
|
hide: VariableHide.dontHide,
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
|
name: 'server2',
|
||||||
type: 'query',
|
type: 'query',
|
||||||
hide: VariableHide.hideLabel,
|
hide: VariableHide.hideLabel,
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
|
name: 'server3',
|
||||||
type: 'query',
|
type: 'query',
|
||||||
hide: VariableHide.hideVariable,
|
hide: VariableHide.hideVariable,
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
|
name: 'server4',
|
||||||
type: 'constant',
|
type: 'constant',
|
||||||
hide: VariableHide.dontHide,
|
hide: VariableHide.dontHide,
|
||||||
query: 'default value',
|
query: 'default value',
|
||||||
current: { selected: true, text: 'A', value: 'B' },
|
current: { selected: true, text: 'A', value: 'B' },
|
||||||
options: [{ selected: true, text: 'A', value: 'B' }],
|
options: [{ selected: true, text: 'A', value: 'B' }],
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
|
name: 'server5',
|
||||||
type: 'constant',
|
type: 'constant',
|
||||||
hide: VariableHide.hideLabel,
|
hide: VariableHide.hideLabel,
|
||||||
query: 'default value',
|
query: 'default value',
|
||||||
current: { selected: true, text: 'A', value: 'B' },
|
current: { selected: true, text: 'A', value: 'B' },
|
||||||
options: [{ selected: true, text: 'A', value: 'B' }],
|
options: [{ selected: true, text: 'A', value: 'B' }],
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
|
name: 'server6',
|
||||||
type: 'constant',
|
type: 'constant',
|
||||||
hide: VariableHide.hideVariable,
|
hide: VariableHide.hideVariable,
|
||||||
query: 'default value',
|
query: 'default value',
|
||||||
current: { selected: true, text: 'A', value: 'B' },
|
current: { selected: true, text: 'A', value: 'B' },
|
||||||
options: [{ selected: true, text: 'A', value: 'B' }],
|
options: [{ selected: true, text: 'A', value: 'B' }],
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -991,34 +988,34 @@ describe('DashboardModel', () => {
|
|||||||
|
|
||||||
it('should migrate visible constant variables to textbox variables', () => {
|
it('should migrate visible constant variables to textbox variables', () => {
|
||||||
expect(model.templating.list[3]).toEqual({
|
expect(model.templating.list[3]).toEqual({
|
||||||
|
name: 'server4',
|
||||||
type: 'textbox',
|
type: 'textbox',
|
||||||
hide: VariableHide.dontHide,
|
hide: VariableHide.dontHide,
|
||||||
query: 'default value',
|
query: 'default value',
|
||||||
current: { selected: true, text: 'default value', value: 'default value' },
|
current: { selected: true, text: 'default value', value: 'default value' },
|
||||||
options: [{ selected: true, text: 'default value', value: 'default value' }],
|
options: [{ selected: true, text: 'default value', value: 'default value' }],
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
});
|
});
|
||||||
expect(model.templating.list[4]).toEqual({
|
expect(model.templating.list[4]).toEqual({
|
||||||
|
name: 'server5',
|
||||||
type: 'textbox',
|
type: 'textbox',
|
||||||
hide: VariableHide.hideLabel,
|
hide: VariableHide.hideLabel,
|
||||||
query: 'default value',
|
query: 'default value',
|
||||||
current: { selected: true, text: 'default value', value: 'default value' },
|
current: { selected: true, text: 'default value', value: 'default value' },
|
||||||
options: [{ selected: true, text: 'default value', value: 'default value' }],
|
options: [{ selected: true, text: 'default value', value: 'default value' }],
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change current and options for hidden constant variables', () => {
|
it('should change current and options for hidden constant variables', () => {
|
||||||
expect(model.templating.list[5]).toEqual({
|
expect(model.templating.list[5]).toEqual({
|
||||||
|
name: 'server6',
|
||||||
type: 'constant',
|
type: 'constant',
|
||||||
hide: VariableHide.hideVariable,
|
hide: VariableHide.hideVariable,
|
||||||
query: 'default value',
|
query: 'default value',
|
||||||
current: { selected: true, text: 'default value', value: 'default value' },
|
current: { selected: true, text: 'default value', value: 'default value' },
|
||||||
options: [{ selected: true, text: 'default value', value: 'default value' }],
|
options: [{ selected: true, text: 'default value', value: 'default value' }],
|
||||||
datasource: null,
|
datasource: null,
|
||||||
allFormat: '',
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1028,95 +1025,84 @@ describe('DashboardModel', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
model = new DashboardModel({
|
model = new DashboardModel({
|
||||||
|
editable: true,
|
||||||
|
graphTooltip: 0,
|
||||||
|
schemaVersion: 20,
|
||||||
templating: {
|
templating: {
|
||||||
list: [
|
list: [
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_never_refresh_with_options',
|
name: 'variable_with_never_refresh_with_options',
|
||||||
options: [{ text: 'A', value: 'A' }],
|
options: [{ text: 'A', value: 'A' }],
|
||||||
refresh: 0,
|
refresh: 0,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_never_refresh_without_options',
|
name: 'variable_with_never_refresh_without_options',
|
||||||
options: [],
|
options: [],
|
||||||
refresh: 0,
|
refresh: 0,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_dashboard_refresh_with_options',
|
name: 'variable_with_dashboard_refresh_with_options',
|
||||||
options: [{ text: 'A', value: 'A' }],
|
options: [{ text: 'A', value: 'A' }],
|
||||||
refresh: 1,
|
refresh: 1,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_dashboard_refresh_without_options',
|
name: 'variable_with_dashboard_refresh_without_options',
|
||||||
options: [],
|
options: [],
|
||||||
refresh: 1,
|
refresh: 1,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_timerange_refresh_with_options',
|
name: 'variable_with_timerange_refresh_with_options',
|
||||||
options: [{ text: 'A', value: 'A' }],
|
options: [{ text: 'A', value: 'A' }],
|
||||||
refresh: 2,
|
refresh: 2,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_timerange_refresh_without_options',
|
name: 'variable_with_timerange_refresh_without_options',
|
||||||
options: [],
|
options: [],
|
||||||
refresh: 2,
|
refresh: 2,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_no_refresh_with_options',
|
name: 'variable_with_no_refresh_with_options',
|
||||||
options: [{ text: 'A', value: 'A' }],
|
options: [{ text: 'A', value: 'A' }],
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_no_refresh_without_options',
|
name: 'variable_with_no_refresh_without_options',
|
||||||
options: [],
|
options: [],
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_unknown_refresh_with_options',
|
name: 'variable_with_unknown_refresh_with_options',
|
||||||
options: [{ text: 'A', value: 'A' }],
|
options: [{ text: 'A', value: 'A' }],
|
||||||
refresh: 2001,
|
refresh: 2001,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'variable_with_unknown_refresh_without_options',
|
name: 'variable_with_unknown_refresh_without_options',
|
||||||
options: [],
|
options: [],
|
||||||
refresh: 2001,
|
refresh: 2001,
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
name: 'custom',
|
name: 'custom',
|
||||||
options: [{ text: 'custom', value: 'custom' }],
|
options: [{ text: 'custom', value: 'custom' }],
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'textbox',
|
type: 'textbox',
|
||||||
name: 'textbox',
|
name: 'textbox',
|
||||||
options: [{ text: 'Hello', value: 'World' }],
|
options: [{ text: 'Hello', value: 'World' }],
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'datasource',
|
type: 'datasource',
|
||||||
name: 'datasource',
|
name: 'datasource',
|
||||||
options: [{ text: 'ds', value: 'ds' }], // fake example doesn't exist
|
options: [{ text: 'ds', value: 'ds' }], // fake example doesn't exist
|
||||||
},
|
},
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'interval',
|
type: 'interval',
|
||||||
name: 'interval',
|
name: 'interval',
|
||||||
@ -2038,7 +2024,6 @@ describe('DashboardModel', () => {
|
|||||||
model = new DashboardModel({
|
model = new DashboardModel({
|
||||||
templating: {
|
templating: {
|
||||||
list: [
|
list: [
|
||||||
// @ts-expect-error
|
|
||||||
{
|
{
|
||||||
type: 'query',
|
type: 'query',
|
||||||
name: 'var',
|
name: 'var',
|
||||||
|
@ -195,7 +195,7 @@ export class DashboardMigrator {
|
|||||||
variable.type = 'query';
|
variable.type = 'query';
|
||||||
}
|
}
|
||||||
if (variable.allFormat === void 0) {
|
if (variable.allFormat === void 0) {
|
||||||
variable.allFormat = 'glob';
|
delete variable.allFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,10 @@ import {
|
|||||||
LogsSortOrder,
|
LogsSortOrder,
|
||||||
dateTime,
|
dateTime,
|
||||||
TimeRange,
|
TimeRange,
|
||||||
|
LoadingState,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { config, reportInteraction } from '@grafana/runtime';
|
import { config, reportInteraction } from '@grafana/runtime';
|
||||||
import { DataQuery, LoadingState, TimeZone } from '@grafana/schema';
|
import { DataQuery, TimeZone } from '@grafana/schema';
|
||||||
import { Button, Modal, useTheme2 } from '@grafana/ui';
|
import { Button, Modal, useTheme2 } from '@grafana/ui';
|
||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
import { SETTINGS_KEYS } from 'app/features/explore/Logs/utils/logs';
|
import { SETTINGS_KEYS } from 'app/features/explore/Logs/utils/logs';
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { getQueryOptions } from 'test/helpers/getQueryOptions';
|
import { getQueryOptions } from 'test/helpers/getQueryOptions';
|
||||||
|
|
||||||
import { dateTime } from '@grafana/data';
|
import { dateTime, LoadingState } from '@grafana/data';
|
||||||
import { LoadingState } from '@grafana/schema';
|
|
||||||
|
|
||||||
import { LokiDatasource } from './datasource';
|
import { LokiDatasource } from './datasource';
|
||||||
import * as logsTimeSplit from './logsTimeSplitting';
|
import * as logsTimeSplit from './logsTimeSplitting';
|
||||||
|
@ -12,8 +12,8 @@ import {
|
|||||||
parseDuration,
|
parseDuration,
|
||||||
rangeUtil,
|
rangeUtil,
|
||||||
TimeRange,
|
TimeRange,
|
||||||
|
LoadingState,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { LoadingState } from '@grafana/schema';
|
|
||||||
|
|
||||||
import { LokiDatasource } from './datasource';
|
import { LokiDatasource } from './datasource';
|
||||||
import { splitTimeRange as splitLogsTimeRange } from './logsTimeSplitting';
|
import { splitTimeRange as splitLogsTimeRange } from './logsTimeSplitting';
|
||||||
|
Loading…
Reference in New Issue
Block a user