mirror of https://github.com/grafana/grafana
Chore: Reorg packages (#20111)
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master mergepull/20121/head
parent
3e8c00dad1
commit
9b7748ec13
@ -1,5 +1,6 @@ |
|||||||
import { MappingType, ValueMapping, DisplayProcessor, DisplayValue } from '@grafana/data'; |
|
||||||
import { getDisplayProcessor, getColorFromThreshold } from './displayProcessor'; |
import { getDisplayProcessor, getColorFromThreshold } from './displayProcessor'; |
||||||
|
import { DisplayProcessor, DisplayValue } from '../types/displayValue'; |
||||||
|
import { ValueMapping, MappingType } from '../types/valueMapping'; |
||||||
|
|
||||||
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) { |
function assertSame(input: any, processors: DisplayProcessor[], match: DisplayValue) { |
||||||
processors.forEach(processor => { |
processors.forEach(processor => { |
@ -1,21 +1,17 @@ |
|||||||
// Libraries
|
// Libraries
|
||||||
import _ from 'lodash'; |
import _ from 'lodash'; |
||||||
import { |
|
||||||
Threshold, |
|
||||||
getMappedValue, |
|
||||||
FieldConfig, |
|
||||||
DisplayProcessor, |
|
||||||
DecimalInfo, |
|
||||||
DisplayValue, |
|
||||||
DecimalCount, |
|
||||||
} from '@grafana/data'; |
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { getValueFormat } from './valueFormats/valueFormats'; |
import { getColorFromHexRgbOrName } from '../utils/namedColorsPalette'; |
||||||
import { getColorFromHexRgbOrName } from './namedColorsPalette'; |
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { GrafanaTheme, GrafanaThemeType } from '../types/index'; |
import { FieldConfig } from '../types/dataFrame'; |
||||||
|
import { GrafanaTheme, GrafanaThemeType } from '../types/theme'; |
||||||
|
import { DisplayProcessor, DisplayValue, DecimalCount, DecimalInfo } from '../types/displayValue'; |
||||||
|
import { getValueFormat } from '../valueFormats/valueFormats'; |
||||||
|
import { getMappedValue } from '../utils/valueMappings'; |
||||||
|
import { Threshold } from '../types/threshold'; |
||||||
|
// import { GrafanaTheme, GrafanaThemeType, FieldConfig } from '../types/index';
|
||||||
|
|
||||||
interface DisplayProcessorOptions { |
interface DisplayProcessorOptions { |
||||||
config?: FieldConfig; |
config?: FieldConfig; |
@ -1,22 +1,17 @@ |
|||||||
import { |
|
||||||
ReducerID, |
|
||||||
reduceField, |
|
||||||
FieldType, |
|
||||||
DataFrame, |
|
||||||
FieldConfig, |
|
||||||
DisplayValue, |
|
||||||
GraphSeriesValue, |
|
||||||
DataFrameView, |
|
||||||
getTimeField, |
|
||||||
ScopedVars, |
|
||||||
} from '@grafana/data'; |
|
||||||
|
|
||||||
import toNumber from 'lodash/toNumber'; |
import toNumber from 'lodash/toNumber'; |
||||||
import toString from 'lodash/toString'; |
import toString from 'lodash/toString'; |
||||||
|
|
||||||
import { GrafanaTheme, InterpolateFunction } from '../types/index'; |
|
||||||
import { getDisplayProcessor } from './displayProcessor'; |
import { getDisplayProcessor } from './displayProcessor'; |
||||||
import { getFlotPairs } from './flotPairs'; |
import { getFlotPairs } from '../utils/flotPairs'; |
||||||
|
import { FieldConfig, DataFrame, FieldType } from '../types/dataFrame'; |
||||||
|
import { InterpolateFunction } from '../types/panel'; |
||||||
|
import { DataFrameView } from '../dataframe/DataFrameView'; |
||||||
|
import { GraphSeriesValue } from '../types/graph'; |
||||||
|
import { DisplayValue } from '../types/displayValue'; |
||||||
|
import { GrafanaTheme } from '../types/theme'; |
||||||
|
import { ReducerID, reduceField } from '../transformations/fieldReducer'; |
||||||
|
import { ScopedVars } from '../types/ScopedVars'; |
||||||
|
import { getTimeField } from '../dataframe/processDataFrame'; |
||||||
|
|
||||||
export interface FieldDisplayOptions { |
export interface FieldDisplayOptions { |
||||||
values?: boolean; // If true show each row value
|
values?: boolean; // If true show each row value
|
@ -0,0 +1,2 @@ |
|||||||
|
export * from './fieldDisplay'; |
||||||
|
export * from './displayProcessor'; |
@ -1,6 +1,7 @@ |
|||||||
import { ComponentClass } from 'react'; |
import { ComponentClass } from 'react'; |
||||||
import { NavModel, KeyValue } from '@grafana/data'; |
import { KeyValue } from './data'; |
||||||
import { PluginMeta, PluginIncludeType, GrafanaPlugin } from './plugin'; |
import { NavModel } from './navModel'; |
||||||
|
import { PluginMeta, GrafanaPlugin, PluginIncludeType } from './plugin'; |
||||||
|
|
||||||
export interface AppRootProps<T = KeyValue> { |
export interface AppRootProps<T = KeyValue> { |
||||||
meta: AppPluginMeta<T>; |
meta: AppPluginMeta<T>; |
@ -1,4 +0,0 @@ |
|||||||
export interface AppEvent<T> { |
|
||||||
readonly name: string; |
|
||||||
payload?: T; |
|
||||||
} |
|
@ -1,5 +1,10 @@ |
|||||||
import { eventFactory } from './utils'; |
import { eventFactory } from './utils'; |
||||||
|
|
||||||
|
export interface AppEvent<T> { |
||||||
|
readonly name: string; |
||||||
|
payload?: T; |
||||||
|
} |
||||||
|
|
||||||
export type AlertPayload = [string, string?]; |
export type AlertPayload = [string, string?]; |
||||||
|
|
||||||
export const alertSuccess = eventFactory<AlertPayload>('alert-success'); |
export const alertSuccess = eventFactory<AlertPayload>('alert-success'); |
@ -1,20 +1,12 @@ |
|||||||
|
import { Observable } from 'rxjs'; |
||||||
import { ComponentType } from 'react'; |
import { ComponentType } from 'react'; |
||||||
import { |
|
||||||
TimeRange, |
|
||||||
RawTimeRange, |
|
||||||
TableData, |
|
||||||
TimeSeries, |
|
||||||
DataFrame, |
|
||||||
LogRowModel, |
|
||||||
LoadingState, |
|
||||||
DataFrameDTO, |
|
||||||
AnnotationEvent, |
|
||||||
ScopedVars, |
|
||||||
KeyValue, |
|
||||||
} from '@grafana/data'; |
|
||||||
import { PluginMeta, GrafanaPlugin } from './plugin'; |
import { PluginMeta, GrafanaPlugin } from './plugin'; |
||||||
import { PanelData } from './panel'; |
import { PanelData } from './panel'; |
||||||
import { Observable } from 'rxjs'; |
import { LogRowModel } from './logs'; |
||||||
|
import { AnnotationEvent, TimeSeries, TableData, LoadingState, KeyValue } from './data'; |
||||||
|
import { DataFrame, DataFrameDTO } from './dataFrame'; |
||||||
|
import { TimeRange, RawTimeRange } from './time'; |
||||||
|
import { ScopedVars } from './ScopedVars'; |
||||||
|
|
||||||
export interface DataSourcePluginOptionsEditorProps<JSONData = DataSourceJsonData, SecureJSONData = {}> { |
export interface DataSourcePluginOptionsEditorProps<JSONData = DataSourceJsonData, SecureJSONData = {}> { |
||||||
options: DataSourceSettings<JSONData, SecureJSONData>; |
options: DataSourceSettings<JSONData, SecureJSONData>; |
@ -1,7 +1,10 @@ |
|||||||
import { ComponentClass, ComponentType } from 'react'; |
import { ComponentClass, ComponentType } from 'react'; |
||||||
import { LoadingState, DataFrame, TimeRange, TimeZone, ScopedVars, AbsoluteTimeRange } from '@grafana/data'; |
|
||||||
import { DataQueryRequest, DataQueryError } from './datasource'; |
import { DataQueryRequest, DataQueryError } from './datasource'; |
||||||
import { PluginMeta, GrafanaPlugin } from './plugin'; |
import { PluginMeta, GrafanaPlugin } from './plugin'; |
||||||
|
import { ScopedVars } from './ScopedVars'; |
||||||
|
import { LoadingState } from './data'; |
||||||
|
import { DataFrame } from './dataFrame'; |
||||||
|
import { TimeRange, TimeZone, AbsoluteTimeRange } from './time'; |
||||||
|
|
||||||
export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string; |
export type InterpolateFunction = (value: string, scopedVars?: ScopedVars, format?: string | Function) => string; |
||||||
|
|
@ -1,8 +1,7 @@ |
|||||||
import { eventFactory } from '@grafana/data'; |
import { eventFactory } from './utils'; |
||||||
import { DataQueryResponseData, DataQueryError } from '.'; |
import { DataQueryError, DataQueryResponseData } from './datasource'; |
||||||
|
|
||||||
/** Payloads */ |
/** Payloads */ |
||||||
|
|
||||||
export interface PanelChangeViewPayload { |
export interface PanelChangeViewPayload { |
||||||
fullscreen?: boolean; |
fullscreen?: boolean; |
||||||
edit?: boolean; |
edit?: boolean; |
@ -1,5 +1,5 @@ |
|||||||
import { ComponentClass } from 'react'; |
import { ComponentClass } from 'react'; |
||||||
import { KeyValue } from '@grafana/data'; |
import { KeyValue } from './data'; |
||||||
|
|
||||||
export enum PluginState { |
export enum PluginState { |
||||||
alpha = 'alpha', // Only included it `enable_alpha` is true
|
alpha = 'alpha', // Only included it `enable_alpha` is true
|
@ -0,0 +1,236 @@ |
|||||||
|
export enum GrafanaThemeType { |
||||||
|
Light = 'light', |
||||||
|
Dark = 'dark', |
||||||
|
} |
||||||
|
|
||||||
|
export interface GrafanaThemeCommons { |
||||||
|
name: string; |
||||||
|
// TODO: not sure if should be a part of theme
|
||||||
|
breakpoints: { |
||||||
|
xs: string; |
||||||
|
sm: string; |
||||||
|
md: string; |
||||||
|
lg: string; |
||||||
|
xl: string; |
||||||
|
}; |
||||||
|
typography: { |
||||||
|
fontFamily: { |
||||||
|
sansSerif: string; |
||||||
|
monospace: string; |
||||||
|
}; |
||||||
|
size: { |
||||||
|
root: string; |
||||||
|
base: string; |
||||||
|
xs: string; |
||||||
|
sm: string; |
||||||
|
md: string; |
||||||
|
lg: string; |
||||||
|
}; |
||||||
|
weight: { |
||||||
|
light: number; |
||||||
|
regular: number; |
||||||
|
semibold: number; |
||||||
|
bold: number; |
||||||
|
}; |
||||||
|
lineHeight: { |
||||||
|
xs: number; //1
|
||||||
|
sm: number; //1.1
|
||||||
|
md: number; // 4/3
|
||||||
|
lg: number; // 1.5
|
||||||
|
}; |
||||||
|
// TODO: Refactor to use size instead of custom defs
|
||||||
|
heading: { |
||||||
|
h1: string; |
||||||
|
h2: string; |
||||||
|
h3: string; |
||||||
|
h4: string; |
||||||
|
h5: string; |
||||||
|
h6: string; |
||||||
|
}; |
||||||
|
link: { |
||||||
|
decoration: string; |
||||||
|
hoverDecoration: string; |
||||||
|
}; |
||||||
|
}; |
||||||
|
spacing: { |
||||||
|
insetSquishMd: string; |
||||||
|
d: string; |
||||||
|
xxs: string; |
||||||
|
xs: string; |
||||||
|
sm: string; |
||||||
|
md: string; |
||||||
|
lg: string; |
||||||
|
xl: string; |
||||||
|
gutter: string; |
||||||
|
|
||||||
|
// Next-gen forms spacing variables
|
||||||
|
// TODO: Move variables definition to respective components when implementing
|
||||||
|
formSpacingBase: number; |
||||||
|
formMargin: string; |
||||||
|
formFieldsetMargin: string; |
||||||
|
formLegendMargin: string; |
||||||
|
formInputHeight: string; |
||||||
|
formButtonHeight: number; |
||||||
|
formInputPaddingHorizontal: string; |
||||||
|
// Used for icons do define spacing between icon and input field
|
||||||
|
// Applied on the right(prefix) or left(suffix)
|
||||||
|
formInputAffixPaddingHorizontal: string; |
||||||
|
formInputMargin: string; |
||||||
|
formLabelPadding: string; |
||||||
|
formLabelMargin: string; |
||||||
|
formValidationMessagePadding: string; |
||||||
|
}; |
||||||
|
border: { |
||||||
|
radius: { |
||||||
|
sm: string; |
||||||
|
md: string; |
||||||
|
lg: string; |
||||||
|
}; |
||||||
|
width: { |
||||||
|
sm: string; |
||||||
|
}; |
||||||
|
}; |
||||||
|
height: { |
||||||
|
sm: string; |
||||||
|
md: string; |
||||||
|
lg: string; |
||||||
|
}; |
||||||
|
panelPadding: number; |
||||||
|
panelHeaderHeight: number; |
||||||
|
zIndex: { |
||||||
|
dropdown: string; |
||||||
|
navbarFixed: string; |
||||||
|
sidemenu: string; |
||||||
|
tooltip: string; |
||||||
|
modalBackdrop: string; |
||||||
|
modal: string; |
||||||
|
typeahead: string; |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
export interface GrafanaTheme extends GrafanaThemeCommons { |
||||||
|
type: GrafanaThemeType; |
||||||
|
isDark: boolean; |
||||||
|
isLight: boolean; |
||||||
|
background: { |
||||||
|
dropdown: string; |
||||||
|
scrollbar: string; |
||||||
|
scrollbar2: string; |
||||||
|
pageHeader: string; |
||||||
|
}; |
||||||
|
colors: { |
||||||
|
black: string; |
||||||
|
white: string; |
||||||
|
dark1: string; |
||||||
|
dark2: string; |
||||||
|
dark3: string; |
||||||
|
dark4: string; |
||||||
|
dark5: string; |
||||||
|
dark6: string; |
||||||
|
dark7: string; |
||||||
|
dark8: string; |
||||||
|
dark9: string; |
||||||
|
dark10: string; |
||||||
|
gray1: string; |
||||||
|
gray2: string; |
||||||
|
gray3: string; |
||||||
|
gray4: string; |
||||||
|
gray5: string; |
||||||
|
gray6: string; |
||||||
|
gray7: string; |
||||||
|
|
||||||
|
// New greys palette used by next-gen form elements
|
||||||
|
gray98: string; |
||||||
|
gray95: string; |
||||||
|
gray85: string; |
||||||
|
gray70: string; |
||||||
|
gray33: string; |
||||||
|
gray25: string; |
||||||
|
gray15: string; |
||||||
|
gray10: string; |
||||||
|
gray05: string; |
||||||
|
|
||||||
|
// New blues palette used by next-gen form elements
|
||||||
|
blue95: string; |
||||||
|
blue85: string; |
||||||
|
blue77: string; |
||||||
|
|
||||||
|
// New reds palette used by next-gen form elements
|
||||||
|
red88: string; |
||||||
|
|
||||||
|
grayBlue: string; |
||||||
|
inputBlack: string; |
||||||
|
|
||||||
|
// Accent colors
|
||||||
|
blue: string; |
||||||
|
blueBase: string; |
||||||
|
blueShade: string; |
||||||
|
blueLight: string; |
||||||
|
blueFaint: string; |
||||||
|
redBase: string; |
||||||
|
redShade: string; |
||||||
|
greenBase: string; |
||||||
|
greenShade: string; |
||||||
|
red: string; |
||||||
|
yellow: string; |
||||||
|
purple: string; |
||||||
|
variable: string; |
||||||
|
orange: string; |
||||||
|
orangeDark: string; |
||||||
|
queryRed: string; |
||||||
|
queryGreen: string; |
||||||
|
queryPurple: string; |
||||||
|
queryKeyword: string; |
||||||
|
queryOrange: string; |
||||||
|
brandPrimary: string; |
||||||
|
brandSuccess: string; |
||||||
|
brandWarning: string; |
||||||
|
brandDanger: string; |
||||||
|
|
||||||
|
// Status colors
|
||||||
|
online: string; |
||||||
|
warn: string; |
||||||
|
critical: string; |
||||||
|
|
||||||
|
// Link colors
|
||||||
|
link: string; |
||||||
|
linkDisabled: string; |
||||||
|
linkHover: string; |
||||||
|
linkExternal: string; |
||||||
|
|
||||||
|
// Text colors
|
||||||
|
body: string; |
||||||
|
text: string; |
||||||
|
textStrong: string; |
||||||
|
textWeak: string; |
||||||
|
textFaint: string; |
||||||
|
textEmphasis: string; |
||||||
|
|
||||||
|
// TODO: move to background section
|
||||||
|
bodyBg: string; |
||||||
|
pageBg: string; |
||||||
|
headingColor: string; |
||||||
|
|
||||||
|
pageHeaderBorder: string; |
||||||
|
|
||||||
|
// Next-gen forms functional colors
|
||||||
|
formLabel: string; |
||||||
|
formDescription: string; |
||||||
|
formLegend: string; |
||||||
|
formInputBg: string; |
||||||
|
formInputBgDisabled: string; |
||||||
|
formInputBorder: string; |
||||||
|
formInputBorderHover: string; |
||||||
|
formInputBorderActive: string; |
||||||
|
formInputBorderInvalid: string; |
||||||
|
formInputFocusOutline: string; |
||||||
|
formInputText: string; |
||||||
|
formInputTextStrong: string; |
||||||
|
formInputTextWhite: string; |
||||||
|
formValidationMessageText: string; |
||||||
|
formValidationMessageBg: string; |
||||||
|
}; |
||||||
|
shadow: { |
||||||
|
pageHeader: string; |
||||||
|
}; |
||||||
|
} |
@ -1,5 +1,7 @@ |
|||||||
|
import { MutableDataFrame } from '../dataframe/MutableDataFrame'; |
||||||
import { getFlotPairs, getFlotPairsConstant } from './flotPairs'; |
import { getFlotPairs, getFlotPairsConstant } from './flotPairs'; |
||||||
import { MutableDataFrame, TimeRange, dateTime } from '@grafana/data'; |
import { TimeRange } from '../types/time'; |
||||||
|
import { dateTime } from '../datetime/moment_wrapper'; |
||||||
|
|
||||||
describe('getFlotPairs', () => { |
describe('getFlotPairs', () => { |
||||||
const series = new MutableDataFrame({ |
const series = new MutableDataFrame({ |
@ -1,5 +1,10 @@ |
|||||||
|
import { Field } from '../types/dataFrame'; |
||||||
|
import { NullValueMode } from '../types/data'; |
||||||
|
import { GraphSeriesValue } from '../types/graph'; |
||||||
|
import { TimeRange } from '../types/time'; |
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import { NullValueMode, GraphSeriesValue, Field, TimeRange } from '@grafana/data'; |
// import { NullValueMode, GraphSeriesValue, Field, TimeRange } from '@grafana/data';
|
||||||
|
|
||||||
export interface FlotPairsOptions { |
export interface FlotPairsOptions { |
||||||
xField: Field; |
xField: Field; |
@ -1,6 +1,6 @@ |
|||||||
import flatten from 'lodash/flatten'; |
import flatten from 'lodash/flatten'; |
||||||
import { GrafanaThemeType } from '../types/theme'; |
|
||||||
import tinycolor from 'tinycolor2'; |
import tinycolor from 'tinycolor2'; |
||||||
|
import { GrafanaThemeType } from '../types/theme'; |
||||||
|
|
||||||
type Hue = 'green' | 'yellow' | 'red' | 'blue' | 'orange' | 'purple'; |
type Hue = 'green' | 'yellow' | 'red' | 'blue' | 'orange' | 'purple'; |
||||||
|
|
@ -1,6 +1,5 @@ |
|||||||
import { DecimalCount } from '@grafana/data'; |
|
||||||
|
|
||||||
import { toFixed } from './valueFormats'; |
import { toFixed } from './valueFormats'; |
||||||
|
import { DecimalCount } from '../types/displayValue'; |
||||||
|
|
||||||
export function toPercent(size: number, decimals: DecimalCount) { |
export function toPercent(size: number, decimals: DecimalCount) { |
||||||
if (size === null) { |
if (size === null) { |
@ -1,6 +1,7 @@ |
|||||||
import { toUtc, toDuration as duration, dateTime, DecimalCount } from '@grafana/data'; |
import { toDuration as duration, toUtc, dateTime } from '../datetime/moment_wrapper'; |
||||||
|
|
||||||
import { toFixed, toFixedScaled } from './valueFormats'; |
import { toFixed, toFixedScaled } from './valueFormats'; |
||||||
|
import { DecimalCount } from '../types/displayValue'; |
||||||
|
|
||||||
interface IntervalsInSeconds { |
interface IntervalsInSeconds { |
||||||
[interval: string]: number; |
[interval: string]: number; |
@ -0,0 +1 @@ |
|||||||
|
export * from './valueFormats'; |
@ -1,6 +1,5 @@ |
|||||||
import { DecimalCount } from '@grafana/data'; |
|
||||||
|
|
||||||
import { scaledUnits } from './valueFormats'; |
import { scaledUnits } from './valueFormats'; |
||||||
|
import { DecimalCount } from '../types/displayValue'; |
||||||
|
|
||||||
export function currency(symbol: string) { |
export function currency(symbol: string) { |
||||||
const units = ['', 'K', 'M', 'B', 'T']; |
const units = ['', 'K', 'M', 'B', 'T']; |
@ -1,6 +1,5 @@ |
|||||||
import { DecimalCount } from '@grafana/data'; |
|
||||||
|
|
||||||
import { getCategories } from './categories'; |
import { getCategories } from './categories'; |
||||||
|
import { DecimalCount } from '../types/displayValue'; |
||||||
|
|
||||||
export type ValueFormatter = ( |
export type ValueFormatter = ( |
||||||
value: number, |
value: number, |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue