|
@@ -7,6 +7,7 @@ import { tablePanelEditor } from './editor';
|
|
|
import { columnOptionsTab } from './column_options';
|
|
import { columnOptionsTab } from './column_options';
|
|
|
import { TableRenderer } from './renderer';
|
|
import { TableRenderer } from './renderer';
|
|
|
import { isTableData } from '@grafana/ui';
|
|
import { isTableData } from '@grafana/ui';
|
|
|
|
|
+import { TemplateSrv } from 'app/features/templating/template_srv';
|
|
|
|
|
|
|
|
class TablePanelCtrl extends MetricsPanelCtrl {
|
|
class TablePanelCtrl extends MetricsPanelCtrl {
|
|
|
static templateUrl = 'module.html';
|
|
static templateUrl = 'module.html';
|
|
@@ -46,7 +47,14 @@ class TablePanelCtrl extends MetricsPanelCtrl {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
/** @ngInject */
|
|
/** @ngInject */
|
|
|
- constructor($scope, $injector, templateSrv, private annotationsSrv, private $sanitize, private variableSrv) {
|
|
|
|
|
|
|
+ constructor(
|
|
|
|
|
+ $scope: any,
|
|
|
|
|
+ $injector: any,
|
|
|
|
|
+ templateSrv: TemplateSrv,
|
|
|
|
|
+ private annotationsSrv: any,
|
|
|
|
|
+ private $sanitize: any,
|
|
|
|
|
+ private variableSrv: any
|
|
|
|
|
+ ) {
|
|
|
super($scope, $injector);
|
|
super($scope, $injector);
|
|
|
|
|
|
|
|
this.pageIndex = 0;
|
|
this.pageIndex = 0;
|
|
@@ -72,11 +80,11 @@ class TablePanelCtrl extends MetricsPanelCtrl {
|
|
|
this.addEditorTab('Column Styles', columnOptionsTab, 3);
|
|
this.addEditorTab('Column Styles', columnOptionsTab, 3);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- onInitPanelActions(actions) {
|
|
|
|
|
|
|
+ onInitPanelActions(actions: any[]) {
|
|
|
actions.push({ text: 'Export CSV', click: 'ctrl.exportCsv()' });
|
|
actions.push({ text: 'Export CSV', click: 'ctrl.exportCsv()' });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- issueQueries(datasource) {
|
|
|
|
|
|
|
+ issueQueries(datasource: any) {
|
|
|
this.pageIndex = 0;
|
|
this.pageIndex = 0;
|
|
|
|
|
|
|
|
if (this.panel.transform === 'annotations') {
|
|
if (this.panel.transform === 'annotations') {
|
|
@@ -94,12 +102,12 @@ class TablePanelCtrl extends MetricsPanelCtrl {
|
|
|
return super.issueQueries(datasource);
|
|
return super.issueQueries(datasource);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- onDataError(err) {
|
|
|
|
|
|
|
+ onDataError(err: any) {
|
|
|
this.dataRaw = [];
|
|
this.dataRaw = [];
|
|
|
this.render();
|
|
this.render();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- onDataReceived(dataList) {
|
|
|
|
|
|
|
+ onDataReceived(dataList: any) {
|
|
|
this.dataRaw = dataList;
|
|
this.dataRaw = dataList;
|
|
|
this.pageIndex = 0;
|
|
this.pageIndex = 0;
|
|
|
|
|
|
|
@@ -137,7 +145,7 @@ class TablePanelCtrl extends MetricsPanelCtrl {
|
|
|
return super.render(this.table);
|
|
return super.render(this.table);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- toggleColumnSort(col, colIndex) {
|
|
|
|
|
|
|
+ toggleColumnSort(col: any, colIndex: any) {
|
|
|
// remove sort flag from current column
|
|
// remove sort flag from current column
|
|
|
if (this.table.columns[this.panel.sort.col]) {
|
|
if (this.table.columns[this.panel.sort.col]) {
|
|
|
this.table.columns[this.panel.sort.col].sort = false;
|
|
this.table.columns[this.panel.sort.col].sort = false;
|
|
@@ -167,7 +175,7 @@ class TablePanelCtrl extends MetricsPanelCtrl {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- link(scope, elem, attrs, ctrl: TablePanelCtrl) {
|
|
|
|
|
|
|
+ link(scope: any, elem: JQuery, attrs: any, ctrl: TablePanelCtrl) {
|
|
|
let data;
|
|
let data;
|
|
|
const panel = ctrl.panel;
|
|
const panel = ctrl.panel;
|
|
|
let pageCount = 0;
|
|
let pageCount = 0;
|