Compare commits

..

8 Commits

Author SHA1 Message Date
Julie Wang
a53a669154 Addressed additional style errors. 2018-09-04 08:46:53 -04:00
Julie Wang
0602613b6e Addressed lint style issues. 2018-08-09 22:55:59 -07:00
Julie Wang
7620432388 Updated whitespace. 2018-08-09 22:10:43 -07:00
Julie Wang
fc8663c049 Reverted unecessary whitespace change. 2018-08-09 21:50:40 -07:00
Julie Wang
adfe30a891 Added comments to clarify code. 2018-08-09 21:15:54 -07:00
Wang
5218e350c3 Updates tests in locator controller. 2018-08-09 17:32:28 -07:00
Julie Wang
88615e92d2 Added tests for new folder action and locator controller. 2018-08-09 16:40:00 -07:00
Julie Wang
12477a220b testing new implementation. 2018-08-06 22:31:23 -07:00
41 changed files with 817 additions and 251 deletions

61
API.md
View File

@@ -52,6 +52,7 @@
- [The URL Status Indicator](#the-url-status-indicator)
- [Creating a Simple Indicator](#creating-a-simple-indicator)
- [Custom Indicators](#custom-indicators)
- [Included Plugins](#included-plugins)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -993,7 +994,7 @@ A common use case for indicators is to convey the state of some external system
persistence backend or HTTP server. So long as this system is accessible via HTTP request,
Open MCT provides a general purpose indicator to show whether the server is available and
returing a 2xx status code. The URL Status Indicator is made available as a default plugin. See
the [documentation](./src/plugins/URLIndicatorPlugin) for details on how to install and configure the
[Included Plugins](#included-plugins) below for details on how to install and configure the
URL Status Indicator.
### Creating a Simple Indicator
@@ -1044,4 +1045,60 @@ A completely custom indicator can be added by simple providing a DOM element to
openmct.indicators.add({
element: domNode
});
```
```
## Included Plugins
Open MCT is packaged along with a few general-purpose plugins:
* `openmct.plugins.Conductor` provides a user interface for working with time
within the application. If activated, configuration must be provided. This is
detailed in the section on [Time Conductor Configuration](#time-conductor-configuration).
* `openmct.plugins.CouchDB` is an adapter for using CouchDB for persistence
of user-created objects. This is a constructor that takes the URL for the
CouchDB database as a parameter, e.g.
```javascript
openmct.install(openmct.plugins.CouchDB('http://localhost:5984/openmct'))
```
* `openmct.plugins.Elasticsearch` is an adapter for using Elasticsearch for
persistence of user-created objects. This is a
constructor that takes the URL for the Elasticsearch instance as a
parameter. eg.
```javascript
openmct.install(openmct.plugins.CouchDB('http://localhost:9200'))
```
* `openmct.plugins.Espresso` and `openmct.plugins.Snow` are two different
themes (dark and light) available for Open MCT. Note that at least one
of these themes must be installed for Open MCT to appear correctly.
* `openmct.plugins.URLIndicator` adds an indicator which shows the
availability of a URL with the following options:
- `url` : URL to indicate the status of
- `iconClass`: Icon to show in the status bar, defaults to `icon-database`, [list of all icons](https://nasa.github.io/openmct/style-guide/#/browse/styleguide:home?view=items)
- `interval`: Interval between checking the connection, defaults to `10000`
- `label` Name showing up as text in the status bar, defaults to url
```javascript
openmct.install(openmct.plugins.URLIndicator({
url: 'http://localhost:8080',
iconClass: 'check',
interval: 10000,
label: 'Localhost'
})
);
```
* `openmct.plugins.LocalStorage` provides persistence of user-created
objects in browser-local storage. This is particularly useful in
development environments.
* `openmct.plugins.MyItems` adds a top-level folder named "My Items"
when the application is first started, providing a place for a
user to store created items.
* `openmct.plugins.UTCTimeSystem` provides a default time system for Open MCT.
Generally, you will want to either install these plugins, or install
different plugins that provide persistence and an initial folder
hierarchy.
eg.
```javascript
openmct.install(openmct.plugins.LocalStorage());
openmct.install(openmct.plugins.MyItems());
```

View File

@@ -20,8 +20,14 @@ API. Open MCT is also being refactored to minimize the dependencies that using
Open MCT imposes on developers, such as the current requirement to use
AngularJS.
This new API has not yet been heavily used and is likely to contain defects.
You can help by trying it out, and reporting any issues you encounter
using our GitHub issue tracker. Such issues may include bugs, suggestions,
missing documentation, or even just requests for help if you're having
trouble.
We want Open MCT to be as easy to use, install, run, and develop for as
possible, and your feedback will help us get there! Feedback can be provided via [GitHub issues](https://github.com/nasa/openmct/issues), or by emailing us at [arc-dl-openmct@nasa.gov](mailto:arc-dl-openmct@nasa.gov).
possible, and your feedback will help us get there!
## Building and Running Open MCT Locally

View File

@@ -31,6 +31,7 @@ var gulp = require('gulp'),
git = require('git-rev-sync'),
moment = require('moment'),
project = require('./package.json'),
_ = require('lodash'),
paths = {
main: 'openmct.js',
dist: 'dist',
@@ -139,7 +140,7 @@ gulp.task('checkstyle', function () {
var mkdirp = require('mkdirp');
var reportName = 'jscs-html-report.html';
var reportPath = path.resolve(paths.reports, 'checkstyle', reportName);
var moveReport = fs.rename.bind(fs, reportName, reportPath, function () {});
var moveReport = fs.rename.bind(fs, reportName, reportPath, _.noop);
mkdirp.sync(path.resolve(paths.reports, 'checkstyle'));
@@ -178,4 +179,4 @@ gulp.task('install', [ 'assets', 'scripts' ]);
gulp.task('verify', [ 'lint', 'test', 'checkstyle' ]);
gulp.task('build', [ 'verify', 'install' ]);
gulp.task('build', [ 'verify', 'install' ]);

View File

@@ -41,14 +41,14 @@ requirejs.config({
"lodash": "bower_components/lodash/lodash",
"d3-selection": "node_modules/d3-selection/dist/d3-selection.min",
"d3-scale": "node_modules/d3-scale/build/d3-scale.min",
"d3-axis": "node_modules/d3-axis/dist/d3-axis.min",
"d3-array": "node_modules/d3-array/dist/d3-array.min",
"d3-collection": "node_modules/d3-collection/dist/d3-collection.min",
"d3-axis": "node_modules/d3-axis/build/d3-axis.min",
"d3-array": "node_modules/d3-array/build/d3-array.min",
"d3-collection": "node_modules/d3-collection/build/d3-collection.min",
"d3-color": "node_modules/d3-color/build/d3-color.min",
"d3-format": "node_modules/d3-format/build/d3-format.min",
"d3-interpolate": "node_modules/d3-interpolate/build/d3-interpolate.min",
"d3-time": "node_modules/d3-time/dist/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/dist/d3-time-format.min",
"d3-time": "node_modules/d3-time/build/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min",
"html2canvas": "node_modules/html2canvas/dist/html2canvas.min",
"painterro": "node_modules/painterro/build/painterro.min",
"printj": "node_modules/printj/dist/printj.min"

View File

@@ -1,7 +1,7 @@
{
"name": "openmct",
"version": "0.14.0-SNAPSHOT",
"description": "The Open MCT core platform.",
"description": "The Open MCT core platform",
"dependencies": {
"d3-array": "1.2.x",
"d3-axis": "1.0.x",
@@ -43,6 +43,7 @@
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "^1.1.2",
"karma-requirejs": "^1.1.0",
"lodash": "^3.10.1",
"markdown-toc": "^0.11.7",
"marked": "^0.3.5",
"merge-stream": "^1.0.0",

View File

@@ -33,6 +33,7 @@ define([
"./src/actions/SaveAndStopEditingAction",
"./src/actions/SaveAsAction",
"./src/actions/CancelAction",
"./src/actions/CreateNewFolderAction",
"./src/policies/EditActionPolicy",
"./src/policies/EditPersistableObjectsPolicy",
"./src/policies/EditableLinkPolicy",
@@ -71,6 +72,7 @@ define([
SaveAndStopEditingAction,
SaveAsAction,
CancelAction,
CreateNewFolderAction,
EditActionPolicy,
EditPersistableObjectsPolicy,
EditableLinkPolicy,
@@ -145,7 +147,10 @@ define([
"depends": [
"$scope",
"$timeout",
"objectService"
"objectService",
"typeService",
"policyService",
"instantiate"
]
}
],
@@ -242,6 +247,14 @@ define([
"cssClass": "icon-x no-label",
"description": "Discard changes made to these objects.",
"depends": []
},
{
"key": "create-new-folder",
"implementation": CreateNewFolderAction,
"description": "Creates a new folder.",
"depends": [
"typeService"
]
}
],
"policies": [

View File

@@ -0,0 +1,33 @@
<!--span
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.
-->
<div name="newFolder" ng-controller="LocatorController">
<div ng-if="!createNewFolder">
<a class="s-button icon-folder-new" ng-click="createNewFolderClickHandler()" >
<span class="title-label">New Folder</span>
</a>
</div>
<div ng-if="createNewFolder">
<span><input type="text" ng-model="newFolderName" name="newFolderName"></span>
<a class="s-button" ng-click="createClickHandler()">Create</a>
<a class="s-button icon-x" ng-click="cancelClickHandler()"></a>
</div>
</div>

View File

@@ -1,5 +1,5 @@
<!--
Open MCT, Copyright (c) 2014-2018, United States Government
Open MCT, Copyright (c) 2014-2017, United States Government
as represented by the Administrator of the National Aeronautics and Space
Administration. All rights reserved.
@@ -26,4 +26,22 @@
ng-model="treeModel">
</mct-representation>
</div>
<!-- Create New Folder Action -->
<div class="newFolderCreation" style="margin-top:10px; position:absolute; left:0px;">
<!-- New folder button, triggers create new folder action. -->
<div ng-show="!newFolderCreationTriggered">
<a class="s-button icon-folder-new" ng-class="{disabled: !validParent()}" ng-click="newFolderButtonClickHandler()">
<span class="text-label">New Folder</span>
</a>
</div>
<!-- Get folder name -->
<div ng-show="newFolderCreationTriggered">
<input type="text" ng-model="newFolderNameInput">
<a class="s-button" ng-class="{ disabled: !validParent() || !validFolderName() }" ng-click="newFolderCreateButtonClickHandler()">Create</a>
<a class="s-button icon-x" ng-click="newFolderCancelButtonClickHandler()"></a>
</div>
</div>
</div>

View File

@@ -0,0 +1,89 @@
/*****************************************************************************
* 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 (
) {
/**
* The CreateNewFolderAction; action is triggered by the new folder button in the locator.
*
* @constructor
* @implements {Action}
* @memberof platform/commonUI/edit
*/
function CreateNewFolderAction(
typeService,
context
) {
this.parent = (context || {}).domainObject;
this.typeService = typeService;
this.type = typeService.getType('folder');
}
CreateNewFolderAction.prototype.perform = function (folderName) {
var parent = this.parent,
typeService = this.typeService,
newModel = this.type.getInitialModel(),
folderType = typeService.getType('folder');
newModel.type = folderType.getKey();
newModel.name = folderName;
function instantiateObject() {
var newObject = parent.useCapability('instantiation', newModel);
newObject.useCapability('mutation', function () {
newModel.location = parent.getId();
});
return addToParentAndReturn(newObject);
}
function addToParentAndReturn(newObject) {
return parent.getCapability('composition').add(newObject)
.then(function () {
return newObject;
});
}
return instantiateObject(newModel, parent);
};
/**
* Check if this action is applicable in a given context.
* This will ensure that a domain object is present in the context,
* and that this domain object is in Edit mode.
* @returns true if applicable
*/
CreateNewFolderAction.appliesTo = function (context) {
var parent = (context || {}).domainObject;
return parent && parent.hasCapability('editor');
};
return CreateNewFolderAction;
}
);

View File

@@ -51,7 +51,7 @@ define([
/**
* Perform this action.
*/
RemoveAction.prototype.perform = function (skipWarning) {
RemoveAction.prototype.perform = function () {
var dialog,
dialogService = this.dialogService,
domainObject = this.domainObject,
@@ -115,18 +115,12 @@ define([
return parent.useCapability('mutation', doMutate);
}
if (skipWarning) {
removeFromContext(domainObject);
} else {
/*
* Pass in the function to remove the domain object so it can be
* associated with an 'OK' button press
*/
dialog = new RemoveDialog(dialogService, domainObject, removeFromContext);
dialog.show();
}
/*
* Pass in the function to remove the domain object so it can be
* associated with an 'OK' button press
*/
dialog = new RemoveDialog(dialogService, domainObject, removeFromContext);
dialog.show();
};
// Object needs to have a parent for Remove to be applicable

View File

@@ -1,5 +1,5 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* Open MCT, Copyright (c) 2014-2017, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
@@ -31,7 +31,7 @@ define(
* @memberof platform/commonUI/browse
* @constructor
*/
function LocatorController($scope, $timeout, objectService) {
function LocatorController($scope, $timeout, objectService, typeService, policyService, instantiate) {
// Populate values needed by the locator control. These are:
// * rootObject: The top-level object, since we want to show
// the full tree
@@ -66,8 +66,8 @@ define(
// Restrict which locations can be selected
if (domainObject &&
$scope.structure &&
$scope.structure.validate) {
$scope.structure &&
$scope.structure.validate) {
if (!$scope.structure.validate(domainObject)) {
setLocatingObject(priorObject, undefined);
return;
@@ -81,11 +81,64 @@ define(
!!$scope.treeModel.selectedObject
);
}
// Check if create new folder is a valid action for selected object
$scope.validParent = function () {
if ($scope.treeModel.selectedObject) {
return policyService.allow(
"composition",
$scope.treeModel.selectedObject,
instantiate(typeService.getType('folder').getInitialModel())
);
} else {
return false;
}
};
}
$scope.newFolderButtonClickHandler = function () {
$scope.newFolderCreationTriggered = true;
};
$scope.newFolderCancelButtonClickHandler = function () {
$scope.newFolderCreationTriggered = false;
resetNewFolderNameInput();
};
// Get expected input pattern for folder name
var folderNamePattern = new RegExp(
typeService.getType('folder').getProperties()[0].propertyDefinition.pattern
);
// Validate folder name externally to avoid affecting overall form validation
$scope.validFolderName = function () {
return $scope.newFolderNameInput && folderNamePattern.test($scope.newFolderNameInput);
};
function selectAndScrollToNewFolder(newFolder) {
$scope.treeModel.selectedObject = newFolder;
}
function resetNewFolderNameInput() {
$scope.newFolderNameInput = "Unnamed Folder";
$scope.newFolderCreationTriggered = false;
}
// Create new folder, update selection to new folder and reset new folder button
$scope.newFolderCreateButtonClickHandler = function () {
var createNewFolderAction = $scope.treeModel.selectedObject.getCapability('action').getActions('create-new-folder')[0];
createNewFolderAction.perform($scope.newFolderNameInput)
.then(selectAndScrollToNewFolder)
.then(resetNewFolderNameInput);
};
// Initial state for the tree's model
$scope.treeModel =
{ selectedObject: $scope.ngModel[$scope.field] };
$scope.treeModel = { selectedObject: $scope.ngModel[$scope.field] };
//Initial values for new folder action
$scope.newFolderNameInput = "Unnamed Folder";
$scope.newFolderCreationTriggered = false;
// Watch for changes from the tree
$scope.$watch("treeModel.selectedObject", setLocatingObject);

View File

@@ -0,0 +1,117 @@
/*****************************************************************************
* 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(
['../../src/actions/CreateNewFolderAction'],
function (CreateNewFolderAction) {
describe("The Create New Folder Action", function () {
var mockDomainObject,
mockNewObject,
mockType,
testModel,
mockFolderName,
mockTypeService,
mockActionContext,
mockCompositionCapability,
action;
function mockPromise(value) {
return (value && value.then) ? value : {
then: function (callback) {
return mockPromise(callback(value));
}
};
}
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[
"getCapability",
"useCapability",
"hasCapability",
"getId"
]
);
mockNewObject = jasmine.createSpyObj(
"newObject",
[
"getCapability",
"useCapability",
"hasCapability",
"getId"
]
);
mockType = jasmine.createSpyObj(
"type",
[
"getKey",
"getInitialModel"
]
);
testModel = {
type: mockType,
name: "Name",
location: "someLocation"
};
mockFolderName = "Name";
mockTypeService = jasmine.createSpyObj(
"typeService",
["getType"]
);
mockActionContext = { domainObject: mockDomainObject };
mockCompositionCapability = jasmine.createSpyObj(
"composition",
["add"]
);
mockType.getKey.and.returnValue("test");
mockType.getInitialModel.and.returnValue(testModel);
mockDomainObject.getCapability.and.callFake(function (capability) {
return (capability === 'composition') && mockCompositionCapability;
});
mockDomainObject.hasCapability.and.returnValue(true);
mockCompositionCapability.add.and.returnValue(mockPromise(true));
mockDomainObject.useCapability.and.callFake(function (capability) {
return (capability === 'instantiation') && mockNewObject;
});
mockTypeService.getType.and.returnValue(mockType);
mockDomainObject.getId.and.returnValue("id");
action = new CreateNewFolderAction(mockTypeService, mockActionContext);
});
it("uses the instantiation capability when performed", function () {
action.perform(mockFolderName);
expect(mockDomainObject.useCapability)
.toHaveBeenCalledWith("instantiation", jasmine.any(Object));
});
it("adds new objects to the parent's composition", function () {
action.perform(mockFolderName);
expect(mockDomainObject.getCapability).toHaveBeenCalledWith("composition");
expect(mockCompositionCapability.add).toHaveBeenCalled();
});
it("is only applicable when a domain object is in context", function () {
expect(CreateNewFolderAction.appliesTo(mockActionContext)).toBeTruthy();
expect(CreateNewFolderAction.appliesTo({})).toBeFalsy();
expect(mockDomainObject.hasCapability).toHaveBeenCalledWith('editor');
});
});
}
);

View File

@@ -124,17 +124,6 @@ define(
expect(mockParent.useCapability).not.toHaveBeenCalledWith("mutation", jasmine.any(Function));
});
it("does not show a blocking message dialog when true is passed to perform", function () {
mockParent = jasmine.createSpyObj(
"parent",
["getModel", "getCapability", "useCapability"]
);
action.perform(true);
expect(mockDialogService.showBlockingMessage).not.toHaveBeenCalled();
});
describe("after the remove callback is triggered", function () {
var mockChildContext,
mockChildObject,

View File

@@ -31,26 +31,63 @@ define(
var mockScope,
mockTimeout,
mockDomainObject,
mockFolderObject,
mockRootObject,
mockContext,
mockActions,
mockObjectService,
mockTypeService,
mockType,
mockInstantiate,
mockPolicyService,
getObjectsPromise,
testModel,
capabilities,
mockCreateNewFolderAction,
mockActionCapability,
mockProperties,
controller;
beforeEach(function () {
mockScope = jasmine.createSpyObj(
"$scope",
["$watch"]
["$watch", "validParent"]
);
mockTimeout = jasmine.createSpy("$timeout");
mockInstantiate = jasmine.createSpy("instantiate");
mockDomainObject = jasmine.createSpyObj(
"domainObject",
["getCapability"]
[
"useCapability",
"getModel",
"getCapability"
]
);
mockFolderObject = jasmine.createSpyObj(
"folderObject",
[
"useCapability",
"getModel",
"getCapability"
]
);
mockCreateNewFolderAction = jasmine.createSpyObj(
"createNewFolderAction",
[
"perform"
]
);
mockRootObject = jasmine.createSpyObj(
"rootObject",
["getCapability"]
);
mockActionCapability = jasmine.createSpyObj(
"actionCapability",
[
"getActions",
"perform"
]
);
mockContext = jasmine.createSpyObj(
"context",
["getRoot"]
@@ -59,25 +96,70 @@ define(
"objectService",
["getObjects"]
);
mockTypeService = jasmine.createSpyObj(
"typeService",
["getType"]
);
mockPolicyService = jasmine.createSpyObj(
"policyService",
["allow"]
);
getObjectsPromise = jasmine.createSpyObj(
"promise",
["then"]
);
mockDomainObject.getCapability.and.returnValue(mockContext);
mockType = jasmine.createSpyObj(
"type",
[
"getKey",
"getProperties",
"getInitialModel"
]
);
testModel = { someKey: "some value" };
mockProperties = ['a', 'b', 'c'].map(function (k) {
var mockProperty = jasmine.createSpyObj(
'property-' + k,
['propertyDefinition']
);
mockProperty.propertyDefinition = {
key: "name",
pattern: "test"
};
return mockProperty;
});
capabilities = {
"action" : mockActionCapability,
"context": mockContext
};
mockActions = [mockCreateNewFolderAction];
mockContext.getRoot.and.returnValue(mockRootObject);
mockObjectService.getObjects.and.returnValue(getObjectsPromise);
mockTypeService.getType.and.callFake(function (typename) {
return mockType;
});
mockInstantiate.and.returnValue(mockFolderObject);
mockType.getKey.and.returnValue("test");
mockType.getInitialModel.and.returnValue(testModel);
mockType.getProperties.and.returnValue(mockProperties);
mockDomainObject.getCapability.and.callFake(function (capability) {
return capabilities[capability];
});
mockDomainObject.useCapability.and.returnValue();
mockDomainObject.getModel.and.returnValue(testModel);
mockFolderObject.getCapability.and.returnValue(capabilities);
mockFolderObject.useCapability.and.returnValue();
mockFolderObject.getModel.and.returnValue(testModel);
mockScope.ngModel = {};
mockScope.field = "someField";
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService, mockTypeService, mockPolicyService, mockInstantiate);
});
describe("when context is available", function () {
beforeEach(function () {
mockContext.getRoot.and.returnValue(mockRootObject);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService, mockTypeService, mockPolicyService, mockInstantiate);
});
it("adds a treeModel to scope", function () {
@@ -145,7 +227,7 @@ define(
getObjectsPromise.then.and.callFake(function (callback) {
callback({'ROOT': defaultRoot});
});
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
controller = new LocatorController(mockScope, mockTimeout, mockObjectService, mockTypeService, mockPolicyService, mockInstantiate);
});
it("provides a default context where none is available", function () {
@@ -169,3 +251,4 @@ define(
});
}
);

View File

@@ -1,7 +0,0 @@
# Espresso Theme
Dark theme for the Open MCT user interface.
## Installation
```js
openmct.install(openmct.plugins.Espresso());
```

View File

@@ -1,7 +0,0 @@
# Espresso Theme
A light colored theme for the Open MCT user interface.
## Installation
```js
openmct.install(openmct.plugins.Snow());
```

View File

@@ -102,14 +102,14 @@ define(
* @returns {Action[]} an array of matching actions
* @memberof platform/core.ActionCapability#
*/
ActionCapability.prototype.perform = function (context, flag) {
ActionCapability.prototype.perform = function (context) {
// Alias to getActions(context)[0].perform, with a
// check for empty arrays.
var actions = this.getActions(context);
return this.$q.when(
(actions && actions.length > 0) ?
actions[0].perform(flag) :
actions[0].perform() :
undefined
);
};

View File

@@ -92,7 +92,7 @@ define(
.then(function () {
return object
.getCapability('action')
.perform('remove', true);
.perform('remove');
});
};

View File

@@ -224,11 +224,10 @@ define(
locationPromise.resolve();
});
it("removes object from parent without user warning dialog", function () {
it("removes object from parent", function () {
expect(actionCapability.perform)
.toHaveBeenCalledWith('remove', true);
.toHaveBeenCalledWith('remove');
});
});
});
@@ -245,9 +244,9 @@ define(
.toHaveBeenCalled();
});
it("removes object from parent without user warning dialog", function () {
it("removes object from parent", function () {
expect(actionCapability.perform)
.toHaveBeenCalledWith('remove', true);
.toHaveBeenCalledWith('remove');
});
});

View File

@@ -87,8 +87,7 @@ define(
'setDisplayedValue',
'subscribeToObject',
'unsubscribe',
'updateView',
'setSelection'
'updateView'
].forEach(function (name) {
self[name] = self[name].bind(self);
});
@@ -225,7 +224,7 @@ define(
// Respond to external bounds changes
this.openmct.time.on("bounds", updateDisplayBounds);
this.openmct.selection.on('change', this.setSelection);
this.openmct.selection.on('change', this.setSelection.bind(this));
this.$element.on('click', this.bypassSelection.bind(this));
this.unlisten = this.openmct.objects.observe(this.newDomainObject, '*', function (obj) {
this.newDomainObject = JSON.parse(JSON.stringify(obj));
@@ -234,9 +233,6 @@ define(
this.updateElementPositions(this.newDomainObject.layoutGrid);
refreshElements();
//force a click, to initialize Fixed Position Controller on SelectionAPI
$element[0].click();
}
FixedController.prototype.updateElementPositions = function (layoutGrid) {

View File

@@ -1,8 +0,0 @@
# My Items plugin
Defines top-level folder named "My Items" to store user-created items. Enabled by default, this can be disabled in a
read-only deployment with no user-editable objects.
## Installation
```js
openmct.install(openmct.plugins.MyItems());
```

View File

@@ -35,30 +35,28 @@ mct-table {
}
.mct-table {
tr {
display: flex; // flex-flow defaults to row nowrap (which is what we want) so no need to define
height: 18px; // Needed when a row has empty values in its cells
align-items: stretch;
}
td, th {
box-sizing: border-box;
display: block;
flex: 1 0 auto;
white-space: nowrap;
}
thead {
display: block;
tr {
display: block;
white-space: nowrap;
th {
display: inline-block;
box-sizing: border-box;
}
}
}
tbody {
tr {
position: absolute;
white-space: nowrap;
display: block;
}
td {
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
display: inline-block;
}
}
}

View File

@@ -1,14 +0,0 @@
# Import / Export Plugin
The Import/Export plugin allows objects to be exported as JSON files. This allows for sharing of objects between users
who are not using a shared persistence store. It also allows object trees to be backed up. Additionally, object trees
exported using this tool can then be exposed as read-only static root trees using the
[Static Root Plugin](../../src/plugins/staticRootPlugin/README.md).
Upon installation it will add two new context menu actions to allow import and export of objects. Initiating the Export
action on an object will produce a JSON file that includes the object and all of its composed children. Selecting Import
on an object will allow the user to import a previously exported object tree as a child of the selected object.
## Installation
```js
openmct.install(openmct.plugins.ImportExport())
```

View File

@@ -133,7 +133,7 @@ define(['lodash'], function (_) {
copyOfChild.location = parentId;
parent.composition[index] = copyOfChild.identifier;
this.tree[newIdString] = copyOfChild;
this.tree[parentId].composition[index] = copyOfChild.identifier;
this.tree[parentId].composition[index] = newIdString;
return copyOfChild;
};

View File

@@ -79,18 +79,16 @@ define(['zepto'], function ($) {
var parentModel = parent.getModel();
var newObj;
seen.push(this.getKeyString(parent.getId()));
seen.push(parent.getId());
parentModel.composition.forEach(function (childId, index) {
var childIdString = this.getKeyString(childId);
if (!tree[childIdString] || seen.includes(childIdString)) {
if (!tree[childId] || seen.includes(childId)) {
return;
}
newObj = this.instantiate(tree[childIdString], childIdString);
// New object has not been persisted yet so clear persisted
// timestamp from copied model.
delete newObj.getModel().persisted;
newObj.getCapability('persistence').persist();
newObj = this.instantiate(tree[childId], childId);
parent.getCapability("composition").add(newObj);
newObj.getCapability("location")
.setPrimaryLocation(tree[childId].location);
this.deepInstantiate(newObj, tree, seen);
}, this);
}
@@ -105,10 +103,6 @@ define(['zepto'], function ($) {
return tree;
};
ImportAsJSONAction.prototype.getKeyString = function (identifier) {
return this.openmct.objects.makeKeyString(identifier);
};
/**
* Rewrites all instances of a given id in the tree with a newly generated
* replacement to prevent collision.

View File

@@ -47,12 +47,7 @@ define(
uniqueId = 0;
newObjects = [];
openmct = {
$injector: jasmine.createSpyObj('$injector', ['get']),
objects: {
makeKeyString: function (identifier) {
return identifier.key;
}
}
$injector: jasmine.createSpyObj('$injector', ['get'])
};
mockInstantiate = jasmine.createSpy('instantiate').and.callFake(
function (model, id) {
@@ -159,7 +154,7 @@ define(
body: JSON.stringify({
"openmct": {
"infiniteParent": {
"composition": [{key: "infinteChild", namespace: ""}],
"composition": ["infinteChild"],
"name": "1",
"type": "folder",
"modified": 1503598129176,
@@ -167,7 +162,7 @@ define(
"persisted": 1503598129176
},
"infinteChild": {
"composition": [{key: "infinteParent", namespace: ""}],
"composition": ["infiniteParent"],
"name": "2",
"type": "folder",
"modified": 1503598132428,

View File

@@ -1,8 +1,2 @@
# Couch DB Persistence Plugin
An adapter for using CouchDB for persistence of user-created objects. The plugin installation function takes the URL
for the CouchDB database as a parameter.
## Installation
```js
openmct.install(openmct.plugins.CouchDB('http://localhost:5984/openmct'))
```
This bundle implements a connection to an external CouchDB persistence
store in Open MCT.

View File

@@ -1,8 +1,2 @@
# Elasticsearch Persistence Provider
An adapter for using Elastic for persistence of user-created objects. The installation function takes the URL for an
Elasticsearch server as a parameter.
## Installation
```js
openmct.install(openmct.plugins.Elasticsearch('http://localhost:9200'))
```
This bundle implements a connection to an external ElasticSearch persistence
store in Open MCT.

View File

@@ -1,9 +0,0 @@
# Local Storage Plugin
Provides persistence of user-created objects in browser Local Storage. Objects persisted in this way will only be
available from the browser and machine on which they were persisted. For shared persistence, consider the
[Elasticsearch](../elastic/) and [CouchDB](../couch/) persistence plugins.
## Installation
```js
openmct.install(openmct.plugins.LocalStorage());
```

View File

@@ -0,0 +1,49 @@
/*****************************************************************************
* 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.
*****************************************************************************/
// Converts all templateUrl references in bundle.js files to
// plain template references, loading said templates with the
// RequireJS text plugin.
var glob = require('glob'),
fs = require('fs');
function migrate(file) {
var sourceCode = fs.readFileSync(file, 'utf8'),
lines = sourceCode.split('\n')
.filter(function (line) {
return !(/^\W*['"]use strict['"];\W*$/.test(line));
})
.filter(function (line) {
return line.indexOf("/*global") !== 0;
});
fs.writeFileSync(file, lines.join('\n'));
}
glob('@(src|platform)/**/*.js', {}, function (err, files) {
if (err) {
console.log(err);
return;
}
files.forEach(migrate);
});

View File

@@ -0,0 +1,106 @@
/*****************************************************************************
* 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.
*****************************************************************************/
// Converts all templateUrl references in bundle.js files to
// plain template references, loading said templates with the
// RequireJS text plugin.
var glob = require('glob'),
fs = require('fs'),
path = require('path'),
_ = require('lodash');
function toTemplateName(templateUrl) {
var parts = templateUrl.split('/');
return _.camelCase(parts[parts.length - 1].replace(".html", "")) +
"Template";
}
function getTemplateUrl(sourceLine) {
return _.trim(sourceLine.split(":")[1], "\", ");
}
function hasTemplateUrl(sourceLine) {
return sourceLine.indexOf("templateUrl") !== -1;
}
function findTemplateURLs(sourceCode) {
return sourceCode.split('\n')
.map(_.trim)
.filter(hasTemplateUrl)
.map(getTemplateUrl);
}
function injectRequireArgument(sourceCode, templateUrls) {
var lines = sourceCode.split('\n'),
index;
templateUrls = _.uniq(templateUrls);
// Add arguments for source paths...
index = lines.map(_.trim).indexOf("'legacyRegistry'");
lines = lines.slice(0, index).concat(templateUrls.map(function (url) {
return " \"text!./res/" + url + "\",";
}).concat(lines.slice(index)));
/// ...and for arguments
index = lines.map(_.trim).indexOf("legacyRegistry");
lines = lines.slice(0, index).concat(templateUrls.map(function (url) {
return " " + toTemplateName(url) + ",";
}).concat(lines.slice(index)));
return lines.join('\n');
}
function rewriteUrl(sourceLine) {
return [
sourceLine.substring(0, sourceLine.indexOf(sourceLine.trim())),
"\"template\": " + toTemplateName(getTemplateUrl(sourceLine)),
_.endsWith(sourceLine, ",") ? "," : ""
].join('');
}
function rewriteLine(sourceLine) {
return hasTemplateUrl(sourceLine) ?
rewriteUrl(sourceLine.replace("templateUrl", "template")) :
sourceLine;
}
function rewriteTemplateUrls(sourceCode) {
return sourceCode.split('\n').map(rewriteLine).join('\n');
}
function migrate(file) {
var sourceCode = fs.readFileSync(file, 'utf8');
fs.writeFileSync(file, rewriteTemplateUrls(
injectRequireArgument(sourceCode, findTemplateURLs(sourceCode))
), 'utf8');
}
glob('platform/**/bundle.js', {}, function (err, files) {
if (err) {
console.log(err);
return;
}
files.forEach(migrate);
});

View File

@@ -0,0 +1,34 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global define*/
define([
<%= implPaths %>
'legacyRegistry'
], function (
<%= implNames %>
legacyRegistry
) {
"use strict";
legacyRegistry.register("<%= bundleName %>", <%= bundleContents %>);
});

72
scripts/rebundle.js Normal file
View File

@@ -0,0 +1,72 @@
// Temporary utility script to rewrite bundle.json
// files as bundle.js files.
var glob = require('glob'),
fs = require('fs'),
path = require('path'),
_ = require('lodash'),
template = _.template(
fs.readFileSync(path.resolve(__dirname, 'rebundle-template.txt'), 'utf8')
);
function indent(str, depth) {
return _.trimLeft(str.split('\n').map(function (line) {
return _.repeat(' ', depth || 1) + line;
}).filter(function (line) {
return line.trim().length > 0;
}).join('\n'));
}
function findImpls(bundleContents) {
return _(bundleContents.extensions || {})
.map()
.flatten()
.pluck('implementation')
.filter()
.uniq()
.value();
}
function toIdentifier(impl) {
var parts = impl.replace(".js", "").split('/');
return parts[parts.length - 1];
}
function toPath(impl) {
return "\"./src/" + impl.replace(".js", "") + "\"";
}
function replaceImpls(bundleText) {
var rx = /"implementation": "([^"]*)"/;
return bundleText.split('\n').map(function (line) {
var m = line.match(rx);
return m !== null ?
line.replace(rx, '"implementation": ' + toIdentifier(m[1])) :
line;
}).join('\n');
}
function rebundle(file) {
var plainJson = fs.readFileSync(file, 'utf8'),
bundleContents = JSON.parse(plainJson),
impls = findImpls(bundleContents),
bundleName = file.replace("/bundle.json", ""),
outputFile = file.replace(".json", ".js"),
contents = template({
bundleName: bundleName,
implPaths: indent(impls.map(toPath).concat([""]).join(",\n")),
implNames: indent(impls.map(toIdentifier).concat([""]).join(",\n")),
bundleContents: indent(replaceImpls(JSON.stringify(bundleContents, null, 4)))
});
fs.writeFileSync(outputFile, contents, 'utf8');
}
glob('**/bundle.json', {}, function (err, files) {
if (err) {
console.log(err);
return;
}
files.forEach(rebundle);
});

View File

@@ -177,15 +177,7 @@ define([
CompositionCollection.prototype.load = function () {
return this.provider.load(this.domainObject)
.then(function (children) {
return Promise.all(children.map(function (c) {
return this.publicAPI.objects.get(c);
}, this));
}.bind(this))
.then(function (childObjects) {
childObjects.forEach(function (c) {
this.add(c, true);
}, this);
return childObjects;
return Promise.all(children.map(this.onProviderAdd, this));
}.bind(this))
.then(function (children) {
this.emit('load');

View File

@@ -1,21 +0,0 @@
# URL Indicator
Adds an indicator which shows the availability of a URL, with success based on receipt of a 200 HTTP code. Can be used
for monitoring the availability of web services.
## Installation
```js
openmct.install(openmct.plugins.URLIndicator({
url: 'http://localhost:8080',
iconClass: 'check',
interval: 10000,
label: 'Localhost'
})
);
```
## Options
* __url__: URL to indicate the status of
* __iconClass__: Icon to show in the status bar, defaults to icon-database. See the [Style Guide](https://nasa.github.io/openmct/style-guide/#/browse/styleguide:home/glyphs?view=styleguide.glyphs) for more icon options.
* __interval__: Interval between checking the connection, defaults to 10000
* __label__: Name showing up as text in the status bar, defaults to url

View File

@@ -25,6 +25,15 @@ define([
], function (
AutoflowTabularView
) {
/**
* This plugin provides an Autoflow Tabular View for domain objects
* in Open MCT.
*
* @param {Object} options
* @param {String} [options.type] the domain object type for which
* this view should be available; if omitted, this view will
* be available for all objects
*/
return function (options) {
return function (openmct) {
var views = (openmct.mainViews || openmct.objectViews);

View File

@@ -1,15 +0,0 @@
# Autoflow View
This plugin provides the Autoflow View for domain objects in Open MCT. This view allows users to visualize the latest
values of a collection of telemetry points in a condensed list.
## Installation
``` js
openmct.install(openmct.plugins.AutoflowView({
type: "telemetry.fixed"
}));
```
## Options
* `type`: The object type to add the Autoflow View to. Currently supports a single value. If not provided, will make the
Autoflow view available for all objects (which is probably not what you want).

View File

@@ -1,10 +0,0 @@
# Plot Plugin
Enables plot visualization of telemetry data. This plugin adds a plot view that is available from the view switcher for
all telemetry objects. Two user createble objects are also added by this plugin, for Overlay and Stacked Plots.
Telemetry objects can be added to Overlay and Stacked Plots via drag and drop.
## Installation
``` js
openmct.install(openmct.plugins.Plot());
```

View File

@@ -1,19 +0,0 @@
# Static Root Plugin
This plugin takes an object tree as JSON and exposes it as a non-editable root level tree. This can be useful if you
have static non-editable content that you wish to expose, such as a standard set of displays that should not be edited
(but which can be copied and then modified if desired).
Any object tree in Open MCT can be exported as JSON after installing the
[Import/Export plugin](../../../platform/import-export/README.md).
## Installation
``` js
openmct.install(openmct.plugins.StaticRootPlugin('mission', 'data/static-objects.json'));
```
## Parameters
The StaticRootPlugin takes two parameters:
1. __namespace__: This should be a name that uniquely identifies this collection of objects.
2. __path__: The file that the static tree should be exposed from. This will need to be a path that is reachable by a web
browser, ie not a path on the local file system.

View File

@@ -1,10 +0,0 @@
# Summary Widget Plugin
Summary widgets can be used to provide visual indication of state based on telemetry data. They allow rules to be
defined that can then be used to change the appearance of the summary widget element based on data. For example, a
summary widget could be defined that is green when a temparature reading is between `0` and `100` centigrade, red when
it's above `100`, and orange when it's below `0`.
## Installation
```js
openmct.install(openmct.plugins.SummaryWidget());
```

View File

@@ -67,14 +67,14 @@ requirejs.config({
"lodash": "bower_components/lodash/lodash",
"d3-selection": "node_modules/d3-selection/dist/d3-selection.min",
"d3-scale": "node_modules/d3-scale/build/d3-scale.min",
"d3-axis": "node_modules/d3-axis/dist/d3-axis.min",
"d3-array": "node_modules/d3-array/dist/d3-array.min",
"d3-collection": "node_modules/d3-collection/dist/d3-collection.min",
"d3-axis": "node_modules/d3-axis/build/d3-axis.min",
"d3-array": "node_modules/d3-array/build/d3-array.min",
"d3-collection": "node_modules/d3-collection/build/d3-collection.min",
"d3-color": "node_modules/d3-color/build/d3-color.min",
"d3-format": "node_modules/d3-format/build/d3-format.min",
"d3-interpolate": "node_modules/d3-interpolate/build/d3-interpolate.min",
"d3-time": "node_modules/d3-time/dist/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/dist/d3-time-format.min",
"d3-time": "node_modules/d3-time/build/d3-time.min",
"d3-time-format": "node_modules/d3-time-format/build/d3-time-format.min",
"html2canvas": "node_modules/html2canvas/dist/html2canvas.min",
"painterro": "node_modules/painterro/build/painterro.min",
"printj": "node_modules/printj/dist/printj.min"