2020-04-15 09:51:51 -05:00
|
|
|
import React, { PureComponent } from 'react';
|
2020-04-17 07:03:21 -05:00
|
|
|
import {
|
|
|
|
applyFieldOverrides,
|
|
|
|
DataFrame,
|
|
|
|
DataTransformerID,
|
2020-05-20 03:07:35 -05:00
|
|
|
dateTimeFormat,
|
|
|
|
getFrameDisplayName,
|
2020-04-17 07:03:21 -05:00
|
|
|
SelectableValue,
|
|
|
|
toCSV,
|
|
|
|
transformDataFrame,
|
2020-05-25 04:12:53 -05:00
|
|
|
getTimeField,
|
|
|
|
FieldType,
|
|
|
|
FormattedVector,
|
|
|
|
DisplayProcessor,
|
|
|
|
getDisplayProcessor,
|
2020-04-17 07:03:21 -05:00
|
|
|
} from '@grafana/data';
|
2020-06-29 06:31:39 -05:00
|
|
|
import { Button, Field, Icon, Switch, Select, Table, VerticalGroup, Container, HorizontalGroup } from '@grafana/ui';
|
2020-04-27 02:09:05 -05:00
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
|
|
|
2020-04-15 09:51:51 -05:00
|
|
|
import { getPanelInspectorStyles } from './styles';
|
|
|
|
import { config } from 'app/core/config';
|
|
|
|
import { saveAs } from 'file-saver';
|
2020-06-29 06:31:39 -05:00
|
|
|
import { css } from 'emotion';
|
2020-05-13 06:03:34 -05:00
|
|
|
import { GetDataOptions } from '../../state/PanelQueryRunner';
|
2020-06-29 06:31:39 -05:00
|
|
|
import { QueryOperationRow } from 'app/core/components/QueryOperationRow/QueryOperationRow';
|
|
|
|
import { PanelModel } from 'app/features/dashboard/state';
|
|
|
|
import { DetailText } from './DetailText';
|
2020-06-30 07:51:04 -05:00
|
|
|
import { getDatasourceSrv } from '../../../plugins/datasource_srv';
|
2020-04-15 09:51:51 -05:00
|
|
|
|
|
|
|
interface Props {
|
2020-05-13 06:03:34 -05:00
|
|
|
panel: PanelModel;
|
2020-06-18 07:31:30 -05:00
|
|
|
data?: DataFrame[];
|
2020-04-15 09:51:51 -05:00
|
|
|
isLoading: boolean;
|
2020-05-13 06:03:34 -05:00
|
|
|
options: GetDataOptions;
|
|
|
|
onOptionsChange: (options: GetDataOptions) => void;
|
2020-04-15 09:51:51 -05:00
|
|
|
}
|
|
|
|
|
2020-04-17 07:03:21 -05:00
|
|
|
interface State {
|
2020-06-29 06:31:39 -05:00
|
|
|
/** The string is seriesToColumns transformation. Otherwise it is a dataframe index */
|
|
|
|
selectedDataFrame: number | DataTransformerID;
|
2020-04-17 07:03:21 -05:00
|
|
|
transformId: DataTransformerID;
|
|
|
|
dataFrameIndex: number;
|
2020-06-29 06:31:39 -05:00
|
|
|
transformationOptions: Array<SelectableValue<DataTransformerID>>;
|
2020-04-17 07:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
export class InspectDataTab extends PureComponent<Props, State> {
|
2020-04-15 09:51:51 -05:00
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
2020-04-17 07:03:21 -05:00
|
|
|
|
|
|
|
this.state = {
|
2020-06-29 06:31:39 -05:00
|
|
|
selectedDataFrame: DataTransformerID.seriesToColumns,
|
2020-04-17 07:03:21 -05:00
|
|
|
dataFrameIndex: 0,
|
2020-06-29 06:31:39 -05:00
|
|
|
transformId: DataTransformerID.seriesToColumns,
|
2020-04-17 07:03:21 -05:00
|
|
|
transformationOptions: buildTransformationOptions(),
|
|
|
|
};
|
2020-04-15 09:51:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
exportCsv = (dataFrame: DataFrame) => {
|
2020-05-14 13:14:23 -05:00
|
|
|
const { panel } = this.props;
|
|
|
|
const { transformId } = this.state;
|
2020-05-25 04:12:53 -05:00
|
|
|
|
|
|
|
// Replace the time field with a formatted time
|
|
|
|
const { timeIndex, timeField } = getTimeField(dataFrame);
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
|
2020-05-25 04:12:53 -05:00
|
|
|
if (timeField) {
|
|
|
|
// Use the configurd date or standandard time display
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
let processor: DisplayProcessor | undefined = timeField.display;
|
2020-05-25 04:12:53 -05:00
|
|
|
if (!processor) {
|
|
|
|
processor = getDisplayProcessor({
|
|
|
|
field: timeField,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const formattedDateField = {
|
|
|
|
...timeField,
|
|
|
|
type: FieldType.string,
|
|
|
|
values: new FormattedVector(timeField.values, processor),
|
|
|
|
};
|
|
|
|
|
|
|
|
const fields = [...dataFrame.fields];
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
fields[timeIndex!] = formattedDateField;
|
|
|
|
|
2020-05-25 04:12:53 -05:00
|
|
|
dataFrame = {
|
|
|
|
...dataFrame,
|
|
|
|
fields,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-04-15 09:51:51 -05:00
|
|
|
const dataFrameCsv = toCSV([dataFrame]);
|
|
|
|
|
2020-07-08 01:53:03 -05:00
|
|
|
const blob = new Blob([String.fromCharCode(0xfeff), dataFrameCsv], {
|
|
|
|
type: 'text/csv;charset=utf-8',
|
2020-04-15 09:51:51 -05:00
|
|
|
});
|
2020-05-14 13:14:23 -05:00
|
|
|
const transformation = transformId !== DataTransformerID.noop ? '-as-' + transformId.toLocaleLowerCase() : '';
|
|
|
|
const fileName = `${panel.title}-data${transformation}-${dateTimeFormat(new Date())}.csv`;
|
|
|
|
saveAs(blob, fileName);
|
2020-04-15 09:51:51 -05:00
|
|
|
};
|
|
|
|
|
2020-06-29 06:31:39 -05:00
|
|
|
onDataFrameChange = (item: SelectableValue<DataTransformerID | number>) => {
|
|
|
|
this.setState({
|
|
|
|
transformId:
|
|
|
|
item.value === DataTransformerID.seriesToColumns ? DataTransformerID.seriesToColumns : DataTransformerID.noop,
|
|
|
|
dataFrameIndex: typeof item.value === 'number' ? item.value : 0,
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
selectedDataFrame: item.value!,
|
2020-06-29 06:31:39 -05:00
|
|
|
});
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
|
2020-05-13 06:03:34 -05:00
|
|
|
this.props.onOptionsChange({
|
|
|
|
...this.props.options,
|
|
|
|
});
|
2020-04-17 07:03:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
getTransformedData(): DataFrame[] {
|
|
|
|
const { transformId, transformationOptions } = this.state;
|
|
|
|
const { data } = this.props;
|
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
const currentTransform = transformationOptions.find(item => item.value === transformId);
|
|
|
|
|
|
|
|
if (currentTransform && currentTransform.transformer.id !== DataTransformerID.noop) {
|
|
|
|
return transformDataFrame([currentTransform.transformer], data);
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
getProcessedData(): DataFrame[] {
|
2020-05-13 06:03:34 -05:00
|
|
|
const { options } = this.props;
|
|
|
|
let data = this.props.data;
|
|
|
|
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
if (!data) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
2020-05-13 06:03:34 -05:00
|
|
|
if (this.state.transformId !== DataTransformerID.noop) {
|
|
|
|
data = this.getTransformedData();
|
|
|
|
}
|
|
|
|
|
2020-07-01 01:53:29 -05:00
|
|
|
// In case the transform removes the currently selected data frame
|
|
|
|
if (!data[this.state.dataFrameIndex]) {
|
|
|
|
this.setState({
|
|
|
|
dataFrameIndex: 0,
|
|
|
|
selectedDataFrame: 0,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-13 06:03:34 -05:00
|
|
|
// We need to apply field config even though it was already applied in the PanelQueryRunner.
|
|
|
|
// That's because transformers create new fields and data frames, so i.e. display processor is no longer there
|
2020-04-17 07:03:21 -05:00
|
|
|
return applyFieldOverrides({
|
2020-05-13 06:03:34 -05:00
|
|
|
data,
|
2020-04-17 07:03:21 -05:00
|
|
|
theme: config.theme,
|
2020-05-13 06:03:34 -05:00
|
|
|
fieldConfig: options.withFieldConfig ? this.props.panel.fieldConfig : { defaults: {}, overrides: [] },
|
2020-04-17 07:03:21 -05:00
|
|
|
replaceVariables: (value: string) => {
|
|
|
|
return value;
|
|
|
|
},
|
2020-06-30 07:51:04 -05:00
|
|
|
getDataSourceSettingsByUid: getDatasourceSrv().getDataSourceSettingsByUid,
|
2020-04-17 07:03:21 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
getActiveString() {
|
2020-06-29 06:31:39 -05:00
|
|
|
const { selectedDataFrame } = this.state;
|
|
|
|
const { options, data } = this.props;
|
|
|
|
let activeString = '';
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
|
|
|
|
if (!data) {
|
|
|
|
return activeString;
|
|
|
|
}
|
|
|
|
|
2020-06-29 06:31:39 -05:00
|
|
|
if (selectedDataFrame === DataTransformerID.seriesToColumns) {
|
|
|
|
activeString = 'series joined by time';
|
|
|
|
} else {
|
|
|
|
activeString = getFrameDisplayName(data[selectedDataFrame as number]);
|
|
|
|
}
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
|
2020-06-29 06:31:39 -05:00
|
|
|
if (options.withTransforms || options.withFieldConfig) {
|
|
|
|
activeString += ' - applied ';
|
|
|
|
if (options.withTransforms) {
|
|
|
|
activeString += 'panel transformations ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.withTransforms && options.withFieldConfig) {
|
|
|
|
activeString += 'and ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.withFieldConfig) {
|
|
|
|
activeString += 'field configuration';
|
|
|
|
}
|
|
|
|
}
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
|
2020-06-29 06:31:39 -05:00
|
|
|
return activeString;
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
}
|
2020-06-29 06:31:39 -05:00
|
|
|
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
renderDataOptions(dataFrames: DataFrame[]) {
|
2020-06-29 06:31:39 -05:00
|
|
|
const { options, onOptionsChange, panel, data } = this.props;
|
|
|
|
const { transformId, transformationOptions, selectedDataFrame } = this.state;
|
2020-07-01 01:53:29 -05:00
|
|
|
|
2020-05-20 07:15:06 -05:00
|
|
|
const styles = getPanelInspectorStyles();
|
|
|
|
|
|
|
|
const panelTransformations = panel.getTransformations();
|
|
|
|
const showPanelTransformationsOption =
|
|
|
|
panelTransformations && panelTransformations.length > 0 && (transformId as any) !== 'join by time';
|
|
|
|
const showFieldConfigsOption = !panel.plugin?.fieldConfigRegistry.isEmpty();
|
|
|
|
const showDataOptions = showPanelTransformationsOption || showFieldConfigsOption;
|
|
|
|
|
2020-06-29 06:31:39 -05:00
|
|
|
let dataSelect = dataFrames;
|
|
|
|
if (selectedDataFrame === DataTransformerID.seriesToColumns) {
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
dataSelect = data!;
|
2020-06-29 06:31:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
const choices = dataSelect.map((frame, index) => {
|
|
|
|
return {
|
|
|
|
value: index,
|
|
|
|
label: `${getFrameDisplayName(frame)} (${index})`,
|
|
|
|
} as SelectableValue<number>;
|
|
|
|
});
|
|
|
|
|
|
|
|
const selectableOptions = [...transformationOptions, ...choices];
|
|
|
|
|
2020-05-20 07:15:06 -05:00
|
|
|
if (!showDataOptions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2020-06-29 06:31:39 -05:00
|
|
|
<QueryOperationRow
|
|
|
|
title="Table data options"
|
|
|
|
headerElement={<DetailText>{this.getActiveString()}</DetailText>}
|
|
|
|
isOpen={false}
|
|
|
|
>
|
|
|
|
<div className={styles.options}>
|
|
|
|
<VerticalGroup spacing="lg">
|
2020-07-01 01:53:29 -05:00
|
|
|
<Field
|
|
|
|
label="Show data frame"
|
|
|
|
className={css`
|
|
|
|
margin-bottom: 0;
|
|
|
|
`}
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
disabled={data!.length < 2}
|
2020-07-01 01:53:29 -05:00
|
|
|
>
|
|
|
|
<Select
|
|
|
|
options={selectableOptions}
|
|
|
|
value={selectedDataFrame}
|
|
|
|
onChange={this.onDataFrameChange}
|
|
|
|
width={30}
|
|
|
|
/>
|
|
|
|
</Field>
|
|
|
|
|
2020-06-29 06:31:39 -05:00
|
|
|
<HorizontalGroup>
|
|
|
|
{showPanelTransformationsOption && (
|
|
|
|
<Field
|
|
|
|
label="Apply panel transformations"
|
|
|
|
description="Table data is displayed with transformations defined in the panel Transform tab."
|
|
|
|
>
|
|
|
|
<Switch
|
|
|
|
value={!!options.withTransforms}
|
|
|
|
onChange={() => onOptionsChange({ ...options, withTransforms: !options.withTransforms })}
|
|
|
|
/>
|
|
|
|
</Field>
|
|
|
|
)}
|
|
|
|
{showFieldConfigsOption && (
|
|
|
|
<Field
|
|
|
|
label="Apply field configuration"
|
|
|
|
description="Table data is displayed with options defined in the Field and Override tabs."
|
|
|
|
>
|
|
|
|
<Switch
|
|
|
|
value={!!options.withFieldConfig}
|
|
|
|
onChange={() => onOptionsChange({ ...options, withFieldConfig: !options.withFieldConfig })}
|
|
|
|
/>
|
|
|
|
</Field>
|
|
|
|
)}
|
|
|
|
</HorizontalGroup>
|
|
|
|
</VerticalGroup>
|
|
|
|
</div>
|
|
|
|
</QueryOperationRow>
|
2020-05-20 07:15:06 -05:00
|
|
|
);
|
Chore: Fix all Typescript strict null errors (#26204)
* Chore: Fix typescript strict null errors
* Added new limit
* Fixed ts issue
* fixed tests
* trying to fix type inference
* Fixing more ts errors
* Revert tsconfig option
* Fix
* Fixed code
* More fixes
* fix tests
* Updated snapshot
* Chore: More ts strict null fixes
* More fixes in some really messed up azure config components
* More fixes, current count: 441
* 419
* More fixes
* Fixed invalid initial state in explore
* Fixing tests
* Fixed tests
* Explore fix
* More fixes
* Progress
* Sub 300
* Now at 218
* Progress
* Update
* Progress
* Updated tests
* at 159
* fixed tests
* Progress
* YAy blow 100! at 94
* 10,9,8,7,6,5,4,3,2,1... lift off
* Fixed tests
* Fixed more type errors
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2020-07-10 05:46:59 -05:00
|
|
|
}
|
2020-05-20 07:15:06 -05:00
|
|
|
|
2020-04-15 09:51:51 -05:00
|
|
|
render() {
|
2020-06-29 06:31:39 -05:00
|
|
|
const { isLoading } = this.props;
|
|
|
|
const { dataFrameIndex } = this.state;
|
2020-04-15 09:51:51 -05:00
|
|
|
const styles = getPanelInspectorStyles();
|
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
Loading <Icon name="fa fa-spinner" className="fa-spin" size="lg" />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-17 07:03:21 -05:00
|
|
|
const dataFrames = this.getProcessedData();
|
|
|
|
|
|
|
|
if (!dataFrames || !dataFrames.length) {
|
2020-04-15 09:51:51 -05:00
|
|
|
return <div>No Data</div>;
|
|
|
|
}
|
|
|
|
|
2020-07-01 01:53:29 -05:00
|
|
|
if (!dataFrames[dataFrameIndex]) {
|
|
|
|
return <div>Could not find the Data Frame</div>;
|
|
|
|
}
|
|
|
|
|
2020-04-15 09:51:51 -05:00
|
|
|
return (
|
2020-04-27 02:09:05 -05:00
|
|
|
<div className={styles.dataTabContent} aria-label={selectors.components.PanelInspector.Data.content}>
|
2020-06-29 06:31:39 -05:00
|
|
|
<div className={styles.actionsWrapper}>
|
|
|
|
<div className={styles.dataDisplayOptions}>{this.renderDataOptions(dataFrames)}</div>
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
onClick={() => this.exportCsv(dataFrames[dataFrameIndex])}
|
|
|
|
className={css`
|
|
|
|
margin-bottom: 10px;
|
|
|
|
`}
|
|
|
|
>
|
|
|
|
Download CSV
|
|
|
|
</Button>
|
|
|
|
</div>
|
2020-06-18 07:31:30 -05:00
|
|
|
<Container grow={1}>
|
2020-04-15 09:51:51 -05:00
|
|
|
<AutoSizer>
|
|
|
|
{({ width, height }) => {
|
|
|
|
if (width === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={{ width, height }}>
|
2020-04-17 07:03:21 -05:00
|
|
|
<Table width={width} height={height} data={dataFrames[dataFrameIndex]} />
|
2020-04-15 09:51:51 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</AutoSizer>
|
2020-06-18 07:31:30 -05:00
|
|
|
</Container>
|
2020-04-15 09:51:51 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-04-17 07:03:21 -05:00
|
|
|
|
|
|
|
function buildTransformationOptions() {
|
2020-06-29 06:31:39 -05:00
|
|
|
const transformations: Array<SelectableValue<DataTransformerID>> = [
|
2020-04-17 07:03:21 -05:00
|
|
|
{
|
2020-06-29 06:31:39 -05:00
|
|
|
value: DataTransformerID.seriesToColumns,
|
|
|
|
label: 'Series joined by time',
|
2020-04-17 07:03:21 -05:00
|
|
|
transformer: {
|
|
|
|
id: DataTransformerID.seriesToColumns,
|
|
|
|
options: { byField: 'Time' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
return transformations;
|
|
|
|
}
|