Merge branch 'master' into one-weird-trick

This commit is contained in:
Andrew Henry 2023-08-22 11:25:32 -07:00
commit cfdc6d7f20
22 changed files with 164 additions and 75 deletions

5
.npmrc
View File

@ -1,4 +1,7 @@
loglevel=warn
#Prevent folks from ignoring an important error when building from source
engine-strict=true
engine-strict=true
# Dont include lockfile
package-lock=false

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
lts/*

View File

@ -18,11 +18,12 @@ Building and running Open MCT in your local dev environment is very easy. Be sur
`git clone https://github.com/nasa/openmct.git`
2. Install development dependencies. Note: Check the package.json engine for our tested and supported node versions.
2. (Optionally) Install the correct node version using [nvm](https://github.com/nvm-sh/nvm) (`nvm install`)
3. Install development dependencies. Note: Check the package.json engine for our tested and supported node versions.
`npm install`
3. Run a local development server
4. Run a local development server
`npm start`
@ -51,6 +52,8 @@ For more on developing with Open MCT, see our documentation for a guide on [Deve
This is a fast moving project and we do our best to test and support the widest possible range of browsers, operating systems, and nodejs APIs. We have a published list of support available in our package.json's `browserslist` key.
The project uses `nvm` to ensure the node and npm version used, is coherent in all projects. Install nvm (non-windows), [here](https://github.com/nvm-sh/nvm) or the windows equivalent [here](https://github.com/coreybutler/nvm-windows)
If you encounter an issue with a particular browser, OS, or nodejs API, please file a [GitHub issue](https://github.com/nasa/openmct/issues/new/choose)
## Plugins

View File

@ -28,7 +28,7 @@
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<title></title>
<title>Open MCT</title>
<script src="dist/openmct.js"></script>
<link
rel="icon"
@ -51,7 +51,7 @@
sizes="16x16"
type="image/x-icon"
/>
<style type="text/css">
<style>
@keyframes splash-spinner {
0% {
transform: translate(-50%, -50%) rotate(0deg);

View File

@ -111,6 +111,7 @@
"cov:unit:publish": "codecov --disable=gcov -f ./coverage/unit/lcov.info -F unit",
"prepare": "npm run build:prod && npx tsc"
},
"homepage": "https://nasa.github.io/openmct",
"repository": {
"type": "git",
"url": "https://github.com/nasa/openmct.git"
@ -126,6 +127,12 @@
"ios_saf >= 16",
"Safari >= 16"
],
"author": "National Aeronautics and Space Administration",
"license": "Apache-2.0"
"author": {
"name": "National Aeronautics and Space Administration",
"url": "https://www.nasa.gov"
},
"license": "Apache-2.0",
"keywords": [
"nasa"
]
}

View File

@ -554,28 +554,34 @@ export default class ObjectAPI {
*/
async getTelemetryPath(identifier, telemetryIdentifier) {
const objectDetails = await this.get(identifier);
const telemetryPath = [];
if (objectDetails.composition && !['folder'].includes(objectDetails.type)) {
let sourceTelemetry = objectDetails.composition[0];
let telemetryPath = [];
if (objectDetails?.type === 'folder') {
return telemetryPath;
}
let sourceTelemetry = null;
if (telemetryIdentifier && utils.identifierEquals(identifier, telemetryIdentifier)) {
sourceTelemetry = identifier;
} else if (objectDetails.composition) {
sourceTelemetry = objectDetails.composition[0];
if (telemetryIdentifier) {
sourceTelemetry = objectDetails.composition.find(
(telemetrySource) =>
this.makeKeyString(telemetrySource) === this.makeKeyString(telemetryIdentifier)
sourceTelemetry = objectDetails.composition.find((telemetrySource) =>
utils.identifierEquals(telemetrySource, telemetryIdentifier)
);
}
const compositionElement = await this.get(sourceTelemetry);
if (!['yamcs.telemetry', 'generator'].includes(compositionElement.type)) {
return telemetryPath;
}
const telemetryKey = compositionElement.identifier.key;
const telemetryPathObjects = await this.getOriginalPath(telemetryKey);
telemetryPathObjects.forEach((pathObject) => {
if (pathObject.type === 'root') {
return;
}
telemetryPath.unshift(pathObject.name);
});
}
const compositionElement = await this.get(sourceTelemetry);
if (!['yamcs.telemetry', 'generator', 'yamcs.aggregate'].includes(compositionElement.type)) {
return telemetryPath;
}
const telemetryPathObjects = await this.getOriginalPath(compositionElement.identifier);
telemetryPath = telemetryPathObjects
.reverse()
.filter((pathObject) => pathObject.type !== 'root')
.map((pathObject) => pathObject.name);
return telemetryPath;
}

View File

@ -57,13 +57,22 @@ class TooltipAPI {
* @private for platform-internal use
*/
showTooltip(tooltip) {
this.removeAllTooltips();
this.activeToolTips.push(tooltip);
tooltip.show();
}
/**
* API method to allow for removing all tooltips
*/
removeAllTooltips() {
if (!this.activeToolTips?.length) {
return;
}
for (let i = this.activeToolTips.length - 1; i > -1; i--) {
this.activeToolTips[i].destroy();
this.activeToolTips.splice(i, 1);
}
this.activeToolTips.push(tooltip);
tooltip.show();
}
/**

View File

@ -3,6 +3,7 @@
height: auto;
width: auto;
padding: $interiorMargin;
overflow-wrap: break-word;
}
.c-tooltip {

View File

@ -68,7 +68,12 @@ define([], function () {
this.updateRowData.bind(this)
);
this.openmct.telemetry.request(this.domainObject, { size: 1 }).then(
const options = {
size: 1,
strategy: 'latest',
timeContext: this.openmct.time.getContextForView([])
};
this.openmct.telemetry.request(this.domainObject, options).then(
function (history) {
if (!this.initialized && history.length > 0) {
this.updateRowData(history[history.length - 1]);

View File

@ -98,9 +98,11 @@ export default function () {
};
function getScatterPlotFormControl(openmct) {
let destroyComponent;
return {
show(element, model, onChange) {
const { vNode } = mount(
const { vNode, destroy } = mount(
{
el: element,
components: {
@ -122,8 +124,12 @@ export default function () {
element
}
);
destroyComponent = destroy;
return vNode;
},
destroy() {
destroyComponent();
}
};
}

View File

@ -30,7 +30,7 @@ export default function plugin(appliesToObjects, options = { indicator: true })
return function install(openmct) {
if (installIndicator) {
const { vNode } = mount(
const { vNode, destroy } = mount(
{
components: {
GlobalClearIndicator
@ -49,7 +49,8 @@ export default function plugin(appliesToObjects, options = { indicator: true })
let indicator = {
element: vNode.el,
key: 'global-clear-indicator',
priority: openmct.priority.DEFAULT
priority: openmct.priority.DEFAULT,
destroy: destroy
};
openmct.indicators.add(indicator);

View File

@ -167,9 +167,11 @@ export default function () {
};
function getGaugeFormController(openmct) {
let destroyComponent;
return {
show(element, model, onChange) {
const { vNode } = mount(
const { vNode, destroy } = mount(
{
el: element,
components: {
@ -191,8 +193,12 @@ export default function () {
element
}
);
destroyComponent = destroy;
return vNode.componentInstance;
},
destroy() {
destroyComponent();
}
};
}

View File

@ -638,7 +638,11 @@ export default {
this.valueKey = this.metadata.valuesForHints(['range'])[0].source;
this.openmct.telemetry.request(domainObject, { strategy: 'latest' }).then((values) => {
const options = {
strategy: 'latest',
timeContext: this.openmct.time.getContextForView([])
};
this.openmct.telemetry.request(domainObject, options).then((values) => {
const length = values.length;
this.updateValue(values[length - 1]);
});

View File

@ -98,6 +98,9 @@ export default {
if (this.unlisten) {
this.unlisten();
}
if (this.destroyImageryContainer) {
this.destroyImageryContainer();
}
},
methods: {
setTimeContext() {
@ -237,7 +240,10 @@ export default {
imageryContainer = existingContainer;
imageryContainer.style.maxWidth = `${containerWidth}px`;
} else {
const { vNode } = mount(
if (this.destroyImageryContainer) {
this.destroyImageryContainer();
}
const { vNode, destroy } = mount(
{
components: {
SwimLane
@ -257,6 +263,7 @@ export default {
}
);
this.destroyImageryContainer = destroy;
const component = vNode.componentInstance;
this.$refs.imageryHolder.appendChild(component.$el);

View File

@ -90,7 +90,10 @@ export default {
drawerElement.innerHTML = '<div></div>';
const divElement = document.querySelector('.l-shell__drawer div');
mount(
if (this.destroySnapshotContainer) {
this.destroySnapshotContainer();
}
const { destroy } = mount(
{
el: divElement,
components: {
@ -113,6 +116,7 @@ export default {
element: divElement
}
);
this.destroySnapshotContainer = destroy;
},
updateSnapshotIndicatorTitle() {
const snapshotCount = this.snapshotContainer.getSnapshots().length;

View File

@ -83,7 +83,7 @@ function installBaseNotebookFunctionality(openmct) {
openmct.actions.register(new CopyToNotebookAction(openmct));
openmct.actions.register(new ExportNotebookAsTextAction(openmct));
const { vNode } = mount(
const { vNode, destroy } = mount(
{
components: {
NotebookSnapshotIndicator
@ -102,7 +102,8 @@ function installBaseNotebookFunctionality(openmct) {
const indicator = {
element: vNode.el,
key: 'notebook-snapshot-indicator',
priority: openmct.priority.DEFAULT
priority: openmct.priority.DEFAULT,
destroy: destroy
};
openmct.indicators.add(indicator);

View File

@ -24,7 +24,7 @@ import NotificationIndicator from './components/NotificationIndicator.vue';
export default function plugin() {
return function install(openmct) {
const { vNode } = mount(
const { vNode, destroy } = mount(
{
components: {
NotificationIndicator
@ -42,7 +42,8 @@ export default function plugin() {
let indicator = {
key: 'notifications-indicator',
element: vNode.el,
priority: openmct.priority.DEFAULT
priority: openmct.priority.DEFAULT,
destroy: destroy
};
openmct.indicators.add(indicator);
};

View File

@ -43,6 +43,14 @@ sh ./src/plugins/persistence/couch/replace-localstorage-with-couchdb-indexhtml.s
Open MCT will now use your local CouchDB container as its persistence store. Access the CouchDB instance manager by visiting <http://localhost:5984/_utils>.
### Removing CouchDB Container completely
To completely remove the CouchDB container and volumes:
```sh
docker stop couch-couchdb-1;docker rm couch-couchdb-1;docker volume rm couch_couchdb
```
## macOS
While we highly recommend using the CouchDB docker-compose installation, it is still possible to install CouchDB through other means.

View File

@ -18,7 +18,6 @@ if [ "${COUCH_ADMIN_PASSWORD}" ]; then
CURL_USERPASS_ARG+=":${COUCH_ADMIN_PASSWORD}"
fi
# Functions
resource_exists() {
response=$(curl -u "${CURL_USERPASS_ARG}" -s -o /dev/null -I -w "%{http_code}" $1);
if [ "200" == "${response}" ]; then
@ -29,16 +28,16 @@ resource_exists() {
}
db_exists() {
resource_exists $COUCH_BASE_LOCAL/$OPENMCT_DATABASE_NAME
resource_exists "$COUCH_BASE_LOCAL"/"$OPENMCT_DATABASE_NAME"
}
create_db() {
response=$(curl -su "${CURL_USERPASS_ARG}" -XPUT $COUCH_BASE_LOCAL/$OPENMCT_DATABASE_NAME);
echo $response
response=$(curl -su "${CURL_USERPASS_ARG}" -XPUT "$COUCH_BASE_LOCAL"/"$OPENMCT_DATABASE_NAME");
echo "$response"
}
admin_user_exists() {
response=$(curl -su "${CURL_USERPASS_ARG}" -o /dev/null -I -w "%{http_code}" $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/admins/$COUCH_ADMIN_USER);
response=$(curl -su "${CURL_USERPASS_ARG}" -o /dev/null -I -w "%{http_code}" "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/admins/"$COUCH_ADMIN_USER");
if [ "200" == "${response}" ]; then
echo "TRUE"
else
@ -48,26 +47,26 @@ admin_user_exists() {
create_admin_user() {
echo Creating admin user
curl -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/admins/$COUCH_ADMIN_USER -d \'"$COUCH_ADMIN_PASSWORD"\'
curl -X PUT "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/admins/"$COUCH_ADMIN_USER" -d \'"$COUCH_ADMIN_PASSWORD"\'
}
is_cors_enabled() {
resource_exists $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/httpd/enable_cors
resource_exists "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/httpd/enable_cors
}
enable_cors() {
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/httpd/enable_cors -d '"true"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/origins -d '"*"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/credentials -d '"true"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/methods -d '"GET, PUT, POST, HEAD, DELETE"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT $COUCH_BASE_LOCAL/_node/$COUCH_NODE_NAME/_config/cors/headers -d '"accept, authorization, content-type, origin, referer, x-csrf-token"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/httpd/enable_cors -d '"true"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/cors/origins -d '"*"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/cors/credentials -d '"true"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/cors/methods -d '"GET, PUT, POST, HEAD, DELETE"'
curl -su "${CURL_USERPASS_ARG}" -o /dev/null -X PUT "$COUCH_BASE_LOCAL"/_node/"$COUCH_NODE_NAME"/_config/cors/headers -d '"accept, authorization, content-type, origin, referer, x-csrf-token"'
}
update_db_permissions() {
local db_name=$1
echo "Updating ${db_name} database permissions"
response=$(curl -su "${CURL_USERPASS_ARG}" --location \
--request PUT $COUCH_BASE_LOCAL/$db_name/_security \
--request PUT "$COUCH_BASE_LOCAL"/"$db_name"/_security \
--header 'Content-Type: application/json' \
--data-raw '{ "admins": {"roles": []},"members": {"roles": []}}')
if [ "{\"ok\":true}" == "${response}" ]; then
@ -77,17 +76,24 @@ update_db_permissions() {
fi
}
create_system_tables() {
local system_tables=("_users" "_replicator")
for table in "${system_tables[@]}"; do
echo "Creating $table database"
response=$(curl -su "${CURL_USERPASS_ARG}" -X PUT $COUCH_BASE_LOCAL/$table)
if [ "{\"ok\":true}" == "${response}" ]; then
echo "Successfully created $table database"
else
echo "Unable to create $table database"
fi
done
create_users_table() {
echo "Creating _users database"
response=$(curl -su "${CURL_USERPASS_ARG}" -XPUT "$COUCH_BASE_LOCAL"/_users)
if [ "{\"ok\":true}" == "${response}" ]; then
echo "Successfully created _users database"
else
echo "Unable to create _users database"
fi
}
create_replicator_table() {
echo "Creating _replicator database"
response=$(curl -su "${CURL_USERPASS_ARG}" -XPUT "$COUCH_BASE_LOCAL"/_replicator)
if [ "{\"ok\":true}" == "${response}" ]; then
echo "Successfully created _replicator database"
else
echo "Unable to create _replicator database"
fi
}
# Main script execution
@ -100,17 +106,24 @@ else
echo "Admin user exists"
fi
# Check if system tables exist; if not, create them.
system_tables_exist=$(resource_exists $COUCH_BASE_LOCAL/_users)
if [ "TRUE" == "${system_tables_exist}" ]; then
echo "System tables exist, skipping creation"
# Check if the _users table exists; if not, create it.
users_table_exists=$(resource_exists "$COUCH_BASE_LOCAL"/_users)
if [ "FALSE" == "${users_table_exists}" ]; then
create_users_table
else
echo "Fresh install, creating system tables"
create_system_tables
echo "_users database already exists, skipping creation"
fi
# Check if the _replicator database exists; if not, create it.
replicator_table_exists=$(resource_exists "$COUCH_BASE_LOCAL/_replicator")
if [ "FALSE" == "${replicator_table_exists}" ]; then
create_replicator_table
else
echo "_replicator database already exists, skipping creation"
fi
# Check if the database exists; if not, create it.
if [ "FALSE" == $(db_exists) ]; then
if [ "FALSE" == "$(db_exists)" ]; then
response=$(create_db)
if [ "{\"ok\":true}" == "${response}" ]; then
echo "Database successfully created"
@ -126,7 +139,7 @@ update_db_permissions "_replicator"
update_db_permissions "${OPENMCT_DATABASE_NAME}"
# Check if CORS is enabled; if not, enable it.
if [ "FALSE" == $(is_cors_enabled) ]; then
if [ "FALSE" == "$(is_cors_enabled)" ]; then
echo "Enabling CORS"
enable_cors
else

View File

@ -197,7 +197,7 @@ export default {
this.composition.load();
}
const { vNode } = mount(
const { vNode, destroy } = mount(
{
components: {
Plot
@ -249,6 +249,7 @@ export default {
}
);
this.component = vNode.componentInstance;
this._destroy = destroy;
if (this.isEditing) {
this.setSelection();

View File

@ -25,7 +25,7 @@ import UserIndicator from './components/UserIndicator.vue';
export default function UserIndicatorPlugin() {
function addIndicator(openmct) {
const { vNode } = mount(
const { vNode, destroy } = mount(
{
components: {
UserIndicator
@ -43,7 +43,8 @@ export default function UserIndicatorPlugin() {
openmct.indicators.add({
key: 'user-indicator',
element: vNode.el,
priority: openmct.priority.HIGH
priority: openmct.priority.HIGH,
destroy: destroy
});
}

View File

@ -25,6 +25,7 @@
&__bar {
background: $colorProgressBar;
height: 100%;
min-height: $progressBarMinH;
&.--indeterminate {
position: absolute;