mirror of
https://github.com/nasa/openmct.git
synced 2025-05-31 14:40:48 +00:00
[Table] Export table contents as CSV
This commit is contained in:
parent
f21f22d95c
commit
699f6ba458
@ -12,7 +12,7 @@ define(
|
|||||||
* @param element
|
* @param element
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MCTTableController($scope, $timeout, element) {
|
function MCTTableController($scope, $timeout, element, exportService) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
@ -47,7 +47,13 @@ define(
|
|||||||
setDefaults($scope);
|
setDefaults($scope);
|
||||||
|
|
||||||
$scope.exportAsCSV = function () {
|
$scope.exportAsCSV = function () {
|
||||||
window.alert("Export!");
|
var headers = $scope.headers;
|
||||||
|
exportService.exportCSV($scope.displayRows.map(function (row) {
|
||||||
|
return headers.reduce(function (r, header) {
|
||||||
|
r[header] = row[header].text;
|
||||||
|
return r;
|
||||||
|
}, {});
|
||||||
|
}), { headers: headers });
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggleSort = function (key) {
|
$scope.toggleSort = function (key) {
|
||||||
|
@ -81,7 +81,13 @@ define(
|
|||||||
return {
|
return {
|
||||||
restrict: "E",
|
restrict: "E",
|
||||||
template: TableTemplate,
|
template: TableTemplate,
|
||||||
controller: ['$scope', '$timeout', '$element', MCTTableController],
|
controller: [
|
||||||
|
'$scope',
|
||||||
|
'$timeout',
|
||||||
|
'$element',
|
||||||
|
'exportService',
|
||||||
|
MCTTableController
|
||||||
|
],
|
||||||
scope: {
|
scope: {
|
||||||
headers: "=",
|
headers: "=",
|
||||||
rows: "=",
|
rows: "=",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user