mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
[Timeline] Read resource utilizations during CSV export
This commit is contained in:
parent
546cde56a8
commit
f683ca44a2
@ -68,11 +68,12 @@ define([
|
||||
* @constructor
|
||||
* @memberof {platform/features/timeline}
|
||||
*/
|
||||
function TimelineColumnizer(domainObjects) {
|
||||
function TimelineColumnizer(domainObjects, resourceMap) {
|
||||
var maxComposition = 0,
|
||||
maxRelationships = 0,
|
||||
columnNames = {},
|
||||
columns = [],
|
||||
costKeys = [],
|
||||
foundTimespan = false,
|
||||
i;
|
||||
|
||||
@ -84,6 +85,14 @@ define([
|
||||
}
|
||||
}
|
||||
|
||||
function addCostProperties(costCapability) {
|
||||
costCapability.resources().forEach(function (key) {
|
||||
if (costKeys.indexOf(key) === -1) {
|
||||
costKeys.push(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
columns.push(new IdColumn());
|
||||
|
||||
domainObjects.forEach(function (domainObject) {
|
||||
@ -105,6 +114,10 @@ define([
|
||||
foundTimespan = true;
|
||||
}
|
||||
|
||||
if (domainObject.hasCapability('cost')) {
|
||||
addCostProperties(domainObject.getCapability('cost'));
|
||||
}
|
||||
|
||||
if (metadataProperties) {
|
||||
metadataProperties.forEach(addMetadataProperty);
|
||||
}
|
||||
@ -115,6 +128,10 @@ define([
|
||||
columns.push(new TimespanColumn(false));
|
||||
}
|
||||
|
||||
costKeys.forEach(function (key) {
|
||||
columns.push(new UtilizationColumn(resourceMap[key]));
|
||||
});
|
||||
|
||||
for (i = 0; i < maxComposition; i += 1) {
|
||||
columns.push(new CompositionColumn(i));
|
||||
}
|
||||
|
58
platform/features/timeline/src/actions/UtilizationColumn.js
Normal file
58
platform/features/timeline/src/actions/UtilizationColumn.js
Normal file
@ -0,0 +1,58 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2009-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([], function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A column showing utilization costs associated with activities.
|
||||
* @constructor
|
||||
* @param {string} key the key for the particular cost
|
||||
* @implements {platform/features/timeline.TimelineCSVColumn}
|
||||
*/
|
||||
function UtilizationColumn(resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
UtilizationColumn.prototype.name = function () {
|
||||
return this.resource.name;
|
||||
};
|
||||
|
||||
UtilizationColumn.prototype.value = function (domainObject) {
|
||||
var resource = this.resource;
|
||||
|
||||
function getUtilizationValue(utilizations) {
|
||||
utilizations = utilizations.filter(function (utilization) {
|
||||
return key === resource.key;
|
||||
});
|
||||
return utilizations.length === 1 ? utilizations[0].value : "";
|
||||
}
|
||||
|
||||
return !domainObject.hasCapability('utilization') ?
|
||||
"" :
|
||||
domainObject.getCapability('utilization').internal()
|
||||
.then(getUtilizationValue);
|
||||
};
|
||||
|
||||
return UtilizationColumn;
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user