exportCsvModalCtrl.ts 909 B

1234567891011121314151617181920212223242526272829303132
  1. ///<reference path="../../headers/common.d.ts" />
  2. import config from 'app/core/config';
  3. import angular from 'angular';
  4. import _ from 'lodash';
  5. import * as fileExport from 'app/core/utils/file_export';
  6. const module = angular.module('grafana.controllers');
  7. export class ExportCsvModalCtrl {
  8. scope: any;
  9. seriesList: any = [];
  10. /** @ngInject */
  11. constructor(private $scope) {
  12. this.seriesList = $scope.seriesList;
  13. this.$scope = $scope;
  14. $scope.asRows = true;
  15. $scope.dateTimeFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  16. $scope.export = this.export.bind(this);
  17. }
  18. export() {
  19. if (this.$scope.asRows) {
  20. fileExport.exportSeriesListToCsv(this.seriesList, this.$scope.dateTimeFormat);
  21. } else {
  22. fileExport.exportSeriesListToCsvColumns(this.seriesList, this.$scope.dateTimeFormat);
  23. }
  24. this.$scope.dismiss();
  25. }
  26. }
  27. module.controller('ExportCsvModalCtrl', ExportCsvModalCtrl);