mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix type errors
This commit is contained in:
parent
d7b1fd75e3
commit
ca5d7c3510
@ -86,7 +86,8 @@ export class DataTable extends Component<Props, State> {
|
|||||||
|
|
||||||
// Update the data when data or sort changes
|
// Update the data when data or sort changes
|
||||||
if (dataChanged || sortBy !== prevState.sortBy || sortDirection !== prevState.sortDirection) {
|
if (dataChanged || sortBy !== prevState.sortBy || sortDirection !== prevState.sortDirection) {
|
||||||
this.setState({ data: sortTableData(data, sortBy, sortDirection === 'DESC') });
|
const sorted = data ? sortTableData(data, sortBy, sortDirection === 'DESC') : data;
|
||||||
|
this.setState({ data: sorted });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ import TableModel from 'app/core/table_model';
|
|||||||
|
|
||||||
import { getColorDefinitionByName } from '@grafana/ui';
|
import { getColorDefinitionByName } from '@grafana/ui';
|
||||||
import { ScopedVars } from '@grafana/ui/src/types';
|
import { ScopedVars } from '@grafana/ui/src/types';
|
||||||
import moment from 'moment';
|
|
||||||
import { TableRenderer } from './renderer';
|
import { TableRenderer } from './renderer';
|
||||||
import { Index } from 'react-virtualized';
|
import { Index } from 'react-virtualized';
|
||||||
import { ColumnStyle } from './DataTable';
|
import { ColumnStyle } from './DataTable';
|
||||||
|
@ -98,7 +98,7 @@ export class TableRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createColumnFormatter(header: Column, style?: ColumnStyle): CellFormatter {
|
createColumnFormatter(schema: Column, style?: ColumnStyle): CellFormatter {
|
||||||
if (!style) {
|
if (!style) {
|
||||||
return this.defaultCellFormatter;
|
return this.defaultCellFormatter;
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ export class TableRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (style.type === 'number') {
|
if (style.type === 'number') {
|
||||||
const valueFormatter = getValueFormat(style.unit || header.unit);
|
const valueFormatter = getValueFormat(style.unit || schema.unit || 'none');
|
||||||
|
|
||||||
return v => {
|
return v => {
|
||||||
if (v === null || v === void 0) {
|
if (v === null || v === void 0) {
|
||||||
|
@ -174,8 +174,8 @@ export function processTimeSeries({ timeSeries, nullValueMode }: Options): TimeS
|
|||||||
return vmSeries;
|
return vmSeries;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sortTableData(data?: TableData, sortIndex?: number, reverse = false): TableData {
|
export function sortTableData(data: TableData, sortIndex?: number, reverse = false): TableData {
|
||||||
if (data && isNumber(sortIndex)) {
|
if (isNumber(sortIndex)) {
|
||||||
const copy = {
|
const copy = {
|
||||||
...data,
|
...data,
|
||||||
rows: [...data.rows].sort((a, b) => {
|
rows: [...data.rows].sort((a, b) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user