diff --git a/public/app/features/dashboard/all.js b/public/app/features/dashboard/all.js
index 3315371a78f..242d464d77b 100644
--- a/public/app/features/dashboard/all.js
+++ b/public/app/features/dashboard/all.js
@@ -17,9 +17,9 @@ define([
'./upload',
'./import/dash_import',
'./export/export_modal',
+ './export_data/export_data_modal',
'./dash_list_ctrl',
'./ad_hoc_filters',
'./row/row_ctrl',
'./repeat_option/repeat_option',
- './exportCsvModalCtrl'
], function () {});
diff --git a/public/app/features/dashboard/exportCsvModalCtrl.ts b/public/app/features/dashboard/exportCsvModalCtrl.ts
deleted file mode 100644
index 0e2e2d3f232..00000000000
--- a/public/app/features/dashboard/exportCsvModalCtrl.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-///
-
-import config from 'app/core/config';
-import angular from 'angular';
-import _ from 'lodash';
-import * as fileExport from 'app/core/utils/file_export';
-
-const module = angular.module('grafana.controllers');
-
-export class ExportCsvModalCtrl {
- scope: any;
- seriesList: any = [];
- /** @ngInject */
- constructor(private $scope) {
- this.seriesList = $scope.seriesList;
- this.$scope = $scope;
- $scope.asRows = true;
- $scope.dateTimeFormat = 'YYYY-MM-DDTHH:mm:ssZ';
- $scope.export = this.export.bind(this);
- }
-
- export() {
- if (this.$scope.asRows) {
- fileExport.exportSeriesListToCsv(this.seriesList, this.$scope.dateTimeFormat);
- } else {
- fileExport.exportSeriesListToCsvColumns(this.seriesList, this.$scope.dateTimeFormat);
- }
- this.$scope.dismiss();
- }
-}
-
-module.controller('ExportCsvModalCtrl', ExportCsvModalCtrl);
diff --git a/public/app/features/dashboard/partials/exportCsvModal.html b/public/app/features/dashboard/export_data/export_data_modal.html
similarity index 53%
rename from public/app/features/dashboard/partials/exportCsvModal.html
rename to public/app/features/dashboard/export_data/export_data_modal.html
index ae3b4dfdf7d..ad6494f16cc 100644
--- a/public/app/features/dashboard/partials/exportCsvModal.html
+++ b/public/app/features/dashboard/export_data/export_data_modal.html
@@ -1,10 +1,10 @@
-
diff --git a/public/app/features/dashboard/export_data/export_data_modal.ts b/public/app/features/dashboard/export_data/export_data_modal.ts
new file mode 100644
index 00000000000..80b2ff7d2f2
--- /dev/null
+++ b/public/app/features/dashboard/export_data/export_data_modal.ts
@@ -0,0 +1,41 @@
+///
+
+import angular from 'angular';
+import * as fileExport from 'app/core/utils/file_export';
+import appEvents from 'app/core/app_events';
+
+export class ExportDataModalCtrl {
+ private data: any[];
+ asRows: Boolean = true;
+ dateTimeFormat: String = 'YYYY-MM-DDTHH:mm:ssZ';
+ /** @ngInject */
+ constructor(private $scope) { }
+
+ export() {
+ if (this.asRows) {
+ fileExport.exportSeriesListToCsv(this.data, this.dateTimeFormat);
+ } else {
+ fileExport.exportSeriesListToCsvColumns(this.data, this.dateTimeFormat);
+ }
+ this.dismiss();
+ }
+
+ dismiss() {
+ appEvents.emit('hide-modal');
+ }
+}
+
+export function exportDataModal() {
+ return {
+ restrict: 'E',
+ templateUrl: 'public/app/features/dashboard/export_data/export_data_modal.html',
+ controller: ExportDataModalCtrl,
+ controllerAs: 'ctrl',
+ scope: {
+ data: '<' // The difference to '=' is that the bound properties are not watched
+ },
+ bindToController: true
+ };
+}
+
+angular.module('grafana.directives').directive('exportDataModal', exportDataModal);
diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts
index 89c280ed5e5..e9ca8c5c4e2 100644
--- a/public/app/plugins/panel/graph/module.ts
+++ b/public/app/plugins/panel/graph/module.ts
@@ -311,11 +311,10 @@ class GraphCtrl extends MetricsPanelCtrl {
}
exportCsv() {
- var scope = this.$scope.$new();
+ var scope = this.$scope.$new(true);
scope.seriesList = this.seriesList;
-
this.publishAppEvent('show-modal', {
- src: 'public/app/features/dashboard/partials/exportCsvModal.html',
+ templateHtml: '',
scope,
modalClass: 'modal--narrow'
});