mirror of
https://github.com/nasa/openmct.git
synced 2025-05-29 13:44:21 +00:00
[Timeline] Inject resources into CSV action
This commit is contained in:
parent
f683ca44a2
commit
f16a107105
@ -93,7 +93,11 @@ define([
|
||||
"name": "Export Timeline as CSV",
|
||||
"category": "contextual",
|
||||
"implementation": ExportTimelineAsCSVAction,
|
||||
"depends": [ "exportService", "notificationService" ]
|
||||
"depends": [
|
||||
"exportService",
|
||||
"notificationService",
|
||||
"resources[]"
|
||||
]
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
|
@ -29,14 +29,21 @@ define(["./ExportTimelineAsCSVTask"], function (ExportTimelineAsCSVTask) {
|
||||
*
|
||||
* @param exportService the service used to perform the CSV export
|
||||
* @param notificationService the service used to show notifications
|
||||
* @param {Array} resources an array of `resources` extensions
|
||||
* @param context the Action's context
|
||||
* @implements {Action}
|
||||
* @constructor
|
||||
* @memberof {platform/features/timeline}
|
||||
*/
|
||||
function ExportTimelineAsCSVAction(exportService, notificationService, context) {
|
||||
function ExportTimelineAsCSVAction(
|
||||
exportService,
|
||||
notificationService,
|
||||
resources,
|
||||
context
|
||||
) {
|
||||
this.task = new ExportTimelineAsCSVTask(
|
||||
exportService,
|
||||
resources,
|
||||
context.domainObject
|
||||
);
|
||||
this.notificationService = notificationService;
|
||||
|
@ -37,11 +37,13 @@ define([
|
||||
* @constructor
|
||||
* @memberof {platform/features/timeline}
|
||||
* @param exportService the service used to export as CSV
|
||||
* @param resources the `resources` extension category
|
||||
* @param {DomainObject} domainObject the timeline being exported
|
||||
*/
|
||||
function ExportTimelineAsCSVTask(exportService, domainObject) {
|
||||
function ExportTimelineAsCSVTask(exportService, resources, domainObject) {
|
||||
this.domainObject = domainObject;
|
||||
this.exportService = exportService;
|
||||
this.resources = resources;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,7 +56,7 @@ define([
|
||||
var exportService = this.exportService;
|
||||
|
||||
function doExport(objects) {
|
||||
var exporter = new TimelineColumnizer(objects),
|
||||
var exporter = new TimelineColumnizer(objects, this.resources),
|
||||
options = { headers: exporter.headers() };
|
||||
return exporter.rows().then(function (rows) {
|
||||
return exportService.exportCSV(rows, options);
|
||||
|
@ -68,12 +68,11 @@ define([
|
||||
* @constructor
|
||||
* @memberof {platform/features/timeline}
|
||||
*/
|
||||
function TimelineColumnizer(domainObjects, resourceMap) {
|
||||
function TimelineColumnizer(domainObjects, resources) {
|
||||
var maxComposition = 0,
|
||||
maxRelationships = 0,
|
||||
columnNames = {},
|
||||
columns = [],
|
||||
costKeys = [],
|
||||
foundTimespan = false,
|
||||
i;
|
||||
|
||||
@ -114,10 +113,6 @@ define([
|
||||
foundTimespan = true;
|
||||
}
|
||||
|
||||
if (domainObject.hasCapability('cost')) {
|
||||
addCostProperties(domainObject.getCapability('cost'));
|
||||
}
|
||||
|
||||
if (metadataProperties) {
|
||||
metadataProperties.forEach(addMetadataProperty);
|
||||
}
|
||||
@ -128,8 +123,8 @@ define([
|
||||
columns.push(new TimespanColumn(false));
|
||||
}
|
||||
|
||||
costKeys.forEach(function (key) {
|
||||
columns.push(new UtilizationColumn(resourceMap[key]));
|
||||
resources.forEach(function (resource) {
|
||||
columns.push(new UtilizationColumn(resource));
|
||||
});
|
||||
|
||||
for (i = 0; i < maxComposition; i += 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user