Merge pull request #1400 from nasa/plugins-1398

[Plugins] Adapt legacy plugins
This commit is contained in:
Pete Richards 2017-01-17 13:22:24 -08:00 committed by GitHub
commit 290dd0abf0
4 changed files with 81 additions and 12 deletions

15
API.md
View File

@ -269,12 +269,27 @@ The plugin will be invoked to configure Open MCT before it is started.
Open MCT is packaged along with a few general-purpose plugins: Open MCT is packaged along with a few general-purpose plugins:
* `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.
`openmct.install(new 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, e.g.
`openmct.install(new openmct.plugins.CouchDB('http://localhost:9200'))`.
Domain objects will be indexed at `/mct/domain_object`.
* `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.localStorage` provides persistence of user-created * `openmct.plugins.localStorage` provides persistence of user-created
objects in browser-local storage. This is particularly useful in objects in browser-local storage. This is particularly useful in
development environments. development environments.
* `openmct.plugins.myItems` adds a top-level folder named "My Items" * `openmct.plugins.myItems` adds a top-level folder named "My Items"
when the application is first started, providing a place for a when the application is first started, providing a place for a
user to store created items. user to store created items.
* `openmct.plugins.utcTimeSystem` provides support for using the time
conductor with UTC time.
Generally, you will want to either install these plugins, or install Generally, you will want to either install these plugins, or install
different plugins that provide persistence and an initial folder different plugins that provide persistence and an initial folder

View File

@ -32,12 +32,13 @@
[ [
'example/imagery', 'example/imagery',
'example/eventGenerator', 'example/eventGenerator',
'example/generator', 'example/generator'
'platform/features/my-items',
'platform/persistence/local'
].forEach( ].forEach(
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry) openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
); );
openmct.install(openmct.plugins.myItems);
openmct.install(openmct.plugins.localStorage);
openmct.install(openmct.plugins.espresso);
openmct.start(); openmct.start();
}); });
</script> </script>

View File

@ -109,7 +109,6 @@ define([
'platform/commonUI/general', 'platform/commonUI/general',
'platform/commonUI/inspect', 'platform/commonUI/inspect',
'platform/commonUI/mobile', 'platform/commonUI/mobile',
'platform/commonUI/themes/espresso',
'platform/commonUI/notification', 'platform/commonUI/notification',
'platform/containment', 'platform/containment',
'platform/execution', 'platform/execution',

View File

@ -21,13 +21,67 @@
*****************************************************************************/ *****************************************************************************/
define([ define([
], function () { 'lodash'
return { ], function (_) {
localStorage: function (openmct) { var bundleMap = {
openmct.legacyRegistry.enable('platform/persistence/local'); couchDB: 'platform/persistence/couch',
}, elasticsearch: 'platform/persistence/elastic',
myItems: function (openmct) { espresso: 'platform/commonUI/themes/espresso',
openmct.legacyRegistry.enable('platform/features/my-items'); localStorage: 'platform/persistence/local',
} myItems: 'platform/features/my-items',
snow: 'platform/commonUI/themes/snow',
utcTimeSystem: 'platform/features/conductor/utcTimeSystem'
}; };
var plugins = _.mapValues(bundleMap, function (bundleName, pluginName) {
return function (openmct) {
openmct.legacyRegistry.enable(bundleName);
};
});
plugins.CouchDB = function (url) {
return function (openmct) {
if (url) {
var bundleName = "config/couch";
openmct.legacyRegistry.register(bundleName, {
"extensions": {
"constants": [
{
"key": "COUCHDB_PATH",
"value": url,
"priority": "mandatory"
}
]
}
});
openmct.legacyRegistry.enable(bundleName);
}
openmct.legacyRegistry.enable(bundleMap.couchDB);
};
};
plugins.Elasticsearch = function (url) {
return function (openmct) {
if (url) {
var bundleName = "config/elastic";
openmct.legacyRegistry.register(bundleName, {
"extensions": {
"constants": [
{
"key": "ELASTIC_ROOT",
"value": url,
"priority": "mandatory"
}
]
}
});
openmct.legacyRegistry.enable(bundleName);
}
openmct.legacyRegistry.enable(bundleMap.elasticsearch);
};
};
return plugins;
}); });