2019-03-05 16:07:46 -08:00
|
|
|
// Libraries
|
2019-03-07 16:52:20 -08:00
|
|
|
import React, { Component } from 'react';
|
2019-03-05 18:17:44 -08:00
|
|
|
|
2019-03-05 16:07:46 -08:00
|
|
|
// Types
|
2019-12-18 08:38:50 +01:00
|
|
|
import { Table } from '@grafana/ui';
|
2019-12-23 06:22:54 +01:00
|
|
|
import { PanelProps, applyFieldOverrides } from '@grafana/data';
|
2019-03-06 10:54:47 -08:00
|
|
|
import { Options } from './types';
|
2019-12-23 06:22:54 +01:00
|
|
|
import { config } from 'app/core/config';
|
2019-03-06 10:54:47 -08:00
|
|
|
|
2019-03-05 16:07:46 -08:00
|
|
|
interface Props extends PanelProps<Options> {}
|
|
|
|
|
|
2019-12-23 06:22:54 +01:00
|
|
|
const paddingBottom = 16;
|
2019-12-18 08:38:50 +01:00
|
|
|
|
2019-03-07 16:52:20 -08:00
|
|
|
export class TablePanel extends Component<Props> {
|
2019-03-06 10:10:04 -08:00
|
|
|
constructor(props: Props) {
|
|
|
|
|
super(props);
|
2019-03-05 18:17:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-12-23 06:22:54 +01:00
|
|
|
const { data, height, width, replaceVariables, options } = this.props;
|
2019-03-06 10:10:04 -08:00
|
|
|
|
2019-04-16 13:23:34 -07:00
|
|
|
if (data.series.length < 1) {
|
2019-03-05 16:07:46 -08:00
|
|
|
return <div>No Table Data...</div>;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-23 06:22:54 +01:00
|
|
|
const dataProcessed = applyFieldOverrides({
|
|
|
|
|
data: data.series,
|
|
|
|
|
fieldOptions: options.fieldOptions,
|
|
|
|
|
theme: config.theme,
|
|
|
|
|
replaceVariables,
|
|
|
|
|
})[0];
|
|
|
|
|
|
|
|
|
|
return <Table height={height - paddingBottom} width={width} data={dataProcessed} />;
|
2019-03-05 16:07:46 -08:00
|
|
|
}
|
|
|
|
|
}
|