From fab1def790c0fdb6ee8d00d970e4142ed6917109 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Wed, 16 May 2018 13:20:58 -0700 Subject: [PATCH] fixes issue #1999 - Use Object name as default export filename (#2001) * fixes issue #1999 add dynamic name(object name) to exportAsCSV filename * make requested changes --- .../features/table/res/templates/telemetry-table.html | 1 + .../features/table/src/controllers/MCTTableController.js | 9 +++++++-- .../table/src/controllers/TelemetryTableController.js | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/features/table/res/templates/telemetry-table.html b/platform/features/table/res/templates/telemetry-table.html index fa91a39d06..9f64ea29b6 100644 --- a/platform/features/table/res/templates/telemetry-table.html +++ b/platform/features/table/res/templates/telemetry-table.html @@ -9,6 +9,7 @@ enableSort="true" auto-scroll="autoScroll" default-sort="defaultSort" + export-as="{{ exportAs }}" class="tabular-holder has-control-bar"> diff --git a/platform/features/table/src/controllers/MCTTableController.js b/platform/features/table/src/controllers/MCTTableController.js index 4ad17304ff..9d814b4c7a 100644 --- a/platform/features/table/src/controllers/MCTTableController.js +++ b/platform/features/table/src/controllers/MCTTableController.js @@ -88,13 +88,18 @@ define( setDefaults($scope); $scope.exportAsCSV = function () { - var headers = $scope.displayHeaders; + var headers = $scope.displayHeaders, + filename = $(element[0]).attr('export-as'); + exportService.exportCSV($scope.displayRows.map(function (row) { return headers.reduce(function (r, header) { r[header] = row[header].text; return r; }, {}); - }), { headers: headers }); + }), { + headers: headers, + filename: filename + }); }; $scope.toggleSort = function (key) { diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index 1413c955ff..03b728bb37 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -78,6 +78,8 @@ define( this.domainObject = objectUtils.toNewFormat($scope.domainObject.getModel(), $scope.domainObject.getId()); + this.$scope.exportAs = this.$scope.domainObject.getModel().name; + _.bindAll(this, [ 'destroy', 'sortByTimeSystem',