From 1a10c966e01081acbf7f932d7f7550011ce038b5 Mon Sep 17 00:00:00 2001 From: Deep Tailor Date: Fri, 20 Jul 2018 15:45:30 -0700 Subject: [PATCH] deprecated timeline (#2119) * first release of deprecated timeline * Better deprecation message and use unknown icon class * Update deprecated-timeline-message.html Added a period to end of sentence. * remove unused files, and commented code - If we need timeline again we can recover from git * Provide link to tracker in deprecation message --- platform/features/timeline/bundle.js | 598 +----------------- .../timeline/res/sass/_activities.scss | 77 --- .../res/sass/_constants-espresso.scss | 42 -- .../timeline/res/sass/_constants-snow.scss | 42 -- .../timeline/res/sass/_constants.scss | 63 -- .../timeline/res/sass/_timeline-thematic.scss | 185 ------ .../timeline/res/sass/_timelines.scss | 333 ---------- .../timeline/res/sass/timeline-espresso.scss | 33 - .../timeline/res/sass/timeline-snow.scss | 32 - .../features/timeline/res/sass/timeline.scss | 32 - .../res/templates/activity-gantt.html | 38 -- .../res/templates/controls/datetime.html | 83 --- .../deprecated-timeline-message.html | 10 + .../timeline/res/templates/legend-item.html | 34 - .../res/templates/resource-graph-labels.html | 37 -- .../res/templates/resource-graphs.html | 34 - .../templates/tabular-swimlane-cols-data.html | 37 -- .../templates/tabular-swimlane-cols-tree.html | 57 -- .../timeline/res/templates/ticks.html | 39 -- .../timeline/res/templates/timeline.html | 223 ------- .../timeline/res/templates/values.html | 27 - .../timeline/src/TimelineConstants.js | 31 - .../timeline/src/TimelineFormatter.js | 76 --- .../timeline/src/actions/CompositionColumn.js | 54 -- .../src/actions/ExportTimelineAsCSVAction.js | 79 --- .../src/actions/ExportTimelineAsCSVTask.js | 71 --- .../features/timeline/src/actions/IdColumn.js | 46 -- .../timeline/src/actions/MetadataColumn.js | 48 -- .../timeline/src/actions/ModeColumn.js | 52 -- .../src/actions/TimelineColumnizer.js | 172 ----- .../timeline/src/actions/TimelineTraverser.js | 83 --- .../timeline/src/actions/TimespanColumn.js | 53 -- .../timeline/src/actions/UtilizationColumn.js | 72 --- .../src/capabilities/ActivityTimespan.js | 119 ---- .../ActivityTimespanCapability.js | 61 -- .../src/capabilities/ActivityUtilization.js | 50 -- .../src/capabilities/CostCapability.js | 75 --- .../src/capabilities/CumulativeGraph.js | 152 ----- .../src/capabilities/GraphCapability.js | 100 --- .../src/capabilities/ResourceGraph.js | 147 ----- .../src/capabilities/TimelineTimespan.js | 124 ---- .../TimelineTimespanCapability.js | 87 --- .../src/capabilities/TimelineUtilization.js | 50 -- .../src/capabilities/UtilizationCapability.js | 224 ------- .../timeline/src/chart/Canvas2DChart.js | 117 ---- .../features/timeline/src/chart/GLChart.js | 160 ----- .../timeline/src/chart/MCTTimelineChart.js | 250 -------- .../ActivityModeValuesController.js | 60 -- .../src/controllers/TimelineController.js | 143 ----- .../controllers/TimelineDateTimeController.js | 91 --- .../controllers/TimelineGanttController.js | 86 --- .../controllers/TimelineGraphController.js | 95 --- .../src/controllers/TimelineTOIController.js | 111 ---- .../controllers/TimelineTableController.js | 51 -- .../src/controllers/TimelineTickController.js | 116 ---- .../src/controllers/TimelineZoomController.js | 155 ----- .../drag/TimelineDragHandleFactory.js | 74 --- .../controllers/drag/TimelineDragHandler.js | 248 -------- .../controllers/drag/TimelineDragPopulator.js | 95 --- .../src/controllers/drag/TimelineEndHandle.js | 96 --- .../controllers/drag/TimelineMoveHandle.js | 131 ---- .../controllers/drag/TimelineSnapHandler.js | 106 ---- .../controllers/drag/TimelineStartHandle.js | 96 --- .../src/controllers/graph/TimelineGraph.js | 189 ------ .../graph/TimelineGraphPopulator.js | 158 ----- .../graph/TimelineGraphRenderer.js | 81 --- .../swimlane/TimelineColorAssigner.js | 120 ---- .../src/controllers/swimlane/TimelineProxy.js | 77 --- .../controllers/swimlane/TimelineSwimlane.js | 173 ----- .../swimlane/TimelineSwimlaneDecorator.js | 113 ---- .../swimlane/TimelineSwimlaneDropHandler.js | 207 ------ .../swimlane/TimelineSwimlanePopulator.js | 212 ------- .../src/directives/MCTResourceGraphDrop.js | 81 --- .../src/directives/MCTSwimlaneDrag.js | 66 -- .../src/directives/MCTSwimlaneDrop.js | 147 ----- .../src/directives/SwimlaneDragConstants.js | 40 -- .../timeline/src/services/ObjectLoader.js | 133 ---- .../timeline/test/TimelineConstantsSpec.js | 33 - .../timeline/test/TimelineFormatterSpec.js | 60 -- .../test/actions/CompositionColumnSpec.js | 78 --- .../actions/ExportTimelineAsCSVActionSpec.js | 165 ----- .../actions/ExportTimelineAsCSVTaskSpec.js | 73 --- .../timeline/test/actions/IdColumnSpec.js | 60 -- .../test/actions/MetadataColumnSpec.js | 75 --- .../timeline/test/actions/ModeColumnSpec.js | 82 --- .../test/actions/TimelineColumnizerSpec.js | 118 ---- .../test/actions/TimelineTraverserSpec.js | 132 ---- .../test/actions/TimespanColumnSpec.js | 90 --- .../ActivityTimespanCapabilitySpec.js | 90 --- .../test/capabilities/ActivityTimespanSpec.js | 99 --- .../capabilities/ActivityUtilizationSpec.js | 39 -- .../test/capabilities/CostCapabilitySpec.js | 79 --- .../test/capabilities/CumulativeGraphSpec.js | 86 --- .../test/capabilities/GraphCapabilitySpec.js | 118 ---- .../test/capabilities/ResourceGraphSpec.js | 75 --- .../TimelineTimespanCapabilitySpec.js | 138 ---- .../test/capabilities/TimelineTimespanSpec.js | 110 ---- .../capabilities/TimelineUtilizationSpec.js | 39 -- .../capabilities/UtilizationCapabilitySpec.js | 214 ------- .../timeline/test/chart/Canvas2DChartSpec.js | 95 --- .../timeline/test/chart/GLChartSpec.js | 143 ----- .../test/chart/MCTTimelineChartSpec.js | 216 ------- .../ActivityModeValuesControllerSpec.js | 51 -- .../controllers/TimelineControllerSpec.js | 240 ------- .../TimelineDateTimeControllerSpec.js | 76 --- .../TimelineGanttControllerSpec.js | 101 --- .../TimelineGraphControllerSpec.js | 87 --- .../controllers/TimelineTOIControllerSpec.js | 138 ---- .../TimelineTableControllerSpec.js | 50 -- .../controllers/TimelineTickControllerSpec.js | 86 --- .../controllers/TimelineZoomControllerSpec.js | 154 ----- .../drag/TimelineDragHandleFactorySpec.js | 85 --- .../drag/TimelineDragHandlerSpec.js | 207 ------ .../drag/TimelineDragPopulatorSpec.js | 72 --- .../controllers/drag/TimelineEndHandleSpec.js | 115 ---- .../drag/TimelineMoveHandleSpec.js | 182 ------ .../drag/TimelineSnapHandlerSpec.js | 79 --- .../drag/TimelineStartHandleSpec.js | 114 ---- .../graph/TimelineGraphPopulatorSpec.js | 151 ----- .../graph/TimelineGraphRendererSpec.js | 75 --- .../controllers/graph/TimelineGraphSpec.js | 170 ----- .../swimlane/TimelineColorAssignerSpec.js | 88 --- .../controllers/swimlane/TimelineProxySpec.js | 106 ---- .../swimlane/TimelineSwimlaneDecoratorSpec.js | 183 ------ .../TimelineSwimlaneDropHandlerSpec.js | 237 ------- .../swimlane/TimelineSwimlanePopulatorSpec.js | 163 ----- .../swimlane/TimelineSwimlaneSpec.js | 223 ------- .../directives/MCTResourceGraphDropSpec.js | 159 ----- .../test/directives/MCTSwimlaneDragSpec.js | 95 --- .../test/directives/MCTSwimlaneDropSpec.js | 176 ------ .../directives/SwimlaneDragConstantsSpec.js | 34 - .../test/services/ObjectLoaderSpec.js | 159 ----- 132 files changed, 25 insertions(+), 14498 deletions(-) delete mode 100644 platform/features/timeline/res/sass/_activities.scss delete mode 100644 platform/features/timeline/res/sass/_constants-espresso.scss delete mode 100644 platform/features/timeline/res/sass/_constants-snow.scss delete mode 100644 platform/features/timeline/res/sass/_constants.scss delete mode 100644 platform/features/timeline/res/sass/_timeline-thematic.scss delete mode 100644 platform/features/timeline/res/sass/_timelines.scss delete mode 100644 platform/features/timeline/res/sass/timeline-espresso.scss delete mode 100644 platform/features/timeline/res/sass/timeline-snow.scss delete mode 100644 platform/features/timeline/res/sass/timeline.scss delete mode 100644 platform/features/timeline/res/templates/activity-gantt.html delete mode 100644 platform/features/timeline/res/templates/controls/datetime.html create mode 100644 platform/features/timeline/res/templates/deprecated-timeline-message.html delete mode 100644 platform/features/timeline/res/templates/legend-item.html delete mode 100644 platform/features/timeline/res/templates/resource-graph-labels.html delete mode 100644 platform/features/timeline/res/templates/resource-graphs.html delete mode 100644 platform/features/timeline/res/templates/tabular-swimlane-cols-data.html delete mode 100644 platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html delete mode 100644 platform/features/timeline/res/templates/ticks.html delete mode 100644 platform/features/timeline/res/templates/timeline.html delete mode 100644 platform/features/timeline/res/templates/values.html delete mode 100644 platform/features/timeline/src/TimelineConstants.js delete mode 100644 platform/features/timeline/src/TimelineFormatter.js delete mode 100644 platform/features/timeline/src/actions/CompositionColumn.js delete mode 100644 platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js delete mode 100644 platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js delete mode 100644 platform/features/timeline/src/actions/IdColumn.js delete mode 100644 platform/features/timeline/src/actions/MetadataColumn.js delete mode 100644 platform/features/timeline/src/actions/ModeColumn.js delete mode 100644 platform/features/timeline/src/actions/TimelineColumnizer.js delete mode 100644 platform/features/timeline/src/actions/TimelineTraverser.js delete mode 100644 platform/features/timeline/src/actions/TimespanColumn.js delete mode 100644 platform/features/timeline/src/actions/UtilizationColumn.js delete mode 100644 platform/features/timeline/src/capabilities/ActivityTimespan.js delete mode 100644 platform/features/timeline/src/capabilities/ActivityTimespanCapability.js delete mode 100644 platform/features/timeline/src/capabilities/ActivityUtilization.js delete mode 100644 platform/features/timeline/src/capabilities/CostCapability.js delete mode 100644 platform/features/timeline/src/capabilities/CumulativeGraph.js delete mode 100644 platform/features/timeline/src/capabilities/GraphCapability.js delete mode 100644 platform/features/timeline/src/capabilities/ResourceGraph.js delete mode 100644 platform/features/timeline/src/capabilities/TimelineTimespan.js delete mode 100644 platform/features/timeline/src/capabilities/TimelineTimespanCapability.js delete mode 100644 platform/features/timeline/src/capabilities/TimelineUtilization.js delete mode 100644 platform/features/timeline/src/capabilities/UtilizationCapability.js delete mode 100644 platform/features/timeline/src/chart/Canvas2DChart.js delete mode 100644 platform/features/timeline/src/chart/GLChart.js delete mode 100644 platform/features/timeline/src/chart/MCTTimelineChart.js delete mode 100644 platform/features/timeline/src/controllers/ActivityModeValuesController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineDateTimeController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineGanttController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineGraphController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineTOIController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineTableController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineTickController.js delete mode 100644 platform/features/timeline/src/controllers/TimelineZoomController.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineDragHandler.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineEndHandle.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js delete mode 100644 platform/features/timeline/src/controllers/drag/TimelineStartHandle.js delete mode 100644 platform/features/timeline/src/controllers/graph/TimelineGraph.js delete mode 100644 platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js delete mode 100644 platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js delete mode 100644 platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js delete mode 100644 platform/features/timeline/src/controllers/swimlane/TimelineProxy.js delete mode 100644 platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js delete mode 100644 platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js delete mode 100644 platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js delete mode 100644 platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js delete mode 100644 platform/features/timeline/src/directives/MCTResourceGraphDrop.js delete mode 100644 platform/features/timeline/src/directives/MCTSwimlaneDrag.js delete mode 100644 platform/features/timeline/src/directives/MCTSwimlaneDrop.js delete mode 100644 platform/features/timeline/src/directives/SwimlaneDragConstants.js delete mode 100644 platform/features/timeline/src/services/ObjectLoader.js delete mode 100644 platform/features/timeline/test/TimelineConstantsSpec.js delete mode 100644 platform/features/timeline/test/TimelineFormatterSpec.js delete mode 100644 platform/features/timeline/test/actions/CompositionColumnSpec.js delete mode 100644 platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js delete mode 100644 platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js delete mode 100644 platform/features/timeline/test/actions/IdColumnSpec.js delete mode 100644 platform/features/timeline/test/actions/MetadataColumnSpec.js delete mode 100644 platform/features/timeline/test/actions/ModeColumnSpec.js delete mode 100644 platform/features/timeline/test/actions/TimelineColumnizerSpec.js delete mode 100644 platform/features/timeline/test/actions/TimelineTraverserSpec.js delete mode 100644 platform/features/timeline/test/actions/TimespanColumnSpec.js delete mode 100644 platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js delete mode 100644 platform/features/timeline/test/capabilities/ActivityTimespanSpec.js delete mode 100644 platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js delete mode 100644 platform/features/timeline/test/capabilities/CostCapabilitySpec.js delete mode 100644 platform/features/timeline/test/capabilities/CumulativeGraphSpec.js delete mode 100644 platform/features/timeline/test/capabilities/GraphCapabilitySpec.js delete mode 100644 platform/features/timeline/test/capabilities/ResourceGraphSpec.js delete mode 100644 platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js delete mode 100644 platform/features/timeline/test/capabilities/TimelineTimespanSpec.js delete mode 100644 platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js delete mode 100644 platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js delete mode 100644 platform/features/timeline/test/chart/Canvas2DChartSpec.js delete mode 100644 platform/features/timeline/test/chart/GLChartSpec.js delete mode 100644 platform/features/timeline/test/chart/MCTTimelineChartSpec.js delete mode 100644 platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineTOIControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineTableControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineTickControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js delete mode 100644 platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js delete mode 100644 platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js delete mode 100644 platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js delete mode 100644 platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js delete mode 100644 platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js delete mode 100644 platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js delete mode 100644 platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js delete mode 100644 platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js delete mode 100644 platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js delete mode 100644 platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js delete mode 100644 platform/features/timeline/test/directives/MCTResourceGraphDropSpec.js delete mode 100644 platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js delete mode 100644 platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js delete mode 100644 platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js delete mode 100644 platform/features/timeline/test/services/ObjectLoaderSpec.js diff --git a/platform/features/timeline/bundle.js b/platform/features/timeline/bundle.js index d7a8463de0..34b387cf4e 100644 --- a/platform/features/timeline/bundle.js +++ b/platform/features/timeline/bundle.js @@ -21,597 +21,29 @@ *****************************************************************************/ define([ - "./src/actions/ExportTimelineAsCSVAction", - "./src/controllers/TimelineController", - "./src/controllers/TimelineGraphController", - "./src/controllers/TimelineDateTimeController", - "./src/controllers/TimelineZoomController", - "./src/controllers/TimelineTickController", - "./src/controllers/TimelineTableController", - "./src/controllers/TimelineGanttController", - "./src/controllers/TimelineTOIController", - "./src/controllers/ActivityModeValuesController", - "./src/capabilities/ActivityTimespanCapability", - "./src/capabilities/TimelineTimespanCapability", - "./src/capabilities/UtilizationCapability", - "./src/capabilities/GraphCapability", - "./src/capabilities/CostCapability", - "./src/directives/MCTSwimlaneDrop", - "./src/directives/MCTSwimlaneDrag", - "./src/directives/MCTResourceGraphDrop", - "./src/services/ObjectLoader", - "./src/chart/MCTTimelineChart", - "text!./res/templates/values.html", - "text!./res/templates/timeline.html", - "text!./res/templates/activity-gantt.html", - "text!./res/templates/tabular-swimlane-cols-tree.html", - "text!./res/templates/tabular-swimlane-cols-data.html", - "text!./res/templates/resource-graphs.html", - "text!./res/templates/resource-graph-labels.html", - "text!./res/templates/legend-item.html", - "text!./res/templates/ticks.html", - "text!./res/templates/controls/datetime.html", + "text!./res/templates/deprecated-timeline-message.html", 'legacyRegistry' ], function ( - ExportTimelineAsCSVAction, - TimelineController, - TimelineGraphController, - TimelineDateTimeController, - TimelineZoomController, - TimelineTickController, - TimelineTableController, - TimelineGanttController, - TimelineTOIController, - ActivityModeValuesController, - ActivityTimespanCapability, - TimelineTimespanCapability, - UtilizationCapability, - GraphCapability, - CostCapability, - MCTSwimlaneDrop, - MCTSwimlaneDrag, - MCTResourceGraphDrop, - ObjectLoader, - MCTTimelineChart, - valuesTemplate, - timelineTemplate, - activityGanttTemplate, - tabularSwimlaneColsTreeTemplate, - tabularSwimlaneColsDataTemplate, - resourceGraphsTemplate, - resourceGraphLabelsTemplate, - legendItemTemplate, - ticksTemplate, - datetimeTemplate, + deprecatedTimelineMessage, legacyRegistry ) { - - legacyRegistry.register("platform/features/timeline", { - "name": "Timelines", - "description": "Resources, templates, CSS, and code for Timelines.", - "resources": "res", - "extensions": { - "actions": [ + legacyRegistry.register('platform/features/timeline', { + extensions: { + types: [ { - "key": "timeline.export", - "name": "Export Timeline as CSV", - "category": "contextual", - "implementation": ExportTimelineAsCSVAction, - "depends": [ - "$log", - "exportService", - "notificationService", - "resources[]" - ] + key: "timeline", + name: "Timeline", + description: "Timeline, Activity and Activity Mode objects have been deprecated and will no longer be supported. (07/18/2018)", + priority: 502 } ], - "constants": [ + views: [ { - "key": "TIMELINE_MINIMUM_DURATION", - "description": "The minimum duration to display in a timeline view (one hour.)", - "value": 3600000 - }, - { - "key": "TIMELINE_MAXIMUM_OFFSCREEN", - "description": "Maximum amount, in pixels, of a Gantt bar which may go off screen.", - "value": 1000 - }, - { - "key": "TIMELINE_ZOOM_CONFIGURATION", - "description": "Describes major tick sizes in milliseconds, and width in pixels.", - "value": { - "levels": [ - 1000, - 2000, - 5000, - 10000, - 20000, - 30000, - 60000, - 120000, - 300000, - 600000, - 1200000, - 1800000, - 3600000, - 7200000, - 14400000, - 28800000, - 43200000, - 86400000, - 86400000 * 2, - 86400000 * 5, - 86400000 * 10, - 86400000 * 20, - 86400000 * 30, - 86400000 * 60, - 86400000 * 120, - 86400000 * 240, - 86400000 * 365 - ], - "width": 200 - } - } - ], - "types": [ - { - "key": "timeline", - "name": "Timeline", - "cssClass": "icon-timeline", - "description": "A time-oriented container that lets you enclose and organize other Timelines and Activities. The Timeline view provides both tabular and Gantt views as well as resource utilization graphing of Activities.", - "priority": 502, - "features": [ - "creation" - ], - "contains": [ - "timeline", - "activity" - ], - "properties": [ - { - "name": "Start date/time", - "control": "timeline-datetime", - "required": true, - "property": [ - "start" - ], - "options": [ - "SET" - ] - }, - { - "name": "Battery capacity (Watt-hours)", - "control": "textfield", - "required": false, - "conversion": "number", - "property": [ - "capacity" - ], - "pattern": "^-?\\d+(\\.\\d*)?$" - }, - { - "name": "Battery starting SOC (%)", - "control": "textfield", - "required": false, - "conversion": "number", - "property": [ - "startingSOC" - ], - "pattern": "^([0-9](\\.\\d*)?|[1-9][0-9](\\.\\d*)?|100)%?$" - } - ], - "model": { - "composition": [], - "start": { - "timestamp": 0 - } - } - }, - { - "key": "activity", - "name": "Activity", - "cssClass": "icon-activity", - "features": [ - "creation" - ], - "contains": [ - "activity" - ], - "description": "An event or process that starts and ends at a discrete datetime. Activities can be nested in other Activities, and can be added to Timelines. Activity Modes can be added to an Activity to define its resource utilization over time.", - "priority": 501, - "properties": [ - { - "name": "Start date/time", - "control": "timeline-datetime", - "required": true, - "property": [ - "start" - ], - "options": [ - "SET" - ] - }, - { - "name": "Duration", - "control": "duration", - "required": true, - "property": [ - "duration" - ] - } - ], - "model": { - "composition": [], - "relationships": { - "modes": [] - }, - "start": { - "timestamp": 0 - }, - "duration": { - "timestamp": 0 - } - } - }, - { - "key": "mode", - "name": "Activity Mode", - "cssClass": "icon-activity-mode", - "features": [ - "creation" - ], - "description": "When a sub-system utilizes Power or Communications resources over time, you can define those values in an Activity Mode. Activity Modes can then be linked to Activities to allow resource utilization graphing and estimating in a Timeline.", - "priority": 500, - "model": { - "resources": { - "comms": 0, - "power": 0 - } - }, - "properties": [ - { - "name": "Comms (Kbps)", - "control": "textfield", - "conversion": "number", - "pattern": "^-?\\d+(\\.\\d*)?$", - "property": [ - "resources", - "comms" - ] - }, - { - "name": "Power (watts)", - "control": "textfield", - "conversion": "number", - "pattern": "^-?\\d+(\\.\\d*)?$", - "property": [ - "resources", - "power" - ] - } - ] - } - ], - "views": [ - { - "key": "values", - "name": "Values", - "cssClass": "icon-activity-mode", - "template": valuesTemplate, - "type": "mode", - "uses": [ - "cost" - ], - "editable": false - }, - { - "key": "timeline", - "name": "Timeline", - "cssClass": "icon-timeline", - "type": "timeline", - "description": "A time-oriented container that lets you enclose and organize other Timelines and Activities. The Timeline view provides both tabular and Gantt views as well as resource utilization graphing of Activities.", - "template": timelineTemplate, - "editable": true, - "toolbar": { - "sections": [ - { - "items": [ - { - "method": "add", - "control": "menu-button", - "text": "Add", - "options": [ - { - "name": "Timeline", - "cssClass": "icon-timeline", - "key": "timeline" - }, - { - "name": "Activity", - "cssClass": "icon-activity", - "key": "activity" - } - ] - } - ] - }, - { - "items": [ - { - "cssClass": "icon-plot-resource", - "description": "Graph Resource Utilization", - "control": "button", - "method": "toggleGraph" - }, - { - "cssClass": "icon-activity-mode", - "control": "dialog-button", - "description": "Apply Activity Modes...", - "title": "Apply Activity Modes", - "dialog": { - "control": "selector", - "name": "Modes", - "type": "mode", - "layout": "controls-under" - }, - "property": "modes" - }, - { - "cssClass": "icon-chain-links", - "description": "Edit Activity Link", - "title": "Activity Link", - "control": "dialog-button", - "dialog": { - "control": "textfield", - "name": "Link", - "pattern": "^(ftp|https?)\\:\\/\\/\\w+(\\.\\w+)*(\\:\\d+)?(\\/\\S*)*$", - "cssClass": "l-input-lg" - }, - "property": "link" - }, - { - "cssClass": "icon-gear", - "description": "Edit Properties...", - "control": "button", - "method": "properties" - } - ] - }, - { - "items": [ - { - "method": "remove", - "description": "Remove Item", - "control": "button", - "cssClass": "icon-trash" - } - ] - } - ] - } - } - ], - "stylesheets": [ - { - "stylesheetUrl": "css/timeline.css" - }, - { - "stylesheetUrl": "css/timeline-espresso.css", - "theme": "espresso" - }, - { - "stylesheetUrl": "css/timeline-snow.css", - "theme": "snow" - } - ], - "representations": [ - { - "key": "gantt", - "template": activityGanttTemplate, - "uses": [ - "timespan", - "type" - ] - } - ], - "templates": [ - { - "key": "timeline-tabular-swimlane-cols-tree", - "priority": "mandatory", - "template": tabularSwimlaneColsTreeTemplate - }, - { - "key": "timeline-tabular-swimlane-cols-data", - "priority": "mandatory", - "template": tabularSwimlaneColsDataTemplate - }, - { - "key": "timeline-resource-graphs", - "priority": "mandatory", - "template": resourceGraphsTemplate - }, - { - "key": "timeline-resource-graph-labels", - "priority": "mandatory", - "template": resourceGraphLabelsTemplate - }, - { - "key": "timeline-legend-item", - "priority": "mandatory", - "template": legendItemTemplate - }, - { - "key": "timeline-ticks", - "priority": "mandatory", - "template": ticksTemplate - } - ], - "controls": [ - { - "key": "timeline-datetime", - "template": datetimeTemplate - }, - { - "key": "duration", - "template": datetimeTemplate - } - ], - "controllers": [ - { - "key": "TimelineController", - "implementation": TimelineController, - "depends": [ - "$scope", - "$q", - "objectLoader", - "TIMELINE_MINIMUM_DURATION" - ] - }, - { - "key": "TimelineGraphController", - "implementation": TimelineGraphController, - "depends": [ - "$scope", - "resources[]" - ] - }, - { - "key": "TimelineDateTimeController", - "implementation": TimelineDateTimeController, - "depends": [ - "$scope" - ] - }, - { - "key": "TimelineZoomController", - "implementation": TimelineZoomController, - "depends": [ - "$scope", - "$window", - "TIMELINE_ZOOM_CONFIGURATION" - ] - }, - { - "key": "TimelineTickController", - "implementation": TimelineTickController - }, - { - "key": "TimelineTableController", - "implementation": TimelineTableController - }, - { - "key": "TimelineGanttController", - "implementation": TimelineGanttController, - "depends": [ - "TIMELINE_MAXIMUM_OFFSCREEN" - ] - }, - { - "key": "TimelineTOIController", - "implementation": TimelineTOIController, - "depends": [ - "openmct", - "timerService", - "$scope" - ] - }, - { - "key": "ActivityModeValuesController", - "implementation": ActivityModeValuesController, - "depends": [ - "resources[]" - ] - } - ], - "capabilities": [ - { - "key": "timespan", - "implementation": ActivityTimespanCapability, - "depends": [ - "$q" - ] - }, - { - "key": "timespan", - "implementation": TimelineTimespanCapability, - "depends": [ - "$q" - ] - }, - { - "key": "utilization", - "implementation": UtilizationCapability, - "depends": [ - "$q" - ] - }, - { - "key": "graph", - "implementation": GraphCapability, - "depends": [ - "$q" - ] - }, - { - "key": "cost", - "implementation": CostCapability - } - ], - "directives": [ - { - "key": "mctSwimlaneDrop", - "implementation": MCTSwimlaneDrop, - "depends": [ - "dndService" - ] - }, - { - "key": "mctSwimlaneDrag", - "implementation": MCTSwimlaneDrag, - "depends": [ - "dndService" - ] - }, - { - "key": "mctTimelineChart", - "implementation": MCTTimelineChart, - "depends": [ - "$interval", - "$log" - ] - }, - { - "key": "mctResourceGraphDrop", - "implementation": MCTResourceGraphDrop, - "depends": [ - "dndService" - ] - } - ], - "services": [ - { - "key": "objectLoader", - "implementation": ObjectLoader, - "depends": [ - "$q" - ] - } - ], - "resources": [ - { - "key": "power", - "name": "Power", - "units": "watts" - }, - { - "key": "comms", - "name": "Comms", - "units": "Kbps" - }, - { - "key": "battery", - "name": "Battery State-of-Charge", - "units": "%" + key: "timeline", + name: "Timeline", + type: "timeline", + description: "Timeline, Activity and Activity Mode objects have been deprecated and will no longer be supported. (07/18/2018)", + template: deprecatedTimelineMessage } ] } diff --git a/platform/features/timeline/res/sass/_activities.scss b/platform/features/timeline/res/sass/_activities.scss deleted file mode 100644 index 55ead35628..0000000000 --- a/platform/features/timeline/res/sass/_activities.scss +++ /dev/null @@ -1,77 +0,0 @@ -.l-timeline-gantt { - min-width: 2px; - overflow: hidden; - position: absolute; - top: $timelineSwimlaneGanttVM; bottom: $timelineSwimlaneGanttVM; - - .bar { - @include ellipsize(); - height: $activityBarH; - line-height: $activityBarH; - padding: 0 $interiorMargin; - - span { - $iconW: 20px; - @include absPosDefault(); - display: block; - &.s-activity-type { - right: auto; width: $iconW; - text-align: center; - &.timeline { - &:before { - content:"S"; - } - } - &.activity { - &:before { - content:"A"; - } - } - } - &.s-title { - overflow: hidden; - text-overflow: ellipsis; - left: $iconW; - } - &.duration { - left: auto; - opacity: 0.75; - right: 0; - text-align: right; - width: 60px; - } - &.handle { - top: 0; - bottom: 0; - height: auto; - width: 15px; - &.left { - right: auto; - } - &.middle { - right: 15px; - left: 15px; - width: auto; - } - &.right { - right: 0; - left: auto; - } - } - } - } - &.sm .bar span { - // Hide icon and label if width is too small - display: none; - } -} - -.edit-mode .s-timeline-gantt, -.s-status-editing .s-timeline-gantt { - .handle { - cursor: col-resize; - &.mid { - cursor: ew-resize; - } - } -} diff --git a/platform/features/timeline/res/sass/_constants-espresso.scss b/platform/features/timeline/res/sass/_constants-espresso.scss deleted file mode 100644 index 426ed4a23d..0000000000 --- a/platform/features/timeline/res/sass/_constants-espresso.scss +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -// General -$timelineHeaderColorBg: pullForward($colorBodyBg, 5%); -$timelineColorAlt1: pullForward($timelineHeaderColorBg, 10%); -$colorGanttBarBg: #5555aa; -$colorGanttBarFg: #fff; -$colorGanttBarSelectedBg: #ccc; -$colorGanttBarSelectedFg: #333; -$colorGanttBarTabularFgIcon: #8594ff; - -// Swimlane colors -$colorDropTarg: rgba($colorGanttBarBg, 0.4); -$colorSwimlaneSelectedBg: #222; -$colorSwimlaneSelectedFg: #ccc; -$colorGanttToggle: $colorKey; -$shdwGanttBar: rgba(black, 0.4) 0 1px 3px; - -// Resource graphs -$timelineResourceGraphBg: rgba(black, 0.2); -$timelineResourceGraphFg: $colorBodyFg; -$timelineResourceGraphLegendFg: $colorBodyFg; diff --git a/platform/features/timeline/res/sass/_constants-snow.scss b/platform/features/timeline/res/sass/_constants-snow.scss deleted file mode 100644 index aaeedd3b25..0000000000 --- a/platform/features/timeline/res/sass/_constants-snow.scss +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -// General -$timelineHeaderColorBg: pullForward($colorBodyBg, 5%); -$timelineColorAlt1: pullForward($timelineHeaderColorBg, 10%); -$colorGanttBarBg: #5555aa; -$colorGanttBarFg: #fff; -$colorGanttBarSelectedBg: $colorGanttBarBg; -$colorGanttBarSelectedFg: $colorGanttBarFg; -$colorGanttBarTabularFgIcon: #8594ff; - -// Swimlane colors -$colorDropTarg: rgba($colorGanttBarBg, 0.4); -$colorSwimlaneSelectedBg: rgba($colorGanttBarBg, 0.25); -$colorSwimlaneSelectedFg: pullForward($colorBodyFg, 10%); -$colorGanttToggle: $colorKey; -$shdwGanttBar: rgba(black, 0.1) 0 1px 3px; - -// Resource graphs -$timelineResourceGraphBg: $colorPlotBg; -$timelineResourceGraphFg: $colorBodyFg; -$timelineResourceGraphLegendFg: $colorBodyFg; diff --git a/platform/features/timeline/res/sass/_constants.scss b/platform/features/timeline/res/sass/_constants.scss deleted file mode 100644 index 8836f5b7fd..0000000000 --- a/platform/features/timeline/res/sass/_constants.scss +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -@mixin activityBg($bg, $gamma: 10) { - @include background-image(linear-gradient(lighten($bg, $gamma), $bg)); -} - -// Timeline constants -$activityBarH: 17px; -$timelinePaneLeftW: 30%; -$timelinePaneBtmH: 30%; -$timelineResourceGraphYLabelsMargin: 70px; -$timelineTopPaneHeaderH: 30px; - -$timelineSwimlaneGanttVM: 2px; // The vertical space above and below the gantt bars -$timelineSwimlaneH: $activityBarH + ($timelineSwimlaneGanttVM * 2); -$timelineTopPaneHeaderElemMargin: $interiorMargin; - -// Timeline Tabular constants -$timelineColIconW: 16px; -$timelineColResourcePlotW: $timelineColIconW; -$timelineColTitleW: 250px; -$timelineColDatetimeW: 110px; -$timelineColDurationW: 70px; -$timelineColActivityModesW: $timelineColTitleW; -$timelineColPadR: 50px; -$timelineTabularTitleW: $timelineColResourcePlotW + $timelineColTitleW; -$timelineTabularDataW: ($timelineColDatetimeW * 2) + $timelineColDurationW + $timelineColActivityModesW + $timelineColPadR; - - -// // Ported from legacy timelines SASS -$activitiesHolderM: 30px; -$scenarioTopPad: 25px; -$swimlaneVM: 2px; -$timelineVM: 10px; -$timelineBPad: $interiorMargin * 2; -$graphResourceSummaryH: 200px; -$graphResourceSummaryLegendH: 20px; -$scenarioTimelineSummaryH: 20px; -$scenarioTimelineSummaryHExpanded: $graphResourceSummaryH + 30px; -$scenarioPanZoomSliderH: 16px; -$scenarioTicksH: 7px; -$scenarioTickLabelsH: 10px; - - diff --git a/platform/features/timeline/res/sass/_timeline-thematic.scss b/platform/features/timeline/res/sass/_timeline-thematic.scss deleted file mode 100644 index 4029876d55..0000000000 --- a/platform/features/timeline/res/sass/_timeline-thematic.scss +++ /dev/null @@ -1,185 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -.l-timeline-holder { - .l-timeline-pane { - &.t-pane-h { - &.l-timeline-resource-legend { - .l-legend-items { - color: $timelineResourceGraphLegendFg; - } - } - } - } - - // Follow Line - .l-follow-line { - // TODO: move before and after into l-timeline-gantt so those only render in that pane - pointer-events: none; - position: absolute; - top: 0; bottom: 0; - width: 1px; - z-index: 9; // Just below .l-hover-btns-holder - } -} - -.l-timeline-gantt { - .l-follow-line { - $d: 0.8rem; - top: $interiorMargin; - &:before, - &:after { - content: ''; - display: block; - height: $d; - width: $d; - position: absolute; - top: 0; - transform: translateX(-50%); - } - &:before { - // Icon blocker - width: 2 * $d; - } - &:after { - // Icon - font-size: $d; - line-height: $d; - text-align: center; - } - } - -} - -.s-timeline-gantt { - .bar { - color: $colorGanttBarFg; - @include activityBg($colorGanttBarBg); - box-shadow: $shdwGanttBar; - .s-toggle { - color: $colorGanttToggle; - } - } -} - -.s-timeline-tabular { - .l-header .l-cols { - .l-col { - border-left: 1px solid pullForward($timelineHeaderColorBg, 15%); - } - } - - .l-pane-l { - // Left pane of the tabular area - .l-cols { - .t-object-label .t-item-icon { - color: pullForward($colorGanttBarBg, 10%); - } - } - } -} - -.edit-mode .s-timeline-gantt, -.s-status-editing .s-timeline-gantt { - .bar { - &:hover { - @include background-image(linear-gradient(lighten($colorGanttBarBg, 20), lighten($colorGanttBarBg, 10))); - } - } -} - -//*************************************************************** STYLING -.s-timeline { - font-size: 0.75rem; - .s-header { - background-color: $timelineHeaderColorBg; - } - .s-swimlane { - border-bottom: 1px solid pullForward($colorBodyBg, 10%); - line-height: $activityBarH + 2 + 1; - &.exceeded { - @include bgDiagonalStripes(#fff, 0.05, $timelineSwimlaneH + 1); - } - - &.selected { - background-color: $colorSwimlaneSelectedBg; - color: $colorSwimlaneSelectedFg; - - .s-timeline-gantt .bar { - @include activityBg($colorGanttBarSelectedBg, 10); - color: $colorGanttBarSelectedFg; - } - } - - &.drop-into { - background-color: rgba($colorDropTarg, 0.7); - .s-timeline-gantt { - opacity: 0.7; - } - } - &.drop-after { - background-color: rgba(#000, 0.2); - border-bottom-color: rgba($colorDropTarg, 1.0); - } - } - - .s-ticks { - @include bgTicks( $timelineColorAlt1); - } - .s-hover-btns-holder { - $bg: $timelineHeaderColorBg; - $l: 5%; - @include user-select(none); - @include background-image(linear-gradient(-90deg, rgba($bg, 1), rgba($bg, 1) 75%, rgba($bg, 0) 100%)); - } - - .l-timeline-resource-graph { - .l-graph { - background: $timelineResourceGraphBg; - } - .l-title { - color: $timelineResourceGraphFg; - } - } - - .s-follow-line { - background: rgba($timeControllerToiLineColor, 0.5); - } - - .s-timeline-gantt { - .s-follow-line { - &:after { - // Icon - color: $timeControllerToiLineColor; - content: $glyph-icon-timer; - font-family: symbolsfont; - text-shadow: $shdwItemText; - } - &:before { - // Blocker - $bg: $timelineHeaderColorBg; - $l: 30%; - @include background-image(linear-gradient(90deg, rgba($bg, 0), rgba($bg, 1) $l, rgba($bg, 1) 100% - $l, rgba($bg, 0))); - - } - } - } -} diff --git a/platform/features/timeline/res/sass/_timelines.scss b/platform/features/timeline/res/sass/_timelines.scss deleted file mode 100644 index 39e690edee..0000000000 --- a/platform/features/timeline/res/sass/_timelines.scss +++ /dev/null @@ -1,333 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -//*************************************************************** LAYOUT -.l-timeline-holder { - @include absPosDefault(); - - &.split-layout { - >.splitter { - // Top of splitter within Timelines should be 0 - top: 0; - } - } - - .l-header { - @include user-select(none); - cursor: default; - } - - .l-timeline-pane { - @include absPosDefault(); - - &.drop-over { - background-color: lighten($colorEditAreaBg, 5%); - } - - .l-width-control { - position: relative; - } - - .l-swimlanes-holder { - @include absPosDefault(); - top: $timelineTopPaneHeaderH + 1; - .l-col.l-plot-resource { - cursor: pointer; - } - } - - // Overall layout - &.t-pane-h { - &.s-timeline-tabular .t-pane-v { - // Vertical panes within tabular area - @include absPosDefault(); - &.l-tabular-l { - // Tree area with item title - right: auto; // Set this to auto and uncomment width below when additional tabular columns are added - width: $timelineTabularTitleW; - .l-swimlanes-holder { - bottom: $scrollbarTrackSize; - } - } - &.l-tabular-r { - // Start, end, duration, activity modes columns - @include scrollH(scroll); - left: $timelineTabularTitleW; - .l-width { - @include absPosDefault(0, visible); - min-width: $timelineTabularDataW; - width: 100%; - } - } - } - &.l-timeline-gantt { - .abs.l-timeline-gantt-header-w { - overflow: hidden; - height: $timelineTopPaneHeaderH; - } - .l-swimlanes-holder { - @include scrollV(scroll); - bottom: $scrollbarTrackSize; - } - } - &.l-timeline-resource-legend { - box-sizing: border-box; - padding: $interiorMargin 0; - white-space: nowrap; - - .l-legend-items { - @include absPosDefault(); - @include scrollV(); - top: 25px; - } - .legend-item { - // Inherits from /platform/commonUI/general/res/sass/plots/_plots-main.scss - display: block; - margin-bottom: $interiorMarginSm; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - .color-swatch { - vertical-align: baseline; - } - .title-label { - vertical-align: baseline; - } - } - } - - &.l-timeline-resource-graph { - $m: $interiorMargin; - - .l-graphs-holder { - @include absPosDefault(); - bottom: $scrollbarTrackSize; - - .l-graphs { - @include absPosDefault(); - @include scrollV(scroll); - } - - .l-graph-labels-holder { - @include absPosDefault(); - overflow: hidden; - right: auto; - width: 400px; - } - } - - .l-scroll-control { - @include absPosDefault(); - overflow-x: scroll; - overflow-y: hidden; - top: auto; right: $scrollbarTrackSize; - height: $scrollbarTrackSize; - .l-width-control { - height: 10px; // Need to add height to force scrollbar to appear - } - } - - .l-graph, - .l-graph-labels { - height: 80px; - margin-bottom: $interiorMarginSm; - position: relative; - } - - .l-title { - @include ellipsize(); - top: $m; left: $m; - position: absolute; - } - - .l-graph { - width: 100%; - .l-graph-area { - canvas { - width: 100%; - height: 100%; - } - } - } - - .l-graph-labels { - z-index: 10; - } - - .l-graph-area { - @include absPosDefault(); - top: 20px; bottom: 5px; - .l-labels-holder { - @include absPosDefault(); - justify-content: space-between; - left: $m; - .t-resource-graph-tick-label { - font-size: 0.9em; - &.tick-label-y { - text-align: left; - } - } - } - } - } - } - - &.l-pane-l { - right: auto; - min-width: 50px; - max-width: 90%; - width: $timelinePaneLeftW; - } - - &.l-pane-r { - left: 0; - } - - &.l-pane-top { - bottom: $timelinePaneBtmH; - } - &.l-pane-btm { - top: auto; - min-height: 20px; - max-height: 80%; - height: $timelinePaneBtmH; - } - } - - .l-swimlane { - height: $timelineSwimlaneH; - position: relative; - } - - // Header - .s-timeline-tabular .l-header, - .s-timeline-gantt .l-header { - @include absPosDefault(0, visible); - bottom: auto; height: $timelineTopPaneHeaderH; - - .l-header-elem { - @include absPosDefault($timelineTopPaneHeaderElemMargin, visible); - display: block; - &.l-labels { - .l-label { - position: absolute; - width: 140px; - margin-left: -70px; - text-align: center; - } - } - } - } - - .l-hover-btns-holder { - @include absPosDefault(); - box-sizing: border-box; - height: $timelineTopPaneHeaderH; - left: auto; - padding: $interiorMargin $interiorMargin $interiorMargin $interiorMargin * 10; - text-align: right; - z-index: 10; - } - - // Tabular Columns - .l-cols { - @include absPosDefault(0, visible); - text-wrap: none; - white-space: nowrap; - .l-col { - box-sizing: border-box; - @include ellipsize(); - display: inline-block; - height: 100%; - padding: 0 $interiorMargin; - position: relative; - text-wrap: none; - white-space: nowrap; - - &.l-col-icon { - width: $timelineColIconW; - text-align: center; - padding: 0; - } - - &.l-plot-resource { - border-left: none !important; - padding-left: 0; - } - - &.l-title { - width: $timelineColTitleW; - .rep-object-label { - border-radius: $basicCr; - display: inline-block; - padding: 0 $interiorMargin; - } - } - - &.l-start, - &.l-end, - &.l-duration { - width: $timelineColDatetimeW; - } - - &.l-activity-modes { - display: none; // Temp, until modes can be displayed - width: $timelineColActivityModesW; - } - } - } - - .s-timeline-tabular { - .l-header .l-cols { - top: $timelineTopPaneHeaderElemMargin; bottom: $timelineTopPaneHeaderElemMargin; - } - - .l-pane-l { - // Left pane of the tabular area - .l-cols { - left: $timelineTopPaneHeaderElemMargin; - } - } - } - - // Ticks - .l-ticks, - .l-subticks { - @include absPosDefault(); - top: auto; bottom: $interiorMarginSm; - } - - .l-ticks { - height: 10px - } - - .l-subticks { - height: 5px - } -} - -.s-status-editing .l-title .rep-object-label[draggable="true"] { - @include transition(background-color, 0.25s); - cursor: pointer; - &:hover { - background-color: $colorItemTreeHoverBg; - } -} \ No newline at end of file diff --git a/platform/features/timeline/res/sass/timeline-espresso.scss b/platform/features/timeline/res/sass/timeline-espresso.scss deleted file mode 100644 index 8f19984843..0000000000 --- a/platform/features/timeline/res/sass/timeline-espresso.scss +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -$output-bourbon-deprecation-warnings: false; -@import "bourbon"; - -@import "../../../../commonUI/general/res/sass/constants"; -@import "../../../../commonUI/general/res/sass/mixins"; -@import "../../../../commonUI/general/res/sass/glyphs"; -@import "../../../../commonUI/themes/espresso/res/sass/constants"; -@import "../../../../commonUI/themes/espresso/res/sass/mixins"; -@import "constants"; -@import "constants-espresso"; -@import "timeline-thematic"; - diff --git a/platform/features/timeline/res/sass/timeline-snow.scss b/platform/features/timeline/res/sass/timeline-snow.scss deleted file mode 100644 index 3ee52b20a2..0000000000 --- a/platform/features/timeline/res/sass/timeline-snow.scss +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -$output-bourbon-deprecation-warnings: false; -@import "bourbon"; - -@import "../../../../commonUI/general/res/sass/constants"; -@import "../../../../commonUI/general/res/sass/mixins"; -@import "../../../../commonUI/general/res/sass/glyphs"; -@import "../../../../commonUI/themes/snow/res/sass/constants"; -@import "../../../../commonUI/themes/snow/res/sass/mixins"; -@import "constants"; -@import "constants-snow"; -@import "timeline-thematic"; diff --git a/platform/features/timeline/res/sass/timeline.scss b/platform/features/timeline/res/sass/timeline.scss deleted file mode 100644 index b10235cbc4..0000000000 --- a/platform/features/timeline/res/sass/timeline.scss +++ /dev/null @@ -1,32 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -$output-bourbon-deprecation-warnings: false; -@import "bourbon"; - -@import "../../../../commonUI/general/res/sass/constants"; -@import "../../../../commonUI/general/res/sass/mixins"; -@import "../../../../commonUI/general/res/sass/glyphs"; -@import "../../../../commonUI/themes/espresso/res/sass/constants"; -@import "../../../../commonUI/themes/espresso/res/sass/mixins"; -@import "constants"; -@import "activities"; -@import "timelines"; diff --git a/platform/features/timeline/res/templates/activity-gantt.html b/platform/features/timeline/res/templates/activity-gantt.html deleted file mode 100644 index df8f12ef0a..0000000000 --- a/platform/features/timeline/res/templates/activity-gantt.html +++ /dev/null @@ -1,38 +0,0 @@ - -
- -
- - - {{model.name}} - -
- -
diff --git a/platform/features/timeline/res/templates/controls/datetime.html b/platform/features/timeline/res/templates/controls/datetime.html deleted file mode 100644 index c904fcefbf..0000000000 --- a/platform/features/timeline/res/templates/controls/datetime.html +++ /dev/null @@ -1,83 +0,0 @@ - -
- -
- Days - Hours - Minutes - Seconds - Time System -
- - -
- - - - - - - - - - - - - - SET - -
-
- - -
diff --git a/platform/features/timeline/res/templates/deprecated-timeline-message.html b/platform/features/timeline/res/templates/deprecated-timeline-message.html new file mode 100644 index 0000000000..d92eec8de2 --- /dev/null +++ b/platform/features/timeline/res/templates/deprecated-timeline-message.html @@ -0,0 +1,10 @@ +
+ Timeline, Activity and Activity Mode objects have been deprecated and will no longer be supported. +
+
+ Please open an issue in the + + Open MCT Issue tracker + + if you have any questions about the timeline plugin. +
diff --git a/platform/features/timeline/res/templates/legend-item.html b/platform/features/timeline/res/templates/legend-item.html deleted file mode 100644 index 3c41af351d..0000000000 --- a/platform/features/timeline/res/templates/legend-item.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - {{ngModel.path}} - {{ngModel.domainObject.getModel().name}} - - diff --git a/platform/features/timeline/res/templates/resource-graph-labels.html b/platform/features/timeline/res/templates/resource-graph-labels.html deleted file mode 100644 index a14560e0df..0000000000 --- a/platform/features/timeline/res/templates/resource-graph-labels.html +++ /dev/null @@ -1,37 +0,0 @@ - -
- {{parameters.title}} -
-
-
-
- {{parameters.high}} -
-
- {{parameters.middle}} -
-
- {{parameters.low}} -
-
-
diff --git a/platform/features/timeline/res/templates/resource-graphs.html b/platform/features/timeline/res/templates/resource-graphs.html deleted file mode 100644 index 51d2f6a053..0000000000 --- a/platform/features/timeline/res/templates/resource-graphs.html +++ /dev/null @@ -1,34 +0,0 @@ - - -
-
- -
-
- - -
-
-
diff --git a/platform/features/timeline/res/templates/tabular-swimlane-cols-data.html b/platform/features/timeline/res/templates/tabular-swimlane-cols-data.html deleted file mode 100644 index 8fcacdae4a..0000000000 --- a/platform/features/timeline/res/templates/tabular-swimlane-cols-data.html +++ /dev/null @@ -1,37 +0,0 @@ - -
-
- {{tabularVal.niceTime(ngModel.timespan().getStart())}} - {{tabularVal.niceTime(ngModel.timespan().getEnd())}} - {{tabularVal.niceTime(ngModel.timespan().getDuration())}} - -
-
diff --git a/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html b/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html deleted file mode 100644 index 8da5fe17c7..0000000000 --- a/platform/features/timeline/res/templates/tabular-swimlane-cols-tree.html +++ /dev/null @@ -1,57 +0,0 @@ - -
-
- - - - - - - - - - - - -
-
diff --git a/platform/features/timeline/res/templates/ticks.html b/platform/features/timeline/res/templates/ticks.html deleted file mode 100644 index c56f41d9cc..0000000000 --- a/platform/features/timeline/res/templates/ticks.html +++ /dev/null @@ -1,39 +0,0 @@ - - diff --git a/platform/features/timeline/res/templates/timeline.html b/platform/features/timeline/res/templates/timeline.html deleted file mode 100644 index 8fe2ec4312..0000000000 --- a/platform/features/timeline/res/templates/timeline.html +++ /dev/null @@ -1,223 +0,0 @@ - -
- - - - - -
- -
- - -
- - -
- -
- - -
-
- -
- - -
-
-
-
- - - - - -
-
{{ngModel.title}}Resource Graph Legend
-
- - -
-
-
- - - - - - - - - - - - - -
-
- - - -
- - - - - - - - -
-
- -
- - -
- - -
-
-
- - - - - - - - -
-
-
-
- - - - - -
-
-
- - -
- -
-
-
-
-
-
-
-
- - -
-
-
diff --git a/platform/features/timeline/res/templates/values.html b/platform/features/timeline/res/templates/values.html deleted file mode 100644 index b177dfcb33..0000000000 --- a/platform/features/timeline/res/templates/values.html +++ /dev/null @@ -1,27 +0,0 @@ - - diff --git a/platform/features/timeline/src/TimelineConstants.js b/platform/features/timeline/src/TimelineConstants.js deleted file mode 100644 index 8246c5755a..0000000000 --- a/platform/features/timeline/src/TimelineConstants.js +++ /dev/null @@ -1,31 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * Defines constant values for use in timeline view. - */ -define({ - // Pixel width of start/end handles - HANDLE_WIDTH: 32, - // Pixel tolerance for snapping behavior - SNAP_WIDTH: 16 -}); diff --git a/platform/features/timeline/src/TimelineFormatter.js b/platform/features/timeline/src/TimelineFormatter.js deleted file mode 100644 index 6122ca8195..0000000000 --- a/platform/features/timeline/src/TimelineFormatter.js +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - // Conversion factors from time units to milliseconds - var SECONDS = 1000, - MINUTES = SECONDS * 60, - HOURS = MINUTES * 60, - DAYS = HOURS * 24; - - /** - * Formatters for durations shown in a timeline view. - * @constructor - */ - function TimelineFormatter() { - - // Format a numeric value to a string with some number of digits - function formatValue(value, digits) { - var v = value.toString(10); - // Pad with zeroes - while (v.length < digits) { - v = "0" + v; - } - return v; - } - - // Format duration to string - function formatDuration(duration) { - var days = Math.floor(duration / DAYS), - hours = Math.floor(duration / HOURS) % 24, - minutes = Math.floor(duration / MINUTES) % 60, - seconds = Math.floor(duration / SECONDS) % 60, - millis = Math.floor(duration) % 1000; - - return formatValue(days, 3) + " " + - formatValue(hours, 2) + ":" + - formatValue(minutes, 2) + ":" + - formatValue(seconds, 2) + "." + - formatValue(millis, 3); - } - - return { - /** - * Format the provided duration. - * @param {number} duration duration, in milliseconds - * @returns {string} displayable representation of duration - */ - format: formatDuration - }; - } - - return TimelineFormatter; - } -); diff --git a/platform/features/timeline/src/actions/CompositionColumn.js b/platform/features/timeline/src/actions/CompositionColumn.js deleted file mode 100644 index 52b593bfa4..0000000000 --- a/platform/features/timeline/src/actions/CompositionColumn.js +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - - /** - * A column containing references to other objects contained - * in a domain object's composition. - * @param {number} index the zero-based index of the composition - * element associated with this column - * @param idMap an object containing key value pairs, where keys - * are domain object identifiers and values are whatever - * should appear in CSV output in their place - * @constructor - * @implements {platform/features/timeline.TimelineCSVColumn} - */ - function CompositionColumn(index, idMap) { - this.index = index; - this.idMap = idMap; - } - - CompositionColumn.prototype.name = function () { - return "Child " + (this.index + 1); - }; - - CompositionColumn.prototype.value = function (domainObject) { - var model = domainObject.getModel(), - composition = model.composition || []; - - return composition.length > this.index ? - this.idMap[composition[this.index]] : ""; - }; - - return CompositionColumn; -}); diff --git a/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js b/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js deleted file mode 100644 index f090aac0a4..0000000000 --- a/platform/features/timeline/src/actions/ExportTimelineAsCSVAction.js +++ /dev/null @@ -1,79 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define(["./ExportTimelineAsCSVTask"], function (ExportTimelineAsCSVTask) { - - /** - * Implements the "Export Timeline as CSV" action. - * - * @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( - $log, - exportService, - notificationService, - resources, - context - ) { - this.$log = $log; - this.task = new ExportTimelineAsCSVTask( - exportService, - resources, - context.domainObject - ); - this.notificationService = notificationService; - } - - ExportTimelineAsCSVAction.prototype.perform = function () { - var notificationService = this.notificationService, - notification = notificationService.notify({ - title: "Exporting CSV", - unknownProgress: true - }), - $log = this.$log; - - return this.task.run() - .then(function () { - notification.dismiss(); - }) - .catch(function (err) { - $log.warn(err); - notification.dismiss(); - notificationService.error("Error exporting CSV"); - }); - }; - - ExportTimelineAsCSVAction.appliesTo = function (context) { - return context.domainObject && - context.domainObject.hasCapability('type') && - context.domainObject.getCapability('type') - .instanceOf('timeline'); - }; - - return ExportTimelineAsCSVAction; -}); diff --git a/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js b/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js deleted file mode 100644 index 34dae554d8..0000000000 --- a/platform/features/timeline/src/actions/ExportTimelineAsCSVTask.js +++ /dev/null @@ -1,71 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * Module defining ExportTimelineAsCSVTask. Created by vwoeltje on 2/8/16. - */ -define([ - "./TimelineTraverser", - "./TimelineColumnizer" -], function (TimelineTraverser, TimelineColumnizer) { - - /** - * Runs (and coordinates) the preparation and export of CSV data - * for the "Export Timeline as CSV" action. - * - * @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, resources, domainObject) { - this.domainObject = domainObject; - this.exportService = exportService; - this.resources = resources; - } - - /** - * Run this CSV export task. - * - * @returns {Promise} a promise that will be resolved when the - * export has finished (or rejected if there are problems.) - */ - ExportTimelineAsCSVTask.prototype.run = function () { - var exportService = this.exportService; - var resources = this.resources; - - function doExport(objects) { - var exporter = new TimelineColumnizer(objects, resources), - options = { headers: exporter.headers() }; - return exporter.rows().then(function (rows) { - return exportService.exportCSV(rows, options); - }); - } - - return new TimelineTraverser(this.domainObject) - .buildObjectList() - .then(doExport); - }; - - return ExportTimelineAsCSVTask; -}); diff --git a/platform/features/timeline/src/actions/IdColumn.js b/platform/features/timeline/src/actions/IdColumn.js deleted file mode 100644 index 7f12089ce4..0000000000 --- a/platform/features/timeline/src/actions/IdColumn.js +++ /dev/null @@ -1,46 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - - /** - * A column showing identifying domain objects. - * @constructor - * @param idMap an object containing key value pairs, where keys - * are domain object identifiers and values are whatever - * should appear in CSV output in their place - * @implements {platform/features/timeline.TimelineCSVColumn} - */ - function IdColumn(idMap) { - this.idMap = idMap; - } - - IdColumn.prototype.name = function () { - return "Index"; - }; - - IdColumn.prototype.value = function (domainObject) { - return this.idMap[domainObject.getId()]; - }; - - return IdColumn; -}); diff --git a/platform/features/timeline/src/actions/MetadataColumn.js b/platform/features/timeline/src/actions/MetadataColumn.js deleted file mode 100644 index a71792c7e4..0000000000 --- a/platform/features/timeline/src/actions/MetadataColumn.js +++ /dev/null @@ -1,48 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - - /** - * A column reflecting properties from domain object metadata. - * @constructor - * @implements {platform/features/timeline.TimelineCSVColumn} - */ - function MetadataColumn(propertyName) { - this.propertyName = propertyName; - } - - MetadataColumn.prototype.name = function () { - return this.propertyName; - }; - - MetadataColumn.prototype.value = function (domainObject) { - var properties = domainObject.useCapability('metadata'), - name = this.propertyName; - return properties.reduce(function (value, property) { - return property.name === name ? - property.value : value; - }, ""); - }; - - return MetadataColumn; -}); diff --git a/platform/features/timeline/src/actions/ModeColumn.js b/platform/features/timeline/src/actions/ModeColumn.js deleted file mode 100644 index 1525c14695..0000000000 --- a/platform/features/timeline/src/actions/ModeColumn.js +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - - /** - * A column showing relationships to activity modes. - * @constructor - * @param {number} index the zero-based index of the composition - * element associated with this column - * @param idMap an object containing key value pairs, where keys - * are domain object identifiers and values are whatever - * should appear in CSV output in their place - * @implements {platform/features/timeline.TimelineCSVColumn} - */ - function ModeColumn(index, idMap) { - this.index = index; - this.idMap = idMap; - } - - ModeColumn.prototype.name = function () { - return "Activity Mode " + (this.index + 1); - }; - - ModeColumn.prototype.value = function (domainObject) { - var model = domainObject.getModel(), - modes = (model.relationships || {}).modes || []; - return modes.length > this.index ? - this.idMap[modes[this.index]] : ""; - }; - - return ModeColumn; -}); diff --git a/platform/features/timeline/src/actions/TimelineColumnizer.js b/platform/features/timeline/src/actions/TimelineColumnizer.js deleted file mode 100644 index f8e525264c..0000000000 --- a/platform/features/timeline/src/actions/TimelineColumnizer.js +++ /dev/null @@ -1,172 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([ - "./IdColumn", - "./ModeColumn", - "./CompositionColumn", - "./MetadataColumn", - "./TimespanColumn", - "./UtilizationColumn" -], function ( - IdColumn, - ModeColumn, - CompositionColumn, - MetadataColumn, - TimespanColumn, - UtilizationColumn -) { - - /** - * A description of how to populate a given column within a - * prepared table of domain object data, for CSV export. - * @interface platform/features/timeline.TimelineCSVColumn - */ - - /** - * Get the value that belongs in this column for a given - * domain object. - * @memberof {platform/features/timeline.TimelineCSVColumn#} - * @method value - * @param {DomainObject} domainObject the domain object - * represented by this row - * @returns {string|Promise} the value for this cell - */ - - /** - * Get the name of this column, as belongs in a header. - * @memberof {platform/features/timeline.TimelineCSVColumn#} - * @method name - * @returns {string} the name of this column - */ - - /** - * Handles conversion of a list of domain objects to a table - * representation appropriate for CSV export. - * - * @param {DomainObject[]} domainObjects the objects to include - * in the exported data - * @param {Array} resources an array of `resources` extensions - * @constructor - * @memberof {platform/features/timeline} - */ - function TimelineColumnizer(domainObjects, resources) { - var maxComposition = 0, - maxRelationships = 0, - columnNames = {}, - columns = [], - foundTimespan = false, - idMap, - i; - - function addMetadataProperty(property) { - var name = property.name; - if (!columnNames[name]) { - columnNames[name] = true; - columns.push(new MetadataColumn(name)); - } - } - - idMap = domainObjects.reduce(function (map, domainObject, index) { - map[domainObject.getId()] = index + 1; - return map; - }, {}); - - columns.push(new IdColumn(idMap)); - - domainObjects.forEach(function (domainObject) { - var model = domainObject.getModel(), - composition = model.composition, - relationships = model.relationships, - modes = relationships && relationships.modes, - metadataProperties = domainObject.useCapability('metadata'); - - if (composition) { - maxComposition = Math.max(maxComposition, composition.length); - } - - if (modes) { - maxRelationships = Math.max(maxRelationships, modes.length); - } - - if (domainObject.hasCapability('timespan')) { - foundTimespan = true; - } - - if (metadataProperties) { - metadataProperties.forEach(addMetadataProperty); - } - }); - - if (foundTimespan) { - columns.push(new TimespanColumn(true)); - columns.push(new TimespanColumn(false)); - } - - resources.forEach(function (resource) { - columns.push(new UtilizationColumn(resource)); - }); - - for (i = 0; i < maxComposition; i += 1) { - columns.push(new CompositionColumn(i, idMap)); - } - - for (i = 0; i < maxRelationships; i += 1) { - columns.push(new ModeColumn(i, idMap)); - } - - this.domainObjects = domainObjects; - this.columns = columns; - } - - /** - * Get a tabular representation of domain object data. - * Each row corresponds to a single object; each element - * in each row corresponds to a property designated by - * the `headers`, correlated by index. - * @returns {Promise.} domain object data - */ - TimelineColumnizer.prototype.rows = function () { - var columns = this.columns; - - function toRow(domainObject) { - return Promise.all(columns.map(function (column) { - return column.value(domainObject); - })); - } - - return Promise.all(this.domainObjects.map(toRow)); - }; - - /** - * Get the column headers associated with this tabular - * representation of objects. - * @returns {string[]} column headers - */ - TimelineColumnizer.prototype.headers = function () { - return this.columns.map(function (column) { - return column.name(); - }); - }; - - return TimelineColumnizer; -}); diff --git a/platform/features/timeline/src/actions/TimelineTraverser.js b/platform/features/timeline/src/actions/TimelineTraverser.js deleted file mode 100644 index fd965f5383..0000000000 --- a/platform/features/timeline/src/actions/TimelineTraverser.js +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - - /** - * Builds a list of domain objects which should be included - * in the CSV export of a given timeline. - * @param {DomainObject} domainObject the object being exported - * @constructor - */ - function TimelineTraverser(domainObject) { - this.domainObject = domainObject; - } - - /** - * Get a list of domain objects for CSV export. - * @returns {Promise.} a list of domain objects - */ - TimelineTraverser.prototype.buildObjectList = function () { - var idSet = {}, - objects = []; - - function addObject(domainObject) { - var id = domainObject.getId(), - subtasks = []; - - function addCompositionObjects() { - return domainObject.useCapability('composition') - .then(function (childObjects) { - return Promise.all(childObjects.map(addObject)); - }); - } - - function addRelationships() { - var relationship = domainObject.getCapability('relationship'); - relationship.getRelatedObjects('modes') - .then(function (modeObjects) { - return Promise.all(modeObjects.map(addObject)); - }); - } - - if (!idSet[id]) { - idSet[id] = true; - objects.push(domainObject); - if (domainObject.hasCapability('composition')) { - subtasks.push(addCompositionObjects()); - } - if (domainObject.hasCapability('relationship')) { - subtasks.push(addRelationships()); - } - } - - return Promise.all(subtasks); - } - - return addObject(this.domainObject).then(function () { - return objects; - }); - }; - - return TimelineTraverser; - -}); diff --git a/platform/features/timeline/src/actions/TimespanColumn.js b/platform/features/timeline/src/actions/TimespanColumn.js deleted file mode 100644 index a44bf170ae..0000000000 --- a/platform/features/timeline/src/actions/TimespanColumn.js +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define(['../TimelineFormatter'], function (TimelineFormatter) { - - var FORMATTER = new TimelineFormatter(); - - /** - * A column showing start or end times associated with a domain object. - * @constructor - * @param {boolean} isStart true if this column refers to the object's - * start time; false if it refers to the object's end time - * @implements {platform/features/timeline.TimelineCSVColumn} - */ - function TimespanColumn(isStart) { - this.isStart = isStart; - } - - TimespanColumn.prototype.name = function () { - return this.isStart ? "Start" : "End"; - }; - - TimespanColumn.prototype.value = function (domainObject) { - var isStart = this.isStart; - return domainObject.hasCapability('timespan') ? - domainObject.useCapability('timespan').then(function (timespan) { - return FORMATTER.format( - isStart ? timespan.getStart() : timespan.getEnd() - ); - }) : ""; - }; - - return TimespanColumn; -}); diff --git a/platform/features/timeline/src/actions/UtilizationColumn.js b/platform/features/timeline/src/actions/UtilizationColumn.js deleted file mode 100644 index 3574806708..0000000000 --- a/platform/features/timeline/src/actions/UtilizationColumn.js +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - /** - * 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 () { - var units = { - "Kbps": "Kb", - "watts": "watt-seconds" - }[this.resource.units] || "unknown units"; - - return this.resource.name + " (" + units + ")"; - }; - - UtilizationColumn.prototype.value = function (domainObject) { - var resource = this.resource; - - function getCost(utilization) { - var seconds = (utilization.end - utilization.start) / 1000; - return seconds * utilization.value; - } - - function getUtilizationValue(utilizations) { - utilizations = utilizations.filter(function (utilization) { - return utilization.key === resource.key; - }); - - if (utilizations.length === 0) { - return ""; - } - - return utilizations.map(getCost).reduce(function (a, b) { - return a + b; - }, 0); - } - - return domainObject.hasCapability('utilization') ? - domainObject.getCapability('utilization').internal() - .then(getUtilizationValue) : - ""; - }; - - return UtilizationColumn; -}); diff --git a/platform/features/timeline/src/capabilities/ActivityTimespan.js b/platform/features/timeline/src/capabilities/ActivityTimespan.js deleted file mode 100644 index 2d8a26efe2..0000000000 --- a/platform/features/timeline/src/capabilities/ActivityTimespan.js +++ /dev/null @@ -1,119 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Describes the time span of an activity object. - * @param model the activity's object model - */ - function ActivityTimespan(model, mutation) { - // Get the start time for this timeline - function getStart() { - return model.start.timestamp; - } - - // Get the end time for this timeline - function getEnd() { - return model.start.timestamp + model.duration.timestamp; - } - - // Get the duration of this timeline - function getDuration() { - return model.duration.timestamp; - } - - // Get the epoch used by this timeline - function getEpoch() { - return model.start.epoch; // Surface elapsed time - } - - // Set the start time associated with this object - function setStart(value) { - var end = getEnd(); - mutation.mutate(function (m) { - m.start.timestamp = Math.max(value, 0); - // Update duration to keep end time - m.duration.timestamp = Math.max(end - value, 0); - }, model.modified); - } - - // Set the duration associated with this object - function setDuration(value) { - mutation.mutate(function (m) { - m.duration.timestamp = Math.max(value, 0); - }, model.modified); - } - - // Set the end time associated with this object - function setEnd(value) { - var start = getStart(); - mutation.mutate(function (m) { - m.duration.timestamp = Math.max(value - start, 0); - }, model.modified); - } - - return { - /** - * Get the start time, in milliseconds relative to the epoch. - * @returns {number} the start time - */ - getStart: getStart, - /** - * Get the duration, in milliseconds. - * @returns {number} the duration - */ - getDuration: getDuration, - /** - * Get the end time, in milliseconds relative to the epoch. - * @returns {number} the end time - */ - getEnd: getEnd, - /** - * Set the start time, in milliseconds relative to the epoch. - * @param {number} the new value - */ - setStart: setStart, - /** - * Set the duration, in milliseconds. - * @param {number} the new value - */ - setDuration: setDuration, - /** - * Set the end time, in milliseconds relative to the epoch. - * @param {number} the new value - */ - setEnd: setEnd, - /** - * Get a string identifying the reference epoch used for - * start and end times. - * @returns {string} the epoch - */ - getEpoch: getEpoch - }; - } - - return ActivityTimespan; - } -); diff --git a/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js b/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js deleted file mode 100644 index 58ae8ae8df..0000000000 --- a/platform/features/timeline/src/capabilities/ActivityTimespanCapability.js +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./ActivityTimespan'], - function (ActivityTimespan) { - - /** - * Implements the `timespan` capability for Activity objects. - * - * @constructor - * @param $q Angular's $q, for promise-handling - * @param {DomainObject} domainObject the Activity - */ - function ActivityTimespanCapability($q, domainObject) { - // Promise time span - function promiseTimeSpan() { - return $q.when(new ActivityTimespan( - domainObject.getModel(), - domainObject.getCapability('mutation') - )); - } - - return { - /** - * Get the time span (start, end, duration) of this activity. - * @returns {Promise.} the time span of - * this activity - */ - invoke: promiseTimeSpan - }; - } - - // Only applies to timeline objects - ActivityTimespanCapability.appliesTo = function (model) { - return model && (model.type === 'activity'); - }; - - return ActivityTimespanCapability; - - } -); diff --git a/platform/features/timeline/src/capabilities/ActivityUtilization.js b/platform/features/timeline/src/capabilities/ActivityUtilization.js deleted file mode 100644 index dbe89d2669..0000000000 --- a/platform/features/timeline/src/capabilities/ActivityUtilization.js +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Provides data to populate resource graphs associated - * with activities in a timeline view. - * This is a placeholder until WTD-918. - * @constructor - */ - function ActivityUtilization() { - return { - getPointCount: function () { - return 0; - }, - getDomainValue: function () { - return 0; - }, - getRangeValue: function () { - return 0; - } - }; - } - - return ActivityUtilization; - } - -); diff --git a/platform/features/timeline/src/capabilities/CostCapability.js b/platform/features/timeline/src/capabilities/CostCapability.js deleted file mode 100644 index dc1f8c8d70..0000000000 --- a/platform/features/timeline/src/capabilities/CostCapability.js +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Exposes costs associated with a subsystem mode. - * @constructor - */ - function CostCapability(domainObject) { - var model = domainObject.getModel(); - - return { - /** - * Get a list of resource types which have associated - * costs for this object. Returned values are machine-readable - * keys, and should be paired with external metadata for - * presentation (see category of extension `resources`). - * @returns {string[]} resource types - */ - resources: function () { - return Object.keys(model.resources || {}).sort(); - }, - /** - * Get the cost associated with a resource of an identified - * type (typically, one of the types reported from a - * `resources` call.) - * @param {string} key the resource type - * @returns {number} the associated cost - */ - cost: function (key) { - return (model.resources || {})[key] || 0; - }, - /** - * Get an object containing key-value pairs describing - * resource utilization as described by this object. - * Keys are resource types; values are levels of associated - * resource utilization. - * @returns {object} resource utilizations - */ - invoke: function () { - return model.resources || {}; - } - }; - } - - // Only applies to subsystem modes. - CostCapability.appliesTo = function (model) { - return (model || {}).type === 'mode'; - }; - - return CostCapability; - } -); diff --git a/platform/features/timeline/src/capabilities/CumulativeGraph.js b/platform/features/timeline/src/capabilities/CumulativeGraph.js deleted file mode 100644 index 6724d6ee13..0000000000 --- a/platform/features/timeline/src/capabilities/CumulativeGraph.js +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Provide points for a cumulative resource summary graph, using - * a provided instantaneous resource summary graph. - * - * @param {ResourceGraph} graph the resource graph - * @param {number} minimum the minimum allowable level - * @param {number} maximum the maximum allowable level - * @param {number} initial the initial state of the resource - * @param {number} rate the rate at which one unit of instantaneous - * utilization changes the available level in one unit - * of domain values (that is, per millisecond) - * @constructor - */ - function CumulativeGraph(graph, minimum, maximum, initial, rate) { - var values; - - // Calculate the domain value at which a line starting at - // (domain, range) and proceeding with the specified slope - // will have the specified range value. - function intercept(domain, range, slope, value) { - // value = slope * (intercept - domain) + range - // value - range = slope * ... - // intercept - domain = (value - range) / slope - // intercept = domain + (value - range) / slope - return domain + (value - range) / slope; - } - - // Initialize the data values - function initializeValues() { - var vals = [], - slope = 0, - i; - - // Add a point (or points, if needed) reaching to the provided - // domain and/or range value - function addPoint(domain, range) { - var previous = vals[vals.length - 1], - delta = domain - previous.domain, // time delta - change = delta * slope * rate, // change - next = previous.range + change; - - // Crop to minimum boundary... - if (next < minimum) { - vals.push({ - domain: intercept( - previous.domain, - previous.range, - slope * rate, - minimum - ), - range: minimum - }); - next = minimum; - } - - // ...and maximum boundary - if (next > maximum) { - vals.push({ - domain: intercept( - previous.domain, - previous.range, - slope * rate, - maximum - ), - range: maximum - }); - next = maximum; - } - - // Add the new data value - if (delta > 0) { - vals.push({ domain: domain, range: next }); - } - - slope = range; - } - - vals.push({ domain: 0, range: initial }); - - for (i = 0; i < graph.getPointCount(); i += 1) { - addPoint(graph.getDomainValue(i), graph.getRangeValue(i)); - } - - return vals; - } - - function convertToPercent(point) { - point.range = 100 * - (point.range - minimum) / (maximum - minimum); - } - - // Calculate cumulative values... - values = initializeValues(); - - // ...and convert to percentages. - values.forEach(convertToPercent); - - return { - /** - * Get the total number of points in this graph. - * @returns {number} the total number of points - */ - getPointCount: function () { - return values.length; - }, - /** - * Get the domain value (timestamp) for a point in this graph. - * @returns {number} the domain value - */ - getDomainValue: function (index) { - return values[index].domain; - }, - /** - * Get the range value (utilization level) for a point in - * this graph. - * @returns {number} the range value - */ - getRangeValue: function (index) { - return values[index].range; - } - }; - } - - return CumulativeGraph; - } -); diff --git a/platform/features/timeline/src/capabilities/GraphCapability.js b/platform/features/timeline/src/capabilities/GraphCapability.js deleted file mode 100644 index 181c909f79..0000000000 --- a/platform/features/timeline/src/capabilities/GraphCapability.js +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./ResourceGraph', './CumulativeGraph'], - function (ResourceGraph, CumulativeGraph) { - - /** - * Implements the `graph` capability for Timeline and - * Activity objects. - * - * @constructor - * @param {DomainObject} domainObject the Timeline or Activity - */ - function GraphCapability($q, domainObject) { - - - // Build graphs for this group of utilizations - function buildGraphs(utilizations) { - var utilizationMap = {}, - result = {}, - startingSOC; - - // Bucket utilizations by type - utilizations.forEach(function (u) { - var k = u.key; - utilizationMap[k] = utilizationMap[k] || []; - utilizationMap[k].push(u); - }); - - // ...then convert to graphs - Object.keys(utilizationMap).forEach(function (k) { - result[k] = new ResourceGraph(utilizationMap[k]); - }); - - // Add battery state of charge - if (domainObject.getModel().type === 'timeline' && - result.power && - domainObject.getModel().capacity > 0) { - startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ? - 100 : parseFloat(domainObject.getModel().startingSOC); - - result.battery = new CumulativeGraph( - result.power, - 0, - domainObject.getModel().capacity, // Watts - (startingSOC / 100) * domainObject.getModel().capacity, - 1 / 3600000 // millis-to-hour (since units are watt-hours) - ); - } - - return result; - } - - return { - /** - * Get resource graphs associated with this object. - * This is given as a promise for key-value pairs, - * where keys are resource types and values are graph - * objects. - * @returns {Promise} a promise for resource graphs - */ - invoke: function () { - return $q.when( - domainObject.useCapability('utilization') || [] - ).then(buildGraphs); - } - }; - } - - // Only applies to timeline objects - GraphCapability.appliesTo = function (model) { - return model && - ((model.type === 'timeline') || - (model.type === 'activity')); - }; - - return GraphCapability; - - } -); diff --git a/platform/features/timeline/src/capabilities/ResourceGraph.js b/platform/features/timeline/src/capabilities/ResourceGraph.js deleted file mode 100644 index dc80899c1b..0000000000 --- a/platform/features/timeline/src/capabilities/ResourceGraph.js +++ /dev/null @@ -1,147 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - // Utility function to copy an array, sorted by a specific field - function sort(array, field) { - return array.slice().sort(function (a, b) { - return a[field] - b[field]; - }); - } - - /** - * Provides data to populate resource graphs associated - * with timelines and activities. - * @param {Array} utilizations resource utilizations - * @constructor - */ - function ResourceGraph(utilizations) { - // Overview of algorithm here: - // * Goal: Have a list of time/value pairs which represents - // points along a stepped chart of resource utilization. - // Each change (stepping up or down) should have two points, - // at the bottom and top of the step respectively. - // * Step 1: Prepare two lists of utilizations sorted by start - // and end times. The "starts" will become step-ups, the - // "ends" will become step-downs. - // * Step 2: Initialize empty arrays for results, and a variable - // for the current utilization level. - // * Step 3: While there are still start or end times to add... - // * Step 3a: Determine whether the next change should be a - // step-up (start) or step-down (end) based on which of the - // next start/end times comes next (note that starts and ends - // are both sorted, so we look at the head of the array.) - // * Step 3b: Pull the next start or end (per previous decision) - // and convert it to a time-delta pair, negating if it's an - // end time (to step down or "un-step") - // * Step 3c: Add a point at the new time and the current - // running total (first point in the step, before the change) - // then increment the running total and add a new point - // (second point in the step, after the change) - // * Step 4: Filter out unnecessary points (if two activities - // run up against each other, there will be a zero-duration - // spike if we don't filter out the extra points from their - // start/end times.) - // - var starts = sort(utilizations, "start"), - ends = sort(utilizations, "end"), - values = [], - running = 0; - - // If there are sequences of points with the same timestamp, - // allow only the first and last. - function filterPoint(value, index, vals) { - // Allow the first or last point as a base case; aside from - // that, allow only points that have different timestamps - // from their predecessor or successor. - return (index === 0) || (index === vals.length - 1) || - (value.domain !== vals[index - 1].domain) || - (value.domain !== vals[index + 1].domain); - } - - // Add a step up or down (Step 3c above) - function addDelta(time, delta) { - values.push({ domain: time, range: running }); - running += delta; - values.push({ domain: time, range: running }); - } - - // Add a start time (Step 3b above) - function addStart() { - var next = starts.shift(); - addDelta(next.start, next.value); - } - - // Add an end time (Step 3b above) - function addEnd() { - var next = ends.shift(); - addDelta(next.end, -next.value); - } - - // Decide whether next step should correspond to a start or - // an end. (Step 3c above) - function pickStart() { - return ends.length < 1 || - (starts.length > 0 && starts[0].start <= ends[0].end); - } - - // Build up start/end arrays (step 3 above) - while (starts.length > 0 || ends.length > 0) { - (pickStart() ? addStart : addEnd)(); - } - - // Filter out excess points - values = values.filter(filterPoint); - - return { - /** - * Get the total number of points in this graph. - * @returns {number} the total number of points - */ - getPointCount: function () { - return values.length; - }, - /** - * Get the domain value (timestamp) for a point in this graph. - * @returns {number} the domain value - */ - getDomainValue: function (index) { - return values[index].domain; - }, - /** - * Get the range value (utilization level) for a point in - * this graph. - * @returns {number} the range value - */ - getRangeValue: function (index) { - return values[index].range; - } - }; - } - - return ResourceGraph; - } - -); diff --git a/platform/features/timeline/src/capabilities/TimelineTimespan.js b/platform/features/timeline/src/capabilities/TimelineTimespan.js deleted file mode 100644 index 31289b5924..0000000000 --- a/platform/features/timeline/src/capabilities/TimelineTimespan.js +++ /dev/null @@ -1,124 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Describes the time span of a timeline object. - * @param model the timeline's object model - * @param {Timespan[]} time spans of contained activities - */ - function TimelineTimespan(model, mutation, timespans) { - // Get the start time for this timeline - function getStart() { - return model.start.timestamp; - } - - // Get the end time for another time span - function getTimespanEnd(timespan) { - return timespan.getEnd(); - } - - // Wrapper for Math.max; used for max-finding of end time - function max(a, b) { - return Math.max(a, b); - } - - // Get the end time for this timeline - function getEnd() { - return timespans.map(getTimespanEnd).reduce(max, getStart()); - } - - // Get the duration of this timeline - function getDuration() { - return getEnd() - getStart(); - } - - // Set the start time associated with this object - function setStart(value) { - mutation.mutate(function (m) { - m.start.timestamp = Math.max(value, 0); - }, model.modified); - } - - // Set the duration associated with this object - function setDuration() { - // No-op; duration is implicit - } - - // Set the end time associated with this object - function setEnd() { - // No-op; end time is implicit - } - - // Get the epoch used by this timeline - function getEpoch() { - return model.start.epoch; - } - - return { - /** - * Get the start time, in milliseconds relative to the epoch. - * @returns {number} the start time - */ - getStart: getStart, - /** - * Get the duration, in milliseconds. - * @returns {number} the duration - */ - getDuration: getDuration, - /** - * Get the end time, in milliseconds relative to the epoch. - * @returns {number} the end time - */ - getEnd: getEnd, - /** - * Set the start time, in milliseconds relative to the epoch. - * @param {number} the new value - */ - setStart: setStart, - /** - * Set the duration, in milliseconds. Timeline durations are - * implicit, so this is actually a no-op - * @param {number} the new value - */ - setDuration: setDuration, - /** - * Set the end time, in milliseconds. Timeline end times are - * implicit, so this is actually a no-op. - * @param {number} the new value - */ - setEnd: setEnd, - /** - * Get a string identifying the reference epoch used for - * start and end times. - * @returns {string} the epoch - */ - getEpoch: getEpoch - }; - } - - return TimelineTimespan; - } -); diff --git a/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js b/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js deleted file mode 100644 index 3306380b21..0000000000 --- a/platform/features/timeline/src/capabilities/TimelineTimespanCapability.js +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./TimelineTimespan'], - function (TimelineTimespan) { - - /** - * Implements the `timespan` capability for Timeline objects. - * - * @constructor - * @param $q Angular's $q, for promise-handling - * @param {DomainObject} domainObject the Timeline - */ - function TimelineTimespanCapability($q, domainObject) { - // Check if a capability is defin - - // Look up a child object's time span - function lookupTimeSpan(childObject) { - return childObject.useCapability('timespan'); - } - - // Check if a child object exposes a time span - function hasTimeSpan(childObject) { - return childObject.hasCapability('timespan'); - } - - // Instantiate a time span bounding other time spans - function giveTimeSpan(timespans) { - return new TimelineTimespan( - domainObject.getModel(), - domainObject.getCapability('mutation'), - timespans - ); - } - - // Build a time span object that fits all children - function buildTimeSpan(childObjects) { - return $q.all( - childObjects.filter(hasTimeSpan).map(lookupTimeSpan) - ).then(giveTimeSpan); - } - - // Promise - function promiseTimeSpan() { - return domainObject.useCapability('composition') - .then(buildTimeSpan); - } - - return { - /** - * Get the time span (start, end, duration) of this timeline. - * @returns {Promise.} the time span of - * this timeline - */ - invoke: promiseTimeSpan - }; - } - - // Only applies to timeline objects - TimelineTimespanCapability.appliesTo = function (model) { - return model && (model.type === 'timeline'); - }; - - return TimelineTimespanCapability; - - } -); diff --git a/platform/features/timeline/src/capabilities/TimelineUtilization.js b/platform/features/timeline/src/capabilities/TimelineUtilization.js deleted file mode 100644 index 6062b04055..0000000000 --- a/platform/features/timeline/src/capabilities/TimelineUtilization.js +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Provides data to populate resource graphs associated - * with timelines in a timeline view. - * This is a placeholder until WTD-918. - * @constructor - */ - function TimelineUtilization() { - return { - getPointCount: function () { - return 1000; - }, - getDomainValue: function (index) { - return 60000 * index; - }, - getRangeValue: function (index) { - return Math.sin(index) * (index % 10); - } - }; - } - - return TimelineUtilization; - } - -); diff --git a/platform/features/timeline/src/capabilities/UtilizationCapability.js b/platform/features/timeline/src/capabilities/UtilizationCapability.js deleted file mode 100644 index cd035f15c5..0000000000 --- a/platform/features/timeline/src/capabilities/UtilizationCapability.js +++ /dev/null @@ -1,224 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Provide the resource utilization over time for a timeline - * or activity object. A utilization is presented as an object - * with four properties: - * * `key`: The resource being utilized. - * * `value`: The numeric utilization of that resource. - * * `start`: The start time of the resource's utilization. - * * `end`: The duration of this resource's utilization. - * * `epoch`: The epoch to which `start` is relative. - * @constructor - */ - function UtilizationCapability($q, domainObject) { - - // Utility function for array reduction - function concatenate(a, b) { - return (a || []).concat(b || []); - } - - // Check whether an element in an array looks unique (for below) - function unique(element, index, array) { - return (index === 0) || (array[index - 1] !== element); - } - - // Utility function to ensure sorted array is all unique - function uniquify(array) { - return array.filter(unique); - } - - // Utility function for sorting strings arrays - function sort(array) { - return array.sort(); - } - - // Combine into one big array - function flatten(arrayOfArrays) { - return arrayOfArrays.reduce(concatenate, []); - } - - // Promise the objects contained by this timeline/activity - function promiseComposition() { - return $q.when(domainObject.useCapability('composition') || []); - } - - // Promise all subsystem modes associated with this object - function promiseModes() { - var relationship = domainObject.getCapability('relationship'), - modes = relationship && relationship.getRelatedObjects('modes'); - return $q.when(modes || []); - } - - // Promise the utilization which results directly from this object - function promiseInternalUtilization() { - var utilizations = {}; - - // Record the cost of a given activity mode - function addUtilization(mode) { - var cost = mode.getCapability('cost'); - if (cost) { - cost.resources().forEach(function (k) { - utilizations[k] = utilizations[k] || 0; - utilizations[k] += cost.cost(k); - }); - } - } - - // Record costs for these modes - function addUtilizations(modes) { - modes.forEach(addUtilization); - } - - // Look up start/end times for this object - function lookupTimespan() { - return domainObject.useCapability('timespan'); - } - - // Provide the result - function giveResult(timespan) { - // Convert to utilization objects - return Object.keys(utilizations).sort().map(function (k) { - return { - key: k, - value: utilizations[k], - start: timespan.getStart(), - end: timespan.getEnd(), - epoch: timespan.getEpoch() - }; - }); - } - - return promiseModes() - .then(addUtilizations) - .then(lookupTimespan) - .then(giveResult); - } - - // Look up a specific object's resource utilization - function lookupUtilization(object) { - return object.useCapability('utilization'); - } - - // Look up a specific object's resource utilization keys - function lookupUtilizationResources(object) { - var utilization = object.getCapability('utilization'); - return utilization && utilization.resources(); - } - - // Promise a consolidated list of resource utilizations - function mapUtilization(objects) { - return $q.all(objects.map(lookupUtilization)) - .then(flatten); - } - - // Promise a consolidated list of resource utilization keys - function mapUtilizationResources(objects) { - return $q.all(objects.map(lookupUtilizationResources)) - .then(flatten); - } - - // Promise utilization associated with contained objects - function promiseExternalUtilization() { - // Get the composition, then consolidate their utilizations - return promiseComposition().then(mapUtilization); - } - - // Get resource keys for this mode - function getModeKeys(mode) { - var cost = mode.getCapability('cost'); - return cost ? cost.resources() : []; - } - - // Map the above (for use in below) - function mapModeKeys(modes) { - return modes.map(getModeKeys); - } - - // Promise identifiers for resources associated with modes - function promiseInternalKeys() { - return promiseModes().then(mapModeKeys).then(flatten); - } - - // Promise identifiers for resources associated with modes - function promiseExternalKeys() { - return promiseComposition().then(mapUtilizationResources); - } - - // Promise identifiers for resources used - function promiseResourceKeys() { - return $q.all([ - promiseInternalKeys(), - promiseExternalKeys() - ]).then(flatten).then(sort).then(uniquify); - } - - // Promise all utilization - function promiseAllUtilization() { - // Concatenate internal utilization (from activity modes) - // with external utilization (from subactivities) - return $q.all([ - promiseInternalUtilization(), - promiseExternalUtilization() - ]).then(flatten); - } - - return { - /** - * Get the keys for resources associated with this object. - * @returns {Promise.} a promise for resource identifiers - */ - resources: promiseResourceKeys, - /** - * Get the resource utilization associated with this object - * directly, not including any resource utilization associated - * with contained objects. - * @returns {Promise.} - */ - internal: promiseInternalUtilization, - /** - * Get the resource utilization associated with this - * object. Results are not sorted. This requires looking - * at contained objects, which in turn must happen - * asynchronously, so this returns a promise. - * @returns {Promise.} a promise for all resource - * utilizations - */ - invoke: promiseAllUtilization - }; - } - - // Only applies to timelines and activities - UtilizationCapability.appliesTo = function (model) { - return model && - ((model.type === 'timeline') || - (model.type === 'activity')); - }; - - return UtilizationCapability; - } -); diff --git a/platform/features/timeline/src/chart/Canvas2DChart.js b/platform/features/timeline/src/chart/Canvas2DChart.js deleted file mode 100644 index 2bfa0dee3f..0000000000 --- a/platform/features/timeline/src/chart/Canvas2DChart.js +++ /dev/null @@ -1,117 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Create a new chart which uses Canvas's 2D API for rendering. - * - * @memberof platform/features/plot - * @constructor - * @implements {platform/features/plot.Chart} - * @param {CanvasElement} canvas the canvas object to render upon - * @throws {Error} an error is thrown if Canvas's 2D API is unavailable. - */ - function Canvas2DChart(canvas) { - this.canvas = canvas; - this.c2d = canvas.getContext('2d'); - this.width = canvas.width; - this.height = canvas.height; - this.dimensions = [this.width, this.height]; - this.origin = [0, 0]; - - if (!this.c2d) { - throw new Error("Canvas 2d API unavailable."); - } - } - - // Convert from logical to physical x coordinates - Canvas2DChart.prototype.x = function (v) { - return ((v - this.origin[0]) / this.dimensions[0]) * this.width; - }; - - // Convert from logical to physical y coordinates - Canvas2DChart.prototype.y = function (v) { - return this.height - - ((v - this.origin[1]) / this.dimensions[1]) * this.height; - }; - - // Set the color to be used for drawing operations - Canvas2DChart.prototype.setColor = function (color) { - var mappedColor = color.map(function (c, i) { - return i < 3 ? Math.floor(c * 255) : (c); - }).join(','); - this.c2d.strokeStyle = "rgba(" + mappedColor + ")"; - this.c2d.fillStyle = "rgba(" + mappedColor + ")"; - }; - - - Canvas2DChart.prototype.clear = function () { - var canvas = this.canvas; - this.width = canvas.width; - this.height = canvas.height; - this.c2d.clearRect(0, 0, this.width, this.height); - }; - - Canvas2DChart.prototype.setDimensions = function (newDimensions, newOrigin) { - this.dimensions = newDimensions; - this.origin = newOrigin; - }; - - Canvas2DChart.prototype.drawLine = function (buf, color, points) { - var i; - - this.setColor(color); - - // Configure context to draw two-pixel-thick lines - this.c2d.lineWidth = 2; - - // Start a new path... - if (buf.length > 1) { - this.c2d.beginPath(); - this.c2d.moveTo(this.x(buf[0]), this.y(buf[1])); - } - - // ...and add points to it... - for (i = 2; i < points * 2; i = i + 2) { - this.c2d.lineTo(this.x(buf[i]), this.y(buf[i + 1])); - } - - // ...before finally drawing it. - this.c2d.stroke(); - }; - - Canvas2DChart.prototype.drawSquare = function (min, max, color) { - var x1 = this.x(min[0]), - y1 = this.y(min[1]), - w = this.x(max[0]) - x1, - h = this.y(max[1]) - y1; - - this.setColor(color); - this.c2d.fillRect(x1, y1, w, h); - }; - - return Canvas2DChart; - } -); diff --git a/platform/features/timeline/src/chart/GLChart.js b/platform/features/timeline/src/chart/GLChart.js deleted file mode 100644 index a625dffdeb..0000000000 --- a/platform/features/timeline/src/chart/GLChart.js +++ /dev/null @@ -1,160 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * Module defining GLPlot. Created by vwoeltje on 11/12/14. - */ -define( - [], - function () { - - // WebGL shader sources (for drawing plain colors) - var FRAGMENT_SHADER = [ - "precision mediump float;", - "uniform vec4 uColor;", - "void main(void) {", - "gl_FragColor = uColor;", - "}" - ].join('\n'), - VERTEX_SHADER = [ - "attribute vec2 aVertexPosition;", - "uniform vec2 uDimensions;", - "uniform vec2 uOrigin;", - "void main(void) {", - "gl_Position = vec4(2.0 * ((aVertexPosition - uOrigin) / uDimensions) - vec2(1,1), 0, 1);", - "}" - ].join('\n'); - - /** - * Create a new chart which uses WebGL for rendering. - * - * @memberof platform/features/plot - * @constructor - * @implements {platform/features/plot.Chart} - * @param {CanvasElement} canvas the canvas object to render upon - * @throws {Error} an error is thrown if WebGL is unavailable. - */ - function GLChart(canvas) { - var gl = canvas.getContext("webgl", { preserveDrawingBuffer: true }) || - canvas.getContext("experimental-webgl", { preserveDrawingBuffer: true }), - vertexShader, - fragmentShader, - program, - aVertexPosition, - uColor, - uDimensions, - uOrigin; - - // Ensure a context was actually available before proceeding - if (!gl) { - throw new Error("WebGL unavailable."); - } - - // Initialize shaders - vertexShader = gl.createShader(gl.VERTEX_SHADER); - gl.shaderSource(vertexShader, VERTEX_SHADER); - gl.compileShader(vertexShader); - fragmentShader = gl.createShader(gl.FRAGMENT_SHADER); - gl.shaderSource(fragmentShader, FRAGMENT_SHADER); - gl.compileShader(fragmentShader); - - // Assemble vertex/fragment shaders into programs - program = gl.createProgram(); - gl.attachShader(program, vertexShader); - gl.attachShader(program, fragmentShader); - gl.linkProgram(program); - gl.useProgram(program); - - // Get locations for attribs/uniforms from the - // shader programs (to pass values into shaders at draw-time) - aVertexPosition = gl.getAttribLocation(program, "aVertexPosition"); - uColor = gl.getUniformLocation(program, "uColor"); - uDimensions = gl.getUniformLocation(program, "uDimensions"); - uOrigin = gl.getUniformLocation(program, "uOrigin"); - gl.enableVertexAttribArray(aVertexPosition); - - // Create a buffer to holds points which will be drawn - this.buffer = gl.createBuffer(); - - // Use a line width of 2.0 for legibility - gl.lineWidth(2.0); - - // Enable blending, for smoothness - gl.enable(gl.BLEND); - gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); - - this.gl = gl; - this.aVertexPosition = aVertexPosition; - this.uColor = uColor; - this.uDimensions = uDimensions; - this.uOrigin = uOrigin; - } - - // Utility function to handle drawing of a buffer; - // drawType will determine whether this is a box, line, etc. - GLChart.prototype.doDraw = function (drawType, buf, color, points) { - var gl = this.gl; - gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer); - gl.bufferData(gl.ARRAY_BUFFER, buf, gl.DYNAMIC_DRAW); - gl.vertexAttribPointer(this.aVertexPosition, 2, gl.FLOAT, false, 0, 0); - gl.uniform4fv(this.uColor, color); - gl.drawArrays(drawType, 0, points); - }; - - GLChart.prototype.clear = function () { - var gl = this.gl; - - // Set the viewport size; note that we use the width/height - // that our WebGL context reports, which may be lower - // resolution than the canvas we requested. - gl.viewport( - 0, - 0, - gl.drawingBufferWidth, - gl.drawingBufferHeight - ); - gl.clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT); - }; - - - GLChart.prototype.setDimensions = function (dimensions, origin) { - var gl = this.gl; - if (dimensions && dimensions.length > 0 && - origin && origin.length > 0) { - gl.uniform2fv(this.uDimensions, dimensions); - gl.uniform2fv(this.uOrigin, origin); - } - }; - - GLChart.prototype.drawLine = function (buf, color, points) { - this.doDraw(this.gl.LINE_STRIP, buf, color, points); - }; - - GLChart.prototype.drawSquare = function (min, max, color) { - this.doDraw(this.gl.TRIANGLE_FAN, new Float32Array( - min.concat([min[0], max[1]]).concat(max).concat([max[0], min[1]]) - ), color, 4); - }; - - return GLChart; - } -); diff --git a/platform/features/timeline/src/chart/MCTTimelineChart.js b/platform/features/timeline/src/chart/MCTTimelineChart.js deleted file mode 100644 index b7d9482eb5..0000000000 --- a/platform/features/timeline/src/chart/MCTTimelineChart.js +++ /dev/null @@ -1,250 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * Module defining MCTTimelineChart. Created by vwoeltje on 11/12/14. - */ -define( - ["./GLChart", "./Canvas2DChart"], - function (GLChart, Canvas2DChart) { - - var TEMPLATE = ""; - - /** - * The mct-timeline-chart directive provides a canvas element which can be - * drawn upon, to support Plot view and similar visualizations. - * - * This directive takes one attribute, "draw", which is an Angular - * expression which will be two-way bound to a drawing object. This - * drawing object should contain: - * - * * `dimensions`: An object describing the logical bounds of the - * drawable area, containing two fields: - * * `origin`: The position, in logical coordinates, of the - * lower-left corner of the chart area. A two-element array. - * * `dimensions`: A two-element array containing the width - * and height of the chart area, in logical coordinates. - * * `lines`: An array of lines to be drawn, where each line is - * expressed as an object containing: - * * `buffer`: A Float32Array containing points in the line, - * in logical coordinate, in sequential x/y pairs. - * * `color`: The color of the line, as a four-element RGBA - * array, where each element is in the range of 0.0-1.0 - * * `points`: The number of points in the line. - * * `boxes`: An array of rectangles to draw in the chart area - * (used for marquee zoom). Each is an object containing: - * * `start`: The first corner of the rectangle (as a two-element - * array, logical coordinates) - * * `end`: The opposite corner of the rectangle (again, as a - * two-element array) - * * `color`: The color of the box, as a four-element RGBA - * array, where each element is in the range of 0.0-1.0 - * - * @memberof platform/features/plot - * @constructor - */ - function MCTTimelineChart($interval, $log) { - // Get an underlying chart implementation - function getChart(Charts, canvas) { - // Try the first available option... - var Chart = Charts[0]; - - // This function recursively try-catches all options; - // if these all fail, issue a warning. - if (!Chart) { - $log.warn("Cannot initialize mct-timeline-chart."); - return undefined; - } - - // Try first option; if it fails, try remaining options - try { - return new Chart(canvas); - } catch (e) { - $log.warn([ - "Could not instantiate chart", - Chart.name, - ";", - e.message - ].join(" ")); - - return getChart(Charts.slice(1), canvas); - } - } - - function linkChart(scope, element) { - var canvas = element.find("canvas")[0], - activeInterval, - chart; - - // Handle drawing, based on contents of the "draw" object - // in scope - function doDraw(draw) { - // Ensure canvas context has same resolution - // as canvas element - canvas.width = canvas.offsetWidth; - canvas.height = canvas.offsetHeight; - - // Clear previous contents - chart.clear(); - - // Nothing to draw if no draw object defined - if (!draw) { - return; - } - - // Set logical boundaries for the chart - chart.setDimensions( - draw.dimensions || [1, 1], - draw.origin || [0, 0] - ); - - // Draw line segments - (draw.lines || []).forEach(function (line) { - chart.drawLine( - line.buffer, - line.color, - line.points - ); - }); - - // Draw boxes (e.g. marquee zoom rect) - (draw.boxes || []).forEach(function (box) { - chart.drawSquare( - box.start, - box.end, - box.color - ); - }); - - } - - // Issue a drawing call, if-and-only-if canvas size - // has changed. This will be called on a timer, since - // there is no event to depend on. - function drawIfResized() { - if (canvas.width !== canvas.offsetWidth || - canvas.height !== canvas.offsetHeight) { - doDraw(scope.draw); - scope.$apply(); - } - } - - // Stop watching for changes to size (scope destroyed) - function releaseInterval() { - if (activeInterval) { - $interval.cancel(activeInterval); - } - } - - // Switch from WebGL to plain 2D if context is lost - function fallbackFromWebGL() { - element.html(TEMPLATE); - canvas = element.find("canvas")[0]; - chart = getChart([Canvas2DChart], canvas); - if (chart) { - doDraw(scope.draw); - } - } - - // Try to initialize a chart. - chart = getChart([GLChart, Canvas2DChart], canvas); - - // If that failed, there's nothing more we can do here. - // (A warning will already have been issued) - if (!chart) { - return; - } - - // WebGL is a bit of a special case; it may work, then fail - // later for various reasons, so we need to listen for this - // and fall back to plain canvas drawing when it occurs. - canvas.addEventListener("webglcontextlost", fallbackFromWebGL); - - // Check for resize, on a timer - activeInterval = $interval(drawIfResized, 1000, 0, false); - - // Watch "draw" for external changes to the set of - // things to be drawn. - scope.$watchCollection("draw", doDraw); - - // Stop checking for resize when scope is destroyed - scope.$on("$destroy", releaseInterval); - } - - return { - // Apply directive only to elements - restrict: "E", - - // Template to use (a canvas element) - template: TEMPLATE, - - // Link function; set up scope - link: linkChart, - - // Initial, isolate scope for the directive - scope: { draw: "=" } - }; - } - - /** - * @interface platform/features/plot.Chart - * @private - */ - - /** - * Clear the chart. - * @method platform/features/plot.Chart#clear - */ - /** - * Set the logical boundaries of the chart. - * @param {number[]} dimensions the horizontal and - * vertical dimensions of the chart - * @param {number[]} origin the horizontal/vertical - * origin of the chart - * @memberof platform/features/plot.Chart#setDimensions - */ - /** - * Draw the supplied buffer as a line strip (a sequence - * of line segments), in the chosen color. - * @param {Float32Array} buf the line strip to draw, - * in alternating x/y positions - * @param {number[]} color the color to use when drawing - * the line, as an RGBA color where each element - * is in the range of 0.0-1.0 - * @param {number} points the number of points to draw - * @memberof platform/features/plot.Chart#drawLine - */ - /** - * Draw a rectangle extending from one corner to another, - * in the chosen color. - * @param {number[]} min the first corner of the rectangle - * @param {number[]} max the opposite corner - * @param {number[]} color the color to use when drawing - * the rectangle, as an RGBA color where each element - * is in the range of 0.0-1.0 - * @memberof platform/features/plot.Chart#drawSquare - */ - - return MCTTimelineChart; - } -); - diff --git a/platform/features/timeline/src/controllers/ActivityModeValuesController.js b/platform/features/timeline/src/controllers/ActivityModeValuesController.js deleted file mode 100644 index d191d95167..0000000000 --- a/platform/features/timeline/src/controllers/ActivityModeValuesController.js +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Controller which support the Values view of Activity Modes. - * @constructor - * @param {Array} resources definitions for extensions of - * category `resources` - */ - function ActivityModeValuesController(resources) { - var metadata = {}; - - // Store metadata for a specific resource type - function storeMetadata(resource) { - var key = (resource || {}).key; - if (key) { - metadata[key] = resource; - } - } - - // Populate the lookup table to resource metadata - resources.forEach(storeMetadata); - - return { - /** - * Look up metadata associated with the specified - * resource type. - */ - metadata: function (key) { - return metadata[key]; - } - }; - } - - return ActivityModeValuesController; - } -); diff --git a/platform/features/timeline/src/controllers/TimelineController.js b/platform/features/timeline/src/controllers/TimelineController.js deleted file mode 100644 index 2b67dc3caa..0000000000 --- a/platform/features/timeline/src/controllers/TimelineController.js +++ /dev/null @@ -1,143 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [ - './swimlane/TimelineSwimlanePopulator', - './graph/TimelineGraphPopulator', - './drag/TimelineDragPopulator' - ], - function ( - TimelineSwimlanePopulator, - TimelineGraphPopulator, - TimelineDragPopulator - ) { - - /** - * Controller for the Timeline view. - * @constructor - */ - function TimelineController($scope, $q, objectLoader, MINIMUM_DURATION) { - var swimlanePopulator = new TimelineSwimlanePopulator( - objectLoader, - $scope.configuration || {}, - $scope.selection - ), - graphPopulator = new TimelineGraphPopulator($q), - dragPopulator = new TimelineDragPopulator(objectLoader); - - // Hash together all modification times. A sum is sufficient here, - // since modified timestamps should be non-decreasing. - function modificationSum() { - var sum = 0; - swimlanePopulator.get().forEach(function (swimlane) { - sum += swimlane.domainObject.getModel().modified || 0; - }); - return sum; - } - - // Reduce graph states to a watch-able number. A bitmask is - // sufficient here, since only ~30 graphed elements make sense - // (due to limits on recognizably unique line colors) - function graphMask() { - var mask = 0, bit = 1; - swimlanePopulator.get().forEach(function (swimlane) { - mask += swimlane.graph() ? 0 : bit; - bit *= 2; - }); - return mask; - } - - // Repopulate based on detected modification to in-view objects - function repopulateSwimlanes() { - swimlanePopulator.populate($scope.domainObject); - dragPopulator.populate($scope.domainObject); - graphPopulator.populate(swimlanePopulator.get()); - } - - // Repopulate graphs based on modification to swimlane graph state - function repopulateGraphs() { - graphPopulator.populate(swimlanePopulator.get()); - } - - // Refresh resource graphs - function refresh() { - if (graphPopulator) { - graphPopulator.get().forEach(function (graph) { - graph.refresh(); - }); - } - } - - $scope.$watch("configuration", swimlanePopulator.configure); - - // Recalculate swimlane state on changes - $scope.$watch("domainObject", swimlanePopulator.populate); - - // Also recalculate whenever anything in view is modified - $scope.$watch(modificationSum, repopulateSwimlanes); - - // Carry over changes in swimlane set to changes in graphs - $scope.$watch(graphMask, repopulateGraphs); - - // Pass selection object into swimlane populator - $scope.$watch("selection", swimlanePopulator.selection); - - // Convey current selection to drag handle populator - $scope.$watch("selection.get()", dragPopulator.select); - - // Provide initial scroll bar state, container for pane positions - $scope.scroll = { x: 0, y: 0 }; - $scope.panes = {}; - - // Expose active set of swimlanes - return { - /** - * Get the end of the displayed timeline, in milliseconds. - * @returns {number} the end of the displayed timeline - */ - end: swimlanePopulator.end.bind(swimlanePopulator), - /** - * Get the swimlanes which should currently be displayed. - * @returns {TimelineSwimlane[]} the swimlanes - */ - swimlanes: swimlanePopulator.get, - /** - * Get the resource graphs which should currently be displayed. - * @returns {TimelineGraph[]} the graphs - */ - graphs: graphPopulator.get, - /** - * Get drag handles for the current selection. - * @returns {TimelineDragHandle[]} the drag handles - */ - handles: dragPopulator.get, - /** - * Refresh resource graphs (during drag.) - */ - refresh: refresh - }; - } - - return TimelineController; - } -); diff --git a/platform/features/timeline/src/controllers/TimelineDateTimeController.js b/platform/features/timeline/src/controllers/TimelineDateTimeController.js deleted file mode 100644 index 7d66acd96d..0000000000 --- a/platform/features/timeline/src/controllers/TimelineDateTimeController.js +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Controller for the `datetime` form control. - * This is a composite control; it includes multiple - * input fields but outputs a single timestamp (in - * milliseconds since start of 1970) to the ngModel. - * - * @constructor - */ - function DateTimeController($scope) { - - // Update the data model - function updateModel(datetime) { - var days = parseInt(datetime.days, 10) || 0, - hour = parseInt(datetime.hours, 10) || 0, - min = parseInt(datetime.minutes, 10) || 0, - sec = parseInt(datetime.seconds, 10) || 0, - epoch = "SET", // Only permit SET, for now - timestamp; - - // Build up timestamp - timestamp = days * 24; - timestamp = (hour + timestamp) * 60; - timestamp = (min + timestamp) * 60; - timestamp = (sec + timestamp) * 1000; - - // Set in the model - $scope.ngModel[$scope.field] = { - timestamp: timestamp, - epoch: epoch - }; - } - - // Update the displayed state - function updateForm(modelState) { - var timestamp = (modelState || {}).timestamp || 0, - datetime = $scope.datetime; - - timestamp = Math.floor(timestamp / 1000); - datetime.seconds = timestamp % 60; - timestamp = Math.floor(timestamp / 60); - datetime.minutes = timestamp % 60; - timestamp = Math.floor(timestamp / 60); - datetime.hours = timestamp % 24; - timestamp = Math.floor(timestamp / 24); - datetime.days = timestamp; - } - - // Retrieve state from field, for watch - function getModelState() { - return $scope.ngModel[$scope.field]; - } - - // Update value whenever any field changes. - $scope.$watchCollection("datetime", updateModel); - $scope.$watchCollection(getModelState, updateForm); - - // Initialize the scope - $scope.datetime = {}; - updateForm(getModelState()); - } - - return DateTimeController; - - } -); diff --git a/platform/features/timeline/src/controllers/TimelineGanttController.js b/platform/features/timeline/src/controllers/TimelineGanttController.js deleted file mode 100644 index 6153064ebe..0000000000 --- a/platform/features/timeline/src/controllers/TimelineGanttController.js +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Control for Gantt bars in a timeline view. - * Primarily responsible for supporting the positioning of Gantt - * bars; particularly, this ensures that the left and right edges - * never go to far off screen, because in some environments this - * will effect rendering performance without visible results. - * @constructor - * @param {number} MAXIMUM_OFFSCREEN the maximum number of pixels - * allowed to go off-screen (to either the left or the right) - */ - function TimelineGanttController(MAXIMUM_OFFSCREEN) { - // Pixel position for the CSS left property - function left(timespan, scroll, toPixels) { - return Math.max( - toPixels(timespan.getStart()), - scroll.x - MAXIMUM_OFFSCREEN - ); - } - - // Pixel value for the CSS width property - function width(timespan, scroll, toPixels) { - var x = left(timespan, scroll, toPixels), - right = Math.min( - toPixels(timespan.getEnd()), - scroll.x + scroll.width + MAXIMUM_OFFSCREEN - ); - return right - x; - } - - return { - /** - * Get the pixel position for the `left` style property - * of a Gantt bar for the specified timespan. - * @param {Timespan} timespan the timespan to be represented - * @param scroll an object containing an `x` and `width` - * property, representing the scroll position and - * visible width, respectively. - * @param {Function} toPixels a function to convert - * a timestamp to a pixel position - * @returns {number} the pixel position of the left edge - */ - left: left, - /** - * Get the pixel value for the `width` style property - * of a Gantt bar for the specified timespan. - * @param {Timespan} timespan the timespan to be represented - * @param scroll an object containing an `x` and `width` - * property, representing the scroll position and - * visible width, respectively. - * @param {Function} toPixels a function to convert - * a timestamp to a pixel position - * @returns {number} the pixel width of this Gantt bar - */ - width: width - }; - } - - return TimelineGanttController; - } -); diff --git a/platform/features/timeline/src/controllers/TimelineGraphController.js b/platform/features/timeline/src/controllers/TimelineGraphController.js deleted file mode 100644 index dbf423e510..0000000000 --- a/platform/features/timeline/src/controllers/TimelineGraphController.js +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -define( - [], - function () { - - /** - * Controller for the graph area of a timeline view. - * The set of graphs to show is provided by the timeline - * controller and communicated into the template via "parameters" - * in scope. - * @constructor - */ - function TimelineGraphController($scope, resources) { - var resourceMap = {}, - labelCache = {}; - - // Add an element to the resource map - function addToResourceMap(resource) { - var key = resource.key; - if (key && !resourceMap[key]) { - resourceMap[key] = resource; - } - } - - // Update the display bounds for all graphs to match - // scroll and/or width. - function updateGraphs(parameters) { - (parameters.graphs || []).forEach(function (graph) { - graph.setBounds(parameters.origin, parameters.duration); - }); - } - - // Add all resources to map for simpler lookup - resources.forEach(addToResourceMap); - - // Update graphs as parameters change - $scope.$watchCollection("parameters", updateGraphs); - - return { - /** - * Get a label object (suitable to pass into the - * `timeline-resource-graph-labels` template) for - * the specified graph. - * @param {TimelineGraph} the graph to label - * @returns {object} an object containing labels - */ - label: function (graph) { - var key = graph.key, - resource = resourceMap[key] || {}, - name = resource.name || "", - units = resource.units, - min = graph.minimum() || 0, - max = graph.maximum() || 0, - label = labelCache[key] || {}; - - // Cache the label (this is passed into a template, - // so avoid excessive digest cycles) - labelCache[key] = label; - - // Include units in title - label.title = name + (units ? (" (" + units + ")") : ""); - - // Provide low, middle, high data values - label.low = min.toFixed(3); - label.middle = ((min + max) / 2).toFixed(3); - label.high = max.toFixed(3); - - return label; - } - }; - } - - return TimelineGraphController; - } -); diff --git a/platform/features/timeline/src/controllers/TimelineTOIController.js b/platform/features/timeline/src/controllers/TimelineTOIController.js deleted file mode 100644 index d189e48738..0000000000 --- a/platform/features/timeline/src/controllers/TimelineTOIController.js +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([], function () { - - /** - * Tracks time-of-interest in timelines, updating both scroll state - * (when appropriate) and positioning of the displayed line. - */ - function TimelineTOIController(openmct, timerService, $scope) { - this.openmct = openmct; - this.timerService = timerService; - this.$scope = $scope; - - this.change = this.change.bind(this); - this.bounds = this.bounds.bind(this); - this.destroy = this.destroy.bind(this); - - this.timerService.on('change', this.change); - this.openmct.time.on('bounds', this.bounds); - - this.$scope.$on('$destroy', this.destroy); - - this.$scope.scroll.follow = this.timerService.hasTimer(); - if (this.$scope.zoomController) { - this.bounds(this.openmct.time.bounds()); - } - } - - - /** - * Handle a `change` event from the timer service; track the - * new timer. - */ - TimelineTOIController.prototype.change = function () { - this.$scope.scroll.follow = - this.$scope.scroll.follow || this.timerService.hasTimer(); - }; - - /** - * Handle a `bounds` event from the time API; scroll the timeline - * to match the current bounds, if currently in follow mode. - */ - TimelineTOIController.prototype.bounds = function (bounds) { - if (this.isFollowing()) { - var start = this.timerService.convert(bounds.start); - var end = this.timerService.convert(bounds.end); - this.duration = bounds.end - bounds.start; - this.$scope.zoomController.bounds(start, end); - } - }; - - /** - * Handle a `$destroy` event from scope; detach all observers. - */ - TimelineTOIController.prototype.destroy = function () { - this.timerService.off('change', this.change); - this.openmct.time.off('bounds', this.bounds); - }; - - /** - * Get the x position of the time-of-interest line, - * in pixels from the left edge of the timeline area. - */ - TimelineTOIController.prototype.x = function () { - var now = this.timerService.now(); - - if (now === undefined) { - return undefined; - } - - return this.$scope.zoomController.toPixels(this.timerService.now()); - }; - - /** - * Check if there is an active time-of-interest to be shown. - * @return {boolean} true when active - */ - TimelineTOIController.prototype.isActive = function () { - return this.x() !== undefined; - }; - - /** - * Check if the timeline should be following time conductor bounds. - * @return {boolean} true when following - */ - TimelineTOIController.prototype.isFollowing = function () { - return !!this.$scope.scroll.follow && this.timerService.now() !== undefined; - }; - - return TimelineTOIController; -}); diff --git a/platform/features/timeline/src/controllers/TimelineTableController.js b/platform/features/timeline/src/controllers/TimelineTableController.js deleted file mode 100644 index 2b51f31ba4..0000000000 --- a/platform/features/timeline/src/controllers/TimelineTableController.js +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ["../TimelineFormatter"], - function (TimelineFormatter) { - - var FORMATTER = new TimelineFormatter(); - - /** - * Provides tabular data for the Timeline's tabular view area. - */ - function TimelineTableController() { - - function getNiceTime(millis) { - return FORMATTER.format(millis); - } - - return { - /** - * Return human-readable time in the expected format, - * currently SET. - * @param {number} millis duration, in millisecond - * @return {string} human-readable duration - */ - niceTime: getNiceTime - }; - } - - return TimelineTableController; - } -); diff --git a/platform/features/timeline/src/controllers/TimelineTickController.js b/platform/features/timeline/src/controllers/TimelineTickController.js deleted file mode 100644 index 56275a6d16..0000000000 --- a/platform/features/timeline/src/controllers/TimelineTickController.js +++ /dev/null @@ -1,116 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ["../TimelineFormatter"], - function (TimelineFormatter) { - - var FORMATTER = new TimelineFormatter(); - - /** - * Provides labels for the tick mark area of a timeline view. - * Since the tick mark region is potentially extremely large, - * only the subset of ticks which will actually be shown in - * view are provided. - * @constructor - */ - function TimelineTickController() { - var labels = [], - lastFirst, - lastStep, - lastCount, - lastStartMillis, - lastEndMillis; - - // Actually recalculate the labels from scratch - function calculateLabels(first, count, step, toMillis) { - var result = [], - current; - - // Create enough labels to fill the visible area - while (result.length < count) { - current = first + step * result.length; - result.push({ - // Horizontal pixel position of this label - left: current, - // Text to display in this label - text: FORMATTER.format(toMillis(current)) - }); - } - - return result; - } - - // Get tick labels for this pixel span (recalculating if needed) - function getLabels(start, width, step, toMillis) { - // Calculate parameters for labels (first pixel position, last - // pixel position.) These are checked to detect changes. - var first = Math.floor(start / step) * step, - last = Math.ceil((start + width) / step) * step, - count = ((last - first) / step) + 1, - startMillis = toMillis(first), - endMillis = toMillis(last), - changed = (lastFirst !== first) || - (lastCount !== count) || - (lastStep !== step) || - (lastStartMillis !== startMillis) || - (lastEndMillis !== endMillis); - - // This will be used in a template, so only recalculate on - // change. - if (changed) { - labels = calculateLabels(first, count, step, toMillis); - // Cache to avoid recomputing later - lastFirst = first; - lastCount = count; - lastStep = step; - lastStartMillis = startMillis; - lastEndMillis = endMillis; - } - - return labels; - } - - - return { - /** - * Get labels for use in the visible region of a timeline's - * tick mark area. This will return the same array instance - * (without recalculating its contents) if called with the - * same parameters (and same apparent zoom state, as determined - * via `toMillis`), so it is safe to use in a template. - * - * @param {number} start left-most pixel position in view - * @param {number} width pixel width in view - * @param {number} step size, in pixels, of each major tick - * @param {Function} toMillis function to convert from pixel - * positions to milliseconds - * @returns {Array} an array of tick mark labels, suitable - * for use in the `timeline-ticks` template - */ - labels: getLabels - }; - } - - return TimelineTickController; - } -); diff --git a/platform/features/timeline/src/controllers/TimelineZoomController.js b/platform/features/timeline/src/controllers/TimelineZoomController.js deleted file mode 100644 index b7af026b77..0000000000 --- a/platform/features/timeline/src/controllers/TimelineZoomController.js +++ /dev/null @@ -1,155 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -define( - [], - function () { - var PADDING = 0.25; - - /** - * Controls the pan-zoom state of a timeline view. - * @constructor - */ - function TimelineZoomController($scope, $window, ZOOM_CONFIGURATION) { - // Prefer to start with the middle index - var zoomLevels = ZOOM_CONFIGURATION.levels || [1000], - zoomIndex = Math.floor(zoomLevels.length / 2), - tickWidth = ZOOM_CONFIGURATION.width || 200, - lastWidth = Number.MAX_VALUE; // Don't constrain prematurely - - function toMillis(pixels) { - return (pixels / tickWidth) * zoomLevels[zoomIndex]; - } - - function toPixels(millis) { - return tickWidth * millis / zoomLevels[zoomIndex]; - } - - // Get/set zoom level - function setZoomLevel(level) { - if (!isNaN(level)) { - // Modify zoom level, keeping it in range - zoomIndex = Math.min( - Math.max(level, 0), - zoomLevels.length - 1 - ); - } - } - - function setScroll(x) { - $window.requestAnimationFrame(function () { - $scope.scroll.x = Math.min( - Math.max(x, 0), - lastWidth - $scope.scroll.width - ); - $scope.$apply(); - }); - } - - function initializeZoomFromStartEnd(start, end) { - var duration = end - start; - zoomIndex = 0; - while (toMillis($scope.scroll.width) < duration && - zoomIndex < zoomLevels.length - 1) { - zoomIndex += 1; - } - setScroll(toPixels(start)); - } - - function initializeZoomFromTimespan(timespan) { - return initializeZoomFromStartEnd( - timespan.getStart(), - timespan.getEnd() - ); - } - - function initializeZoom() { - if ($scope.domainObject) { - $scope.domainObject.useCapability('timespan') - .then(initializeZoomFromTimespan); - } - } - - $scope.$watch("domainObject", initializeZoom); - - return { - /** - * Increase or decrease the current zoom level by a given - * number of steps. Positive steps zoom in, negative steps - * zoom out. - * If called with no arguments, this returns the current - * zoom level, expressed as the number of milliseconds - * associated with a given tick mark. - * @param {number} steps how many steps to zoom in - * @returns {number} current zoom level (as the size of a - * major tick mark, in pixels) - */ - zoom: function (amount) { - // Update the zoom level if called with an argument - if (arguments.length > 0 && !isNaN(amount)) { - var bounds = $scope.scroll; - var center = this.toMillis(bounds.x + bounds.width / 2); - setZoomLevel(zoomIndex + amount); - setScroll(this.toPixels(center) - bounds.width / 2); - } - return zoomLevels[zoomIndex]; - }, - /** - * Adjust the current zoom bounds to fit both the - * start and the end time provided. - * @param {number} start the starting timestamp - * @param {number} end the ending timestamp - */ - bounds: initializeZoomFromStartEnd, - /** - * Set the zoom level to fit the bounds of the timeline - * being viewed. - */ - fit: initializeZoom, - /** - * Get the width, in pixels, of a specific time duration at - * the current zoom level. - * @returns {number} the number of pixels - */ - toPixels: toPixels, - /** - * Get the time duration, in milliseconds, occupied by the - * width (specified in pixels) at the current zoom level. - * @returns {number} the number of pixels - */ - toMillis: toMillis, - /** - * Set the maximum timestamp value to be displayed, and get - * the pixel width necessary to display this value. - * @param {number} timestamp the time to display - */ - width: function (timestamp) { - var pixels = Math.ceil(toPixels(timestamp * (1 + PADDING))); - lastWidth = Math.max($scope.scroll.width, pixels); - return lastWidth; - } - }; - } - - return TimelineZoomController; - - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js b/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js deleted file mode 100644 index 7ecdc36567..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineDragHandleFactory.js +++ /dev/null @@ -1,74 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./TimelineStartHandle', './TimelineEndHandle', './TimelineMoveHandle'], - function (TimelineStartHandle, TimelineEndHandle, TimelineMoveHandle) { - - - var DEFAULT_HANDLES = [ - TimelineStartHandle, - TimelineMoveHandle, - TimelineEndHandle - ], - TIMELINE_HANDLES = [ - TimelineStartHandle, - TimelineMoveHandle - ]; - - /** - * Create a factory for drag handles for timelines/activities - * in a timeline view. - * @constructor - */ - function TimelineDragHandleFactory(dragHandler, snapHandler) { - return { - /** - * Create drag handles for this domain object. - * @param {DomainObject} domainObject the object to be - * manipulated by these gestures - * @returns {Array} array of drag handles - */ - handles: function (domainObject) { - var type = domainObject.getCapability('type'), - id = domainObject.getId(); - - // Instantiate a handle - function instantiate(Handle) { - return new Handle( - id, - dragHandler, - snapHandler - ); - } - - // Instantiate smaller set of handles for timelines - return (type && type.instanceOf('timeline') ? - TIMELINE_HANDLES : DEFAULT_HANDLES) - .map(instantiate); - } - }; - } - - return TimelineDragHandleFactory; - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js b/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js deleted file mode 100644 index d7bb73c6ec..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineDragHandler.js +++ /dev/null @@ -1,248 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Handles business logic (mutation of objects, retrieval of start/end - * times) associated with drag gestures to manipulate start/end times - * of activities and timelines in a Timeline view. - * @constructor - * @param {DomainObject} domainObject the object being viewed - * @param {ObjectLoader} objectLoader service to assist in loading - * subtrees - */ - function TimelineDragHandler(domainObject, objectLoader) { - var timespans = {}, - mutations = {}, - compositions = {}, - dirty = {}; - - // "Cast" a domainObject to an id, if necessary - function toId(value) { - return (typeof value !== 'string' && value.getId) ? - value.getId() : value; - } - - // Get the timespan associated with this domain object - function populateCapabilityMaps(object) { - var id = object.getId(), - timespanPromise = object.useCapability('timespan'); - if (timespanPromise) { - timespanPromise.then(function (timespan) { - // Cache that timespan - timespans[id] = timespan; - // And its mutation capability - mutations[id] = object.getCapability('mutation'); - // And the composition, for bulk moves - compositions[id] = object.getModel().composition || []; - }); - } - } - - // Populate the id->timespan map - function populateTimespans(subgraph) { - populateCapabilityMaps(subgraph.domainObject); - subgraph.composition.forEach(populateTimespans); - } - - // Persist changes for objects by id (when dragging ends) - function finalMutate(id) { - var mutation = mutations[id]; - if (mutation) { - // Mutate just to update the timestamp (since we - // explicitly don't do this during the drag to - // avoid firing a ton of refreshes.) - mutation.mutate(function () {}); - } - } - - // Use the object loader to get objects which have timespans - objectLoader.load(domainObject, 'timespan').then(populateTimespans); - - return { - /** - * Get a list of identifiers for domain objects which have - * timespans that are managed here. - * @returns {string[]} ids for all objects which have managed - * timespans here - */ - ids: function () { - return Object.keys(timespans).sort(); - }, - /** - * Persist any changes to timespans that have been made through - * this handler. - */ - persist: function () { - // Persist every dirty object... - Object.keys(dirty).forEach(finalMutate); - // Clear out the dirty list - dirty = {}; - }, - /** - * Get the start time for a specific domain object. The domain - * object may be specified by its identifier, or passed as a - * domain object instance. If a second, numeric argument is - * passed, this functions as a setter. - * @returns {number} the start time - * @param {string|DomainObject} id the domain object to modify - * @param {number} [value] the new value - */ - start: function (id, value) { - // Convert to domain object id, look up timespan - var timespan = timespans[toId(id)]; - // Use as setter if argument is present - if ((typeof value === 'number') && timespan) { - // Set the start (ensuring that it's non-negative, - // and not after the end time.) - timespan.setStart( - Math.min(Math.max(value, 0), timespan.getEnd()) - ); - // Mark as dirty for subsequent persistence - dirty[toId(id)] = true; - } - // Return value from the timespan - return timespan && timespan.getStart(); - }, - /** - * Get the end time for a specific domain object. The domain - * object may be specified by its identifier, or passed as a - * domain object instance. If a second, numeric argument is - * passed, this functions as a setter. - * @returns {number} the end time - * @param {string|DomainObject} id the domain object to modify - * @param {number} [value] the new value - */ - end: function (id, value) { - // Convert to domain object id, look up timespan - var timespan = timespans[toId(id)]; - // Use as setter if argument is present - if ((typeof value === 'number') && timespan) { - // Set the end (ensuring it doesn't precede start) - timespan.setEnd( - Math.max(value, timespan.getStart()) - ); - // Mark as dirty for subsequent persistence - dirty[toId(id)] = true; - } - // Return value from the timespan - return timespan && timespan.getEnd(); - }, - /** - * Get the duration for a specific domain object. The domain - * object may be specified by its identifier, or passed as a - * domain object instance. If a second, numeric argument is - * passed, this functions as a setter. - * @returns {number} the duration - * @param {string|DomainObject} id the domain object to modify - * @param {number} [value] the new value - */ - duration: function (id, value) { - // Convert to domain object id, look up timespan - var timespan = timespans[toId(id)]; - // Use as setter if argument is present - if ((typeof value === 'number') && timespan) { - // Set duration (ensure that it's non-negative) - timespan.setDuration( - Math.max(value, 0) - ); - // Mark as dirty for subsequent persistence - dirty[toId(id)] = true; - } - // Return value from the timespan - return timespan && timespan.getDuration(); - }, - /** - * Move the start and end of this domain object by the - * specified delta. Contained objects will move as well. - * @param {string|DomainObject} id the domain object to modify - * @param {number} delta the amount by which to change - */ - move: function (id, delta) { - // Overview of algorithm used here: - // - Build up list of ids to actually move - // - Find the minimum start time - // - Change delta so it cannot move minimum past 0 - // - Update start, then end time - var ids = {}, - queue = [toId(id)], - minStart; - - // Update start & end, in that order - function updateStartEnd(spanId) { - var timespan = timespans[spanId], start, end; - if (timespan) { - // Get start/end so we don't get fooled by our - // own adjustments - start = timespan.getStart(); - end = timespan.getEnd(); - // Update start, then end - timespan.setStart(start + delta); - timespan.setEnd(end + delta); - // Mark as dirty for subsequent persistence - dirty[toId(spanId)] = true; - } - } - - // Build up set of ids - while (queue.length > 0) { - // Get the next id to consider - id = queue.shift(); - // If we haven't already considered this... - if (!ids[id]) { - // Add it to the set - ids[id] = true; - // And queue up its composition - queue = queue.concat(compositions[id] || []); - } - } - - // Find the minimum start time - minStart = Object.keys(ids).map(function (spanId) { - // Get the start time; default to +Inf if not - // found, since this will not survive a min - // test if any real timespans are present - return timespans[spanId] ? - timespans[spanId].getStart() : - Number.POSITIVE_INFINITY; - }).reduce(function (a, b) { - // Reduce with a minimum test - return Math.min(a, b); - }, Number.POSITIVE_INFINITY); - - // Ensure delta doesn't exceed bounds - delta = Math.max(delta, -minStart); - - // Update start/end times - if (delta !== 0) { - Object.keys(ids).forEach(updateStartEnd); - } - } - }; - } - - return TimelineDragHandler; - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js b/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js deleted file mode 100644 index 4821ffa5fd..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineDragPopulator.js +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./TimelineDragHandler', './TimelineSnapHandler', './TimelineDragHandleFactory'], - function (TimelineDragHandler, TimelineSnapHandler, TimelineDragHandleFactory) { - - /** - * Provides drag handles for the active selection in a timeline view. - * @constructor - */ - function TimelineDragPopulator(objectLoader) { - var handles = [], - factory, - selectedObject; - - // Refresh active set of drag handles - function refreshHandles() { - handles = (factory && selectedObject) ? - factory.handles(selectedObject) : - []; - } - - // Create a new factory for handles, based on root object in view - function populateForObject(domainObject) { - var dragHandler = domainObject && new TimelineDragHandler( - domainObject, - objectLoader - ); - - // Reinstantiate the factory - factory = dragHandler && new TimelineDragHandleFactory( - dragHandler, - new TimelineSnapHandler(dragHandler) - ); - - // If there's a selected object, restore the handles - refreshHandles(); - } - - // Change the current selection - function select(swimlane) { - // Cache selection to restore handles if other changes occur - selectedObject = swimlane && swimlane.domainObject; - - // Provide handles for this selection, if it's defined - refreshHandles(); - } - - return { - /** - * Get the currently-applicable set of drag handles. - * @returns {Array} drag handles - */ - get: function () { - return handles; - }, - /** - * Set the root object in view. Drag interactions consider - * the full graph for snapping behavior, so this is needed. - * @param {DomainObject} domainObject the timeline object - * being viewed - */ - populate: populateForObject, - /** - * Update selection state. Passing undefined means there - * is no selection. - * @param {TimelineSwimlane} swimlane the selected swimlane - */ - select: select - }; - } - - return TimelineDragPopulator; - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js b/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js deleted file mode 100644 index 7119106ef3..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineEndHandle.js +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../TimelineConstants'], - function (Constants) { - - /** - * Handle for changing the end time of a timeline or - * activity in the Timeline view. - * @constructor - * @param {string} id identifier of the domain object - * @param {TimelineDragHandler} dragHandler the handler which - * will update object state - * @param {TimelineSnapHandler} snapHandler the handler which - * provides candidate snap-to locations. - */ - function TimelineEndHandle(id, dragHandler, snapHandler) { - var initialEnd; - - // Get the snap-to location for a timestamp - function snap(timestamp, zoom) { - return snapHandler.snap( - timestamp, - zoom.toMillis(Constants.SNAP_WIDTH), - id - ); - } - - return { - /** - * Start dragging this handle. - */ - begin: function () { - // Cache the initial state - initialEnd = dragHandler.end(id); - }, - /** - * Drag this handle. - * @param {number} delta pixel delta from start - * @param {TimelineZoomController} zoom provider of zoom state - */ - drag: function (delta, zoom) { - if (initialEnd !== undefined) { - // Update the state - dragHandler.end( - id, - snap(initialEnd + zoom.toMillis(delta), zoom) - ); - } - }, - /** - * Finish dragging this handle. - */ - finish: function () { - // Clear initial state - initialEnd = undefined; - // Persist changes - dragHandler.persist(); - }, - /** - * Get a style object (suitable for passing into `ng-style`) - * for this handle. - * @param {TimelineZoomController} zoom provider of zoom state - */ - style: function (zoom) { - return { - left: zoom.toPixels(dragHandler.end(id)) - Constants.HANDLE_WIDTH + 'px', - width: Constants.HANDLE_WIDTH + 'px' - }; - } - }; - } - - return TimelineEndHandle; - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js b/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js deleted file mode 100644 index 1d5db7bf43..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineMoveHandle.js +++ /dev/null @@ -1,131 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../TimelineConstants'], - function (Constants) { - - /** - * Handle for moving (by drag) a timeline or - * activity in the Timeline view. - * @constructor - * @param {string} id identifier of the domain object - * @param {TimelineDragHandler} dragHandler the handler which - * will update object state - * @param {TimelineSnapHandler} snapHandler the handler which - * provides candidate snap-to locations. - */ - function TimelineMoveHandle(id, dragHandler, snapHandler) { - var initialStart, - initialEnd; - - // Get the snap-to location for a timestamp - function snap(timestamp, zoom) { - return snapHandler.snap( - timestamp, - zoom.toMillis(Constants.SNAP_WIDTH), - id - ); - } - - // Convert a pixel delta to a millisecond delta that will align - // with some useful snap location - function snapDelta(delta, zoom) { - var timeDelta = zoom.toMillis(delta), - desiredStart = initialStart + timeDelta, - desiredEnd = initialEnd + timeDelta, - snappedStart = snap(desiredStart, zoom), - snappedEnd = snap(desiredEnd, zoom), - diffStart = Math.abs(snappedStart - desiredStart), - diffEnd = Math.abs(snappedEnd - desiredEnd), - chooseEnd = false; - - // First, check for case where both changed... - if ((diffStart > 0) && (diffEnd > 0)) { - // ...and choose the smallest change that snaps. - chooseEnd = diffEnd < diffStart; - } else { - // ...otherwise, snap toward the end if it changed. - chooseEnd = diffEnd > 0; - } - // Start is chosen if diffEnd didn't snap, or nothing snapped - - // Our delta is relative to our initial state, but - // dragHandler.move is relative to current state, so whichever - // end we're snapping to, we need to compute a delta - // relative to the current state to get the desired result. - return chooseEnd ? - (snappedEnd - dragHandler.end(id)) : - (snappedStart - dragHandler.start(id)); - } - - return { - /** - * Start dragging this handle. - */ - begin: function () { - // Cache the initial state - initialStart = dragHandler.start(id); - initialEnd = dragHandler.end(id); - }, - /** - * Drag this handle. - * @param {number} delta pixel delta from start - * @param {TimelineZoomController} zoom provider of zoom state - */ - drag: function (delta, zoom) { - if (initialStart !== undefined && initialEnd !== undefined) { - if (delta !== 0) { - dragHandler.move(id, snapDelta(delta, zoom)); - } - } - }, - /** - * Finish dragging this handle. - */ - finish: function () { - // Clear initial state - initialStart = undefined; - initialEnd = undefined; - // Persist changes - dragHandler.persist(); - }, - /** - * Get a style object (suitable for passing into `ng-style`) - * for this handle. - * @param {TimelineZoomController} zoom provider of zoom state - */ - - style: function (zoom) { - return { - left: (zoom.toPixels(dragHandler.start(id)) + - Constants.HANDLE_WIDTH) + 'px', - width: (zoom.toPixels(dragHandler.duration(id)) - - Constants.HANDLE_WIDTH * 2) + 'px' - }; - } - }; - } - - return TimelineMoveHandle; - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js b/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js deleted file mode 100644 index 42d13b8681..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineSnapHandler.js +++ /dev/null @@ -1,106 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Snaps timestamps to match other timestamps within a - * certain tolerance, to support the snap-to-start-and-end - * behavior of drag interactions in a timeline view. - * @constructor - * @param {TimelineDragHandler} dragHandler the handler - * for drag interactions, which maintains start/end - * information for timelines in this view. - */ - function TimelineSnapHandler(dragHandler) { - // Snap to other end points - function snap(timestamp, tolerance, exclude) { - var result = timestamp, - closest = tolerance, - ids, - candidates; - - // Filter an id for inclusion - function include(id) { - return id !== exclude; - } - - // Evaluate a candidate timestamp as a snap-to location - function evaluate(candidate) { - var difference = Math.abs(candidate - timestamp); - // Is this closer than anything else we've found? - if (difference < closest) { - // ...then this is our new result - result = candidate; - // Track how close it was, for subsequent comparison. - closest = difference; - } - } - - // Look up start time; for mapping below - function getStart(id) { - return dragHandler.start(id); - } - - // Look up end time; for mapping below - function getEnd(id) { - return dragHandler.end(id); - } - - // Get list of candidate ids - ids = dragHandler.ids().filter(include); - - // Get candidate timestamps - candidates = ids.map(getStart).concat(ids.map(getEnd)); - - // ...and find the best one - candidates.forEach(evaluate); - - // Closest candidate (or original timestamp) is our result - // now, so return it. - return result; - } - - return { - /** - * Get a timestamp location that is near this - * timestamp (or simply return the provided - * timestamp if none are near enough, according - * to the specified tolerance.) - * Start/end times associated with the domain object - * with the specified identifier will be excluded - * from consideration (to avoid an undesired snap-to-self - * behavior.) - * @param {number} timestamp the timestamp to snap - * @param {number} tolerance the difference within which - * to snap - * @param {string} id the identifier to exclude - */ - snap: snap - }; - } - - return TimelineSnapHandler; - } -); diff --git a/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js b/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js deleted file mode 100644 index 21b631e475..0000000000 --- a/platform/features/timeline/src/controllers/drag/TimelineStartHandle.js +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../TimelineConstants'], - function (Constants) { - - /** - * Handle for changing the start time of a timeline or - * activity in the Timeline view. - * @constructor - * @param {string} id identifier of the domain object - * @param {TimelineDragHandler} dragHandler the handler which - * will update object state - * @param {TimelineSnapHandler} snapHandler the handler which - * provides candidate snap-to locations. - */ - function TimelineStartHandle(id, dragHandler, snapHandler) { - var initialStart; - - // Get the snap-to location for a timestamp - function snap(timestamp, zoom) { - return snapHandler.snap( - timestamp, - zoom.toMillis(Constants.SNAP_WIDTH), - id - ); - } - - return { - /** - * Start dragging this handle. - */ - begin: function () { - // Cache the initial state - initialStart = dragHandler.start(id); - }, - /** - * Drag this handle. - * @param {number} delta pixel delta from start - * @param {TimelineZoomController} zoom provider of zoom state - */ - drag: function (delta, zoom) { - if (initialStart !== undefined) { - // Update the state - dragHandler.start( - id, - snap(initialStart + zoom.toMillis(delta), zoom) - ); - } - }, - /** - * Finish dragging this handle. - */ - finish: function () { - // Clear initial state - initialStart = undefined; - // Persist changes - dragHandler.persist(); - }, - /** - * Get a style object (suitable for passing into `ng-style`) - * for this handle. - * @param {TimelineZoomController} zoom provider of zoom state - */ - style: function (zoom) { - return { - left: zoom.toPixels(dragHandler.start(id)) + 'px', - width: Constants.HANDLE_WIDTH + 'px' - }; - } - }; - } - - return TimelineStartHandle; - } -); diff --git a/platform/features/timeline/src/controllers/graph/TimelineGraph.js b/platform/features/timeline/src/controllers/graph/TimelineGraph.js deleted file mode 100644 index 62ffa68986..0000000000 --- a/platform/features/timeline/src/controllers/graph/TimelineGraph.js +++ /dev/null @@ -1,189 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Provides data to populate a graph in a timeline view. - * @constructor - * @param {string} key the resource's identifying key - * @param {Object.} domainObjects and object - * containing key-value pairs where keys are colors, and - * values are DomainObject instances to be drawn in that - * color - * @param {TimelineGraphRenderer} renderer a renderer which - * can be used to prepare Float32Array instances - */ - function TimelineGraph(key, domainObjects, renderer) { - var drawingObject = { origin: [0, 0], dimensions: [0, 0], modified: 0}, - // lines for the drawing object, by swimlane index - lines = [], - // min/max seen for a given swimlane, by swimlane index - extrema = [], - // current minimum - min = 0, - // current maximum - max = 0, - // line colors to display - colors = Object.keys(domainObjects); - - // Get minimum value, ensure there's some room - function minimum() { - return (min >= max) ? (max - 1) : min; - } - - // Get maximum value, ensure there's some room - function maximum() { - return (min >= max) ? (min + 1) : max; - } - - // Update minimum and maximum values - function updateMinMax() { - // Find the minimum among plot lines - min = extrema.map(function (ex) { - return ex.min; - }).reduce(function (a, b) { - return Math.min(a, b); - }, Number.POSITIVE_INFINITY); - - // Do the same for the maximum - max = extrema.map(function (ex) { - return ex.max; - }).reduce(function (a, b) { - return Math.max(a, b); - }, Number.NEGATIVE_INFINITY); - - // Ensure the infinities don't survive - min = min === Number.POSITIVE_INFINITY ? max : min; - min = min === Number.NEGATIVE_INFINITY ? 0 : min; - max = max === Number.NEGATIVE_INFINITY ? min : max; - } - - // Change contents of the drawing object (to trigger redraw) - function updateDrawingObject() { - // Update drawing object to include non-empty lines - drawingObject.lines = lines.filter(function (line) { - return line.points > 1; - }); - - // Update drawing bounds to fit data - drawingObject.origin[1] = minimum(); - drawingObject.dimensions[1] = maximum() - minimum(); - } - - // Update a specific line, by index - function updateLine(graph, index) { - var buffer = renderer.render(graph), - line = lines[index], - ex = extrema[index], - i; - - // Track minimum/maximum; note we skip x values - for (i = 1; i < buffer.length; i += 2) { - ex.min = Math.min(buffer[i], ex.min); - ex.max = Math.max(buffer[i], ex.max); - } - - // Update line in drawing object - line.buffer = buffer; - line.points = graph.getPointCount(); - line.color = renderer.decode(colors[index]); - - // Update the graph's total min/max - if (line.points > 0) { - updateMinMax(); - } - - // Update the drawing object (used to draw the graph) - updateDrawingObject(); - } - - // Request initialization for a line's contents - function populateLine(color, index) { - var domainObject = domainObjects[color], - graphPromise = domainObject.useCapability('graph'); - - if (graphPromise) { - graphPromise.then(function (g) { - if (g[key]) { - updateLine(g[key], index); - } - }); - } - } - - // Create empty lines - lines = colors.map(function () { - // Sentinel value to exclude these lines - return { points: 0 }; - }); - - // Specify initial min/max state per-line - extrema = colors.map(function () { - return { - min: Number.POSITIVE_INFINITY, - max: Number.NEGATIVE_INFINITY - }; - }); - - // Start creating lines for all swimlanes - colors.forEach(populateLine); - - return { - /** - * Get the minimum resource value that appears in this graph. - * @returns {number} the minimum value - */ - minimum: minimum, - /** - * Get the maximum resource value that appears in this graph. - * @returns {number} the maximum value - */ - maximum: maximum, - /** - * Set the displayed origin and duration, in milliseconds. - * @param {number} [value] value to set, if setting - */ - setBounds: function (offset, duration) { - // We don't update in-place, because we need the change - // to trigger a watch in mct-timeline-chart. - drawingObject.origin = [offset, drawingObject.origin[1]]; - drawingObject.dimensions = [duration, drawingObject.dimensions[1]]; - }, - /** - * Redraw lines in this graph. - */ - refresh: function () { - colors.forEach(populateLine); - }, - // Expose key, drawing object directly for use in templates - key: key, - drawingObject: drawingObject - }; - - } - - return TimelineGraph; - } -); diff --git a/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js b/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js deleted file mode 100644 index 6e26f3aa79..0000000000 --- a/platform/features/timeline/src/controllers/graph/TimelineGraphPopulator.js +++ /dev/null @@ -1,158 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -define( - ['./TimelineGraph', './TimelineGraphRenderer'], - function (TimelineGraph, TimelineGraphRenderer) { - - /** - * Responsible for determining which resource graphs - * to display (based on capabilities exposed by included - * domain objects) and allocating data to those different - * graphs. - * @constructor - */ - function TimelineGraphPopulator($q) { - var graphs = [], - cachedAssignments = {}, - renderer = new TimelineGraphRenderer(); - - // Compare two domain objects - function idsMatch(objA, objB) { - return (objA && objA.getId && objA.getId()) === - (objB && objB.getId && objB.getId()); - } - - // Compare two object sets for equality, to detect - // when graph updates are truly needed. - function deepEquals(objA, objB) { - var keysA, keysB; - - // Check if all keys in both objects match - function keysMatch(keys) { - return keys.map(function (k) { - return deepEquals(objA[k], objB[k]); - }).reduce(function (a, b) { - return a && b; - }, true); - } - - // First, check if they're matching domain objects - if (typeof (objA && objA.getId) === 'function') { - return idsMatch(objA, objB); - } - - // Otherwise, assume key-value pairs - keysA = Object.keys(objA || {}).sort(); - keysB = Object.keys(objB || {}).sort(); - - return (keysA.length === keysB.length) && keysMatch(keysA); - } - - // Populate the graphs for these swimlanes - function populate(swimlanes) { - // Somewhere to store resource assignments - // (as key -> swimlane[]) - var assignments = {}; - - // Look up resources for a domain object - function lookupResources(swimlane) { - var graphPromise = - swimlane.domainObject.useCapability('graph'); - function getKeys(obj) { - return Object.keys(obj); - } - return $q.when( - graphPromise ? (graphPromise.then(getKeys)) : [] - ); - } - - // Add all graph assignments appropriate for this swimlane - function buildAssignments(swimlane) { - // Assign this swimlane to graphs for its resource keys - return lookupResources(swimlane).then(function (resources) { - resources.forEach(function (key) { - assignments[key] = assignments[key] || {}; - assignments[key][swimlane.color()] = - swimlane.domainObject; - }); - }); - } - - // Make a graph for this resource (after assigning) - function makeGraph(key) { - return new TimelineGraph( - key, - assignments[key], - renderer - ); - } - - // Used to filter down to swimlanes which need graphs - function needsGraph(swimlane) { - // Only show swimlanes with graphs & resources to graph - return swimlane.graph() && - swimlane.domainObject.hasCapability('graph'); - } - - // Create graphs according to assignments that have been built - function createGraphs() { - // Only refresh graphs if our assignments actually changed - if (!deepEquals(cachedAssignments, assignments)) { - // Make new graphs - graphs = Object.keys(assignments).sort().map(makeGraph); - // Save resource->color->object assignments - cachedAssignments = assignments; - } else { - // Just refresh the existing graphs - graphs.forEach(function (graph) { - graph.refresh(); - }); - } - } - - // Build up list of assignments, then create graphs - $q.all(swimlanes.filter(needsGraph).map(buildAssignments)) - .then(createGraphs); - } - - return { - /** - * Populate (or re-populate) the list of available resource - * graphs, based on the provided list of swimlanes (and their - * current state.) - * @param {TimelineSwimlane[]} swimlanes the swimlanes to use - */ - populate: populate, - /** - * Get the current list of displayable resource graphs. - * @returns {TimelineGraph[]} the resource graphs - */ - get: function () { - return graphs; - } - }; - } - - return TimelineGraphPopulator; - - } -); diff --git a/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js b/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js deleted file mode 100644 index f826352c6f..0000000000 --- a/platform/features/timeline/src/controllers/graph/TimelineGraphRenderer.js +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Responsible for preparing data for display by - * `mct-timeline-chart` in a timeline's resource graph. - * @constructor - */ - function TimelineGraphRenderer() { - return { - /** - * Render a resource utilization to a Float32Array, - * to be passed to WebGL for display. - * @param {ResourceGraph} graph the resource utilization - * @returns {Float32Array} the rendered buffer - */ - render: function (graph) { - var count = graph.getPointCount(), - buffer = new Float32Array(count * 2), - i; - - // Populate the buffer - for (i = 0; i < count; i += 1) { - buffer[i * 2] = graph.getDomainValue(i); - buffer[i * 2 + 1] = graph.getRangeValue(i); - } - - return buffer; - }, - /** - * Convert an HTML color (in #-prefixed 6-digit hexadecimal) - * to an array of floating point values in a range of 0.0-1.0. - * An alpha element is included to facilitate display in an - * `mct-timeline-chart` (which uses WebGL.) - * @param {string} the color - * @returns {number[]} the same color, in floating-point format - */ - decode: function (color) { - // Check for bad input, default to black if needed - color = /^#[A-Fa-f0-9]{6}$/.test(color) ? color : "#000000"; - - // Pull out R, G, B hex values - return [ - color.substring(1, 3), - color.substring(3, 5), - color.substring(5, 7) - ].map(function (c) { - // Hex -> number - return parseInt(c, 16) / 255; - }).concat([1]); // Add the alpha channel - } - }; - } - - return TimelineGraphRenderer; - - } -); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js b/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js deleted file mode 100644 index 2e3555bf40..0000000000 --- a/platform/features/timeline/src/controllers/swimlane/TimelineColorAssigner.js +++ /dev/null @@ -1,120 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ -define( - [], - function () { - - var COLOR_OPTIONS = [ - "#20b2aa", - "#9acd32", - "#ff8c00", - "#d2b48c", - "#40e0d0", - "#4169ff", - "#ffd700", - "#6a5acd", - "#ee82ee", - "#cc9966", - "#99cccc", - "#66cc33", - "#ffcc00", - "#ff6633", - "#cc66ff", - "#ff0066", - "#ffff00", - "#800080", - "#00868b", - "#008a00", - "#ff0000", - "#0000ff", - "#f5deb3", - "#bc8f8f", - "#4682b4", - "#ffafaf", - "#43cd80", - "#cdc1c5", - "#a0522d", - "#6495ed" - ], - // Fall back to black, as "no more colors available" - FALLBACK_COLOR = "#000000"; - - /** - * Responsible for choosing unique colors for the resource - * graph listing of a timeline view. Supports TimelineController. - * @constructor - * @param colors an object to store color configuration into; - * typically, this should be a property from the view's - * configuration, but TimelineSwimlane manages this. - */ - function TimelineColorAssigner(colors) { - // Find an unused color - function freeColor() { - // Set of used colors - var set = {}, found; - - // Build up a set of used colors - Object.keys(colors).forEach(function (id) { - set[colors[id]] = true; - }); - - // Find an unused color - COLOR_OPTIONS.forEach(function (c) { - found = (!set[c] && !found) ? c : found; - }); - - // Provide the color - return found || FALLBACK_COLOR; - } - - return { - /** - * Get the current color assignment. - * @param {string} id the id to which the color is assigned - */ - get: function (id) { - return colors[id]; - }, - /** - * Assign a new color to this id. If no color is specified, - * an unused color will be chosen. - * @param {string} id the id to which the color is assigned - * @param {string} [color] the new color to assign - */ - assign: function (id, color) { - colors[id] = typeof color === 'string' ? color : freeColor(); - }, - /** - * Release the color assignment for this id. That id will - * no longer have a color associated with it, and its color - * will be free to use in subsequent calls. - * @param {string} id the id whose color should be released - */ - release: function (id) { - delete colors[id]; - } - }; - } - - return TimelineColorAssigner; - } -); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js b/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js deleted file mode 100644 index 6f1c36183b..0000000000 --- a/platform/features/timeline/src/controllers/swimlane/TimelineProxy.js +++ /dev/null @@ -1,77 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Selection proxy for the Timeline view. Implements - * behavior associated with the Add button in the - * timeline's toolbar. - * @constructor - */ - function TimelineProxy(domainObject, selection) { - var actionMap = {}; - - // Populate available Create actions for this domain object - function populateActionMap(object) { - var actionCapability = object.getCapability('action'), - actions = actionCapability ? - actionCapability.getActions('add') : []; - actions.forEach(function (action) { - actionMap[action.getMetadata().type] = action; - }); - } - - // Populate available actions based on current selection - // (defaulting to object-in-view if there is none.) - function populateForSelection() { - var swimlane = selection && selection.get(), - selectedObject = swimlane && swimlane.domainObject; - populateActionMap(selectedObject || domainObject); - } - - populateActionMap(domainObject); - - return { - /** - * Add a domain object of the specified type. - * @param {string} type the type of domain object to add - */ - add: function (type) { - // Update list of create actions; this needs to reflect - // the current selection so that Save in defaults - // appropriately. - populateForSelection(); - - // Create an object of that type - if (actionMap[type]) { - return actionMap[type].perform(); - } - } - }; - } - - return TimelineProxy; - } -); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js deleted file mode 100644 index 01a352d1e4..0000000000 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlane.js +++ /dev/null @@ -1,173 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Describes a swimlane in a timeline view. This will be - * used directly from timeline view. - * - * Only general properties of swimlanes are included here. - * Since swimlanes are also directly selected and exposed to the - * toolbar, the TimelineSwimlaneDecorator should also be used - * to add additional properties to specific swimlanes. - * - * @constructor - * @param {DomainObject} domainObject the represented object - * @param {TimelineColorAssigner} assigner color assignment handler - * @param configuration the view's configuration object - * @param {TimelineSwimlane} parent the parent swim lane (if any) - */ - function TimelineSwimlane(domainObject, assigner, configuration, parent, index) { - var id = domainObject.getId(), - highlight = false, // Drop highlight (middle) - highlightBottom = false, // Drop highlight (lower) - idPath = (parent ? parent.idPath : []).concat([domainObject.getId()]), - depth = parent ? (parent.depth + 1) : 0, - timespan, - path = (!parent || !parent.parent) ? "" : parent.path + - parent.domainObject.getModel().name + " > "; - - // Look up timespan for this object - domainObject.useCapability('timespan').then(function (t) { - timespan = t; - }); - - return { - /** - * Check if this swimlane is currently visible. (That is, - * check to see if its parents are expanded.) - * @returns {boolean} true if it is visible - */ - visible: function () { - return !parent || (parent.expanded && parent.visible()); - }, - /** - * Show the Edit Properties dialog. - */ - properties: function () { - return domainObject.getCapability("action").perform("properties"); - }, - /** - * Toggle inclusion of this swimlane's represented object in - * the resource graph area. - */ - toggleGraph: function () { - configuration.graph = configuration.graph || {}; - configuration.graph[id] = !configuration.graph[id]; - // Assign or release legend color - assigner[configuration.graph[id] ? 'assign' : 'release'](id); - }, - /** - * Get (or set, if an argument is provided) the flag which - * determines if the object in this swimlane is included in - * the set of active resource graphs. - * @param {boolean} [value] the state to set (if setting) - * @returns {boolean} true if included; otherwise false - */ - graph: function (value) { - // Set if an argument was provided - if (arguments.length > 0) { - configuration.graph = configuration.graph || {}; - configuration.graph[id] = !!value; - // Assign or release the legend color - assigner[value ? 'assign' : 'release'](id); - } - // Provide the current state - return (configuration.graph || {})[id]; - }, - /** - * Get (or set, if an argument is provided) the color - * associated with this swimlane when its contents are - * included in the set of active resource graphs. - * @param {string} [value] the color to set (if setting) - * @returns {string} the color for resource graphing - */ - color: function (value) { - // Set if an argument was provided - if (arguments.length > 0) { - // Defer to the color assigner - assigner.assign(id, value); - } - // Provide the current value - return assigner.get(id); - }, - /** - * Get (or set, if an argument is provided) the drag - * highlight state for this swimlane. True means the body - * of the swimlane should be highlighted for drop into. - */ - highlight: function (value) { - // Set if an argument was provided - if (arguments.length > 0) { - highlight = value; - } - // Provide current value - return highlight; - }, - /** - * Get (or set, if an argument is provided) the drag - * highlight state for this swimlane. True means the body - * of the swimlane should be highlighted for drop after. - */ - highlightBottom: function (value) { - // Set if an argument was provided - if (arguments.length > 0) { - highlightBottom = value; - } - // Provide current value - return highlightBottom; - }, - /** - * Check if a swimlane exceeds the bounds of its parent. - * @returns {boolean} true if there is a bounds violation - */ - exceeded: function () { - var parentTimespan = parent && parent.timespan(); - return timespan && parentTimespan && - (timespan.getStart() < parentTimespan.getStart() || - timespan.getEnd() > parentTimespan.getEnd()); - }, - /** - * Get the timespan associated with this swimlane - */ - timespan: function () { - return timespan; - }, - // Expose domain object, expansion state, indentation depth - domainObject: domainObject, - expanded: true, - depth: depth, - path: path, - id: id, - idPath: idPath, - parent: parent, - index: index, - children: [] // Populated by populator - }; - } - - return TimelineSwimlane; - } -); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js deleted file mode 100644 index bafd5cd71c..0000000000 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDecorator.js +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./TimelineSwimlaneDropHandler'], - function (TimelineSwimlaneDropHandler) { - - var ACTIVITY_RELATIONSHIP = "modes"; - - /** - * Adds optional methods to TimelineSwimlanes, in order - * to conditionally make available options in the toolbar. - * @constructor - */ - function TimelineSwimlaneDecorator(swimlane, selection) { - var domainObject = swimlane && swimlane.domainObject, - model = (domainObject && domainObject.getModel()) || {}, - mutator = domainObject && domainObject.getCapability('mutation'), - type = domainObject && domainObject.getCapability('type'), - dropHandler = new TimelineSwimlaneDropHandler(swimlane); - - // Activity Modes dialog - function modes(value) { - // Can be used as a setter... - if (arguments.length > 0 && Array.isArray(value)) { - if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) { - // Update the relationships - mutator.mutate(function (m) { - m.relationships = m.relationships || {}; - m.relationships[ACTIVITY_RELATIONSHIP] = value; - }); - } - } - // ...otherwise, use as a getter - return (model.relationships || {})[ACTIVITY_RELATIONSHIP] || []; - } - - // Activity Link dialog - function link(value) { - // Can be used as a setter... - if (arguments.length > 0 && (typeof value === 'string') && - value !== model.link) { - // Update the link - mutator.mutate(function (m) { - m.link = value; - }); - } - return model.link; - } - - // Fire the Remove action - function remove() { - return domainObject.getCapability("action").perform("remove"); - } - - // Select the current swimlane - function select() { - selection.select(swimlane); - } - - // Check if the swimlane is selected - function selected() { - return selection.get() === swimlane; - } - - // Activities should have the Activity Modes and Activity Link dialog - if (type && type.instanceOf("activity") && mutator) { - swimlane.modes = modes; - swimlane.link = link; - } - - // Everything but the top-level object should have Remove - if (swimlane.parent) { - swimlane.remove = remove; - } - - // We're in edit mode, if a selection is available - if (selection) { - // Add shorthands to select, and check for selection - swimlane.select = select; - swimlane.selected = selected; - } - - // Expose drop handlers (which needed a reference to the swimlane) - swimlane.allowDropIn = dropHandler.allowDropIn; - swimlane.allowDropAfter = dropHandler.allowDropAfter; - swimlane.drop = dropHandler.drop; - - return swimlane; - } - - return TimelineSwimlaneDecorator; - } -); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js deleted file mode 100644 index 8aa642f6fb..0000000000 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlaneDropHandler.js +++ /dev/null @@ -1,207 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * Handles drop (from drag-and-drop) initiated changes to a swimlane. - * @constructor - */ - function TimelineSwimlaneDropHandler(swimlane) { - // Check if we are in edit mode (also check parents) - function inEditMode() { - return swimlane.domainObject.hasCapability('editor') && - swimlane.domainObject.getCapability('editor').inEditContext(); - } - - // Boolean and (for reduce below) - function or(a, b) { - return a || b; - } - - // Check if pathA entirely contains pathB - function pathContains(swimlaneToCheck, id) { - // Check if id at a specific index matches (for map below) - function matches(pathId) { - return pathId === id; - } - - // Path A contains Path B if it is longer, and all of - // B's ids match the ids in A. - return swimlaneToCheck.idPath.map(matches).reduce(or, false); - } - - // Check if a swimlane contains a child with the specified id - function contains(swimlaneToCheck, id) { - // Check if a child swimlane has a matching domain object id - function matches(child) { - return child.domainObject.getId() === id; - } - - // Find any one child id that matches this id - return swimlaneToCheck.children.map(matches).reduce(or, false); - } - - // Initiate mutation of a domain object - function doMutate(domainObject, mutator) { - return domainObject.useCapability("mutation", mutator); - } - - // Check if this swimlane is in a state where a drop-after will - // act as a drop-into-at-first position (expanded and non-empty) - function expandedForDropInto() { - return swimlane.expanded && swimlane.children.length > 0; - } - - // Check if the swimlane is ready to accept a drop-into - // (instead of drop-after) - function isDropInto() { - return swimlane.highlight() || expandedForDropInto(); - } - - function isReorder(targetObject, droppedObject) { - var droppedContext = droppedObject.getCapability('context'), - droppedParent = - droppedContext && droppedContext.getParent(), - droppedParentId = droppedParent && droppedParent.getId(); - return targetObject.getId() === droppedParentId; - } - - // Choose an appropriate composition action for the drag-and-drop - function chooseAction(targetObject, droppedObject) { - var actionCapability = - targetObject.getCapability('action'), - actionKey = droppedObject.hasCapability('editor') ? - 'move' : 'link'; - - return actionCapability && actionCapability.getActions({ - key: actionKey, - selectedObject: droppedObject - })[0]; - } - - // Choose an index for insertion in a domain object's composition - function chooseTargetIndex(id, offset, composition) { - return Math.max( - Math.min( - (composition || []).indexOf(id) + offset, - (composition || []).length - ), - 0 - ); - } - - // Insert an id into target's composition - function insert(id, target, indexOffset) { - var myId = swimlane.domainObject.getId(); - return doMutate(target, function (model) { - model.composition = - model.composition.filter(function (compId) { - return compId !== id; - }); - model.composition.splice( - chooseTargetIndex(myId, indexOffset, model.composition), - 0, - id - ); - }); - } - - function canDrop(targetObject, droppedObject) { - - return isReorder(targetObject, droppedObject) || - !!chooseAction(targetObject, droppedObject); - } - - function drop(domainObject, targetObject, indexOffset) { - function changeIndex() { - var id = domainObject.getId(); - return insert(id, targetObject, indexOffset); - } - - return isReorder(targetObject, domainObject) ? - changeIndex() : - chooseAction(targetObject, domainObject) - .perform().then(changeIndex); - } - - return { - /** - * Check if a drop-into should be allowed for this swimlane, - * for the provided domain object identifier. - * @param {string} id identifier for the domain object to be - * dropped - * @returns {boolean} true if this should be allowed - */ - allowDropIn: function (id, domainObject) { - return inEditMode() && - !pathContains(swimlane, id) && - !contains(swimlane, id) && - canDrop(swimlane.domainObject, domainObject); - }, - /** - * Check if a drop-after should be allowed for this swimlane, - * for the provided domain object identifier. - * @param {string} id identifier for the domain object to be - * dropped - * @returns {boolean} true if this should be allowed - */ - allowDropAfter: function (id, domainObject) { - var target = expandedForDropInto() ? - swimlane : swimlane.parent; - return inEditMode() && - target && - !pathContains(target, id) && - canDrop(target.domainObject, domainObject); - }, - /** - * Drop the provided domain object into a timeline. This is - * provided as a mandatory id, and an optional domain object - * instance; if the latter is provided, it will be removed - * from its parent before being added. (This is specifically - * to support moving Activity objects around within a Timeline.) - * @param {string} id the identifier for the domain object - * @param {DomainObject} [domainObject] the object itself - */ - drop: function (id, domainObject) { - // Get the desired drop object, and destination index - var dropInto = isDropInto(), - dropTarget = dropInto ? - swimlane.domainObject : - swimlane.parent.domainObject, - dropIndexOffset = (!dropInto) ? 1 : - (swimlane.expanded && swimlane.highlightBottom()) ? - Number.NEGATIVE_INFINITY : - Number.POSITIVE_INFINITY; - - if (swimlane.highlight() || swimlane.highlightBottom()) { - return drop(domainObject, dropTarget, dropIndexOffset); - } - } - }; - } - - return TimelineSwimlaneDropHandler; - } -); diff --git a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js b/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js deleted file mode 100644 index 38d7d8ba23..0000000000 --- a/platform/features/timeline/src/controllers/swimlane/TimelineSwimlanePopulator.js +++ /dev/null @@ -1,212 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [ - './TimelineSwimlane', - './TimelineSwimlaneDecorator', - './TimelineColorAssigner', - './TimelineProxy' - ], - function ( - TimelineSwimlane, - TimelineSwimlaneDecorator, - TimelineColorAssigner, - TimelineProxy - ) { - - /** - * Populates and maintains a list of swimlanes for a given - * timeline view. - * @constructor - */ - function TimelineSwimlanePopulator(objectLoader, configuration, selection) { - var swimlanes = [], - start = Number.POSITIVE_INFINITY, - end = Number.NEGATIVE_INFINITY, - assigner, - lastDomainObject; - - // Track extremes of start/end times - function trackStartEnd(timespan) { - if (timespan) { - start = Math.min(start, timespan.getStart()); - end = Math.max(end, timespan.getEnd()); - } - } - - // Add domain object (and its subgraph) in as swimlanes - function populateSwimlanes(subgraph, parent, index) { - var domainObject = subgraph.domainObject, - swimlane; - - // For the recursive step - function populate(childSubgraph, nextIndex) { - populateSwimlanes(childSubgraph, swimlane, nextIndex); - } - - // Make sure we have a valid object instance... - if (domainObject) { - // Create the new swimlane - swimlane = new TimelineSwimlaneDecorator(new TimelineSwimlane( - domainObject, - assigner, - configuration, - parent, - index || 0 - ), selection); - // Track start & end times of this domain object - domainObject.useCapability('timespan').then(trackStartEnd); - // Add it to our list - swimlanes.push(swimlane); - // Fill in parent's children - ((parent || {}).children || []).push(swimlane); - // Add in children - subgraph.composition.forEach(populate); - } - } - - // Restore a selection - function reselect(path, candidates, depth) { - // Next ID on the path - var next = path[depth || 0]; - - // Ensure a default - depth = depth || 0; - - // Search through this layer of candidates to see - // if they might contain our selection (based on id path) - candidates.forEach(function (swimlane) { - // Check if we're on the right path... - if (swimlane.id === next) { - // Do we still have ids to check? - if (depth < path.length - 1) { - // Yes, so recursively explore that path - reselect(path, swimlane.children, depth + 1); - } else { - // Nope, we found the object to select - selection.select(swimlane); - } - } - }); - } - - // Handle population of swimlanes - function recalculateSwimlanes(domainObject) { - function populate(subgraph) { - // Cache current selection state during refresh - var selected = selection && selection.get(), - selectedIdPath = selected && selected.idPath; - - // Clear existing swimlanes - swimlanes = []; - - // Build new set of swimlanes - populateSwimlanes(subgraph); - - // Restore selection, if there was one - if (selectedIdPath && swimlanes.length > 0) { - reselect(selectedIdPath, [swimlanes[0]]); - } - } - - // Repopulate swimlanes for this object - if (!domainObject) { - populate({}); - } else { - objectLoader.load(domainObject, 'timespan').then(populate); - } - - // Set the selection proxy as well (for the Add button) - if (selection) { - selection.proxy( - domainObject && new TimelineProxy(domainObject, selection) - ); - } - - lastDomainObject = domainObject; - } - - function setSelectionObject(s) { - selection = s; - recalculateSwimlanes(lastDomainObject); - } - - function initialize() { - var colors = (configuration.colors || {}); - assigner = new TimelineColorAssigner(colors); - configuration.colors = colors; - recalculateSwimlanes(lastDomainObject); - } - - // Ensure colors are exposed in configuration - initialize(); - - return { - /** - * Set the selection object associated with this timeline view. - * @param {Object} selection the selection object - */ - selection: setSelectionObject, - - /** - * Update list of swimlanes to match those reachable from this - * object. - * @param {DomainObject} the timeline being viewed - */ - populate: recalculateSwimlanes, - /** - * Get a list of swimlanes for this timeline view. - * @returns {TimelineSwimlane[]} current swimlanes - */ - get: function () { - return swimlanes; - }, - /** - * Get the first timestamp in the set of swimlanes. - * @returns {number} first timestamp - */ - start: function () { - return start; - }, - /** - * Get the last timestamp in the set of swimlanes. - * @returns {number} first timestamp - */ - end: function () { - return end; - }, - /** - * Pass a new configuration object (to retrieve and store - * swimlane configuration) - * @param newConfig - */ - configure: function (newConfig) { - configuration = newConfig; - initialize(); - } - }; - } - - return TimelineSwimlanePopulator; - } -); diff --git a/platform/features/timeline/src/directives/MCTResourceGraphDrop.js b/platform/features/timeline/src/directives/MCTResourceGraphDrop.js deleted file mode 100644 index 86ccabb2e6..0000000000 --- a/platform/features/timeline/src/directives/MCTResourceGraphDrop.js +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./SwimlaneDragConstants'], - function (SwimlaneDragConstants) { - - /** - * Defines the `mct-resource-graph-drop` directive. When a drop occurs - * on an element with this attribute, the swimlane targeted by the drop - * will receive the dropped domain object (at which point it can handle - * the drop, typically by toggling the swimlane graph.) - * @param {DndService} dndService drag-and-drop service - */ - function MCTResourceGraphDrop(dndService) { - - function link(scope, element, attrs) { - // Handle dragover - element.on('dragover', function (e) { - var swimlane = dndService.getData( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE - ); - - if (typeof swimlane !== "undefined" && !swimlane.graph()) { - element.addClass('drop-over'); - scope.$apply(); - e.preventDefault(); - } - }); - // Handle drops - element.on('drop', function (e) { - var swimlane = dndService.getData( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE - ); - - element.removeClass('drop-over'); - - // Only toggle if the graph isn't already set - if (typeof swimlane !== "undefined" && !swimlane.graph()) { - swimlane.toggleGraph(); - e.preventDefault(); - } - }); - // Clear highlights when drag leaves this swimlane - element.on('dragleave', function (e) { - element.removeClass('drop-over'); - scope.$apply(); - e.preventDefault(); - }); - } - - return { - // Applies to attributes - restrict: "A", - // Link using above function - link: link - }; - } - - return MCTResourceGraphDrop; - } -); diff --git a/platform/features/timeline/src/directives/MCTSwimlaneDrag.js b/platform/features/timeline/src/directives/MCTSwimlaneDrag.js deleted file mode 100644 index 9e6deb0145..0000000000 --- a/platform/features/timeline/src/directives/MCTSwimlaneDrag.js +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./SwimlaneDragConstants'], - function (SwimlaneDragConstants) { - - /** - * Defines the `mct-swimlane-drag` directive. When a drag is initiated - * form an element with this attribute, the swimlane being dragged - * (identified by the value of this attribute, as an Angular expression) - * will be exported to the `dndService` as part of the active drag-drop - * state. - * @param {DndService} dndService drag-and-drop service - */ - function MCTSwimlaneDrag(dndService) { - function link(scope, element, attrs) { - // Look up the swimlane from the provided expression - function swimlane() { - return scope.$eval(attrs.mctSwimlaneDrag); - } - // When drag starts, publish via dndService - element.on('dragstart', function () { - dndService.setData( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE, - swimlane() - ); - }); - // When drag ends, clear via dndService - element.on('dragend', function () { - dndService.removeData( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE - ); - }); - } - - return { - // Applies to attributes - restrict: "A", - // Link using above function - link: link - }; - } - - return MCTSwimlaneDrag; - } -); diff --git a/platform/features/timeline/src/directives/MCTSwimlaneDrop.js b/platform/features/timeline/src/directives/MCTSwimlaneDrop.js deleted file mode 100644 index 8c5d9ff215..0000000000 --- a/platform/features/timeline/src/directives/MCTSwimlaneDrop.js +++ /dev/null @@ -1,147 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['./SwimlaneDragConstants'], - function (SwimlaneDragConstants) { - - /** - * Defines the `mct-swimlane-drop` directive. When a drop occurs - * on an element with this attribute, the swimlane targeted by the drop - * (identified by the value of this attribute, as an Angular expression) - * will receive the dropped domain object (at which point it can handle - * the drop, typically by inserting/reordering.) - * @param {DndService} dndService drag-and-drop service - */ - function MCTSwimlaneDrop(dndService) { - - // Handle dragover events - function dragOver(e, element, swimlane) { - var event = (e || {}).originalEvent || e, - height = element[0].offsetHeight, - rect = element[0].getBoundingClientRect(), - offset = event.pageY - rect.top, - id = dndService.getData( - SwimlaneDragConstants.MCT_DRAG_TYPE - ), - draggedObject = dndService.getData( - SwimlaneDragConstants.MCT_EXTENDED_DRAG_TYPE - ); - - if (id) { - // TODO: Vary this based on modifier keys - event.dataTransfer.dropEffect = 'move'; - - // Set the swimlane's drop highlight state; top 75% is - // for drop-into, bottom 25% is for drop-after. - swimlane.highlight( - offset < (height * 0.75) && - swimlane.allowDropIn(id, draggedObject) - ); - swimlane.highlightBottom( - offset >= (height * 0.75) && - swimlane.allowDropAfter(id, draggedObject) - ); - - // Indicate that we will accept the drag - if (swimlane.highlight() || swimlane.highlightBottom()) { - event.preventDefault(); // Required in Chrome? - return false; - } - } - } - - // Handle drop events - function drop(e, element, swimlane) { - var event = (e || {}).originalEvent || e, - dataTransfer = event.dataTransfer, - id = dataTransfer.getData( - SwimlaneDragConstants.MCT_DRAG_TYPE - ), - draggedSwimlane = dndService.getData( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE - ), - droppedObject = draggedSwimlane ? - draggedSwimlane.domainObject : - dndService.getData( - SwimlaneDragConstants.MCT_EXTENDED_DRAG_TYPE - ); - - if (id) { - event.stopPropagation(); - e.preventDefault(); - // Delegate the drop to the swimlane itself - swimlane.drop(id, droppedObject); - } - - // Clear the swimlane highlights - swimlane.highlight(false); - swimlane.highlightBottom(false); - } - - function link(scope, element, attrs) { - // Lookup swimlane by evaluating this attribute - function lookupSwimlane() { - return scope.$eval(attrs.mctSwimlaneDrop); - } - // Handle dragover - element.on('dragover', function (e) { - var swimlane = lookupSwimlane(), - highlight = swimlane.highlight(), - highlightBottom = swimlane.highlightBottom(); - - dragOver(e, element, swimlane); - - if (highlightBottom !== swimlane.highlightBottom() || - highlight !== swimlane.highlight()) { - scope.$apply(); - } - }); - // Handle drops - element.on('drop', function (e) { - drop(e, element, lookupSwimlane()); - scope.$apply(); - }); - // Clear highlights when drag leaves this swimlane - element.on('dragleave', function () { - var swimlane = lookupSwimlane(), - wasHighlighted = swimlane.highlight() || - swimlane.highlightBottom(); - swimlane.highlight(false); - swimlane.highlightBottom(false); - if (wasHighlighted) { - scope.$apply(); - } - }); - } - - return { - // Applies to attributes - restrict: "A", - // Link using above function - link: link - }; - } - - return MCTSwimlaneDrop; - } -); diff --git a/platform/features/timeline/src/directives/SwimlaneDragConstants.js b/platform/features/timeline/src/directives/SwimlaneDragConstants.js deleted file mode 100644 index 8190498fc6..0000000000 --- a/platform/features/timeline/src/directives/SwimlaneDragConstants.js +++ /dev/null @@ -1,40 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define({ - /** - * The string identifier for the data type used for drag-and-drop - * composition of domain objects. (e.g. in event.dataTransfer.setData - * calls.) - */ - MCT_DRAG_TYPE: 'mct-domain-object-id', - /** - * The string identifier for the data type used for drag-and-drop - * composition of domain objects, by object instance (passed through - * the dndService) - */ - MCT_EXTENDED_DRAG_TYPE: 'mct-domain-object', - /** - * String identifier for swimlanes being dragged. - */ - TIMELINE_SWIMLANE_DRAG_TYPE: 'timeline-swimlane' -}); diff --git a/platform/features/timeline/src/services/ObjectLoader.js b/platform/features/timeline/src/services/ObjectLoader.js deleted file mode 100644 index 685cf48833..0000000000 --- a/platform/features/timeline/src/services/ObjectLoader.js +++ /dev/null @@ -1,133 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [], - function () { - - /** - * The ObjectLoader is a utility service for loading subgraphs - * of the composition hierarchy, starting at a provided object, - * and optionally filtering out objects which fail to meet certain - * criteria. - * @constructor - */ - function ObjectLoader($q) { - - // Build up an object containing id->object pairs - // for the subset of the graph that is relevant. - function loadSubGraph(domainObject, criterion) { - var result = { domainObject: domainObject, composition: [] }, - visiting = {}, - filter; - - // Check object existence (for criterion-less filtering) - function exists(object) { - return !!object; - } - - // Check for capability matching criterion - function hasCapability(object) { - return object && object.hasCapability(criterion); - } - - // For the recursive step... - function loadSubGraphFor(childObject) { - return loadSubGraph(childObject, filter); - } - - // Store loaded subgraphs into the result - function storeSubgraphs(subgraphs) { - result.composition = subgraphs; - } - - // Avoid infinite recursion - function notVisiting(object) { - return !visiting[object.getId()]; - } - - // Put the composition of this domain object into the result - function mapIntoResult(composition) { - return $q.all( - composition.filter(filter).filter(notVisiting) - .map(loadSubGraphFor) - ).then(storeSubgraphs); - } - - // Used to give the final result after promise chaining - function giveResult() { - // Stop suppressing recursive visitation - visiting[domainObject.getId()] = true; - // And return the expecting result value - return result; - } - - // Load composition for - function loadComposition() { - // First, record that we're looking at this domain - // object to detect cycles and avoid an infinite loop - visiting[domainObject.getId()] = true; - // Look up the composition, store it to the graph structure - return domainObject.useCapability('composition') - .then(mapIntoResult) - .then(giveResult); - } - - // Choose the filter function to use - filter = typeof criterion === 'function' ? criterion : - (typeof criterion === 'string' ? hasCapability : - exists); - - // Load child hierarchy, then provide the flat list - return domainObject.hasCapability('composition') ? - loadComposition() : $q.when(result); - } - - return { - /** - * Load domain objects contained in the subgraph of the - * composition hierarchy which starts at the specified - * domain object, optionally pruning out objects (and their - * subgraphs) which match a certain criterion. - * The result is given as a promise for an object containing - * key-value pairs, where keys are domain object identifiers - * and values are domain objects in the subgraph. - * The criterion may be omitted (in which case no pruning is - * done) or specified as a string, in which case it will be - * treated as the name of a required capability, or specified - * as a function, which should return a truthy/falsy value - * when called with a domain object to indicate whether or - * not it should be included in the result set. - * - * @param {DomainObject} domainObject the domain object to - * start from - * @param {string|Function} [criterion] the criterion used - * to prune domain objects - * @returns {Promise} a promise for loaded domain objects - */ - load: loadSubGraph - }; - } - - return ObjectLoader; - } -); diff --git a/platform/features/timeline/test/TimelineConstantsSpec.js b/platform/features/timeline/test/TimelineConstantsSpec.js deleted file mode 100644 index 1079d49724..0000000000 --- a/platform/features/timeline/test/TimelineConstantsSpec.js +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../src/TimelineConstants'], - function (TimelineConstants) { - describe("The set of Timeline constants", function () { - it("specifies a handle width", function () { - expect(TimelineConstants.HANDLE_WIDTH) - .toEqual(jasmine.any(Number)); - }); - }); - } -); diff --git a/platform/features/timeline/test/TimelineFormatterSpec.js b/platform/features/timeline/test/TimelineFormatterSpec.js deleted file mode 100644 index 8f286947e9..0000000000 --- a/platform/features/timeline/test/TimelineFormatterSpec.js +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../src/TimelineFormatter'], - function (TimelineFormatter) { - - var SECOND = 1000, - MINUTE = SECOND * 60, - HOUR = MINUTE * 60, - DAY = HOUR * 24; - - describe("The timeline formatter", function () { - var formatter; - - beforeEach(function () { - formatter = new TimelineFormatter(); - }); - - it("formats durations with seconds", function () { - expect(formatter.format(SECOND)).toEqual("000 00:00:01.000"); - }); - - it("formats durations with milliseconds", function () { - expect(formatter.format(SECOND + 42)).toEqual("000 00:00:01.042"); - }); - - it("formats durations with days", function () { - expect(formatter.format(3 * DAY + SECOND)).toEqual("003 00:00:01.000"); - }); - - it("formats durations with hours", function () { - expect(formatter.format(DAY + HOUR * 11 + SECOND)).toEqual("001 11:00:01.000"); - }); - - it("formats durations with minutes", function () { - expect(formatter.format(HOUR + MINUTE * 21)).toEqual("000 01:21:00.000"); - }); - }); - } -); diff --git a/platform/features/timeline/test/actions/CompositionColumnSpec.js b/platform/features/timeline/test/actions/CompositionColumnSpec.js deleted file mode 100644 index 6c753a6616..0000000000 --- a/platform/features/timeline/test/actions/CompositionColumnSpec.js +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/CompositionColumn'], - function (CompositionColumn) { - var TEST_IDS = ['a', 'b', 'c', 'd', 'e', 'f']; - - describe("CompositionColumn", function () { - var testIndex, - testIdMap, - column; - - beforeEach(function () { - testIndex = 3; - testIdMap = TEST_IDS.reduce(function (map, id, index) { - map[id] = index; - return map; - }, {}); - column = new CompositionColumn(testIndex, testIdMap); - }); - - it("includes a one-based index in its name", function () { - expect(column.name().indexOf(String(testIndex + 1))) - .not.toEqual(-1); - }); - - describe("value", function () { - var mockDomainObject, - testModel; - - beforeEach(function () { - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'getCapability'] - ); - testModel = { composition: TEST_IDS }; - mockDomainObject.getModel.and.returnValue(testModel); - }); - - it("returns a corresponding value from the map", function () { - expect(column.value(mockDomainObject)) - .toEqual(testIdMap[testModel.composition[testIndex]]); - }); - - it("returns nothing when composition is exceeded", function () { - testModel.composition = ['foo']; - expect(column.value(mockDomainObject)).toEqual(""); - }); - - it("returns nothing when composition is absent", function () { - delete testModel.composition; - expect(column.value(mockDomainObject)).toEqual(""); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js b/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js deleted file mode 100644 index e0b492647c..0000000000 --- a/platform/features/timeline/test/actions/ExportTimelineAsCSVActionSpec.js +++ /dev/null @@ -1,165 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/ExportTimelineAsCSVAction'], - function (ExportTimelineAsCSVAction) { - describe("ExportTimelineAsCSVAction", function () { - var mockLog, - mockExportService, - mockNotificationService, - mockNotification, - mockDomainObject, - mockType, - testContext, - testType, - action, - actionPromise; - - beforeEach(function () { - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'getCapability', 'hasCapability'] - ); - mockType = jasmine.createSpyObj('type', ['instanceOf']); - - mockLog = jasmine.createSpyObj('$log', [ - 'warn', - 'error', - 'info', - 'debug' - ]); - mockExportService = jasmine.createSpyObj( - 'exportService', - ['exportCSV'] - ); - mockNotificationService = jasmine.createSpyObj( - 'notificationService', - ['notify', 'error'] - ); - mockNotification = jasmine.createSpyObj( - 'notification', - ['dismiss'] - ); - - mockNotificationService.notify.and.returnValue(mockNotification); - - mockDomainObject.hasCapability.and.returnValue(true); - mockDomainObject.getCapability.and.returnValue(mockType); - mockType.instanceOf.and.callFake(function (type) { - return type === testType; - }); - - testContext = { domainObject: mockDomainObject }; - - action = new ExportTimelineAsCSVAction( - mockLog, - mockExportService, - mockNotificationService, - [], - testContext - ); - }); - - it("is applicable to timelines", function () { - testType = 'timeline'; - expect(ExportTimelineAsCSVAction.appliesTo(testContext)) - .toBe(true); - }); - - it("is not applicable to non-timelines", function () { - testType = 'folder'; - expect(ExportTimelineAsCSVAction.appliesTo(testContext)) - .toBe(false); - }); - - describe("when performed", function () { - var testPromise; - - beforeEach(function () { - // White-boxy; we know most work is delegated - // to the associated Task, so stub out that interaction. - spyOn(action.task, "run").and.callFake(function () { - return new Promise(function (resolve, reject) { - testPromise = { - resolve: resolve, - reject: reject - }; - }); - }); - actionPromise = action.perform(); - }); - - it("shows a notification", function () { - expect(mockNotificationService.notify) - .toHaveBeenCalled(); - }); - - it("starts an export task", function () { - expect(action.task.run).toHaveBeenCalled(); - }); - - describe("and completed", function () { - beforeEach(function () { - testPromise.resolve(); - return actionPromise; - }); - - it("dismisses the displayed notification", function () { - expect(mockNotification.dismiss) - .toHaveBeenCalled(); - }); - - it("shows no error messages", function () { - expect(mockNotificationService.error) - .not.toHaveBeenCalled(); - }); - }); - - describe("and an error occurs", function () { - var testError; - - beforeEach(function () { - testError = { someProperty: "some value" }; - testPromise.reject(testError); - - return actionPromise; - }); - - it("dismisses the displayed notification", function () { - expect(mockNotification.dismiss) - .toHaveBeenCalled(); - }); - - it("shows an error message", function () { - expect(mockNotificationService.error) - .toHaveBeenCalledWith(jasmine.any(String)); - }); - - it("logs the root cause", function () { - expect(mockLog.warn).toHaveBeenCalledWith(testError); - }); - }); - }); - }); - } -); diff --git a/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js b/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js deleted file mode 100644 index 50723c8dc8..0000000000 --- a/platform/features/timeline/test/actions/ExportTimelineAsCSVTaskSpec.js +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/ExportTimelineAsCSVTask'], - function (ExportTimelineAsCSVTask) { - - // Note that most responsibility is delegated to helper - // classes, so testing here is minimal. - describe("EXportTimelineAsCSVTask", function () { - var mockExportService, - mockDomainObject, - task; - - beforeEach(function () { - mockExportService = jasmine.createSpyObj( - 'exportService', - ['exportCSV'] - ); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - [ - 'getCapability', - 'useCapability', - 'hasCapability', - 'getId', - 'getModel' - ] - ); - - mockDomainObject.getId.and.returnValue('mock'); - mockDomainObject.getModel.and.returnValue({}); - - task = new ExportTimelineAsCSVTask( - mockExportService, - [], - mockDomainObject - ); - }); - - describe("when run", function () { - - beforeEach(function () { - return task.run(); - }); - - it("exports to CSV", function () { - expect(mockExportService.exportCSV) - .toHaveBeenCalled(); - }); - }); - }); - } -); diff --git a/platform/features/timeline/test/actions/IdColumnSpec.js b/platform/features/timeline/test/actions/IdColumnSpec.js deleted file mode 100644 index c7df5894d4..0000000000 --- a/platform/features/timeline/test/actions/IdColumnSpec.js +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/IdColumn'], - function (IdColumn) { - describe("IdColumn", function () { - var testIdMap, - column; - - beforeEach(function () { - testIdMap = { "foo": "bar" }; - column = new IdColumn(testIdMap); - }); - - it("has a name", function () { - expect(column.name()).toEqual(jasmine.any(String)); - }); - - describe("value", function () { - var mockDomainObject, - testId; - - beforeEach(function () { - testId = "foo"; - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'getCapability'] - ); - mockDomainObject.getId.and.returnValue(testId); - }); - - it("provides a value mapped from domain object's identifier", function () { - expect(column.value(mockDomainObject)) - .toEqual(testIdMap[testId]); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/actions/MetadataColumnSpec.js b/platform/features/timeline/test/actions/MetadataColumnSpec.js deleted file mode 100644 index 97b604ba8e..0000000000 --- a/platform/features/timeline/test/actions/MetadataColumnSpec.js +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/MetadataColumn'], - function (MetadataColumn) { - describe("MetadataColumn", function () { - var testName, - column; - - beforeEach(function () { - testName = 'Foo'; - column = new MetadataColumn(testName); - }); - - it("reports its property name", function () { - expect(column.name()).toEqual(testName); - }); - - describe("value", function () { - var mockDomainObject, - testMetadata, - testIndex; - - beforeEach(function () { - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'getCapability', 'useCapability'] - ); - testMetadata = [ - { name: "Something else", value: 123 }, - { value: 456 }, - { name: "And something else", value: 789 } - ]; - testIndex = 1; - testMetadata[testIndex].name = testName; - - mockDomainObject.useCapability.and.callFake(function (c) { - return (c === 'metadata') && testMetadata; - }); - }); - - it("returns a corresponding value", function () { - expect(column.value(mockDomainObject)) - .toEqual(testMetadata[testIndex].value); - }); - - it("returns nothing when no such property is present", function () { - testMetadata[testIndex].name = "Not " + testName; - expect(column.value(mockDomainObject)).toEqual(""); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/actions/ModeColumnSpec.js b/platform/features/timeline/test/actions/ModeColumnSpec.js deleted file mode 100644 index d2c340f658..0000000000 --- a/platform/features/timeline/test/actions/ModeColumnSpec.js +++ /dev/null @@ -1,82 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/ModeColumn'], - function (ModeColumn) { - var TEST_IDS = ['a', 'b', 'c', 'd', 'e', 'f']; - - describe("ModeColumn", function () { - var testIndex, - testIdMap, - column; - - beforeEach(function () { - testIndex = 3; - testIdMap = TEST_IDS.reduce(function (map, id, index) { - map[id] = index; - return map; - }, {}); - column = new ModeColumn(testIndex, testIdMap); - }); - - it("includes a one-based index in its name", function () { - expect(column.name().indexOf(String(testIndex + 1))) - .not.toEqual(-1); - }); - - describe("value", function () { - var mockDomainObject, - testModel; - - beforeEach(function () { - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'getCapability'] - ); - testModel = { - relationships: { - modes: TEST_IDS - } - }; - mockDomainObject.getModel.and.returnValue(testModel); - }); - - it("returns a corresponding value from the map", function () { - expect(column.value(mockDomainObject)) - .toEqual(testIdMap[testModel.relationships.modes[testIndex]]); - }); - - it("returns nothing when relationships are exceeded", function () { - testModel.relationships.modes = ['foo']; - expect(column.value(mockDomainObject)).toEqual(""); - }); - - it("returns nothing when mode relationships are absent", function () { - delete testModel.relationships.modes; - expect(column.value(mockDomainObject)).toEqual(""); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/actions/TimelineColumnizerSpec.js b/platform/features/timeline/test/actions/TimelineColumnizerSpec.js deleted file mode 100644 index 72eca01a9f..0000000000 --- a/platform/features/timeline/test/actions/TimelineColumnizerSpec.js +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/TimelineColumnizer'], - function (TimelineColumnizer) { - describe("TimelineColumnizer", function () { - var mockDomainObjects, - testMetadata, - exporter; - - function makeMockDomainObject(model, index) { - var mockDomainObject = jasmine.createSpyObj( - 'domainObject-' + index, - [ - 'getId', - 'getCapability', - 'useCapability', - 'hasCapability', - 'getModel' - ] - ); - mockDomainObject.getId.and.returnValue('id-' + index); - mockDomainObject.getModel.and.returnValue(model); - mockDomainObject.useCapability.and.callFake(function (c) { - return c === 'metadata' && []; - }); - return mockDomainObject; - } - - beforeEach(function () { - var mockTimespan = jasmine.createSpyObj( - 'timespan', - ['getStart', 'getEnd'] - ); - - testMetadata = [ - { name: "abc", value: 123 }, - { name: "xyz", value: 456 } - ]; - - mockDomainObjects = [ - { composition: ['a', 'b', 'c'] }, - { relationships: { modes: ['x', 'y'] } }, - { } - ].map(makeMockDomainObject); - - mockDomainObjects[1].hasCapability.and.callFake(function (c) { - return c === 'timespan'; - }); - mockDomainObjects[1].useCapability.and.callFake(function (c) { - return c === 'timespan' ? Promise.resolve(mockTimespan) : - c === 'metadata' ? [] : undefined; - }); - mockDomainObjects[2].useCapability.and.callFake(function (c) { - return c === 'metadata' && testMetadata; - }); - - exporter = new TimelineColumnizer(mockDomainObjects, []); - }); - - describe("rows", function () { - var rows; - - beforeEach(function () { - return exporter.rows().then(function (r) { - rows = r; - }); - }); - - - it("include one row per domain object", function () { - expect(rows.length).toEqual(mockDomainObjects.length); - }); - }); - - describe("headers", function () { - var headers; - - beforeEach(function () { - headers = exporter.headers(); - }); - - it("contains all metadata properties", function () { - testMetadata.forEach(function (property) { - expect(headers.indexOf(property.name)) - .not.toEqual(-1); - }); - }); - - it("contains timespan properties", function () { - expect(headers.indexOf("Start")).not.toEqual(-1); - expect(headers.indexOf("End")).not.toEqual(-1); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/actions/TimelineTraverserSpec.js b/platform/features/timeline/test/actions/TimelineTraverserSpec.js deleted file mode 100644 index 804df2b6e8..0000000000 --- a/platform/features/timeline/test/actions/TimelineTraverserSpec.js +++ /dev/null @@ -1,132 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([ - "../../src/actions/TimelineTraverser" -], function (TimelineTraverser) { - - describe("TimelineTraverser", function () { - var testModels, - mockDomainObjects, - traverser; - - function addMockDomainObject(id) { - var mockDomainObject = jasmine.createSpyObj( - 'domainObject-' + id, - [ - 'getId', - 'getCapability', - 'useCapability', - 'hasCapability', - 'getModel' - ] - ), - mockRelationships, - model = testModels[id]; - - mockDomainObject.getId.and.returnValue(id); - mockDomainObject.getModel.and.returnValue(model); - - mockDomainObject.hasCapability.and.callFake(function (c) { - return c === 'composition' ? !!model.composition : - c === 'relationship' ? !!model.relationships : - false; - }); - - if (!!model.composition) { - mockDomainObject.useCapability.and.callFake(function (c) { - return c === 'composition' && - Promise.resolve(model.composition.map(function (cid) { - return mockDomainObjects[cid]; - })); - }); - } - - if (!!model.relationships) { - mockRelationships = jasmine.createSpyObj( - 'relationship', - ['getRelatedObjects'] - ); - mockRelationships.getRelatedObjects.and.callFake(function (k) { - var ids = model.relationships[k] || []; - return Promise.resolve(ids.map(function (objId) { - return mockDomainObjects[objId]; - })); - }); - mockDomainObject.getCapability.and.callFake(function (c) { - return c === 'relationship' && mockRelationships; - }); - } - - mockDomainObjects[id] = mockDomainObject; - } - - beforeEach(function () { - testModels = { - a: { composition: ['b', 'c']}, - b: { composition: ['c'] }, - c: { relationships: { modes: ['d'] } }, - d: {}, - unreachable: {} - }; - - mockDomainObjects = {}; - Object.keys(testModels).forEach(addMockDomainObject); - - traverser = new TimelineTraverser(mockDomainObjects.a); - }); - - describe("buildObjectList", function () { - var objects; - - function contains(id) { - return objects.some(function (object) { - return object.getId() === id; - }); - } - - beforeEach(function () { - return traverser.buildObjectList().then(function (objectList) { - objects = objectList; - }); - }); - - it("includes the object originally passed in", function () { - expect(contains('a')).toBe(true); - }); - - it("includes objects reachable via composition", function () { - expect(contains('b')).toBe(true); - expect(contains('c')).toBe(true); - }); - - it("includes objects reachable via relationships", function () { - expect(contains('d')).toBe(true); - }); - - it("does not include unreachable objects", function () { - expect(contains('unreachable')).toBe(false); - }); - }); - - }); -}); diff --git a/platform/features/timeline/test/actions/TimespanColumnSpec.js b/platform/features/timeline/test/actions/TimespanColumnSpec.js deleted file mode 100644 index 7fb6331f35..0000000000 --- a/platform/features/timeline/test/actions/TimespanColumnSpec.js +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/actions/TimespanColumn', '../../src/TimelineFormatter'], - function (TimespanColumn, TimelineFormatter) { - describe("TimespanColumn", function () { - var testTimes, - mockTimespan, - mockDomainObject, - column; - - beforeEach(function () { - testTimes = { - start: 101000, - end: 987654321 - }; - mockTimespan = jasmine.createSpyObj( - 'timespan', - ['getStart', 'getEnd'] - ); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['useCapability', 'hasCapability'] - ); - mockTimespan.getStart.and.returnValue(testTimes.start); - mockTimespan.getEnd.and.returnValue(testTimes.end); - mockDomainObject.useCapability.and.callFake(function (c) { - return c === 'timespan' && Promise.resolve(mockTimespan); - }); - mockDomainObject.hasCapability.and.callFake(function (c) { - return c === 'timespan'; - }); - }); - - ["start", "end"].forEach(function (bound) { - describe("when referring to " + bound + " times", function () { - var name = bound.charAt(0).toUpperCase() + bound.slice(1); - - beforeEach(function () { - column = new TimespanColumn(bound === "start"); - }); - - it("is named \"" + name + "\"", function () { - expect(column.name()).toEqual(name); - }); - - describe("value", function () { - var testFormatter, - value; - - beforeEach(function () { - value = undefined; - testFormatter = new TimelineFormatter(); - return column.value(mockDomainObject).then(function (v) { - value = v; - }); - }); - - it("returns a formatted " + bound + " time", function () { - var expected = - testFormatter.format(testTimes[bound]); - expect(value).toEqual(expected); - }); - }); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js b/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js deleted file mode 100644 index 3ef068270c..0000000000 --- a/platform/features/timeline/test/capabilities/ActivityTimespanCapabilitySpec.js +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/ActivityTimespanCapability'], - function (ActivityTimespanCapability) { - - describe("An Activity's timespan capability", function () { - var mockQ, - mockDomainObject, - capability; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (callback) { - return asPromise(callback(v)); - } - }; - } - - beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', ['when']); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getModel', 'getCapability'] - ); - - mockQ.when.and.callFake(asPromise); - mockDomainObject.getModel.and.returnValue({ - start: { - timestamp: 42000, - epoch: "TEST" - }, - duration: { - timestamp: 12321 - } - }); - - capability = new ActivityTimespanCapability( - mockQ, - mockDomainObject - ); - }); - - it("applies only to activity objects", function () { - expect(ActivityTimespanCapability.appliesTo({ - type: 'activity' - })).toBeTruthy(); - expect(ActivityTimespanCapability.appliesTo({ - type: 'folder' - })).toBeFalsy(); - }); - - it("provides timespan based on model", function () { - var mockCallback = jasmine.createSpy('callback'); - capability.invoke().then(mockCallback); - // We verify other methods in ActivityTimespanSpec, - // so just make sure we got something that looks right. - expect(mockCallback).toHaveBeenCalledWith({ - getStart: jasmine.any(Function), - getEnd: jasmine.any(Function), - getDuration: jasmine.any(Function), - setStart: jasmine.any(Function), - setEnd: jasmine.any(Function), - setDuration: jasmine.any(Function), - getEpoch: jasmine.any(Function) - }); - }); - }); - } -); diff --git a/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js b/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js deleted file mode 100644 index 88f13a4289..0000000000 --- a/platform/features/timeline/test/capabilities/ActivityTimespanSpec.js +++ /dev/null @@ -1,99 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/ActivityTimespan'], - function (ActivityTimespan) { - - describe("An Activity's timespan", function () { - var testModel, - mutatorModel, - mockMutation, - timespan; - - beforeEach(function () { - testModel = { - start: { - timestamp: 42000, - epoch: "TEST" - }, - duration: { - timestamp: 12321 - } - }; - // Provide a cloned model for mutation purposes - // It is important to distinguish mutation made to - // the model provided via the mutation capability from - // changes made to the model directly (the latter is - // not intended usage.) - mutatorModel = JSON.parse(JSON.stringify(testModel)); - mockMutation = jasmine.createSpyObj("mutation", ["mutate"]); - mockMutation.mutate.and.callFake(function (mutator) { - mutator(mutatorModel); - }); - timespan = new ActivityTimespan(testModel, mockMutation); - }); - - it("provides a start time", function () { - expect(timespan.getStart()).toEqual(42000); - }); - - it("provides an end time", function () { - expect(timespan.getEnd()).toEqual(54321); - }); - - it("provides duration", function () { - expect(timespan.getDuration()).toEqual(12321); - }); - - it("provides an epoch", function () { - expect(timespan.getEpoch()).toEqual("TEST"); - }); - - it("sets start time using mutation capability", function () { - timespan.setStart(52000); - expect(mutatorModel.start.timestamp).toEqual(52000); - // Should have also changed duration to preserve end - expect(mutatorModel.duration.timestamp).toEqual(2321); - // Original model should still be the same - expect(testModel.start.timestamp).toEqual(42000); - }); - - it("sets end time using mutation capability", function () { - timespan.setEnd(44000); - // Should have also changed duration to preserve end - expect(mutatorModel.duration.timestamp).toEqual(2000); - // Original model should still be the same - expect(testModel.duration.timestamp).toEqual(12321); - }); - - it("sets duration using mutation capability", function () { - timespan.setDuration(8000); - // Should have also changed duration to preserve end - expect(mutatorModel.duration.timestamp).toEqual(8000); - // Original model should still be the same - expect(testModel.duration.timestamp).toEqual(12321); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js b/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js deleted file mode 100644 index b831013565..0000000000 --- a/platform/features/timeline/test/capabilities/ActivityUtilizationSpec.js +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/ActivityUtilization'], - function (ActivityUtilization) { - - describe("An Activity's resource utilization", function () { - - // Placeholder; WTD-918 will implement - it("has the expected interface", function () { - var utilization = new ActivityUtilization(); - expect(utilization.getPointCount()).toEqual(jasmine.any(Number)); - expect(utilization.getDomainValue()).toEqual(jasmine.any(Number)); - expect(utilization.getRangeValue()).toEqual(jasmine.any(Number)); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/CostCapabilitySpec.js b/platform/features/timeline/test/capabilities/CostCapabilitySpec.js deleted file mode 100644 index 239e08e312..0000000000 --- a/platform/features/timeline/test/capabilities/CostCapabilitySpec.js +++ /dev/null @@ -1,79 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/CostCapability'], - function (CostCapability) { - - describe("A subsystem mode's cost capability", function () { - var testModel, - capability; - - beforeEach(function () { - var mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getModel', 'getId'] - ); - - testModel = { - resources: { - abc: -1, - power: 12321, - comms: 42 - } - }; - - mockDomainObject.getModel.and.returnValue(testModel); - - capability = new CostCapability(mockDomainObject); - }); - - it("provides a list of resource types", function () { - expect(capability.resources()) - .toEqual(['abc', 'comms', 'power']); - }); - - it("provides resource costs", function () { - expect(capability.cost('abc')).toEqual(-1); - expect(capability.cost('power')).toEqual(12321); - expect(capability.cost('comms')).toEqual(42); - }); - - it("provides all resources in a group", function () { - expect(capability.invoke()).toEqual(testModel.resources); - }); - - it("applies to subsystem modes", function () { - expect(CostCapability.appliesTo({ - type: "mode" - })).toBeTruthy(); - expect(CostCapability.appliesTo({ - type: "activity" - })).toBeFalsy(); - expect(CostCapability.appliesTo({ - type: "other" - })).toBeFalsy(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js b/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js deleted file mode 100644 index 22ba91657a..0000000000 --- a/platform/features/timeline/test/capabilities/CumulativeGraphSpec.js +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/CumulativeGraph'], - function (CumulativeGraph) { - - describe("A cumulative resource graph", function () { - var mockGraph, - points, - graph; - - beforeEach(function () { - points = [0, 10, -10, -100, 20, 100, 0]; - - mockGraph = jasmine.createSpyObj( - 'graph', - ['getPointCount', 'getDomainValue', 'getRangeValue'] - ); - - mockGraph.getPointCount.and.returnValue(points.length * 2); - mockGraph.getDomainValue.and.callFake(function (i) { - return Math.floor(i / 2) * 100 + 25; - }); - mockGraph.getRangeValue.and.callFake(function (i) { - return points[Math.floor(i / 2) + i % 2]; - }); - - graph = new CumulativeGraph( - mockGraph, - 1000, - 2000, - 1500, - 1 / 10 - ); - }); - - it("accumulates its wrapped instantaneous graph", function () { - // Note that range values are percentages - expect(graph.getDomainValue(0)).toEqual(0); - expect(graph.getRangeValue(0)).toEqual(50); // initial state - expect(graph.getDomainValue(1)).toEqual(25); - expect(graph.getRangeValue(1)).toEqual(50); // initial state - expect(graph.getDomainValue(2)).toEqual(125); - expect(graph.getRangeValue(2)).toEqual(60); // +10 - expect(graph.getDomainValue(3)).toEqual(225); - expect(graph.getRangeValue(3)).toEqual(50); // -10 - expect(graph.getDomainValue(4)).toEqual(275); - expect(graph.getRangeValue(4)).toEqual(0); // -100 (hit bottom) - expect(graph.getDomainValue(5)).toEqual(325); - expect(graph.getRangeValue(5)).toEqual(0); // still at 0... - expect(graph.getDomainValue(6)).toEqual(425); - expect(graph.getRangeValue(6)).toEqual(20); // +20 - expect(graph.getDomainValue(7)).toEqual(505); - expect(graph.getRangeValue(7)).toEqual(100); // +100 - expect(graph.getDomainValue(8)).toEqual(525); - expect(graph.getRangeValue(8)).toEqual(100); // still full - expect(graph.getDomainValue(9)).toEqual(625); - expect(graph.getRangeValue(9)).toEqual(100); // still full - expect(graph.getPointCount()).toEqual(10); - }); - - - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js b/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js deleted file mode 100644 index 73dfd9cd40..0000000000 --- a/platform/features/timeline/test/capabilities/GraphCapabilitySpec.js +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/GraphCapability'], - function (GraphCapability) { - - describe("A Timeline's graph capability", function () { - var mockQ, - mockDomainObject, - testModel, - capability; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (cb) { - return asPromise(cb(v)); - } - }; - } - - beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', ['when']); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'useCapability'] - ); - - testModel = { - type: "activity", - resources: { - abc: 100, - xyz: 42 - } - }; - - mockQ.when.and.callFake(asPromise); - mockDomainObject.getModel.and.returnValue(testModel); - - capability = new GraphCapability( - mockQ, - mockDomainObject - ); - }); - - it("is applicable to timelines", function () { - expect(GraphCapability.appliesTo({ - type: "timeline" - })).toBeTruthy(); - }); - - it("is applicable to activities", function () { - expect(GraphCapability.appliesTo(testModel)) - .toBeTruthy(); - }); - - it("is not applicable to other objects", function () { - expect(GraphCapability.appliesTo({ - type: "something" - })).toBeFalsy(); - }); - - it("provides one graph per resource type", function () { - var mockCallback = jasmine.createSpy('callback'); - - mockDomainObject.useCapability.and.returnValue(asPromise([ - { key: "abc", start: 0, end: 15 }, - { key: "abc", start: 0, end: 15 }, - { key: "def", start: 4, end: 15 }, - { key: "xyz", start: 0, end: 20 } - ])); - - capability.invoke().then(mockCallback); - - expect(mockCallback).toHaveBeenCalledWith({ - abc: jasmine.any(Object), - def: jasmine.any(Object), - xyz: jasmine.any(Object) - }); - }); - - it("provides a battery graph for timelines with capacity", function () { - var mockCallback = jasmine.createSpy('callback'); - testModel.capacity = 1000; - testModel.startingSOC = 100; - testModel.type = "timeline"; - mockDomainObject.useCapability.and.returnValue(asPromise([ - { key: "power", start: 0, end: 15 } - ])); - capability.invoke().then(mockCallback); - expect(mockCallback).toHaveBeenCalledWith({ - power: jasmine.any(Object), - battery: jasmine.any(Object) - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/ResourceGraphSpec.js b/platform/features/timeline/test/capabilities/ResourceGraphSpec.js deleted file mode 100644 index a3ec1c3fe7..0000000000 --- a/platform/features/timeline/test/capabilities/ResourceGraphSpec.js +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/ResourceGraph'], - function (ResourceGraph) { - - describe("A resource graph capability", function () { - - // Placeholder; WTD-918 will implement - it("has zero points for zero utilization changes", function () { - var graph = new ResourceGraph([]); - expect(graph.getPointCount()).toEqual(0); - }); - - it("creates steps based on resource utilizations", function () { - var graph = new ResourceGraph([ - { start: 5, end: 100, value: 42 }, - { start: 50, end: 120, value: -22 }, - { start: 15, end: 40, value: 30 }, - { start: 150, end: 180, value: -10 } - ]); - - expect(graph.getPointCount()).toEqual(16); - - // Should get two values at every time stamp, for step-like appearance - [5, 15, 40, 50, 100, 120, 150, 180].forEach(function (v, i) { - expect(graph.getDomainValue(i * 2)).toEqual(v); - expect(graph.getDomainValue(i * 2 + 1)).toEqual(v); - }); - - // Should also repeat values at subsequent indexes, but offset differently, - // for horizontal spans between steps - [0, 42, 72, 42, 20, -22, 0, -10].forEach(function (v, i) { - expect(graph.getRangeValue(i * 2)).toEqual(v); - // Offset backwards; wrap around end of the series - expect(graph.getRangeValue((16 + i * 2 - 1) % 16)).toEqual(v); - }); - }); - - it("filters out zero-duration spikes", function () { - var graph = new ResourceGraph([ - { start: 5, end: 100, value: 42 }, - { start: 100, end: 120, value: -22 }, - { start: 100, end: 180, value: 30 }, - { start: 130, end: 180, value: -10 } - ]); - - // There are only 5 unique timestamps there, so there should - // be 5 steps, for 10 total points - expect(graph.getPointCount()).toEqual(10); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js b/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js deleted file mode 100644 index b8bc198090..0000000000 --- a/platform/features/timeline/test/capabilities/TimelineTimespanCapabilitySpec.js +++ /dev/null @@ -1,138 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/TimelineTimespanCapability'], - function (TimelineTimespanCapability) { - - describe("A Timeline's timespan capability", function () { - var mockQ, - mockDomainObject, - mockChildA, - mockChildB, - mockTimespanA, - mockTimespanB, - capability; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (callback) { - return asPromise(callback(v)); - } - }; - } - - beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', ['when', 'all']); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getModel', 'getCapability', 'useCapability'] - ); - mockChildA = jasmine.createSpyObj( - 'childA', - ['getModel', 'useCapability', 'hasCapability'] - ); - mockChildB = jasmine.createSpyObj( - 'childA', - ['getModel', 'useCapability', 'hasCapability'] - ); - mockTimespanA = jasmine.createSpyObj( - 'timespanA', - ['getEnd'] - ); - mockTimespanB = jasmine.createSpyObj( - 'timespanB', - ['getEnd'] - ); - - mockQ.when.and.callFake(asPromise); - mockQ.all.and.callFake(function (values) { - var result = []; - function addResult(v) { - result.push(v); - } - function promiseResult(v) { - asPromise(v).then(addResult); - } - values.forEach(promiseResult); - return asPromise(result); - }); - mockDomainObject.getModel.and.returnValue({ - start: { - timestamp: 42000, - epoch: "TEST" - }, - duration: { - timestamp: 12321 - } - }); - mockDomainObject.useCapability.and.callFake(function (c) { - if (c === 'composition') { - return asPromise([mockChildA, mockChildB]); - } - }); - mockChildA.hasCapability.and.returnValue(true); - mockChildB.hasCapability.and.returnValue(true); - mockChildA.useCapability.and.callFake(function (c) { - return c === 'timespan' && mockTimespanA; - }); - mockChildB.useCapability.and.callFake(function (c) { - return c === 'timespan' && mockTimespanB; - }); - - capability = new TimelineTimespanCapability( - mockQ, - mockDomainObject - ); - }); - - it("applies only to timeline objects", function () { - expect(TimelineTimespanCapability.appliesTo({ - type: 'timeline' - })).toBeTruthy(); - expect(TimelineTimespanCapability.appliesTo({ - type: 'folder' - })).toBeFalsy(); - }); - - it("provides timespan based on model", function () { - var mockCallback = jasmine.createSpy('callback'); - capability.invoke().then(mockCallback); - // We verify other methods in ActivityTimespanSpec, - // so just make sure we got something that looks right. - expect(mockCallback).toHaveBeenCalledWith({ - getStart: jasmine.any(Function), - getEnd: jasmine.any(Function), - getDuration: jasmine.any(Function), - setStart: jasmine.any(Function), - setEnd: jasmine.any(Function), - setDuration: jasmine.any(Function), - getEpoch: jasmine.any(Function) - }); - // Finally, verify that getEnd recurses - mockCallback.calls.mostRecent().args[0].getEnd(); - expect(mockTimespanA.getEnd).toHaveBeenCalled(); - expect(mockTimespanB.getEnd).toHaveBeenCalled(); - }); - }); - } -); diff --git a/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js b/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js deleted file mode 100644 index 3d352b9a45..0000000000 --- a/platform/features/timeline/test/capabilities/TimelineTimespanSpec.js +++ /dev/null @@ -1,110 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/TimelineTimespan'], - function (TimelineTimespan) { - - describe("A Timeline's timespan", function () { - var testModel, - mockTimespans, - mockMutation, - mutationModel, - timespan; - - function makeMockTimespan(end) { - var mockTimespan = jasmine.createSpyObj( - 'timespan-' + end, - ['getEnd'] - ); - mockTimespan.getEnd.and.returnValue(end); - return mockTimespan; - } - - beforeEach(function () { - testModel = { - start: { - timestamp: 42000, - epoch: "TEST" - } - }; - - mutationModel = JSON.parse(JSON.stringify(testModel)); - - mockMutation = jasmine.createSpyObj("mutation", ["mutate"]); - mockTimespans = [44000, 65000, 1100].map(makeMockTimespan); - - mockMutation.mutate.and.callFake(function (mutator) { - mutator(mutationModel); - }); - - timespan = new TimelineTimespan( - testModel, - mockMutation, - mockTimespans - ); - }); - - it("provides a start time", function () { - expect(timespan.getStart()).toEqual(42000); - }); - - it("provides an end time", function () { - expect(timespan.getEnd()).toEqual(65000); - }); - - it("provides duration", function () { - expect(timespan.getDuration()).toEqual(65000 - 42000); - }); - - it("provides an epoch", function () { - expect(timespan.getEpoch()).toEqual("TEST"); - }); - - - it("sets start time using mutation capability", function () { - timespan.setStart(52000); - expect(mutationModel.start.timestamp).toEqual(52000); - // Original model should still be the same - expect(testModel.start.timestamp).toEqual(42000); - }); - - it("makes no changes with setEnd", function () { - // Copy initial state to verify that it doesn't change - var initialModel = JSON.parse(JSON.stringify(testModel)); - timespan.setEnd(123454321); - // Neither model should have changed - expect(testModel).toEqual(initialModel); - expect(mutationModel).toEqual(initialModel); - }); - - it("makes no changes with setDuration", function () { - // Copy initial state to verify that it doesn't change - var initialModel = JSON.parse(JSON.stringify(testModel)); - timespan.setDuration(123454321); - // Neither model should have changed - expect(testModel).toEqual(initialModel); - expect(mutationModel).toEqual(initialModel); - }); - }); - } -); diff --git a/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js b/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js deleted file mode 100644 index 26f68800e0..0000000000 --- a/platform/features/timeline/test/capabilities/TimelineUtilizationSpec.js +++ /dev/null @@ -1,39 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/TimelineUtilization'], - function (TimelineUtilization) { - - describe("A Timeline's resource utilization", function () { - - // Placeholder; WTD-918 will implement - it("has the expected interface", function () { - var utilization = new TimelineUtilization(); - expect(utilization.getPointCount()).toEqual(jasmine.any(Number)); - expect(utilization.getDomainValue()).toEqual(jasmine.any(Number)); - expect(utilization.getRangeValue()).toEqual(jasmine.any(Number)); - }); - - }); - } -); diff --git a/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js b/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js deleted file mode 100644 index 8ae3e3e571..0000000000 --- a/platform/features/timeline/test/capabilities/UtilizationCapabilitySpec.js +++ /dev/null @@ -1,214 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/capabilities/UtilizationCapability'], - function (UtilizationCapability) { - - describe("A Timeline's utilization capability", function () { - var mockQ, - mockDomainObject, - testModel, - testCapabilities, - mockRelationship, - mockComposition, - mockCallback, - capability; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (callback) { - return asPromise(callback(v)); - }, - testValue: v - }; - } - - function allPromises(promises) { - return asPromise(promises.map(function (p) { - return (p || {}).then ? p.testValue : p; - })); - } - - // Utility function for making domain objects with utilization - // and/or cost capabilities - function fakeDomainObject(resources, start, end, costs) { - return { - getCapability: function (c) { - return ((c === 'utilization') && { - // Utilization capability - resources: function () { - return asPromise(resources); - }, - invoke: function () { - return asPromise(resources.map(function (k) { - return { key: k, start: start, end: end }; - })); - } - }) || ((c === 'cost') && { - // Cost capability - resources: function () { - return Object.keys(costs).sort(); - }, - cost: function (k) { - return costs[k]; - } - }); - }, - useCapability: function (c) { - return this.getCapability(c).invoke(); - } - }; - } - - beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', ['when', 'all']); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getId', 'getModel', 'getCapability', 'useCapability'] - ); - mockRelationship = jasmine.createSpyObj( - 'relationship', - ['getRelatedObjects'] - ); - mockComposition = jasmine.createSpyObj( - 'composition', - ['invoke'] - ); - mockCallback = jasmine.createSpy('callback'); - - testModel = { - type: "activity", - resources: { - abc: 100, - xyz: 42 - } - }; - testCapabilities = { - composition: mockComposition, - relationship: mockRelationship - }; - - mockQ.when.and.callFake(asPromise); - mockQ.all.and.callFake(allPromises); - mockDomainObject.getModel.and.returnValue(testModel); - mockDomainObject.getCapability.and.callFake(function (c) { - return testCapabilities[c]; - }); - mockDomainObject.useCapability.and.callFake(function (c) { - return testCapabilities[c] && testCapabilities[c].invoke(); - }); - - capability = new UtilizationCapability( - mockQ, - mockDomainObject - ); - }); - - it("is applicable to timelines", function () { - expect(UtilizationCapability.appliesTo({ - type: "timeline" - })).toBeTruthy(); - }); - - it("is applicable to activities", function () { - expect(UtilizationCapability.appliesTo(testModel)) - .toBeTruthy(); - }); - - it("is not applicable to other objects", function () { - expect(UtilizationCapability.appliesTo({ - type: "something" - })).toBeFalsy(); - }); - - it("accumulates resources from composition", function () { - mockComposition.invoke.and.returnValue(asPromise([ - fakeDomainObject(['abc', 'def']), - fakeDomainObject(['def', 'xyz']), - fakeDomainObject(['abc', 'xyz']) - ])); - - capability.resources().then(mockCallback); - - expect(mockCallback) - .toHaveBeenCalledWith(['abc', 'def', 'xyz']); - }); - - it("accumulates utilizations from composition", function () { - mockComposition.invoke.and.returnValue(asPromise([ - fakeDomainObject(['abc', 'def'], 10, 100), - fakeDomainObject(['def', 'xyz'], 50, 90) - ])); - - capability.invoke().then(mockCallback); - - expect(mockCallback).toHaveBeenCalledWith([ - { key: 'abc', start: 10, end: 100 }, - { key: 'def', start: 10, end: 100 }, - { key: 'def', start: 50, end: 90 }, - { key: 'xyz', start: 50, end: 90 } - ]); - }); - - it("provides intrinsic utilization from related objects", function () { - var mockTimespan = jasmine.createSpyObj( - 'timespan', - ['getStart', 'getEnd', 'getEpoch'] - ), - mockTimespanCapability = jasmine.createSpyObj( - 'timespanCapability', - ['invoke'] - ); - mockComposition.invoke.and.returnValue(asPromise([])); - mockRelationship.getRelatedObjects.and.returnValue(asPromise([ - fakeDomainObject([], 0, 0, { abc: 5, xyz: 15 }) - ])); - - testCapabilities.timespan = mockTimespanCapability; - mockTimespanCapability.invoke.and.returnValue(asPromise(mockTimespan)); - mockTimespan.getStart.and.returnValue(42); - mockTimespan.getEnd.and.returnValue(12321); - mockTimespan.getEpoch.and.returnValue("TEST"); - - capability.invoke().then(mockCallback); - - expect(mockCallback).toHaveBeenCalledWith([ - { key: 'abc', start: 42, end: 12321, value: 5, epoch: "TEST" }, - { key: 'xyz', start: 42, end: 12321, value: 15, epoch: "TEST" } - ]); - }); - - it("provides resource keys from related objects", function () { - mockComposition.invoke.and.returnValue(asPromise([])); - mockRelationship.getRelatedObjects.and.returnValue(asPromise([ - fakeDomainObject([], 0, 0, { abc: 5, xyz: 15 }) - ])); - - capability.resources().then(mockCallback); - - expect(mockCallback).toHaveBeenCalledWith(['abc', 'xyz']); - }); - - }); - } -); diff --git a/platform/features/timeline/test/chart/Canvas2DChartSpec.js b/platform/features/timeline/test/chart/Canvas2DChartSpec.js deleted file mode 100644 index edaed99025..0000000000 --- a/platform/features/timeline/test/chart/Canvas2DChartSpec.js +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * MergeModelsSpec. Created by vwoeltje on 11/6/14. - */ -define( - ["../../src/chart/Canvas2DChart"], - function (Canvas2DChart) { - - describe("A canvas 2d chart", function () { - var mockCanvas, - mock2d, - chart; - - beforeEach(function () { - mockCanvas = jasmine.createSpyObj("canvas", ["getContext"]); - mock2d = jasmine.createSpyObj( - "2d", - [ - "clearRect", - "beginPath", - "moveTo", - "lineTo", - "stroke", - "fillRect" - ] - ); - mockCanvas.getContext.and.returnValue(mock2d); - - chart = new Canvas2DChart(mockCanvas); - }); - - // Note that tests below are less specific than they - // could be, esp. w.r.t. arguments to drawing calls; - // this is a fallback option so is a lower test priority. - - it("allows the canvas to be cleared", function () { - chart.clear(); - expect(mock2d.clearRect).toHaveBeenCalled(); - }); - - it("does not construct if 2D is unavailable", function () { - mockCanvas.getContext.and.returnValue(undefined); - expect(function () { - return new Canvas2DChart(mockCanvas); - }).toThrow(); - }); - - it("allows dimensions to be set", function () { - // No return value, just verify API is present - chart.setDimensions([120, 120], [0, 10]); - }); - - it("allows lines to be drawn", function () { - var testBuffer = [0, 1, 3, 8], - testColor = [0.25, 0.33, 0.66, 1.0], - testPoints = 2; - chart.drawLine(testBuffer, testColor, testPoints); - expect(mock2d.beginPath).toHaveBeenCalled(); - expect(mock2d.lineTo.calls.count()).toEqual(1); - expect(mock2d.stroke).toHaveBeenCalled(); - }); - - it("allows squares to be drawn", function () { - var testMin = [0, 1], - testMax = [10, 10], - testColor = [0.25, 0.33, 0.66, 1.0]; - - chart.drawSquare(testMin, testMax, testColor); - expect(mock2d.fillRect).toHaveBeenCalled(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/chart/GLChartSpec.js b/platform/features/timeline/test/chart/GLChartSpec.js deleted file mode 100644 index 802347863c..0000000000 --- a/platform/features/timeline/test/chart/GLChartSpec.js +++ /dev/null @@ -1,143 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * MergeModelsSpec. Created by vwoeltje on 11/6/14. - */ -define( - ["../../src/chart/GLChart"], - function (GLChart) { - - describe("A WebGL chart", function () { - var mockCanvas, - mockGL, - glChart; - - beforeEach(function () { - mockCanvas = jasmine.createSpyObj("canvas", ["getContext"]); - mockGL = jasmine.createSpyObj( - "gl", - [ - "createShader", - "compileShader", - "shaderSource", - "attachShader", - "createProgram", - "linkProgram", - "useProgram", - "enableVertexAttribArray", - "getAttribLocation", - "getUniformLocation", - "createBuffer", - "lineWidth", - "enable", - "blendFunc", - "viewport", - "clear", - "uniform2fv", - "uniform4fv", - "bufferData", - "bindBuffer", - "vertexAttribPointer", - "drawArrays" - ] - ); - mockGL.ARRAY_BUFFER = "ARRAY_BUFFER"; - mockGL.DYNAMIC_DRAW = "DYNAMIC_DRAW"; - mockGL.TRIANGLE_FAN = "TRIANGLE_FAN"; - mockGL.LINE_STRIP = "LINE_STRIP"; - - // Echo back names for uniform locations, so we can - // test which of these are set for certain operations. - mockGL.getUniformLocation.and.callFake(function (a, name) { - return name; - }); - - mockCanvas.getContext.and.returnValue(mockGL); - - glChart = new GLChart(mockCanvas); - }); - - it("allows the canvas to be cleared", function () { - glChart.clear(); - expect(mockGL.clear).toHaveBeenCalled(); - }); - - it("does not construct if WebGL is unavailable", function () { - mockCanvas.getContext.and.returnValue(undefined); - expect(function () { - return new GLChart(mockCanvas); - }).toThrow(); - }); - - it("allows dimensions to be set", function () { - glChart.setDimensions([120, 120], [0, 10]); - expect(mockGL.uniform2fv) - .toHaveBeenCalledWith("uDimensions", [120, 120]); - expect(mockGL.uniform2fv) - .toHaveBeenCalledWith("uOrigin", [0, 10]); - }); - - it("allows lines to be drawn", function () { - var testBuffer = [0, 1, 3, 8], - testColor = [0.25, 0.33, 0.66, 1.0], - testPoints = 2; - glChart.drawLine(testBuffer, testColor, testPoints); - expect(mockGL.bufferData).toHaveBeenCalledWith( - mockGL.ARRAY_BUFFER, - testBuffer, - mockGL.DYNAMIC_DRAW - ); - expect(mockGL.uniform4fv) - .toHaveBeenCalledWith("uColor", testColor); - expect(mockGL.drawArrays) - .toHaveBeenCalledWith("LINE_STRIP", 0, testPoints); - }); - - it("allows squares to be drawn", function () { - var testMin = [0, 1], - testMax = [10, 10], - testColor = [0.25, 0.33, 0.66, 1.0]; - - glChart.drawSquare(testMin, testMax, testColor); - - expect(mockGL.uniform4fv) - .toHaveBeenCalledWith("uColor", testColor); - expect(mockGL.drawArrays) - .toHaveBeenCalledWith("TRIANGLE_FAN", 0, 4); - }); - - it("uses buffer sizes reported by WebGL", function () { - // Make sure that GLChart uses the GL buffer size, which may - // differ from what canvas requested. WTD-852 - mockCanvas.width = 300; - mockCanvas.height = 150; - mockGL.drawingBufferWidth = 200; - mockGL.drawingBufferHeight = 175; - - glChart.clear(); - - expect(mockGL.viewport).toHaveBeenCalledWith(0, 0, 200, 175); - }); - }); - } -); diff --git a/platform/features/timeline/test/chart/MCTTimelineChartSpec.js b/platform/features/timeline/test/chart/MCTTimelineChartSpec.js deleted file mode 100644 index f7d2f1f39a..0000000000 --- a/platform/features/timeline/test/chart/MCTTimelineChartSpec.js +++ /dev/null @@ -1,216 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2014-2018, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -/** - * MCTTimelineChart. Created by vwoeltje on 11/6/14. - */ -define( - ["../../src/chart/MCTTimelineChart"], - function (MCTTimelineChart) { - - describe("The mct-timeline-chart directive", function () { - var mockInterval, - mockLog, - mockScope, - mockElement, - mockCanvas, - mockGL, - mockC2d, - mockPromise, - mctChart; - - beforeEach(function () { - mockInterval = - jasmine.createSpy("$interval"); - mockLog = - jasmine.createSpyObj("$log", ["warn", "info", "debug"]); - mockScope = jasmine.createSpyObj( - "$scope", - ["$watchCollection", "$on", "$apply"] - ); - mockElement = - jasmine.createSpyObj("element", ["find", "html"]); - mockInterval.cancel = jasmine.createSpy("cancelInterval"); - mockPromise = jasmine.createSpyObj("promise", ["then"]); - - - // mct-timeline-chart uses GLChart, so it needs WebGL API - mockCanvas = - jasmine.createSpyObj("canvas", ["getContext", "addEventListener"]); - mockGL = jasmine.createSpyObj( - "gl", - [ - "createShader", - "compileShader", - "shaderSource", - "attachShader", - "createProgram", - "linkProgram", - "useProgram", - "enableVertexAttribArray", - "getAttribLocation", - "getUniformLocation", - "createBuffer", - "lineWidth", - "enable", - "blendFunc", - "viewport", - "clear", - "uniform2fv", - "uniform4fv", - "bufferData", - "bindBuffer", - "vertexAttribPointer", - "drawArrays" - ] - ); - mockC2d = jasmine.createSpyObj('c2d', ['clearRect']); - mockGL.ARRAY_BUFFER = "ARRAY_BUFFER"; - mockGL.DYNAMIC_DRAW = "DYNAMIC_DRAW"; - mockGL.TRIANGLE_FAN = "TRIANGLE_FAN"; - mockGL.LINE_STRIP = "LINE_STRIP"; - - // Echo back names for uniform locations, so we can - // test which of these are set for certain operations. - mockGL.getUniformLocation.and.callFake(function (a, name) { - return name; - }); - - mockElement.find.and.returnValue([mockCanvas]); - mockCanvas.getContext.and.callFake(function (type) { - return { webgl: mockGL, '2d': mockC2d }[type]; - }); - mockInterval.and.returnValue(mockPromise); - - mctChart = new MCTTimelineChart(mockInterval, mockLog); - }); - - it("is applicable at the element level", function () { - expect(mctChart.restrict).toEqual("E"); - }); - - it("places a 'draw' attribute in-scope", function () { - // Should ask Angular for the draw attribute - expect(mctChart.scope.draw).toEqual("="); - }); - - it("watches for changes in the drawn object", function () { - mctChart.link(mockScope, mockElement); - expect(mockScope.$watchCollection) - .toHaveBeenCalledWith("draw", jasmine.any(Function)); - }); - - it("issues one draw call per line", function () { - mctChart.link(mockScope, mockElement); - mockScope.$watchCollection.calls.mostRecent().args[1]({ - lines: [{}, {}, {}] - }); - expect(mockGL.drawArrays.calls.count()).toEqual(3); - }); - - it("issues one draw call per box", function () { - mctChart.link(mockScope, mockElement); - mockScope.$watchCollection.calls.mostRecent().args[1]({ - boxes: [ - { start: [0, 0], end: [1, 1] }, - { start: [0, 0], end: [1, 1] }, - { start: [0, 0], end: [1, 1] }, - { start: [0, 0], end: [1, 1] } - ] - }); - expect(mockGL.drawArrays.calls.count()).toEqual(4); - }); - - it("does not fail if no draw object is in scope", function () { - mctChart.link(mockScope, mockElement); - expect(mockScope.$watchCollection.calls.mostRecent().args[1]) - .not.toThrow(); - }); - - it("draws on canvas resize", function () { - mctChart.link(mockScope, mockElement); - - // Should track canvas size in an interval - expect(mockInterval).toHaveBeenCalledWith( - jasmine.any(Function), - jasmine.any(Number), - 0, - false - ); - - // Verify pre-condition - expect(mockGL.clear).not.toHaveBeenCalled(); - - mockCanvas.width = 100; - mockCanvas.offsetWidth = 150; - mockCanvas.height = 200; - mockCanvas.offsetHeight = 200; - mockInterval.calls.mostRecent().args[0](); - - // Use clear as an indication that drawing has occurred - expect(mockGL.clear).toHaveBeenCalled(); - }); - - it("warns if no WebGL context is available", function () { - mockCanvas.getContext.and.returnValue(undefined); - mctChart.link(mockScope, mockElement); - expect(mockLog.warn).toHaveBeenCalled(); - }); - - it("falls back to Canvas 2d API if WebGL context is lost", function () { - mctChart.link(mockScope, mockElement); - expect(mockCanvas.addEventListener) - .toHaveBeenCalledWith("webglcontextlost", jasmine.any(Function)); - expect(mockCanvas.getContext).not.toHaveBeenCalledWith('2d'); - mockCanvas.addEventListener.calls.mostRecent().args[1](); - expect(mockCanvas.getContext).toHaveBeenCalledWith('2d'); - }); - - it("logs nothing in nominal situations (WebGL available)", function () { - // Complement the previous test - mctChart.link(mockScope, mockElement); - expect(mockLog.warn).not.toHaveBeenCalled(); - }); - - // Avoid resource leaks - it("stops polling for size changes on destroy", function () { - mctChart.link(mockScope, mockElement); - - // Should be listening for a destroy event - expect(mockScope.$on).toHaveBeenCalledWith( - "$destroy", - jasmine.any(Function) - ); - - // Precondition - interval still active - expect(mockInterval.cancel).not.toHaveBeenCalled(); - - // Broadcast a $destroy - mockScope.$on.calls.mostRecent().args[1](); - - // Should have stopped the interval - expect(mockInterval.cancel).toHaveBeenCalledWith(mockPromise); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js b/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js deleted file mode 100644 index 6fd2789458..0000000000 --- a/platform/features/timeline/test/controllers/ActivityModeValuesControllerSpec.js +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/controllers/ActivityModeValuesController'], - function (ActivityModeValuesController) { - - describe("An Activity Mode's Values view controller", function () { - var testResources, - controller; - - beforeEach(function () { - testResources = [ - { key: 'abc', name: "Some name" }, - { key: 'def', name: "Test type", units: "Test units" }, - { key: 'xyz', name: "Something else" } - ]; - controller = new ActivityModeValuesController(testResources); - }); - - it("exposes resource metadata by key", function () { - expect(controller.metadata('abc')).toEqual(testResources[0]); - expect(controller.metadata('def')).toEqual(testResources[1]); - expect(controller.metadata('xyz')).toEqual(testResources[2]); - }); - - it("exposes no metadata for unknown keys", function () { - expect(controller.metadata('???')).toBeUndefined(); - }); - }); - } -); diff --git a/platform/features/timeline/test/controllers/TimelineControllerSpec.js b/platform/features/timeline/test/controllers/TimelineControllerSpec.js deleted file mode 100644 index 275387f6a7..0000000000 --- a/platform/features/timeline/test/controllers/TimelineControllerSpec.js +++ /dev/null @@ -1,240 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/controllers/TimelineController'], - function (TimelineController) { - - var DOMAIN_OBJECT_METHODS = [ - 'getModel', - 'getId', - 'useCapability', - 'hasCapability', - 'getCapability' - ]; - - describe("The timeline controller", function () { - var mockScope, - mockQ, - mockLoader, - mockDomainObject, - mockSpan, - testModels, - testConfiguration, - controller; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (callback) { - return asPromise(callback(v)); - }, - testValue: v - }; - } - - function allPromises(promises) { - return asPromise(promises.map(function (p) { - return (p || {}).then ? p.testValue : p; - })); - } - - function subgraph(domainObject, objects) { - function lookupSubgraph(id) { - return subgraph(objects[id], objects); - } - return { - domainObject: domainObject, - composition: (domainObject.getModel().composition || []) - .map(lookupSubgraph) - }; - } - - function fireWatch(expr, value) { - mockScope.$watch.calls.all().forEach(function (call) { - if (call.args[0] === expr) { - call.args[1](value); - } - }); - } - - - beforeEach(function () { - var mockA, mockB, mockUtilization, mockPromise, mockGraph, testCapabilities; - - function getCapability(c) { - return testCapabilities[c]; - } - - function useCapability(c) { - return c === 'timespan' ? asPromise(mockSpan) : - c === 'graph' ? asPromise({ abc: mockGraph, xyz: mockGraph }) : - undefined; - } - - testModels = { - a: { modified: 40, composition: ['b'] }, - b: { modified: 2 } - }; - - testConfiguration = {}; - - mockQ = jasmine.createSpyObj('$q', ['when', 'all']); - mockA = jasmine.createSpyObj('a', DOMAIN_OBJECT_METHODS); - mockB = jasmine.createSpyObj('b', DOMAIN_OBJECT_METHODS); - mockSpan = jasmine.createSpyObj('span', ['getStart', 'getEnd']); - mockUtilization = jasmine.createSpyObj('utilization', ['resources', 'utilization']); - mockGraph = jasmine.createSpyObj('graph', ['getPointCount']); - mockPromise = jasmine.createSpyObj('promise', ['then']); - - mockScope = jasmine.createSpyObj( - "$scope", - ['$watch', '$on'] - ); - mockLoader = jasmine.createSpyObj('objectLoader', ['load']); - mockDomainObject = mockA; - - mockScope.domainObject = mockDomainObject; - mockScope.configuration = testConfiguration; - mockQ.when.and.callFake(asPromise); - mockQ.all.and.callFake(allPromises); - mockA.getId.and.returnValue('a'); - mockA.getModel.and.returnValue(testModels.a); - mockB.getId.and.returnValue('b'); - mockB.getModel.and.returnValue(testModels.b); - mockA.useCapability.and.callFake(useCapability); - mockB.useCapability.and.callFake(useCapability); - mockA.hasCapability.and.returnValue(true); - mockB.hasCapability.and.returnValue(true); - mockA.getCapability.and.callFake(getCapability); - mockB.getCapability.and.callFake(getCapability); - mockSpan.getStart.and.returnValue(42); - mockSpan.getEnd.and.returnValue(12321); - mockUtilization.resources.and.returnValue(['abc', 'xyz']); - mockUtilization.utilization.and.returnValue(mockPromise); - mockLoader.load.and.callFake(function () { - return asPromise(subgraph(mockA, { - a: mockA, - b: mockB - })); - }); - - testCapabilities = { - "utilization": mockUtilization - }; - - controller = new TimelineController(mockScope, mockQ, mockLoader, 0); - }); - - it("exposes scroll state tracker in scope", function () { - expect(mockScope.scroll.x).toEqual(0); - expect(mockScope.scroll.y).toEqual(0); - }); - - it("watches for a configuration object", function () { - expect(mockScope.$watch).toHaveBeenCalledWith( - "configuration", - jasmine.any(Function) - ); - }); - - it("repopulates when modifications are made", function () { - var fnWatchCall; - - // Find the $watch that was given a function - mockScope.$watch.calls.all().forEach(function (call) { - if (typeof call.args[0] === 'function') { - // white-box: we know the first call is - // the one we're looking for - fnWatchCall = fnWatchCall || call; - } - }); - - // Make sure string watch was for domainObject - fireWatch('domainObject', mockDomainObject); - // There should be to swimlanes - expect(controller.swimlanes().length).toEqual(2); - - // Watch should be for sum of modified flags... - expect(fnWatchCall.args[0]()).toEqual(42); - - // Remove the child, then fire the watch - testModels.a.composition = []; - fnWatchCall.args[1](); - - // Swimlanes should have updated - expect(controller.swimlanes().length).toEqual(1); - }); - - it("repopulates graphs when graph choices change", function () { - var tmp; - - // Note that this test is brittle; it relies upon the - // order of $watch calls in TimelineController. - - // Initially populate - fireWatch('domainObject', mockDomainObject); - - // Verify precondition - no graphs - expect(controller.graphs().length).toEqual(0); - - // Execute the watch function for graph state - tmp = mockScope.$watch.calls.all()[3].args[0](); - - // Change graph state - testConfiguration.graph = { a: true, b: true }; - - // Verify that this would have triggered a watch - expect(mockScope.$watch.calls.all()[3].args[0]()) - .not.toEqual(tmp); - - // Run the function the watch would have triggered - mockScope.$watch.calls.all()[3].args[1](); - - // Should have some graphs now - expect(controller.graphs().length).toEqual(2); - - }); - - it("provides drag handles", function () { - // TimelineDragPopulator et al are tested for these, - // so just verify that handles are indeed exposed. - expect(controller.handles()).toEqual(jasmine.any(Array)); - }); - - it("refreshes graphs on request", function () { - var mockGraph = jasmine.createSpyObj('graph', ['refresh']); - - // Sneak a mock graph into the graph populator... - // This is whiteboxy and will have to change if - // GraphPopulator changes - controller.graphs().push(mockGraph); - - // Refresh - controller.refresh(); - - // Should have refreshed the graph - expect(mockGraph.refresh).toHaveBeenCalled(); - }); - }); - - } -); diff --git a/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js b/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js deleted file mode 100644 index 9a802a85a9..0000000000 --- a/platform/features/timeline/test/controllers/TimelineDateTimeControllerSpec.js +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - - -define( - ["../../src/controllers/TimelineDateTimeController"], - function (TimelineDateTimeController) { - - describe("The date-time controller for timeline creation", function () { - var mockScope, - controller; - - beforeEach(function () { - mockScope = jasmine.createSpyObj('$scope', ['$watchCollection']); - mockScope.field = 'testField'; - mockScope.ngModel = { testField: { timestamp: 0, epoch: "SET" } }; - controller = new TimelineDateTimeController(mockScope); - }); - - - // Verify two-way binding support - it("updates model on changes to entry fields", function () { - // Make sure we're looking at the right watch - expect(mockScope.$watchCollection.calls.all()[0].args[0]) - .toEqual("datetime"); - mockScope.$watchCollection.calls.all()[0].args[1]({ - days: 4, - hours: 12, - minutes: 30, - seconds: 11 - }); - expect(mockScope.ngModel.testField.timestamp).toEqual( - ((((((4 * 24) + 12) * 60) + 30) * 60) + 11) * 1000 - ); - }); - - it("updates form when model changes", function () { - // Make sure we're looking at the right watch - expect(mockScope.$watchCollection.calls.all()[1].args[0]) - .toEqual(jasmine.any(Function)); - // ...and that it's really looking at the field in ngModel - expect(mockScope.$watchCollection.calls.all()[1].args[0]()) - .toBe(mockScope.ngModel.testField); - mockScope.$watchCollection.calls.all()[1].args[1]({ - timestamp: ((((((4 * 24) + 12) * 60) + 30) * 60) + 11) * 1000 - }); - expect(mockScope.datetime).toEqual({ - days: 4, - hours: 12, - minutes: 30, - seconds: 11 - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js b/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js deleted file mode 100644 index 4869e143be..0000000000 --- a/platform/features/timeline/test/controllers/TimelineGanttControllerSpec.js +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/controllers/TimelineGanttController'], - function (TimelineGanttController) { - - var TEST_MAX_OFFSCREEN = 50; - - describe("The timeline Gantt bar controller", function () { - var mockTimespan, - testScroll, - mockToPixels, - controller; - - // Shorthands for passing these arguments to the controller - function width() { - return controller.width( - mockTimespan, - testScroll, - mockToPixels - ); - } - function left() { - return controller.left( - mockTimespan, - testScroll, - mockToPixels - ); - } - - - beforeEach(function () { - mockTimespan = jasmine.createSpyObj( - 'timespan', - ['getStart', 'getEnd', 'getDuration'] - ); - testScroll = { x: 0, width: 2000 }; - mockToPixels = jasmine.createSpy('toPixels'); - - mockTimespan.getStart.and.returnValue(100); - mockTimespan.getDuration.and.returnValue(50); - mockTimespan.getEnd.and.returnValue(150); - - mockToPixels.and.callFake(function (t) { - return t * 10; - }); - - controller = new TimelineGanttController(TEST_MAX_OFFSCREEN); - }); - - it("positions start and end points correctly on-screen", function () { - // Test's initial conditions are nominal, so should have - // the same return value as mockToPixels - expect(left()).toEqual(1000); - expect(width()).toEqual(500); - }); - - it("prevents excessive off screen values to the left", function () { - testScroll.x = 1200; - expect(left()).toEqual(1150); - expect(width()).toEqual(350); // ...such that right edge is 1500 - }); - - it("prevents excessive off screen values to the right", function () { - testScroll.width = 1200; - expect(left()).toEqual(1000); - expect(width()).toEqual(250); // ...such that right edge is 1250 - }); - - it("prevents excessive off screen values on both edges", function () { - testScroll.x = 1100; - testScroll.width = 200; // Visible right edge is now 1300 - expect(left()).toEqual(1050); - expect(width()).toEqual(300); // ...such that right edge is 1350 - }); - - - - }); - } -); diff --git a/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js b/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js deleted file mode 100644 index b0f868c5db..0000000000 --- a/platform/features/timeline/test/controllers/TimelineGraphControllerSpec.js +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/controllers/TimelineGraphController'], - function (TimelineGraphController) { - - describe("The Timeline graph controller", function () { - var mockScope, - testResources, - controller; - - beforeEach(function () { - mockScope = jasmine.createSpyObj( - '$scope', - ['$watchCollection'] - ); - testResources = [ - { key: 'abc', name: "Some name" }, - { key: 'def', name: "Test type", units: "Test units" }, - { key: 'xyz', name: "Something else" } - ]; - controller = new TimelineGraphController( - mockScope, - testResources - ); - }); - - it("watches for parameter changes", function () { - expect(mockScope.$watchCollection).toHaveBeenCalledWith( - 'parameters', - jasmine.any(Function) - ); - }); - - it("updates graphs when parameters change", function () { - var mockGraphA = jasmine.createSpyObj('graph-a', ['setBounds']), - mockGraphB = jasmine.createSpyObj('graph-b', ['setBounds']); - - // Supply new parameters - mockScope.$watchCollection.calls.mostRecent().args[1]({ - graphs: [mockGraphA, mockGraphB], - origin: 9, - duration: 144 - }); - - // Graphs should have both been updated - expect(mockGraphA.setBounds).toHaveBeenCalledWith(9, 144); - expect(mockGraphB.setBounds).toHaveBeenCalledWith(9, 144); - }); - - it("provides labels for graphs", function () { - var mockGraph = jasmine.createSpyObj('graph', ['minimum', 'maximum']); - - mockGraph.minimum.and.returnValue(12.3412121); - mockGraph.maximum.and.returnValue(88.7555555); - mockGraph.key = "def"; - - expect(controller.label(mockGraph)).toEqual({ - title: "Test type (Test units)", - low: "12.341", - middle: "50.548", - high: "88.756" - }); - }); - }); - } -); diff --git a/platform/features/timeline/test/controllers/TimelineTOIControllerSpec.js b/platform/features/timeline/test/controllers/TimelineTOIControllerSpec.js deleted file mode 100644 index e9b14db489..0000000000 --- a/platform/features/timeline/test/controllers/TimelineTOIControllerSpec.js +++ /dev/null @@ -1,138 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define([ - "../../src/controllers/TimelineTOIController", - "EventEmitter" -], function (TimelineTOIController, EventEmitter) { - describe("The timeline TOI controller", function () { - var mockmct; - var mockTimerService; - var mockScope; - var controller; - - beforeEach(function () { - mockmct = { time: new EventEmitter() }; - mockmct.time.bounds = jasmine.createSpy('bounds'); - mockTimerService = new EventEmitter(); - mockTimerService.getTimer = jasmine.createSpy('getTimer'); - mockTimerService.hasTimer = jasmine.createSpy('hasTimer'); - mockTimerService.now = jasmine.createSpy('now'); - mockTimerService.convert = jasmine.createSpy('convert'); - mockScope = new EventEmitter(); - mockScope.$on = mockScope.on.bind(mockScope); - mockScope.zoomController = jasmine.createSpyObj('zoom', [ - 'bounds', - 'toPixels' - ]); - mockScope.scroll = { x: 10, width: 1000 }; - - spyOn(mockmct.time, "on").and.callThrough(); - spyOn(mockmct.time, "off").and.callThrough(); - spyOn(mockTimerService, "on").and.callThrough(); - spyOn(mockTimerService, "off").and.callThrough(); - - controller = new TimelineTOIController( - mockmct, - mockTimerService, - mockScope - ); - }); - - it("reports an undefined x position initially", function () { - expect(controller.x()).toBeUndefined(); - }); - - it("listens for bounds changes", function () { - expect(mockmct.time.on) - .toHaveBeenCalledWith('bounds', controller.bounds); - }); - - it("listens for timer changes", function () { - expect(mockTimerService.on) - .toHaveBeenCalledWith('change', controller.change); - }); - - it("is not active", function () { - expect(controller.isActive()).toBe(false); - }); - - describe("on $destroy from scope", function () { - beforeEach(function () { - mockScope.emit("$destroy"); - }); - - it("unregisters listeners", function () { - expect(mockmct.time.off) - .toHaveBeenCalledWith('bounds', controller.bounds); - expect(mockTimerService.off) - .toHaveBeenCalledWith('change', controller.change); - }); - }); - - describe("when a timer and timestamp present", function () { - var mockTimer; - var testNow; - - beforeEach(function () { - testNow = 333221; - mockScope.zoomController.toPixels - .and.callFake(function (millis) { - return millis * 2; - }); - mockTimerService.emit('change', mockTimer); - mockTimerService.now.and.returnValue(testNow); - }); - - it("reports an x value from the zoomController", function () { - var now = mockTimerService.now(); - var expected = mockScope.zoomController.toPixels(now); - expect(controller.x()).toEqual(expected); - }); - }); - - describe("when follow mode is disabled", function () { - beforeEach(function () { - mockScope.scroll.follow = false; - }); - - it("ignores bounds events", function () { - mockmct.time.emit('bounds', { start: 0, end: 1000 }); - expect(mockScope.zoomController.bounds) - .not.toHaveBeenCalled(); - }); - }); - - describe("when follow mode is enabled", function () { - beforeEach(function () { - mockScope.scroll.follow = true; - mockTimerService.now.and.returnValue(500); - }); - - it("zooms on bounds events", function () { - mockmct.time.emit('bounds', { start: 0, end: 1000 }); - expect(mockScope.zoomController.bounds) - .toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js b/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js deleted file mode 100644 index 5a393c015e..0000000000 --- a/platform/features/timeline/test/controllers/TimelineTableControllerSpec.js +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - [ - '../../src/controllers/TimelineTableController', - '../../src/TimelineFormatter' - ], - function (TimelineTableController, TimelineFormatter) { - - describe("The timeline table controller", function () { - var formatter, controller; - - beforeEach(function () { - controller = new TimelineTableController(); - formatter = new TimelineFormatter(); - }); - - // This controller's job is just to expose the formatter - // in scope, so simply verify that the two agree. - it("formats durations", function () { - [0, 100, 4123, 93600, 748801230012].forEach(function (n) { - expect(controller.niceTime(n)) - .toEqual(formatter.format(n)); - }); - }); - - - }); - } -); diff --git a/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js b/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js deleted file mode 100644 index fb07c88433..0000000000 --- a/platform/features/timeline/test/controllers/TimelineTickControllerSpec.js +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/controllers/TimelineTickController', '../../src/TimelineFormatter'], - function (TimelineTickController, TimelineFormatter) { - - var BILLION = 1000000000, - FORMATTER = new TimelineFormatter(); - - describe("The timeline tick controller", function () { - var mockToMillis, - controller; - - function expectedTick(pixelValue) { - return { - left: pixelValue, - text: FORMATTER.format(pixelValue * 2 + BILLION) - }; - } - - beforeEach(function () { - mockToMillis = jasmine.createSpy('toMillis'); - mockToMillis.and.callFake(function (v) { - return v * 2 + BILLION; - }); - controller = new TimelineTickController(); - }); - - it("exposes tick marks within a requested pixel span", function () { - // Simple case - expect(controller.labels(8000, 300, 100, mockToMillis)) - .toEqual([8000, 8100, 8200, 8300].map(expectedTick)); - - // Slightly more complicated case - expect(controller.labels(7480, 4500, 1000, mockToMillis)) - .toEqual([7000, 8000, 9000, 10000, 11000, 12000].map(expectedTick)); - }); - - it("does not rebuild arrays for same inputs", function () { - var firstValue = controller.labels(800, 300, 100, mockToMillis); - - expect(controller.labels(800, 300, 100, mockToMillis)) - .toEqual(firstValue); - - expect(controller.labels(800, 300, 100, mockToMillis)) - .toBe(firstValue); - }); - - it("does rebuild arrays when zoom changes", function () { - var firstValue = controller.labels(800, 300, 100, mockToMillis); - - mockToMillis.and.callFake(function (v) { - return BILLION * 2 + v; - }); - - expect(controller.labels(800, 300, 100, mockToMillis)) - .not.toEqual(firstValue); - - expect(controller.labels(800, 300, 100, mockToMillis)) - .not.toBe(firstValue); - }); - - }); - - } -); diff --git a/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js b/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js deleted file mode 100644 index dc5191f038..0000000000 --- a/platform/features/timeline/test/controllers/TimelineZoomControllerSpec.js +++ /dev/null @@ -1,154 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - - -define( - ['../../src/controllers/TimelineZoomController'], - function (TimelineZoomController) { - - describe("The timeline zoom state controller", function () { - var testConfiguration, - mockScope, - mockWindow, - controller; - - beforeEach(function () { - testConfiguration = { - levels: [1000, 2000, 3500], - width: 12321 - }; - mockScope = - jasmine.createSpyObj("$scope", ['$watch', '$apply']); - mockScope.commit = jasmine.createSpy('commit'); - mockScope.scroll = { x: 0, width: 1000 }; - mockWindow = { - requestAnimationFrame: jasmine.createSpy('raf') - }; - controller = new TimelineZoomController( - mockScope, - mockWindow, - testConfiguration - ); - }); - - it("starts off at a middle zoom level", function () { - expect(controller.zoom()).toEqual(2000); - }); - - it("handles time-to-pixel conversions", function () { - var zoomLevel = controller.zoom(); - expect(controller.toPixels(zoomLevel)).toEqual(12321); - expect(controller.toPixels(zoomLevel * 2)).toEqual(24642); - }); - - it("handles pixel-to-time conversions", function () { - var zoomLevel = controller.zoom(); - expect(controller.toMillis(12321)).toEqual(zoomLevel); - expect(controller.toMillis(24642)).toEqual(zoomLevel * 2); - }); - - it("allows zoom to be changed", function () { - controller.zoom(1); - expect(controller.zoom()).toEqual(3500); - }); - - describe("when watches have fired", function () { - var mockDomainObject, - mockPromise, - mockTimespan, - testStart, - testEnd; - - beforeEach(function () { - testStart = 3000; - testEnd = 5500; - - mockDomainObject = jasmine.createSpyObj('domainObject', [ - 'getId', - 'getModel', - 'getCapability', - 'useCapability' - ]); - mockPromise = jasmine.createSpyObj('promise', ['then']); - mockTimespan = jasmine.createSpyObj('timespan', [ - 'getStart', - 'getEnd', - 'getDuration' - ]); - - mockDomainObject.useCapability.and.callFake(function (c) { - return c === 'timespan' && mockPromise; - }); - mockPromise.then.and.callFake(function (callback) { - callback(mockTimespan); - }); - mockTimespan.getStart.and.returnValue(testStart); - mockTimespan.getEnd.and.returnValue(testEnd); - mockTimespan.getDuration.and.returnValue(testEnd - testStart); - - mockScope.scroll = { x: 0, width: 20000 }; - mockScope.domainObject = mockDomainObject; - - mockScope.$watch.calls.all().forEach(function (call) { - call.args[1](mockScope[call.args[0]]); - }); - - mockWindow.requestAnimationFrame.calls.all().forEach(function (call) { - call.args[0](); - }); - }); - - it("zooms to fit the timeline", function () { - var x1 = mockScope.scroll.x, - x2 = mockScope.scroll.x + mockScope.scroll.width; - expect(Math.round(controller.toMillis(x1))) - .toEqual(testStart); - expect(Math.round(controller.toMillis(x2))) - .toBeGreaterThan(testEnd); - }); - - it("provides a width which is not less than scroll area width", function () { - var testPixel = mockScope.scroll.width / 4, - testMillis = controller.toMillis(testPixel); - expect(controller.width(testMillis)) - .not.toBeLessThan(mockScope.scroll.width); - }); - - it("provides a width with some margin past timestamp", function () { - var testPixel = mockScope.scroll.width * 4, - testMillis = controller.toMillis(testPixel); - expect(controller.width(testMillis)) - .toBeGreaterThan(controller.toPixels(testMillis)); - }); - - it("provides a width which does not greatly exceed timestamp", function () { - var testPixel = mockScope.scroll.width * 4, - testMillis = controller.toMillis(testPixel); - expect(controller.width(testMillis)) - .toBeLessThan(controller.toPixels(testMillis * 2)); - }); - }); - - }); - - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js b/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js deleted file mode 100644 index 6c0d0bf50f..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineDragHandleFactorySpec.js +++ /dev/null @@ -1,85 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/drag/TimelineDragHandleFactory'], - function (TimelineDragHandleFactory) { - - describe("A Timeline drag handle factory", function () { - var mockDragHandler, - mockSnapHandler, - mockDomainObject, - mockType, - testType, - factory; - - beforeEach(function () { - mockDragHandler = jasmine.createSpyObj( - 'dragHandler', - ['start'] - ); - mockSnapHandler = jasmine.createSpyObj( - 'snapHandler', - ['snap'] - ); - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getCapability', 'getId'] - ); - mockType = jasmine.createSpyObj( - 'type', - ['instanceOf'] - ); - - mockDomainObject.getId.and.returnValue('test-id'); - mockDomainObject.getCapability.and.returnValue(mockType); - mockType.instanceOf.and.callFake(function (t) { - return t === testType; - }); - - factory = new TimelineDragHandleFactory( - mockDragHandler, - mockSnapHandler - ); - }); - - it("inspects an object's type capability", function () { - factory.handles(mockDomainObject); - expect(mockDomainObject.getCapability) - .toHaveBeenCalledWith('type'); - }); - - it("provides three handles for activities", function () { - testType = "activity"; - expect(factory.handles(mockDomainObject).length) - .toEqual(3); - }); - - it("provides two handles for timelines", function () { - testType = "timeline"; - expect(factory.handles(mockDomainObject).length) - .toEqual(2); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js b/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js deleted file mode 100644 index 5a3a5b9094..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineDragHandlerSpec.js +++ /dev/null @@ -1,207 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/drag/TimelineDragHandler'], - function (TimelineDragHandler) { - - describe("A Timeline drag handler", function () { - var mockLoader, - mockSelection, - testConfiguration, - mockDomainObject, - mockDomainObjects, - mockTimespans, - mockMutations, - mockCallback, - handler; - - function asPromise(value) { - return (value || {}).then ? value : { - then: function (callback) { - return asPromise(callback(value)); - } - }; - } - - function subgraph(domainObject, objects) { - function lookupSubgraph(id) { - return subgraph(objects[id], objects); - } - return { - domainObject: domainObject, - composition: (domainObject.getModel().composition || []) - .map(lookupSubgraph) - }; - } - - function makeMockDomainObject(id, composition) { - var mockDomainObj = jasmine.createSpyObj( - 'domainObject-' + id, - ['getId', 'getModel', 'getCapability', 'useCapability'] - ); - - mockDomainObj.getId.and.returnValue(id); - mockDomainObj.getModel.and.returnValue({ composition: composition }); - mockDomainObj.useCapability.and.returnValue(asPromise(mockTimespans[id])); - mockDomainObj.getCapability.and.callFake(function (c) { - return { - mutation: mockMutations[id] - }[c]; - }); - - return mockDomainObj; - } - - beforeEach(function () { - mockTimespans = {}; - mockMutations = {}; - ['a', 'b', 'c', 'd', 'e', 'f'].forEach(function (id, index) { - mockTimespans[id] = jasmine.createSpyObj( - 'timespan-' + id, - ['getStart', 'getEnd', 'getDuration', 'setStart', 'setEnd', 'setDuration'] - ); - mockMutations[id] = jasmine.createSpyObj( - 'mutation-' + id, - ['mutate'] - ); - mockTimespans[id].getStart.and.returnValue(index * 1000); - mockTimespans[id].getDuration.and.returnValue(4000 + index); - mockTimespans[id].getEnd.and.returnValue(4000 + index + index * 1000); - }); - - mockLoader = jasmine.createSpyObj('objectLoader', ['load']); - mockDomainObject = makeMockDomainObject('a', ['b', 'c']); - mockDomainObjects = { - a: mockDomainObject, - b: makeMockDomainObject('b', ['d']), - c: makeMockDomainObject('c', ['e', 'f']), - d: makeMockDomainObject('d', []), - e: makeMockDomainObject('e', []), - f: makeMockDomainObject('f', []) - }; - mockSelection = jasmine.createSpyObj('selection', ['get', 'select']); - mockCallback = jasmine.createSpy('callback'); - - testConfiguration = {}; - - mockLoader.load.and.returnValue(asPromise( - subgraph(mockDomainObject, mockDomainObjects) - )); - - handler = new TimelineDragHandler( - mockDomainObject, - mockLoader - ); - }); - - it("uses the loader to find subgraph", function () { - expect(mockLoader.load).toHaveBeenCalledWith( - mockDomainObject, - 'timespan' - ); - }); - - it("reports available object identifiers", function () { - expect(handler.ids()) - .toEqual(Object.keys(mockDomainObjects).sort()); - }); - - it("exposes start/end/duration from timespan capabilities", function () { - expect(handler.start('a')).toEqual(0); - expect(handler.start('b')).toEqual(1000); - expect(handler.start('c')).toEqual(2000); - expect(handler.duration('a')).toEqual(4000); - expect(handler.duration('b')).toEqual(4001); - expect(handler.duration('c')).toEqual(4002); - expect(handler.end('a')).toEqual(4000); - expect(handler.end('b')).toEqual(5001); - expect(handler.end('c')).toEqual(6002); - }); - - it("accepts objects instead of identifiers for start/end/duration calls", function () { - Object.keys(mockDomainObjects).forEach(function (id) { - expect(handler.start(mockDomainObjects[id])).toEqual(handler.start(id)); - expect(handler.duration(mockDomainObjects[id])).toEqual(handler.duration(id)); - expect(handler.end(mockDomainObjects[id])).toEqual(handler.end(id)); - }); - }); - - it("mutates objects", function () { - handler.start('a', 123); - expect(mockTimespans.a.setStart).toHaveBeenCalledWith(123); - handler.duration('b', 42); - expect(mockTimespans.b.setDuration).toHaveBeenCalledWith(42); - handler.end('c', 12321); - expect(mockTimespans.c.setEnd).toHaveBeenCalledWith(12321); - }); - - it("disallows negative starts, durations", function () { - handler.start('a', -100); - handler.duration('b', -1000); - expect(mockTimespans.a.setStart).toHaveBeenCalledWith(0); - expect(mockTimespans.b.setDuration).toHaveBeenCalledWith(0); - }); - - it("disallows starts greater than ends violations", function () { - handler.start('a', 5000); - handler.end('b', 500); - expect(mockTimespans.a.setStart).toHaveBeenCalledWith(4000); // end time - expect(mockTimespans.b.setEnd).toHaveBeenCalledWith(1000); // start time - }); - - it("moves objects in groups", function () { - handler.move('b', 42); - expect(mockTimespans.b.setStart).toHaveBeenCalledWith(1042); - expect(mockTimespans.b.setEnd).toHaveBeenCalledWith(5043); - expect(mockTimespans.d.setStart).toHaveBeenCalledWith(3042); - expect(mockTimespans.d.setEnd).toHaveBeenCalledWith(7045); - // Verify no other interactions - ['a', 'c', 'e', 'f'].forEach(function (id) { - expect(mockTimespans[id].setStart).not.toHaveBeenCalled(); - expect(mockTimespans[id].setEnd).not.toHaveBeenCalled(); - }); - }); - - it("moves whole subtrees", function () { - handler.move('a', 12321); - // We verify the math in the previous test, so just verify - // that the whole tree is effected here. - Object.keys(mockTimespans).forEach(function (id) { - expect(mockTimespans[id].setStart).toHaveBeenCalled(); - }); - }); - - it("prevents bulk moves past 0", function () { - // Have a start later; new lowest start is b, at 1000 - mockTimespans.a.getStart.and.returnValue(10000); - handler.move('a', -10000); - // Verify that move was stopped at 0, for b, even though - // move was initiated at a - expect(mockTimespans.a.setStart).toHaveBeenCalledWith(9000); - expect(mockTimespans.b.setStart).toHaveBeenCalledWith(0); - expect(mockTimespans.c.setStart).toHaveBeenCalledWith(1000); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js b/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js deleted file mode 100644 index fef5871e93..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineDragPopulatorSpec.js +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - - -define( - ['../../../src/controllers/drag/TimelineDragPopulator'], - function (TimelineDragPopulator) { - - describe("The timeline drag populator", function () { - var mockObjectLoader, - mockPromise, - mockSwimlane, - mockDomainObject, - populator; - - beforeEach(function () { - mockObjectLoader = jasmine.createSpyObj("objectLoader", ["load"]); - mockPromise = jasmine.createSpyObj("promise", ["then"]); - mockSwimlane = jasmine.createSpyObj("swimlane", ["color"]); - mockDomainObject = jasmine.createSpyObj( - "domainObject", - ["getCapability", "getId"] - ); - - mockSwimlane.domainObject = mockDomainObject; - mockObjectLoader.load.and.returnValue(mockPromise); - - populator = new TimelineDragPopulator(mockObjectLoader); - }); - - it("loads timespans for the represented object's subgraph", function () { - populator.populate(mockDomainObject); - expect(mockObjectLoader.load).toHaveBeenCalledWith( - mockDomainObject, - 'timespan' - ); - }); - - it("updates handles for selections", function () { - // Ensure we have a represented object context - populator.populate(mockDomainObject); - // Initially, no selection and no handles - expect(populator.get()).toEqual([]); - // Select the swimlane - populator.select(mockSwimlane); - // We should have handles now - expect(populator.get().length).toEqual(3); - }); - - }); - - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js b/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js deleted file mode 100644 index 4cc15f08e4..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineEndHandleSpec.js +++ /dev/null @@ -1,115 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/drag/TimelineEndHandle', '../../../src/TimelineConstants'], - function (TimelineEndHandle, TimelineConstants) { - - describe("A Timeline end drag handle", function () { - var mockDragHandler, - mockSnapHandler, - mockZoomController, - handle; - - beforeEach(function () { - mockDragHandler = jasmine.createSpyObj( - 'dragHandler', - ['end', 'persist'] - ); - mockSnapHandler = jasmine.createSpyObj( - 'snapHandler', - ['snap'] - ); - mockZoomController = jasmine.createSpyObj( - 'zoom', - ['toMillis', 'toPixels'] - ); - - mockDragHandler.end.and.returnValue(12321); - - // Echo back the value from snapper for most tests - mockSnapHandler.snap.and.callFake(function (ts) { - return ts; - }); - - // Double pixels to get millis, for test purposes - mockZoomController.toMillis.and.callFake(function (px) { - return px * 2; - }); - - mockZoomController.toPixels.and.callFake(function (ms) { - return ms / 2; - }); - - handle = new TimelineEndHandle( - 'test-id', - mockDragHandler, - mockSnapHandler - ); - }); - - it("provides a style for templates", function () { - var w = TimelineConstants.HANDLE_WIDTH; - expect(handle.style(mockZoomController)).toEqual({ - // Left should be adjusted by zoom controller - left: (12321 / 2) - w + 'px', - // Width should match the defined constant - width: w + 'px' - }); - }); - - it("forwards drags to the drag handler", function () { - handle.begin(); - handle.drag(100, mockZoomController); - // Should have been interpreted as a +200 ms change - expect(mockDragHandler.end).toHaveBeenCalledWith( - "test-id", - 12521 - ); - }); - - it("snaps drags to other end points", function () { - mockSnapHandler.snap.and.returnValue(42); - handle.begin(); - handle.drag(-10, mockZoomController); - // Should have used snap-to timestamp - expect(mockDragHandler.end).toHaveBeenCalledWith( - "test-id", - 42 - ); - }); - - it("persists when a move is complete", function () { - // Simulate normal drag cycle - handle.begin(); - handle.drag(100, mockZoomController); - // Should not have persisted yet - expect(mockDragHandler.persist).not.toHaveBeenCalled(); - // Finish the drag - handle.finish(); - // Now it should have persisted - expect(mockDragHandler.persist).toHaveBeenCalled(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js b/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js deleted file mode 100644 index ea9263c1dd..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineMoveHandleSpec.js +++ /dev/null @@ -1,182 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/drag/TimelineMoveHandle', '../../../src/TimelineConstants'], - function (TimelineMoveHandle, TimelineConstants) { - - describe("A Timeline move drag handle", function () { - var mockDragHandler, - mockSnapHandler, - mockZoomController, - handle; - - beforeEach(function () { - mockDragHandler = jasmine.createSpyObj( - 'dragHandler', - ['start', 'duration', 'end', 'move', 'persist'] - ); - mockSnapHandler = jasmine.createSpyObj( - 'snapHandler', - ['snap'] - ); - mockZoomController = jasmine.createSpyObj( - 'zoom', - ['toMillis', 'toPixels'] - ); - - mockDragHandler.start.and.returnValue(12321); - mockDragHandler.duration.and.returnValue(4200); - mockDragHandler.end.and.returnValue(12321 + 4200); - - // Echo back the value from snapper for most tests - mockSnapHandler.snap.and.callFake(function (ts) { - return ts; - }); - - // Double pixels to get millis, for test purposes - mockZoomController.toMillis.and.callFake(function (px) { - return px * 2; - }); - - mockZoomController.toPixels.and.callFake(function (ms) { - return ms / 2; - }); - - handle = new TimelineMoveHandle( - 'test-id', - mockDragHandler, - mockSnapHandler - ); - }); - - it("provides a style for templates", function () { - var w = TimelineConstants.HANDLE_WIDTH; - expect(handle.style(mockZoomController)).toEqual({ - // Left should be adjusted by zoom controller - left: (12321 / 2) + w + 'px', - // Width should be duration minus end points - width: 2100 - (w * 2) + 'px' - }); - }); - - it("forwards drags to the drag handler", function () { - handle.begin(); - handle.drag(100, mockZoomController); - // Should have been interpreted as a +200 ms change - expect(mockDragHandler.move).toHaveBeenCalledWith( - "test-id", - 200 - ); - }); - - it("tracks drags incrementally", function () { - handle.begin(); - - handle.drag(100, mockZoomController); - // Should have been interpreted as a +200 ms change... - expect(mockDragHandler.move).toHaveBeenCalledWith( - "test-id", - 200 - ); - - // Reflect the change from the drag handler - mockDragHandler.start.and.returnValue(12521); - mockDragHandler.end.and.returnValue(12521 + 4200); - - // ....followed by a +100 ms change. - handle.drag(150, mockZoomController); - expect(mockDragHandler.move).toHaveBeenCalledWith( - "test-id", - 100 - ); - }); - - it("snaps drags to other end points", function () { - mockSnapHandler.snap.and.callFake(function (ts) { - return ts + 10; - }); - handle.begin(); - handle.drag(100, mockZoomController); - // Should have used snap-to timestamp, which was 10 - // ms greater than the provided one - expect(mockDragHandler.move).toHaveBeenCalledWith( - "test-id", - 210 - ); - }); - - it("considers snaps for both endpoints", function () { - handle.begin(); - expect(mockSnapHandler.snap).not.toHaveBeenCalled(); - handle.drag(100, mockZoomController); - expect(mockSnapHandler.snap.calls.count()).toEqual(2); - }); - - it("chooses the closest snap-to location", function () { - // Use a toggle to give snapped timestamps that are - // different distances away from the original. - // The move handle needs to choose the closest snap-to, - // regardless of whether it is the start/end (which - // will vary based on the initial state of this toggle.) - var toggle = false; - mockSnapHandler.snap.and.callFake(function (ts) { - toggle = !toggle; - return ts + (toggle ? -5 : 10); - }); - handle.begin(); - handle.drag(100, mockZoomController); - expect(mockDragHandler.move).toHaveBeenCalledWith( - "test-id", - 195 // Chose the -5 - ); - - // Reflect the change from the drag handler - mockDragHandler.start.and.returnValue(12521 - 5); - mockDragHandler.end.and.returnValue(12521 + 4200 - 5); - - toggle = true; // Change going-in state - handle.drag(300, mockZoomController); - // Note that the -5 offset is shown in the current state, - // so snapping to the -5 implies that the full 400ms will - // be moved (again, relative to dragHandler's reported state) - expect(mockDragHandler.move).toHaveBeenCalledWith( - "test-id", - 400 // Still chose the -5 - ); - }); - - it("persists when a move is complete", function () { - // Simulate normal drag cycle - handle.begin(); - handle.drag(100, mockZoomController); - // Should not have persisted yet - expect(mockDragHandler.persist).not.toHaveBeenCalled(); - // Finish the drag - handle.finish(); - // Now it should have persisted - expect(mockDragHandler.persist).toHaveBeenCalled(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js b/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js deleted file mode 100644 index eaffb86d18..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineSnapHandlerSpec.js +++ /dev/null @@ -1,79 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/drag/TimelineSnapHandler'], - function (TimelineSnapHandler) { - - describe("A Timeline snap handler", function () { - var mockDragHandler, - handler; - - beforeEach(function () { - var starts = { a: 1000, b: 2000, c: 2500, d: 2600 }, - ends = { a: 2050, b: 3000, c: 2700, d: 10000 }; - - mockDragHandler = jasmine.createSpyObj( - 'dragHandler', - ['start', 'end', 'ids'] - ); - - mockDragHandler.ids.and.returnValue(['a', 'b', 'c', 'd']); - mockDragHandler.start.and.callFake(function (id) { - return starts[id]; - }); - mockDragHandler.end.and.callFake(function (id) { - return ends[id]; - }); - - handler = new TimelineSnapHandler(mockDragHandler); - }); - - it("provides a preferred snap location within tolerance", function () { - expect(handler.snap(2511, 15, 'a')).toEqual(2500); // c's start - expect(handler.snap(2488, 15, 'a')).toEqual(2500); // c's start - expect(handler.snap(10, 1000, 'b')).toEqual(1000); // a's start - expect(handler.snap(2711, 20, 'd')).toEqual(2700); // c's end - }); - - it("excludes provided id from snapping", function () { - // Don't want objects to snap to themselves, so we need - // this exclusion. - expect(handler.snap(2010, 50, 'b')).toEqual(2050); // a's end - // Verify that b's start would have been used had the - // id not been provided - expect(handler.snap(2010, 50, 'd')).toEqual(2000); - }); - - it("snaps to the closest point, when multiple match", function () { - // 2600 and 2700 (plus others) are both in range here - expect(handler.snap(2651, 1000, 'a')).toEqual(2700); - }); - - it("does not snap if no points are within tolerance", function () { - // Closest are 1000 and 2000, which are well outside of tolerance - expect(handler.snap(1503, 100, 'd')).toEqual(1503); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js b/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js deleted file mode 100644 index 7df59b17ce..0000000000 --- a/platform/features/timeline/test/controllers/drag/TimelineStartHandleSpec.js +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/drag/TimelineStartHandle', '../../../src/TimelineConstants'], - function (TimelineStartHandle, TimelineConstants) { - - describe("A Timeline start drag handle", function () { - var mockDragHandler, - mockSnapHandler, - mockZoomController, - handle; - - beforeEach(function () { - mockDragHandler = jasmine.createSpyObj( - 'dragHandler', - ['start', 'persist'] - ); - mockSnapHandler = jasmine.createSpyObj( - 'snapHandler', - ['snap'] - ); - mockZoomController = jasmine.createSpyObj( - 'zoom', - ['toMillis', 'toPixels'] - ); - - mockDragHandler.start.and.returnValue(12321); - - // Echo back the value from snapper for most tests - mockSnapHandler.snap.and.callFake(function (ts) { - return ts; - }); - - // Double pixels to get millis, for test purposes - mockZoomController.toMillis.and.callFake(function (px) { - return px * 2; - }); - - mockZoomController.toPixels.and.callFake(function (ms) { - return ms / 2; - }); - - handle = new TimelineStartHandle( - 'test-id', - mockDragHandler, - mockSnapHandler - ); - }); - - it("provides a style for templates", function () { - expect(handle.style(mockZoomController)).toEqual({ - // Left should be adjusted by zoom controller - left: (12321 / 2) + 'px', - // Width should match the defined constant - width: TimelineConstants.HANDLE_WIDTH + 'px' - }); - }); - - it("forwards drags to the drag handler", function () { - handle.begin(); - handle.drag(100, mockZoomController); - // Should have been interpreted as a +200 ms change - expect(mockDragHandler.start).toHaveBeenCalledWith( - "test-id", - 12521 - ); - }); - - it("snaps drags to other end points", function () { - mockSnapHandler.snap.and.returnValue(42); - handle.begin(); - handle.drag(-10, mockZoomController); - // Should have used snap-to timestamp - expect(mockDragHandler.start).toHaveBeenCalledWith( - "test-id", - 42 - ); - }); - - it("persists when a move is complete", function () { - // Simulate normal drag cycle - handle.begin(); - handle.drag(100, mockZoomController); - // Should not have persisted yet - expect(mockDragHandler.persist).not.toHaveBeenCalled(); - // Finish the drag - handle.finish(); - // Now it should have persisted - expect(mockDragHandler.persist).toHaveBeenCalled(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js b/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js deleted file mode 100644 index 6dfd9407b8..0000000000 --- a/platform/features/timeline/test/controllers/graph/TimelineGraphPopulatorSpec.js +++ /dev/null @@ -1,151 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/graph/TimelineGraphPopulator'], - function (TimelineGraphPopulator) { - - describe("A Timeline's resource graph populator", function () { - var mockSwimlanes, - mockQ, - testResources, - populator; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (callback) { - return asPromise(callback(v)); - }, - testValue: v - }; - } - - function allPromises(promises) { - return asPromise(promises.map(function (p) { - return (p || {}).then ? p.testValue : p; - })); - } - - - beforeEach(function () { - testResources = { - a: ['xyz', 'abc'], - b: ['xyz'], - c: ['xyz', 'abc', 'def', 'ghi'] - }; - - mockQ = jasmine.createSpyObj('$q', ['when', 'all']); - - mockSwimlanes = ['a', 'b', 'c'].map(function (k) { - var mockSwimlane = jasmine.createSpyObj( - 'swimlane-' + k, - ['graph', 'color'] - ), - mockGraph = jasmine.createSpyObj( - 'graph-' + k, - ['getPointCount', 'getDomainValue', 'getRangeValue'] - ); - mockSwimlane.graph.and.returnValue(true); - mockSwimlane.domainObject = jasmine.createSpyObj( - 'domainObject-' + k, - ['getCapability', 'hasCapability', 'useCapability', 'getId'] - ); - mockSwimlane.color.and.returnValue('#' + k); - // Provide just enough information about graphs to support - // determination of which graphs to show - mockSwimlane.domainObject.useCapability.and.callFake(function () { - var obj = {}; - testResources[k].forEach(function (r) { - obj[r] = mockGraph; - }); - return asPromise(obj); - }); - mockSwimlane.domainObject.hasCapability - .and.returnValue(true); - mockSwimlane.domainObject.getId - .and.returnValue(k); - mockGraph.getPointCount.and.returnValue(0); - - return mockSwimlane; - }); - - mockQ.when.and.callFake(asPromise); - mockQ.all.and.callFake(allPromises); - - populator = new TimelineGraphPopulator(mockQ); - }); - - it("provides no graphs by default", function () { - expect(populator.get()).toEqual([]); - }); - - it("provides one graph per resource type", function () { - populator.populate(mockSwimlanes); - // There are 4 unique resource types shared here... - expect(populator.get().length).toEqual(4); - }); - - it("does not include graphs based on swimlane configuration", function () { - mockSwimlanes[2].graph.and.returnValue(false); - populator.populate(mockSwimlanes); - // Only two unique swimlanes in the other two - expect(populator.get().length).toEqual(2); - // Verify interactions as well - expect(mockSwimlanes[0].domainObject.useCapability) - .toHaveBeenCalledWith('graph'); - expect(mockSwimlanes[1].domainObject.useCapability) - .toHaveBeenCalledWith('graph'); - expect(mockSwimlanes[2].domainObject.useCapability) - .not.toHaveBeenCalled(); - }); - - it("does not recreate graphs when swimlanes don't change", function () { - var initialValue; - // Get an initial set of graphs - populator.populate(mockSwimlanes); - initialValue = populator.get(); - // Repopulate with same data; should get same graphs - populator.populate(mockSwimlanes); - expect(populator.get()).toBe(initialValue); - // Something changed... - mockSwimlanes.pop(); - populator.populate(mockSwimlanes); - // Now we should get different graphs - expect(populator.get()).not.toBe(initialValue); - }); - - // Regression test for WTD-1155 - it("does recreate graphs when inclusions change", function () { - var initialValue; - // Get an initial set of graphs - populator.populate(mockSwimlanes); - initialValue = populator.get(); - // Change resource graph inclusion... - mockSwimlanes[1].graph.and.returnValue(false); - populator.populate(mockSwimlanes); - // Now we should get different graphs - expect(populator.get()).not.toBe(initialValue); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js b/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js deleted file mode 100644 index d799f287ee..0000000000 --- a/platform/features/timeline/test/controllers/graph/TimelineGraphRendererSpec.js +++ /dev/null @@ -1,75 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/graph/TimelineGraphRenderer'], - function (TimelineGraphRenderer) { - - describe("A Timeline's graph renderer", function () { - var renderer; - - beforeEach(function () { - renderer = new TimelineGraphRenderer(); - }); - - it("converts utilizations to buffers", function () { - var utilization = { - getPointCount: function () { - return 10; - }, - getDomainValue: function (i) { - return i * 10; - }, - getRangeValue: function (i) { - return Math.sin(i); - } - }, - buffer = renderer.render(utilization), - i; - - // Should be flat list of alternating x/y, - // so 20 elements - expect(buffer.length).toEqual(20); - - // Verify contents - for (i = 0; i < 10; i += 1) { - // Check for 6 decimal digits of precision, roughly - // what we expect after conversion to 32-bit float - expect(buffer[i * 2]).toBeCloseTo(i * 10, 6); - expect(buffer[i * 2 + 1]).toBeCloseTo(Math.sin(i), 6); - } - }); - - it("decodes color strings", function () { - // Note that decoded color should have alpha channel as well - expect(renderer.decode('#FFFFFF')) - .toEqual([1, 1, 1, 1]); - expect(renderer.decode('#000000')) - .toEqual([0, 0, 0, 1]); - expect(renderer.decode('#FF8000')) - .toEqual([1, 0.5019607843137255, 0, 1]); - }); - - - }); - } -); diff --git a/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js b/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js deleted file mode 100644 index 4b04d545ae..0000000000 --- a/platform/features/timeline/test/controllers/graph/TimelineGraphSpec.js +++ /dev/null @@ -1,170 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/graph/TimelineGraph'], - function (TimelineGraph) { - - describe("A Timeline's resource graph", function () { - var mockDomainObjects, - mockRenderer, - testColors, - mockGraphs, - graph; - - function asPromise(v) { - return (v || {}).then ? v : { - then: function (callback) { - return asPromise(callback(v)); - } - }; - } - - - beforeEach(function () { - testColors = { - a: [0, 1, 0], - b: [1, 0, 1], - c: [1, 0, 0] - }; - - mockGraphs = []; - mockDomainObjects = {}; - - ['a', 'b', 'c'].forEach(function (k, i) { - var mockGraph = jasmine.createSpyObj( - 'utilization-' + k, - ['getPointCount', 'getDomainValue', 'getRangeValue'] - ); - mockDomainObjects[k] = jasmine.createSpyObj( - 'domainObject-' + k, - ['getCapability', 'useCapability'] - ); - mockDomainObjects[k].useCapability.and.returnValue(asPromise({ - testResource: mockGraph - })); - mockGraph.getPointCount.and.returnValue(i + 2); - mockGraph.testField = k; - mockGraph.testIndex = i; - - // Store to allow changes later - mockGraphs.push(mockGraph); - }); - - mockRenderer = jasmine.createSpyObj( - 'renderer', - ['render', 'decode'] - ); - - mockRenderer.render.and.callFake(function (utilization) { - var result = []; - while (result.length < (utilization.testIndex + 2) * 2) { - result.push(Math.floor(result.length / 2)); - // Alternate +/- to give something to test to - result.push( - ((result.length % 4 > 1) ? -1 : 1) * - (10 * utilization.testIndex) - ); - } - return result; - }); - - mockRenderer.decode.and.callFake(function (color) { - return testColors[color]; - }); - - graph = new TimelineGraph( - 'testResource', - mockDomainObjects, - mockRenderer - ); - }); - - it("exposes minimum/maximum", function () { - expect(graph.minimum()).toEqual(-20); - expect(graph.maximum()).toEqual(20); - }); - - it("exposes resource key", function () { - expect(graph.key).toEqual('testResource'); - }); - - it("exposes a rendered drawing object", function () { - // Much of the work here is done by the renderer, - // so just check that it got used and assigned - expect(graph.drawingObject.lines).toEqual([ - { - color: testColors.a, - buffer: [0, 0, 1, -0], - points: 2 - }, - { - color: testColors.b, - buffer: [0, 10, 1, -10, 2, 10], - points: 3 - }, - { - color: testColors.c, - buffer: [0, 20, 1, -20, 2, 20, 3, -20], - points: 4 - } - ]); - }); - - it("allows its bounds to be specified", function () { - graph.setBounds(42, 12321); - expect(graph.drawingObject.origin[0]).toEqual(42); - expect(graph.drawingObject.dimensions[0]).toEqual(12321); - }); - - it("provides a minimum/maximum even with no data", function () { - mockGraphs.forEach(function (mockGraph) { - mockGraph.getPointCount.and.returnValue(0); - }); - - // Create a graph of these utilizations - graph = new TimelineGraph( - 'testResource', - mockDomainObjects, - mockRenderer - ); - - // Verify that we get some usable defaults - expect(graph.minimum()).toEqual(jasmine.any(Number)); - expect(graph.maximum()).toEqual(jasmine.any(Number)); - expect(graph.maximum() > graph.minimum()).toBeTruthy(); - }); - - it("refreshes lines upon request", function () { - // Mock renderer looks at testIndex, so change it here... - mockGraphs[0].testIndex = 3; - // Should trigger a new render - graph.refresh(); - // Values correspond to the new index now - expect(graph.drawingObject.lines[0].buffer).toEqual( - [0, 30, 1, -30, 2, 30, 3, -30, 4, 30] - ); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js deleted file mode 100644 index 47f61ff296..0000000000 --- a/platform/features/timeline/test/controllers/swimlane/TimelineColorAssignerSpec.js +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/swimlane/TimelineColorAssigner'], - function (TimelineColorAssigner) { - - describe("The Timeline legend color assigner", function () { - var testConfiguration, - assigner; - - beforeEach(function () { - testConfiguration = {}; - assigner = new TimelineColorAssigner(testConfiguration); - }); - - it("assigns colors by identifier", function () { - expect(assigner.get('xyz')).toBeUndefined(); - assigner.assign('xyz'); - expect(assigner.get('xyz')).toEqual(jasmine.any(String)); - }); - - it("releases colors", function () { - assigner.assign('xyz'); - assigner.release('xyz'); - expect(assigner.get('xyz')).toBeUndefined(); - }); - - it("provides at least 30 unique colors", function () { - var colors = {}, i, ids = []; - - // Add item to set - function set(c) { - colors[c] = true; - } - - // Generate ids - for (i = 0; i < 30; i += 1) { - ids.push("id" + i); - } - - // Assign colors to each id, then retrieve colors, - // storing into the set - ids.forEach(assigner.assign); - ids.map(assigner.get).map(set); - - // Should now be 30 elements in that set - expect(Object.keys(colors).length).toEqual(30); - }); - - it("populates the configuration with colors", function () { - assigner.assign('xyz'); - expect(testConfiguration.xyz).toBeDefined(); - }); - - it("preserves other colors when releases occur", function () { - var c; - assigner.assign('xyz'); - c = assigner.get('xyz'); - // Assign/release a different color - assigner.assign('abc'); - assigner.release('abc'); - // Our original assignment should be preserved - expect(assigner.get('xyz')).toEqual(c); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js deleted file mode 100644 index 88ff210f03..0000000000 --- a/platform/features/timeline/test/controllers/swimlane/TimelineProxySpec.js +++ /dev/null @@ -1,106 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/swimlane/TimelineProxy'], - function (TimelineProxy) { - - describe("The Timeline's selection proxy", function () { - var mockDomainObject, - mockSelection, - mockActionCapability, - mockActions, - proxy; - - beforeEach(function () { - mockDomainObject = jasmine.createSpyObj( - 'domainObject', - ['getCapability'] - ); - mockSelection = jasmine.createSpyObj( - 'selection', - ['get'] - ); - mockActionCapability = jasmine.createSpyObj( - 'action', - ['getActions'] - ); - mockActions = ['a', 'b', 'c'].map(function (type) { - var mockAction = jasmine.createSpyObj( - 'action-' + type, - ['perform', 'getMetadata'] - ); - mockAction.getMetadata.and.returnValue({ type: type }); - return mockAction; - }); - - mockDomainObject.getCapability.and.returnValue(mockActionCapability); - mockActionCapability.getActions.and.returnValue(mockActions); - - proxy = new TimelineProxy(mockDomainObject, mockSelection); - }); - - it("triggers a create action on add", function () { - // Should trigger b's create action - proxy.add('b'); - expect(mockActions[1].perform).toHaveBeenCalled(); - - // Also check that other actions weren't invoked - expect(mockActions[0].perform).not.toHaveBeenCalled(); - expect(mockActions[2].perform).not.toHaveBeenCalled(); - - // Verify that interactions were for correct keys - expect(mockDomainObject.getCapability) - .toHaveBeenCalledWith('action'); - expect(mockActionCapability.getActions) - .toHaveBeenCalledWith('add'); - }); - - it("invokes the action on the selection, if any", function () { - var mockOtherObject = jasmine.createSpyObj( - 'other', - ['getCapability'] - ), - mockOtherAction = jasmine.createSpyObj( - 'actionCapability', - ['getActions'] - ), - mockAction = jasmine.createSpyObj( - 'action', - ['perform', 'getMetadata'] - ); - - // Set up mocks - mockSelection.get.and.returnValue({ domainObject: mockOtherObject }); - mockOtherObject.getCapability.and.returnValue(mockOtherAction); - mockOtherAction.getActions.and.returnValue([mockAction]); - mockAction.getMetadata.and.returnValue({ type: 'z' }); - - // Invoke add method; should create with selected object - proxy.add('z'); - expect(mockAction.perform).toHaveBeenCalled(); - }); - - - }); - } -); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js deleted file mode 100644 index 575d7228d3..0000000000 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDecoratorSpec.js +++ /dev/null @@ -1,183 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/swimlane/TimelineSwimlaneDecorator'], - function (TimelineSwimlaneDecorator) { - - describe("A Timeline swimlane decorator", function () { - var mockSwimlane, - mockSelection, - mockCapabilities, - testModel, - mockPromise, - testModes, - decorator; - - beforeEach(function () { - mockSwimlane = {}; - mockCapabilities = {}; - testModel = {}; - testModes = ['a', 'b', 'c']; - - mockSelection = jasmine.createSpyObj('selection', ['select', 'get']); - - mockSwimlane.domainObject = jasmine.createSpyObj( - 'domainObject', - ['getCapability', 'getModel'] - ); - - mockCapabilities.mutation = jasmine.createSpyObj( - 'mutation', - ['mutate'] - ); - mockCapabilities.type = jasmine.createSpyObj( - 'type', - ['instanceOf'] - ); - mockPromise = jasmine.createSpyObj('promise', ['then']); - - mockSwimlane.domainObject.getCapability.and.callFake(function (c) { - return mockCapabilities[c]; - }); - mockSwimlane.domainObject.getModel.and.returnValue(testModel); - - mockCapabilities.type.instanceOf.and.returnValue(true); - mockCapabilities.mutation.mutate.and.returnValue(mockPromise); - - decorator = new TimelineSwimlaneDecorator( - mockSwimlane, - mockSelection - ); - }); - - it("returns the same object instance", function () { - // Decoration should occur in-place - expect(decorator).toBe(mockSwimlane); - }); - - it("adds a 'modes' getter-setter to activities", function () { - expect(mockSwimlane.modes).toEqual(jasmine.any(Function)); - expect(mockCapabilities.type.instanceOf) - .toHaveBeenCalledWith('activity'); - }); - - it("adds a 'link' getter-setter to activities", function () { - expect(mockSwimlane.link).toEqual(jasmine.any(Function)); - expect(mockCapabilities.type.instanceOf) - .toHaveBeenCalledWith('activity'); - }); - - it("gets modes from the domain object model", function () { - testModel.relationships = { modes: ['a', 'b', 'c'] }; - expect(decorator.modes()).toEqual(['a', 'b', 'c']); - testModel.relationships = { modes: ['x', 'y', 'z'] }; - expect(decorator.modes()).toEqual(['x', 'y', 'z']); - // Verify that it worked as a getter - expect(mockCapabilities.mutation.mutate) - .not.toHaveBeenCalled(); - }); - - it("gets links from the domain object model", function () { - testModel.link = "http://www.nasa.gov"; - expect(decorator.link()).toEqual("http://www.nasa.gov"); - // Verify that it worked as a getter - expect(mockCapabilities.mutation.mutate) - .not.toHaveBeenCalled(); - }); - - it("mutates modes when used as a setter", function () { - decorator.modes(['abc', 'xyz']); - expect(mockCapabilities.mutation.mutate) - .toHaveBeenCalledWith(jasmine.any(Function)); - mockCapabilities.mutation.mutate.calls.mostRecent().args[0](testModel); - expect(testModel.relationships.modes).toEqual(['abc', 'xyz']); - }); - - it("mutates modes when used as a setter", function () { - decorator.link("http://www.noaa.gov"); - expect(mockCapabilities.mutation.mutate) - .toHaveBeenCalledWith(jasmine.any(Function)); - mockCapabilities.mutation.mutate.calls.mostRecent().args[0](testModel); - expect(testModel.link).toEqual("http://www.noaa.gov"); - }); - - it("does not mutate modes when unchanged", function () { - testModel.relationships = { modes: testModes }; - decorator.modes(testModes); - expect(mockCapabilities.mutation.mutate).not.toHaveBeenCalled(); - expect(testModel.relationships.modes).toEqual(testModes); - }); - - it("does mutate modes when changed", function () { - var testModes2 = ['d', 'e', 'f']; - testModel.relationships = { modes: testModes }; - decorator.modes(testModes2); - expect(mockCapabilities.mutation.mutate).toHaveBeenCalled(); - mockCapabilities.mutation.mutate.calls.mostRecent().args[0](testModel); - expect(testModel.relationships.modes).toBe(testModes2); - }); - - it("does not provide a 'remove' method with no parent", function () { - expect(decorator.remove).not.toEqual(jasmine.any(Function)); - }); - - it("fires the 'remove' action when remove is called", function () { - var mockChild = jasmine.createSpyObj( - 'childObject', - ['getCapability', 'getModel'] - ), - mockAction = jasmine.createSpyObj( - 'action', - ['perform'] - ); - - mockChild.getCapability.and.callFake(function (c) { - return c === 'action' ? mockAction : undefined; - }); - - // Create a child swimlane; it should have a remove action - new TimelineSwimlaneDecorator({ - domainObject: mockChild, - parent: decorator, - depth: 1 - }).remove(); - - expect(mockChild.getCapability).toHaveBeenCalledWith('action'); - expect(mockAction.perform).toHaveBeenCalledWith('remove'); - }); - - it("allows the swimlane to be selected", function () { - decorator.select(); - expect(mockSelection.select).toHaveBeenCalledWith(decorator); - }); - - it("allows checking for swimlane selection state", function () { - expect(decorator.selected()).toBeFalsy(); - mockSelection.get.and.returnValue(decorator); - expect(decorator.selected()).toBeTruthy(); - }); - - }); - - } -); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js deleted file mode 100644 index 85f367ba03..0000000000 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneDropHandlerSpec.js +++ /dev/null @@ -1,237 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/swimlane/TimelineSwimlaneDropHandler'], - function (TimelineSwimlaneDropHandler) { - - describe("A timeline's swimlane drop handler", function () { - var mockSwimlane, - mockOtherObject, - mockActionCapability, - mockEditorCapability, - mockContext, - mockAction, - handler; - - beforeEach(function () { - var mockPromise = jasmine.createSpyObj('promise', ['then']); - - mockEditorCapability = jasmine.createSpyObj('editorCapability', ['inEditContext']); - - mockSwimlane = jasmine.createSpyObj( - "swimlane", - ["highlight", "highlightBottom"] - ); - // domainObject, idPath, children, expanded - mockSwimlane.domainObject = jasmine.createSpyObj( - "domainObject", - ["getId", "getCapability", "useCapability", "hasCapability"] - ); - mockSwimlane.idPath = ['a', 'b']; - mockSwimlane.children = [{}]; - mockSwimlane.expanded = true; - - mockSwimlane.parent = {}; - mockSwimlane.parent.idPath = ['a']; - mockSwimlane.parent.domainObject = jasmine.createSpyObj( - "domainObject", - ["getId", "getCapability", "useCapability", "hasCapability"] - ); - mockSwimlane.parent.children = [mockSwimlane]; - - mockSwimlane.children[0].domainObject = jasmine.createSpyObj( - "domainObject", - ["getId", "getCapability", "useCapability", "hasCapability"] - ); - - mockAction = jasmine.createSpyObj('action', ['perform']); - mockAction.perform.and.returnValue(mockPromise); - mockPromise.then.and.callFake(function (callback) { - callback(); - }); - - mockOtherObject = jasmine.createSpyObj( - "domainObject", - ["getId", "getCapability", "useCapability", "hasCapability"] - ); - mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]); - mockContext = jasmine.createSpyObj('context', ['getParent']); - - mockActionCapability.getActions.and.returnValue([mockAction]); - mockSwimlane.parent.domainObject.getId.and.returnValue('a'); - mockSwimlane.domainObject.getId.and.returnValue('b'); - mockSwimlane.children[0].domainObject.getId.and.returnValue('c'); - mockOtherObject.getId.and.returnValue('d'); - - - mockSwimlane.domainObject.getCapability.and.callFake(function (c) { - return { - action: mockActionCapability, - editor: mockEditorCapability - }[c]; - }); - mockSwimlane.parent.domainObject.getCapability.and.callFake(function (c) { - return { - action: mockActionCapability, - editor: mockEditorCapability - }[c]; - }); - mockOtherObject.getCapability.and.callFake(function (c) { - return { - action: mockActionCapability, - context: mockContext, - editor: mockEditorCapability - }[c]; - }); - mockContext.getParent.and.returnValue(mockOtherObject); - - mockSwimlane.domainObject.hasCapability.and.returnValue(true); - - handler = new TimelineSwimlaneDropHandler(mockSwimlane); - }); - - it("disallows drop outside of edit mode", function () { - mockEditorCapability.inEditContext.and.returnValue(true); - // Verify precondition - expect(handler.allowDropIn('d', mockSwimlane.domainObject)) - .toBeTruthy(); - expect(handler.allowDropAfter('d', mockSwimlane.domainObject)) - .toBeTruthy(); - // Act as if we're not in edit mode - mockEditorCapability.inEditContext.and.returnValue(false); - // Now, they should be disallowed - expect(handler.allowDropIn('d', mockSwimlane.domainObject)) - .toBeFalsy(); - expect(handler.allowDropAfter('d', mockSwimlane.domainObject)) - .toBeFalsy(); - - // Verify that editor capability was really checked for - expect(mockSwimlane.domainObject.hasCapability) - .toHaveBeenCalledWith('editor'); - }); - - it("disallows dropping of parents", function () { - var mockParent = mockSwimlane.parent.domainObject; - expect(handler.allowDropIn('a', mockParent)).toBeFalsy(); - expect(handler.allowDropAfter('a', mockParent)).toBeFalsy(); - }); - - it("does not drop when no highlight state is present", function () { - // If there's no hover highlight, there's no drop allowed - handler.drop('d', mockOtherObject); - expect(mockOtherObject.getCapability) - .not.toHaveBeenCalled(); - expect(mockSwimlane.domainObject.useCapability) - .not.toHaveBeenCalled(); - expect(mockSwimlane.parent.domainObject.useCapability) - .not.toHaveBeenCalled(); - }); - - it("inserts into when highlighted", function () { - var testModel = { composition: ['c'] }; - mockSwimlane.highlight.and.returnValue(true); - handler.drop('d', mockOtherObject); - // Should have mutated - expect(mockSwimlane.domainObject.useCapability) - .toHaveBeenCalledWith("mutation", jasmine.any(Function)); - // Run the mutator - mockSwimlane.domainObject.useCapability.calls.mostRecent() - .args[1](testModel); - expect(testModel.composition).toEqual(['c', 'd']); - }); - - it("inserts after as a peer when highlighted at the bottom", function () { - var testModel = { composition: ['x', 'b', 'y'] }; - mockSwimlane.highlightBottom.and.returnValue(true); - mockSwimlane.expanded = false; - handler.drop('d', mockOtherObject); - // Should have mutated - expect(mockSwimlane.parent.domainObject.useCapability) - .toHaveBeenCalledWith("mutation", jasmine.any(Function)); - // Run the mutator - mockSwimlane.parent.domainObject.useCapability.calls.mostRecent() - .args[1](testModel); - expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']); - }); - - it("inserts into when highlighted at the bottom and expanded", function () { - var testModel = { composition: ['c'] }; - mockSwimlane.highlightBottom.and.returnValue(true); - mockSwimlane.expanded = true; - handler.drop('d', mockOtherObject); - // Should have mutated - expect(mockSwimlane.domainObject.useCapability) - .toHaveBeenCalledWith("mutation", jasmine.any(Function)); - // Run the mutator - mockSwimlane.domainObject.useCapability.calls.mostRecent() - .args[1](testModel); - expect(testModel.composition).toEqual(['d', 'c']); - }); - - it("inserts after as a peer when highlighted at the bottom and childless", function () { - var testModel = { composition: ['x', 'b', 'y'] }; - mockSwimlane.highlightBottom.and.returnValue(true); - mockSwimlane.expanded = true; - mockSwimlane.children = []; - handler.drop('d', mockOtherObject); - // Should have mutated - expect(mockSwimlane.parent.domainObject.useCapability) - .toHaveBeenCalledWith("mutation", jasmine.any(Function)); - // Run the mutator - mockSwimlane.parent.domainObject.useCapability.calls.mostRecent() - .args[1](testModel); - expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']); - }); - - it("allows reordering within a parent", function () { - var testModel = { composition: ['x', 'b', 'y', 'd'] }; - - mockSwimlane.highlightBottom.and.returnValue(true); - mockSwimlane.expanded = true; - mockSwimlane.children = []; - mockContext.getParent.and.returnValue(mockSwimlane.parent.domainObject); - - return new Promise(function (resolve, reject) { - mockSwimlane.parent.domainObject.useCapability.and.callFake(function (name, callback) { - resolve(callback); - }); - handler.drop('d', mockOtherObject); - }).then(function (callback) { - callback(testModel); - expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']); - }); - }); - - it("does not invoke an action when reordering", function () { - mockSwimlane.highlightBottom.and.returnValue(true); - mockSwimlane.expanded = true; - mockSwimlane.children = []; - mockContext.getParent - .and.returnValue(mockSwimlane.parent.domainObject); - handler.drop('d', mockOtherObject); - expect(mockAction.perform).not.toHaveBeenCalled(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js deleted file mode 100644 index a68a9e1383..0000000000 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlanePopulatorSpec.js +++ /dev/null @@ -1,163 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/swimlane/TimelineSwimlanePopulator'], - function (TimelineSwimlanePopulator) { - - describe("A Timeline swimlane populator", function () { - var mockLoader, - mockSelection, - testConfiguration, - mockDomainObject, - mockDomainObjects, - mockCallback, - populator; - - function asPromise(value) { - return (value || {}).then ? value : { - then: function (callback) { - return asPromise(callback(value)); - } - }; - } - - function makeMockDomainObject(id, composition) { - var mockDomainObj = jasmine.createSpyObj( - 'domainObject-' + id, - ['getId', 'getModel', 'getCapability', 'useCapability'] - ); - - mockDomainObj.getId.and.returnValue(id); - mockDomainObj.getModel.and.returnValue({ composition: composition }); - mockDomainObj.useCapability.and.returnValue(asPromise(false)); - - return mockDomainObj; - } - - function subgraph(domainObject, objects) { - function lookupSubgraph(id) { - return subgraph(objects[id], objects); - } - return { - domainObject: domainObject, - composition: domainObject.getModel().composition - .map(lookupSubgraph) - }; - } - - beforeEach(function () { - mockLoader = jasmine.createSpyObj('objectLoader', ['load']); - mockDomainObject = makeMockDomainObject('a', ['b', 'c']); - mockDomainObjects = { - a: mockDomainObject, - b: makeMockDomainObject('b', ['d']), - c: makeMockDomainObject('c', ['e', 'f']), - d: makeMockDomainObject('d', []), - e: makeMockDomainObject('e', []), - f: makeMockDomainObject('f', []) - }; - mockSelection = jasmine.createSpyObj( - 'selection', - ['get', 'select', 'proxy'] - ); - mockCallback = jasmine.createSpy('callback'); - - testConfiguration = {}; - - mockLoader.load.and.returnValue(asPromise(subgraph( - mockDomainObject, - mockDomainObjects - ))); - - populator = new TimelineSwimlanePopulator( - mockLoader, - testConfiguration, - mockSelection - ); - }); - - it("uses the loader to find subgraph", function () { - populator.populate(mockDomainObject); - expect(mockLoader.load).toHaveBeenCalledWith( - mockDomainObject, - 'timespan' - ); - }); - - it("provides a list of swimlanes", function () { - populator.populate(mockDomainObject); - // Ensure swimlane order matches depth-first search - expect(populator.get().map(function (swimlane) { - return swimlane.domainObject; - })).toEqual([ - mockDomainObjects.a, - mockDomainObjects.b, - mockDomainObjects.d, - mockDomainObjects.c, - mockDomainObjects.e, - mockDomainObjects.f - ]); - }); - - it("clears swimlanes if no object is provided", function () { - populator.populate(); - expect(populator.get()).toEqual([]); - }); - - it("preserves selection state when possible", function () { - // Repopulate swimlanes - populator.populate(mockDomainObject); - - // Act as if something is already selected - mockSelection.get.and.returnValue(populator.get()[1]); - - // Verify precondition - expect(mockSelection.select).not.toHaveBeenCalled(); - - // Repopulate swimlanes - populator.populate(mockDomainObject); - - // Selection should have been preserved - expect(mockSelection.select).toHaveBeenCalled(); - expect(mockSelection.select.calls.mostRecent().args[0].domainObject) - .toEqual(mockDomainObjects.b); - }); - - it("exposes a selection proxy for the timeline", function () { - populator.populate(mockDomainObject); - expect(mockSelection.proxy).toHaveBeenCalled(); - }); - - it("allows selection object to be changed", function () { - var mockNewSelectionObject = jasmine.createSpyObj( - 'new-selection', - ['get', 'select', 'proxy'] - ); - populator.selection(mockNewSelectionObject); - expect(mockNewSelectionObject.proxy) - .toHaveBeenCalled(); - }); - - }); - } -); diff --git a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js b/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js deleted file mode 100644 index 82c2dcd210..0000000000 --- a/platform/features/timeline/test/controllers/swimlane/TimelineSwimlaneSpec.js +++ /dev/null @@ -1,223 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../../src/controllers/swimlane/TimelineSwimlane'], - function (TimelineSwimlane) { - - describe("A Timeline swimlane", function () { - var parent, - child, - mockParentObject, - mockChildObject, - mockAssigner, - mockActionCapability, - mockParentTimespan, - mockChildTimespan, - testConfiguration; - - function asPromise(v) { - return { then: function (cb) { - cb(v); - } }; - } - - beforeEach(function () { - mockParentObject = jasmine.createSpyObj( - 'parent', - ['getId', 'getCapability', 'useCapability', 'getModel'] - ); - mockChildObject = jasmine.createSpyObj( - 'child', - ['getId', 'getCapability', 'useCapability', 'getModel'] - ); - mockAssigner = jasmine.createSpyObj( - 'assigner', - ['get', 'assign', 'release'] - ); - mockParentTimespan = jasmine.createSpyObj( - 'parentTimespan', - ['getStart', 'getEnd'] - ); - mockChildTimespan = jasmine.createSpyObj( - 'childTimespan', - ['getStart', 'getEnd'] - ); - mockActionCapability = jasmine.createSpyObj('action', ['perform']); - - mockParentObject.getId.and.returnValue('test-parent'); - mockParentObject.getCapability.and.returnValue(mockActionCapability); - mockParentObject.useCapability.and.returnValue(asPromise(mockParentTimespan)); - mockParentObject.getModel.and.returnValue({ name: "Test Parent" }); - mockChildObject.getModel.and.returnValue({ name: "Test Child" }); - mockChildObject.useCapability.and.returnValue(asPromise(mockChildTimespan)); - - testConfiguration = { graph: {} }; - - parent = new TimelineSwimlane( - mockParentObject, - mockAssigner, - testConfiguration - ); - child = new TimelineSwimlane( - mockChildObject, - mockAssigner, - testConfiguration, - parent - ); - }); - - it("exposes its domain object", function () { - expect(parent.domainObject).toEqual(mockParentObject); - expect(child.domainObject).toEqual(mockChildObject); - }); - - it("exposes its depth", function () { - expect(parent.depth).toEqual(0); - expect(child.depth).toEqual(1); - expect(new TimelineSwimlane(mockParentObject, {}, {}, child).depth) - .toEqual(2); - }); - - it("exposes its path as readable text", function () { - var grandchild = new TimelineSwimlane(mockParentObject, {}, {}, child), - ggc = new TimelineSwimlane(mockParentObject, {}, {}, grandchild); - - expect(parent.path).toEqual(""); - expect(child.path).toEqual(""); - expect(grandchild.path).toEqual("Test Child > "); - expect(ggc.path).toEqual("Test Child > Test Parent > "); - }); - - it("starts off expanded", function () { - expect(parent.expanded).toBeTruthy(); - expect(child.expanded).toBeTruthy(); - }); - - it("determines visibility based on parent expansion", function () { - parent.expanded = false; - expect(child.visible()).toBeFalsy(); - parent.expanded = true; - expect(child.visible()).toBeTruthy(); - }); - - it("is visible when it is the root of the timeline subgraph", function () { - expect(parent.visible()).toBeTruthy(); - }); - - it("fires the Edit Properties action on request", function () { - parent.properties(); - expect(mockParentObject.getCapability).toHaveBeenCalledWith('action'); - expect(mockActionCapability.perform).toHaveBeenCalledWith('properties'); - }); - - it("allows resource graph inclusion to be toggled", function () { - expect(testConfiguration.graph['test-parent']).toBeFalsy(); - parent.toggleGraph(); - expect(testConfiguration.graph['test-parent']).toBeTruthy(); - parent.toggleGraph(); - expect(testConfiguration.graph['test-parent']).toBeFalsy(); - }); - - it("provides a getter-setter for graph inclusion", function () { - expect(testConfiguration.graph['test-parent']).toBeFalsy(); - expect(parent.graph(true)).toBeTruthy(); - expect(parent.graph()).toBeTruthy(); - expect(testConfiguration.graph['test-parent']).toBeTruthy(); - expect(parent.graph(false)).toBeFalsy(); - expect(parent.graph()).toBeFalsy(); - expect(testConfiguration.graph['test-parent']).toBeFalsy(); - }); - - it("gets colors from the provided assigner", function () { - mockAssigner.get.and.returnValue("#ABCABC"); - expect(parent.color()).toEqual("#ABCABC"); - // Verify that id was passed, and no other interactions - expect(mockAssigner.get).toHaveBeenCalledWith('test-parent'); - expect(mockAssigner.assign).not.toHaveBeenCalled(); - expect(mockAssigner.release).not.toHaveBeenCalled(); - }); - - it("allows colors to be set", function () { - parent.color("#F0000D"); - expect(mockAssigner.assign).toHaveBeenCalledWith( - 'test-parent', - "#F0000D" - ); - }); - - it("assigns colors when resource graph state is toggled", function () { - expect(mockAssigner.assign).not.toHaveBeenCalled(); - parent.toggleGraph(); - expect(mockAssigner.assign).toHaveBeenCalledWith('test-parent'); - expect(mockAssigner.release).not.toHaveBeenCalled(); - parent.toggleGraph(); - expect(mockAssigner.release).toHaveBeenCalledWith('test-parent'); - }); - - it("assigns colors when resource graph state is set", function () { - expect(mockAssigner.assign).not.toHaveBeenCalled(); - parent.graph(true); - expect(mockAssigner.assign).toHaveBeenCalledWith('test-parent'); - expect(mockAssigner.release).not.toHaveBeenCalled(); - parent.graph(false); - expect(mockAssigner.release).toHaveBeenCalledWith('test-parent'); - }); - - it("provides getter-setters for drag-drop highlights", function () { - expect(parent.highlight()).toBeFalsy(); - parent.highlight(true); - expect(parent.highlight()).toBeTruthy(); - - expect(parent.highlightBottom()).toBeFalsy(); - parent.highlightBottom(true); - expect(parent.highlightBottom()).toBeTruthy(); - }); - - it("detects start/end violations", function () { - mockParentTimespan.getStart.and.returnValue(42); - mockParentTimespan.getEnd.and.returnValue(12321); - - // First, start with a valid timespan - mockChildTimespan.getStart.and.returnValue(84); - mockChildTimespan.getEnd.and.returnValue(100); - expect(child.exceeded()).toBeFalsy(); - - // Start time violation - mockChildTimespan.getStart.and.returnValue(21); - expect(child.exceeded()).toBeTruthy(); - - // Now both in violation - mockChildTimespan.getEnd.and.returnValue(20000); - expect(child.exceeded()).toBeTruthy(); - - // And just the end - mockChildTimespan.getStart.and.returnValue(100); - expect(child.exceeded()).toBeTruthy(); - - // Now back to everything's-just-fine - mockChildTimespan.getEnd.and.returnValue(10000); - expect(child.exceeded()).toBeFalsy(); - }); - }); - } -); diff --git a/platform/features/timeline/test/directives/MCTResourceGraphDropSpec.js b/platform/features/timeline/test/directives/MCTResourceGraphDropSpec.js deleted file mode 100644 index 3c45a52d48..0000000000 --- a/platform/features/timeline/test/directives/MCTResourceGraphDropSpec.js +++ /dev/null @@ -1,159 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/directives/MCTResourceGraphDrop', '../../src/directives/SwimlaneDragConstants'], - function (MCTResourceGraphDrop, SwimlaneDragConstants) { - - describe("The mct-resource-graph-drop directive", function () { - var mockDndService, - mockScope, - mockElement, - testAttrs, - mockSwimlane, - testEvent, - handlers, - directive; - - beforeEach(function () { - handlers = {}; - - mockDndService = jasmine.createSpyObj( - 'dndService', - ['setData', 'getData', 'removeData'] - ); - mockScope = jasmine.createSpyObj('$scope', ['$eval', '$apply']); - mockElement = jasmine.createSpyObj('element', ['on', 'addClass', 'removeClass']); - testAttrs = { mctSwimlaneDrop: "mockSwimlane" }; - mockSwimlane = jasmine.createSpyObj( - "swimlane", - ['graph', 'toggleGraph'] - ); - - testEvent = { - dataTransfer: { getData: jasmine.createSpy() }, - preventDefault: jasmine.createSpy(), - stopPropagation: jasmine.createSpy() - }; - - testEvent.dataTransfer.getData.and.returnValue('abc'); - mockDndService.getData.and.callFake(function (key) { - return key === SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE ? - mockSwimlane : undefined; - }); - - mockSwimlane.graph.and.returnValue(false); - - directive = new MCTResourceGraphDrop(mockDndService); - directive.link(mockScope, mockElement, testAttrs); - - mockElement.on.calls.all().forEach(function (call) { - handlers[call.args[0]] = call.args[1]; - }); - }); - - it("is available as an attribute", function () { - expect(directive.restrict).toEqual("A"); - }); - - [false, true].forEach(function (graphing) { - describe("when swimlane graph is " + (graphing ? "" : "not ") + "enabled", function () { - beforeEach(function () { - mockSwimlane.graph.and.returnValue(graphing); - }); - - - describe("on dragover", function () { - var prefix = !graphing ? "does" : "does not"; - - beforeEach(function () { - handlers.dragover(testEvent); - }); - - it(prefix + " add a drop-over class", function () { - var expectAddClass = expect(mockElement.addClass); - (!graphing ? expectAddClass : expectAddClass.not) - .toHaveBeenCalledWith('drop-over'); - }); - - it(prefix + " call $apply on scope", function () { - var expectApply = expect(mockScope.$apply); - (!graphing ? expectApply : expectApply.not) - .toHaveBeenCalled(); - }); - - it(prefix + " prevent default", function () { - var expectPreventDefault = expect(testEvent.preventDefault); - (!graphing ? expectPreventDefault : expectPreventDefault.not) - .toHaveBeenCalled(); - }); - }); - - describe("on drop", function () { - var prefix = !graphing ? "does" : "does not"; - - beforeEach(function () { - handlers.drop(testEvent); - }); - - it("removes any drop-over class", function () { - expect(mockElement.removeClass) - .toHaveBeenCalledWith('drop-over'); - }); - - it(prefix + " toggle the swimlane's resource graph", function () { - var expectToggle = expect(mockSwimlane.toggleGraph); - (!graphing ? expectToggle : expectToggle.not) - .toHaveBeenCalled(); - }); - - it(prefix + " prevent default", function () { - var expectPreventDefault = expect(testEvent.preventDefault); - (!graphing ? expectPreventDefault : expectPreventDefault.not) - .toHaveBeenCalled(); - }); - }); - - describe("on dragleave", function () { - beforeEach(function () { - handlers.dragleave(testEvent); - }); - - it("removes any drop-over class", function () { - expect(mockElement.removeClass) - .toHaveBeenCalledWith('drop-over'); - }); - - it("calls $apply on scope", function () { - expect(mockScope.$apply).toHaveBeenCalled(); - }); - - it("calls preventDefault on events", function () { - expect(testEvent.preventDefault).toHaveBeenCalled(); - }); - }); - }); - }); - - }); - } -); diff --git a/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js b/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js deleted file mode 100644 index 96f8cf5143..0000000000 --- a/platform/features/timeline/test/directives/MCTSwimlaneDragSpec.js +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/directives/MCTSwimlaneDrag', '../../src/directives/SwimlaneDragConstants'], - function (MCTSwimlaneDrag, SwimlaneDragConstants) { - - describe("The mct-swimlane-drag directive", function () { - var mockDndService, - mockScope, - mockElement, - testAttrs, - handlers, - directive; - - beforeEach(function () { - var scopeExprs = { - someTestExpr: "some swimlane" - }; - - handlers = {}; - - mockDndService = jasmine.createSpyObj( - 'dndService', - ['setData', 'getData', 'removeData'] - ); - mockScope = jasmine.createSpyObj('$scope', ['$eval']); - mockElement = jasmine.createSpyObj('element', ['on']); - testAttrs = { mctSwimlaneDrag: "someTestExpr" }; - - // Simulate evaluation of expressions in scope - mockScope.$eval.and.callFake(function (expr) { - return scopeExprs[expr]; - }); - - directive = new MCTSwimlaneDrag(mockDndService); - - // Run the link function, then capture the event handlers - // for testing. - directive.link(mockScope, mockElement, testAttrs); - - mockElement.on.calls.all().forEach(function (call) { - handlers[call.args[0]] = call.args[1]; - }); - - }); - - it("is available as an attribute", function () { - expect(directive.restrict).toEqual("A"); - }); - - it("exposes the swimlane when dragging starts", function () { - // Verify precondition - expect(mockDndService.setData).not.toHaveBeenCalled(); - // Start a drag - handlers.dragstart(); - // Should have exposed the swimlane - expect(mockDndService.setData).toHaveBeenCalledWith( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE, - "some swimlane" - ); - }); - - it("clears the swimlane when dragging ends", function () { - // Verify precondition - expect(mockDndService.removeData).not.toHaveBeenCalled(); - // Start a drag - handlers.dragend(); - // Should have exposed the swimlane - expect(mockDndService.removeData).toHaveBeenCalledWith( - SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE - ); - }); - }); - } -); diff --git a/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js b/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js deleted file mode 100644 index 4ed612b13e..0000000000 --- a/platform/features/timeline/test/directives/MCTSwimlaneDropSpec.js +++ /dev/null @@ -1,176 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/directives/MCTSwimlaneDrop'], - function (MCTSwimlaneDrop) { - - var TEST_HEIGHT = 100, - TEST_TOP = 600; - - describe("The mct-swimlane-drop directive", function () { - var mockDndService, - mockScope, - mockElement, - testAttrs, - mockSwimlane, - testEvent, - handlers, - directive; - - function getterSetter(value) { - return function (newValue) { - return (value = (arguments.length > 0) ? newValue : value); - }; - } - - beforeEach(function () { - var scopeExprs = {}; - - handlers = {}; - - mockDndService = jasmine.createSpyObj( - 'dndService', - ['setData', 'getData', 'removeData'] - ); - mockScope = jasmine.createSpyObj('$scope', ['$eval', '$apply']); - mockElement = jasmine.createSpyObj('element', ['on']); - testAttrs = { mctSwimlaneDrop: "mockSwimlane" }; - mockSwimlane = jasmine.createSpyObj( - "swimlane", - ["allowDropIn", "allowDropAfter", "drop", "highlight", "highlightBottom"] - ); - mockElement[0] = jasmine.createSpyObj( - "realElement", - ["getBoundingClientRect"] - ); - mockElement[0].offsetHeight = TEST_HEIGHT; - mockElement[0].getBoundingClientRect.and.returnValue({ top: TEST_TOP }); - - // Simulate evaluation of expressions in scope - scopeExprs.mockSwimlane = mockSwimlane; - mockScope.$eval.and.callFake(function (expr) { - return scopeExprs[expr]; - }); - - - mockSwimlane.allowDropIn.and.returnValue(true); - mockSwimlane.allowDropAfter.and.returnValue(true); - // Simulate getter-setter behavior - mockSwimlane.highlight.and.callFake(getterSetter(false)); - mockSwimlane.highlightBottom.and.callFake(getterSetter(false)); - - - - testEvent = { - pageY: TEST_TOP + TEST_HEIGHT / 10, - dataTransfer: { getData: jasmine.createSpy() }, - preventDefault: jasmine.createSpy(), - stopPropagation: jasmine.createSpy() - }; - - testEvent.dataTransfer.getData.and.returnValue('abc'); - mockDndService.getData.and.returnValue({ domainObject: 'someDomainObject' }); - - directive = new MCTSwimlaneDrop(mockDndService); - - // Run the link function, then capture the event handlers - // for testing. - directive.link(mockScope, mockElement, testAttrs); - - mockElement.on.calls.all().forEach(function (call) { - handlers[call.args[0]] = call.args[1]; - }); - - }); - - it("is available as an attribute", function () { - expect(directive.restrict).toEqual("A"); - }); - - it("updates highlights on drag over", function () { - // Near the top - testEvent.pageY = TEST_TOP + TEST_HEIGHT / 10; - - handlers.dragover(testEvent); - - expect(mockSwimlane.highlight).toHaveBeenCalledWith(true); - expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false); - expect(mockScope.$apply).toHaveBeenCalled(); - }); - - it("updates bottom highlights on drag over", function () { - // Near the bottom - testEvent.pageY = TEST_TOP + TEST_HEIGHT - TEST_HEIGHT / 10; - - handlers.dragover(testEvent); - - expect(mockSwimlane.highlight).toHaveBeenCalledWith(false); - expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(true); - expect(mockScope.$apply).toHaveBeenCalled(); - }); - - it("respects swimlane's allowDropIn response", function () { - // Near the top - testEvent.pageY = TEST_TOP + TEST_HEIGHT / 10; - - mockSwimlane.allowDropIn.and.returnValue(false); - - handlers.dragover(testEvent); - - expect(mockSwimlane.highlight).toHaveBeenCalledWith(false); - expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false); - }); - - it("respects swimlane's allowDropAfter response", function () { - // Near the top - testEvent.pageY = TEST_TOP + TEST_HEIGHT - TEST_HEIGHT / 10; - - mockSwimlane.allowDropAfter.and.returnValue(false); - - handlers.dragover(testEvent); - - expect(mockSwimlane.highlight).toHaveBeenCalledWith(false); - expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false); - }); - - it("notifies swimlane on drop", function () { - handlers.drop(testEvent); - expect(mockSwimlane.drop).toHaveBeenCalledWith('abc', 'someDomainObject'); - expect(mockScope.$apply).toHaveBeenCalled(); - }); - - it("invokes preventDefault on drop", function () { - handlers.drop(testEvent); - expect(testEvent.preventDefault).toHaveBeenCalled(); - }); - - it("clears highlights when drag leaves", function () { - mockSwimlane.highlight.and.returnValue(true); - handlers.dragleave(); - expect(mockSwimlane.highlight).toHaveBeenCalledWith(false); - expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false); - expect(mockScope.$apply).toHaveBeenCalled(); - }); - }); - } -); diff --git a/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js b/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js deleted file mode 100644 index a6c9e255e1..0000000000 --- a/platform/features/timeline/test/directives/SwimlaneDragConstantsSpec.js +++ /dev/null @@ -1,34 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/directives/SwimlaneDragConstants'], - function (SwimlaneDragConstants) { - - describe("Timeline swimlane drag constants", function () { - it("define a custom type for swimlane drag-drop", function () { - expect(SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE) - .toEqual(jasmine.any(String)); - }); - }); - } -); diff --git a/platform/features/timeline/test/services/ObjectLoaderSpec.js b/platform/features/timeline/test/services/ObjectLoaderSpec.js deleted file mode 100644 index 9403dbe6c5..0000000000 --- a/platform/features/timeline/test/services/ObjectLoaderSpec.js +++ /dev/null @@ -1,159 +0,0 @@ -/***************************************************************************** - * Open MCT, Copyright (c) 2009-2016, United States Government - * as represented by the Administrator of the National Aeronautics and Space - * Administration. All rights reserved. - * - * Open MCT 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 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. - *****************************************************************************/ - -define( - ['../../src/services/ObjectLoader'], - function (ObjectLoader) { - - describe("The domain object loader", function () { - var mockQ, - mockCallback, - mockDomainObjects, - testCompositions, - objectLoader; - - function asPromise(value) { - return (value || {}).then ? value : { - then: function (callback) { - return asPromise(callback(value)); - } - }; - } - - function lookupObject(id) { - return mockDomainObjects[id]; - } - - function fullSubgraph(id) { - return { - domainObject: mockDomainObjects[id], - composition: (testCompositions[id] || []) - .map(fullSubgraph) - }; - } - - function addDomainObject(id, children, capabilities) { - var mockDomainObject = jasmine.createSpyObj( - 'object-' + id, - ['useCapability', 'hasCapability', 'getId'] - ); - - mockDomainObject.getId.and.returnValue(id); - mockDomainObject.useCapability.and.callFake(function (c) { - return c === 'composition' ? - asPromise(children.map(lookupObject)) : - undefined; - }); - mockDomainObject.hasCapability.and.callFake(function (c) { - return (capabilities.indexOf(c) !== -1) || (c === 'composition'); - }); - mockDomainObjects[id] = mockDomainObject; - - testCompositions[id] = children; - } - - beforeEach(function () { - mockQ = jasmine.createSpyObj('$q', ['when', 'all']); - mockCallback = jasmine.createSpy('callback'); - mockDomainObjects = {}; - testCompositions = {}; - - // Provide subset of q's actual behavior which we - // expect object loader to really need - mockQ.when.and.callFake(asPromise); - mockQ.all.and.callFake(function (values) { - var result = []; - function addResult(v) { - result.push(v); - } - function promiseResult(v) { - asPromise(v).then(addResult); - } - values.forEach(promiseResult); - return asPromise(result); - }); - - // Populate some mock domain objects - addDomainObject('a', ['b', 'c', 'd'], ['test']); - addDomainObject('b', ['c', 'd', 'ba'], []); - addDomainObject('c', ['ca'], ['test']); - addDomainObject('d', [], ['test']); - addDomainObject('ba', [], ['test']); - addDomainObject('ca', [], ['test']); - - objectLoader = new ObjectLoader(mockQ); - }); - - - - it("loads sub-graphs of composition hierarchy", function () { - objectLoader.load(mockDomainObjects.a).then(mockCallback); - // Should have loaded full graph - expect(mockCallback).toHaveBeenCalledWith(fullSubgraph('a')); - }); - - it("filters based on capabilities, if requested", function () { - objectLoader.load(mockDomainObjects.a, 'test') - .then(mockCallback); - // Should have pruned 'b' - expect(mockCallback).toHaveBeenCalledWith({ - domainObject: mockDomainObjects.a, - composition: [ - fullSubgraph('c'), - fullSubgraph('d') - ] - }); - }); - - it("filters with a function, if requested", function () { - function shortName(domainObject) { - return domainObject.getId().length === 1; - } - objectLoader.load(mockDomainObjects.a, shortName) - .then(mockCallback); - // Should have pruned 'ba' and 'ca' - expect(mockCallback).toHaveBeenCalledWith({ - domainObject: mockDomainObjects.a, - composition: [ - { - domainObject: mockDomainObjects.b, - composition: [ - { - domainObject: mockDomainObjects.c, - composition: [] - }, - fullSubgraph('d') - ] - }, - { - domainObject: mockDomainObjects.c, - composition: [] - }, - fullSubgraph('d') - ] - }); - }); - - }); - - } -);