Skip to content

Commit

Permalink
Full angular removal (#170)
Browse files Browse the repository at this point in the history
Co-authored-by: David Tsay <[email protected]>
  • Loading branch information
jvigliotta and davetsay authored May 3, 2024
1 parent a4fe8dd commit 65d264f
Show file tree
Hide file tree
Showing 67 changed files with 1,105 additions and 13,455 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ npm-debug.log
# auto-env files for those that use them.
.env
dist
package-lock.json
test_data/
3 changes: 2 additions & 1 deletion .webpack/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ module.exports = merge(common, {
// for dev, we serve out of dist/ so we need to replace any reference
return content.toString().replace(/"dist\//g, '"');
}
}
},
{ from: './ExampleVenueDefinitions.json', to: 'ExampleVenueDefinitions.json' }
]
})
],
Expand Down
21 changes: 1 addition & 20 deletions loader.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
define([
'openmct',
'./src/AMMOSPlugins',
'./src/legacy/export/bundle',
'./src/legacy/products/bundle',
'./src/legacy/table/bundle',
'./src/legacy/general/res/sass/vista.scss',
'./src/styles/sass/vista.scss',
'./src/commandEventsView/plugin',
'./src/messagesView/plugin',
'./src/product-status/plugin',
'./about.html',
'./src/metadataAction/plugin',
'./src/clearDataIndicator/plugin',
'./src/globalStaleness/plugin',
'./src/dictionaryView/plugin',
'./src/packetSummary/plugin',
'./src/containerView/plugin',
'openmct-legacy-support',
'services/identity/MCWSIdentityProvider',
'./src/persistence/plugin'
], function (
openmct,
AMMOSPlugins,
exportBundle,
productsBundle,
legacyTablesBundle,
VistaStyles, /** Do not delete, needed for webpack to compile scss file*/
CommandEventsViewPlugin,
MessagesPlugin,
ProductStatusPlugin,
AboutTemplate,
MetadataActionPlugin,
ClearDataIndicator,
GlobalStalenessPlugin,
DictionaryViewPlugin,
PacketSummaryPlugin,
ContainerViewPlugin,
LegacySupport,
IdentityProvider,
MCWSPersistenceProviderPlugin
) {
Expand All @@ -47,8 +37,6 @@ define([
});
openmct.setAssetPath(config.assetPath);

openmct.install(LegacySupport.default());

//Optional Themes
if (config.theme) {
openmct.install(openmct.plugins[config.theme]());
Expand Down Expand Up @@ -82,7 +70,6 @@ define([
}
));
openmct.install(ClearDataIndicator.default(config.globalStalenessInterval));
openmct.install(GlobalStalenessPlugin.default(config.globalStalenessInterval));
openmct.install(CommandEventsViewPlugin.default());
openmct.install(MessagesPlugin.default());
openmct.install(ProductStatusPlugin.default());
Expand Down Expand Up @@ -112,12 +99,6 @@ define([
});
}

[
exportBundle,
productsBundle,
legacyTablesBundle
].forEach(openmct.install, openmct);

if (config.plugins) {
if (config.plugins.summaryWidgets) {
openmct.install(openmct.plugins.SummaryWidget());
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "Open MCT for MCWS",
"devDependencies": {
"@braintree/sanitize-url": "6.0.2",
"axios": "^0.21.2",
"babel-loader": "8.2.3",
"babel-plugin-istanbul": "6.1.1",
"bower": "^1.7.7",
Expand Down Expand Up @@ -33,7 +32,6 @@
"moment": "2.29.4",
"node-bourbon": "^4.2.3",
"openmct": "nasa/openmct#omm-r5.2.0-rc2",
"openmct-legacy-support": "akhenry/openmct-legacy-support#omm-r5.1.0-rc1",
"printj": "^1.2.1",
"raw-loader": "^0.5.1",
"resolve-url-loader": "5.0.0",
Expand Down
29 changes: 23 additions & 6 deletions src/AMMOSPlugins.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define([
'services/dataset/DatasetCache',
'services/session/SessionService',
'services/globalStaleness/globalStaleness',
'./types/plugin',
'./taxonomy/plugin',
'./time/plugin',
Expand Down Expand Up @@ -30,10 +31,12 @@ define([
'./mcwsIndicator/plugin',
'./multipleHistoricalSessions/plugin',
'./realtimeSessions/plugin',
'./globalFilters/plugin'
'./globalFilters/plugin',
'./exportDataAction/plugin'
], function (
DatasetCache,
SessionService,
GlobalStaleness,
TypePlugin,
TaxonomyPlugin,
TimePlugin,
Expand Down Expand Up @@ -63,18 +66,20 @@ define([
MCWSIndicatorPlugin,
MultipleHistoricalSessions,
RealtimeSessions,
GlobalFilters
GlobalFilters,
ExportDataAction
) {

function AMMOSPlugins(options) {
return function install(openmct) {
// initialze session service and datasetCache service
// initialze session service, datasetCache service, global staleness
SessionService.default(openmct, options);
DatasetCache.default(openmct);
GlobalStaleness.default(openmct, options.globalStalenessInterval);

openmct.install(new FormatPlugin(options));

const timePlugin = new TimePlugin(options.time);
const timePlugin = new TimePlugin(openmct, options.time);
openmct.install(timePlugin);

const formatKey = options.time.utcFormat;
Expand All @@ -97,10 +102,10 @@ define([

openmct.install(new HistoricalTelemetryPlugin(options));
openmct.install(new RealtimeTelemetryPlugin(vistaTime, options));
openmct.install(new TypePlugin(options));
openmct.install(new TypePlugin.default());
openmct.install(new TaxonomyPlugin(options.taxonomy));
openmct.install(new LinkPlugin(options));
openmct.install(new VenuePlugin(options));
openmct.install(new VenuePlugin.default(options));
openmct.install(FrameWatchViewPlugin.default());
openmct.install(FrameEventFilterViewPlugin.default());
openmct.install(new ChannelTablePlugin.default());
Expand Down Expand Up @@ -128,6 +133,18 @@ define([
openmct.install(CustomFormsPlugin.default());

openmct.install(openmct.plugins.DefaultRootName('VISTA'));
openmct.install(new ExportDataAction.default([
'table',
'telemetry.plot.overlay',
'telemetry.plot.stacked',
'vista.channel',
'vista.channelGroup',
'vista.chanTableGroup',
'vista.evr',
'vista.evrModule',
'vista.evrSource',
'vista.evrView'
]));
openmct.install(ActionModifiersPlugin.default());
openmct.install(new PacketQueryPlugin.default());
if (options.globalFilters) {
Expand Down
84 changes: 84 additions & 0 deletions src/exportDataAction/ExportDataAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import ExportDataTask from './ExportDataTask';

/**
* Implements the "Export Data" action, allowing data for Channels, EVRs,
* or grouped containers of these to be exported as CSV using ES6 class syntax.
*
* @param {openmct} openmct instance
* @memberof vista/export
*/
class ExportDataAction {
constructor(openmct, validTypes) {
this.name = 'Export Historical Data';
this.key = 'vista.export';
this.description = 'Export channel or EVR data as CSV';
this.cssClass = 'icon-download';
this.group = 'view';
this.priority = 1;
this.validTypes = validTypes;

this.openmct = openmct;
}

appliesTo(objectPath) {
const domainObject = objectPath[0];

if (this.isValidType(domainObject)) {
return true;
}

return false;
}

async invoke(objectPath) {
const domainObject = objectPath[0];
const progressDialog = this.openmct.notifications.progress('Exporting CSV', 'unknown');

try {
await this.exportData(domainObject);
} catch (error) {
console.error(error);
this.openmct.notifications.error('Error exporting CSV');
} finally {
progressDialog.dismiss();
}
}

async exportData(domainObject) {
if (this.hasHistoricalTelemetry(domainObject)) {
await this.runExportTask([domainObject]);
} else {
await this.exportCompositionData(domainObject);
}
}

async exportCompositionData(domainObject) {
const compositionCollection = this.openmct.composition.get(domainObject);
const composition = await compositionCollection.load();
const filteredComposition = composition.filter(obj =>
this.isValidType(obj) && this.hasHistoricalTelemetry(obj)
);

if (filteredComposition.length > 0) {
await this.runExportTask(filteredComposition);
} else {
this.openmct.notifications.info('No historical data to export');
}
}

runExportTask(domainObjects) {
const task = new ExportDataTask(this.openmct, domainObjects[0].name, domainObjects);

return task.invoke();
}

isValidType(domainObject) {
return this.validTypes.includes(domainObject?.type);
}

hasHistoricalTelemetry(domainObject) {
return this.openmct.telemetry.isTelemetryObject(domainObject) && !domainObject.telemetry.realtimeOnly;
}
}

export default ExportDataAction;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define([
], function (ExportDataAction) {
'use strict';

describe("The Export Data action", function () {
xdescribe("The Export Data action", function () {
var mockExportService,
openmct,
mockTelemetryObject,
Expand Down
62 changes: 62 additions & 0 deletions src/exportDataAction/ExportDataTask.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import CSV from 'comma-separated-values';
import {saveAs} from 'saveAs';

export default class ExportDataTask {
/**
* Exports telemetry data to CSV for a group of domain objects.
* Used to support the "Export Data" action.
* @see {vista/export.ExportDataAction}
* @param {DomainObject[]} domainObjects the domain object for which
* telemetry data should be exported
*/
constructor(openmct, filename, domainObjects) {
this.openmct = openmct;
this.filename = filename;
this.domainObjects = domainObjects;
}

/**
* Query for telemetry data and export it to CSV.
* @returns {Promise} a promise which will resolve when the export is
* successfully completed, or be rejected if an error occurs
*/
async invoke() {
const telemetryData = await this.fetchAllTelemetryData();
const headers = this.extractHeaders(telemetryData);
const allTelemetry = telemetryData.flat();

return this.exportAsCSV(allTelemetry, headers);
}

async fetchAllTelemetryData() {
return Promise.all(this.domainObjects.map(async (domainObject) => {
return this.openmct.telemetry.request(domainObject, { strategy: 'comprehensive' });
}));
}

extractHeaders(telemetryData) {
const headerSet = new Set();
telemetryData.forEach(data => {
const datum = data[0] || {};
Object.keys(datum).forEach(key => headerSet.add(key));
});
return Array.from(headerSet);
}

exportAsCSV(rows, headers) {
const options = {
headers: headers,
filename: this.filename
};
return this.exportCSV(rows, options);
}

exportCSV(rows, options) {
const headers = options.headers || Object.keys((rows[0] || {})).sort();
const filename = `${options.filename || 'export'}.csv`;
const csvText = new CSV(rows, { header: headers }).encode();
const blob = new Blob([csvText], { type: "text/csv" });
saveAs(blob, filename);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define([
], function (ExportDataTask) {
'use strict';

describe("ExportDataTask", function () {
xdescribe("ExportDataTask", function () {
var testIds,
testTelemetryData,
mockExportService,
Expand Down
8 changes: 8 additions & 0 deletions src/exportDataAction/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ExportDataAction from './ExportDataAction';

export default function (validTypes) {
return function (openmct) {
openmct.actions.register(new ExportDataAction(openmct, validTypes));
};
}

24 changes: 0 additions & 24 deletions src/globalStaleness/globalStaleness.js

This file was deleted.

Loading

0 comments on commit 65d264f

Please sign in to comment.