-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathplugin.js
More file actions
291 lines (265 loc) · 10.8 KB
/
plugin.js
File metadata and controls
291 lines (265 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
import AboutTemplate from './about.html';
// eslint-disable-next-line no-unused-vars
import VistaStyles from './src/styles/sass/vista.scss'; /** Do not delete, needed for webpack to compile scss file*/
import CommandEventsViewPlugin from './src/commandEventsView/plugin.js';
import TaxonomyPlugin from './src/taxonomy/plugin.js';
import HistoricalTelemetryPlugin from './src/historical/plugin.js';
import LinkPlugin from './src/link/plugin.js';
import FormatPlugin from './src/formats/plugin.js';
import MessagesPlugin from './src/messagesView/plugin.js';
import ProductStatusPlugin from './src/product-status/plugin.js';
import MetadataActionPlugin from './src/metadataAction/plugin.js';
import ClearDataIndicatorPlugin from './src/clearDataIndicator/plugin.js';
import DictionaryViewPlugin from './src/dictionaryView/plugin.js';
import PacketSummaryPlugin from './src/packetSummary/plugin.js';
import ContainerViewPlugin from './src/containerView/plugin.js';
import IdentityProvider from './src/services/identity/MCWSIdentityProvider.js';
import MCWSPersistenceProviderPlugin from './src/persistence/plugin.js';
import DatasetCache from './src/services/dataset/DatasetCache.js';
import SessionService from './src/services/session/SessionService.js';
import GlobalStaleness from './src/services/globalStaleness/globalStaleness.js';
import TypePlugin from './src/types/plugin.js';
import TimePlugin from './src/time/plugin.js';
import getVistaTime from './src/services/time/vistaTime.js';
import RealtimeTelemetryPlugin from './src/realtime/plugin.js';
import VenuePlugin from './src/venues/plugin.js';
import mcwsClient from './src/services/mcws/MCWSClient.js';
import UTCDayOfYearFormat from './src/formats/UTCDayOfYearFormat.js';
import FrameWatchViewPlugin from './src/frameSummary/plugin.js';
import FrameEventFilterViewPlugin from './src/frameEventFilterView/plugin.js';
import ChannelTablePlugin from './src/channelTable/channelTablePlugin/plugin.js';
import ChannelTableSetPlugin from './src/channelTable/channelTableSetPlugin/plugin.js';
import ChannelLimitsPlugin from './src/channelLimits/plugin.js';
import FrameAccountabilityPlugin from './src/frameAccountability/plugin.js';
import AlarmsViewPlugin from './src/alarmsView/plugin.js';
import EVRViewPlugin from './src/evrView/plugin.js';
import CustomFormatterPlugin from './src/customFormatter/plugin.js';
import CustomFormsPlugin from './src/customForms/plugin.js';
import ActionModifiersPlugin from './src/actionModifiers/plugin.js';
import RealtimeIndicatorPlugin from './src/realtimeIndicator/plugin.js';
import PacketQueryPlugin from './src/packetQuery/plugin.js';
import MCWSIndicatorPlugin from './src/mcwsIndicator/plugin.js';
import MultipleHistoricalSessions from './src/multipleHistoricalSessions/plugin.js';
import MessageStreamProcessor from './src/messageStreamProcessor/MessageStreamProcessor.js';
import RealtimeSessions from './src/realtimeSessions/plugin.js';
import GlobalFilters from './src/globalFilters/plugin.js';
import ExportDataAction from './src/exportDataAction/plugin.js';
export default function openmctMCWSPlugin(options) {
return function install(openmct) {
const defaultConfig = {
venueAware: {
enabled: false,
venues: 'ExampleVenueDefinitions.json'
},
namespaces: [
{
key: 'dev',
name: 'Shared',
url: ''
},
{
userNamespace: true,
key: 'dev',
name: 'Users',
url: ''
}
],
taxonomy: {
evrDefaultBackgroundColor: undefined,
evrDefaultForegroundColor: undefined,
evrBackgroundColorByLevel: {
FATAL: '#ff0000',
WARNING_HI: '#ff7f24',
WARNING_LO: '#ffff00',
COMMAND: '#00bfff',
ACTIVITY_HI: '#6d6d6d',
ACTIVITY_LO: '#dcdcdc',
DIAGNOSTIC: '#00ff00',
EVR_UNKNOWN: '#00ff00',
FAULT: '#ff0000',
WARNING: '#ff7f24'
},
evrForegroundColorByLevel: {
FATAL: '#ffffff',
WARNING_HI: '#000000',
WARNING_LO: '#000000',
COMMAND: '#ffffff',
ACTIVITY_HI: '#ffffff',
ACTIVITY_LO: '#000000',
DIAGNOSTIC: '#000000',
EVR_UNKNOWN: '#000000',
FAULT: '#ffffff',
WARNING: '#000000'
}
},
time: {
defaultMode: 'fixed',
utcFormat: 'utc.day-of-year',
lmstEpoch: Date.UTC(2020, 2, 18, 0, 0, 0),
subscriptionMCWSFilterDelay: 100,
timeSystems: ['scet', 'ert'],
allowRealtime: true,
allowLAD: true,
records: 10
},
sessionHistoricalMaxResults: 100,
batchHistoricalChannelQueries: false,
disableSortParam: false,
messageStreamUrl: '',
messageTypeFilters: [],
frameAccountabilityExpectedVcidList: [],
queryTimespanLimit: undefined,
globalStalenessInterval: undefined,
customFormatters: [],
sessions: {
historicalSessionFilter: {
disable: false,
maxRecords: 100,
denyUnfilteredQueries: false
},
realtimeSession: {
disable: false
}
},
tablePerformanceOptions: {
telemetryMode: 'unlimited',
persistModeChange: false,
rowLimit: 50
},
assetPath: 'node_modules/openmct/dist',
mcwsPluginAssetPath: 'node_modules/openmct-mcws-plugin/dist'
};
// Deep merge function
function deepMerge(target, source) {
const output = Object.assign({}, target);
if (isObject(target) && isObject(source)) {
Object.keys(source).forEach((key) => {
if (isObject(source[key])) {
if (!(key in target)) {
Object.assign(output, { [key]: source[key] });
} else {
output[key] = deepMerge(target[key], source[key]);
}
} else {
Object.assign(output, { [key]: source[key] });
}
});
}
return output;
}
function isObject(item) {
return item && typeof item === 'object' && !Array.isArray(item);
}
const config = deepMerge(defaultConfig, options || {});
if (config.useDeveloperStorage === undefined) {
// Attempt to define a reasonable default for developer storage that supports Open MCT build tool
if (config.mcwsUrl === undefined || config.mcwsUrl.trim().length === 0) {
config.useDeveloperStorage = true;
} else {
config.useDeveloperStorage = false;
}
}
openmct.setAssetPath(config.assetPath);
openmct.install(ClearDataIndicatorPlugin(config.globalStalenessInterval));
openmct.install(CommandEventsViewPlugin(config.tablePerformanceOptions));
openmct.install(MessagesPlugin(config.tablePerformanceOptions));
openmct.install(ProductStatusPlugin(config.tablePerformanceOptions));
openmct.install(MetadataActionPlugin());
openmct.install(DictionaryViewPlugin(config.tablePerformanceOptions));
openmct.install(PacketSummaryPlugin(config.tablePerformanceOptions));
openmct.install(ContainerViewPlugin());
// initialize session service, datasetCache service, global staleness
SessionService(openmct, config);
DatasetCache(openmct);
GlobalStaleness(openmct, config.globalStalenessInterval);
openmct.install(new FormatPlugin(config));
const timePlugin = new TimePlugin(config.time);
openmct.install(timePlugin);
const formatKey = config.time.utcFormat;
const utcFormat = formatKey
? openmct.telemetry.getFormatter(formatKey)
: new UTCDayOfYearFormat();
const vistaTime = getVistaTime({
options: timePlugin,
format: utcFormat
});
openmct.install(RealtimeIndicatorPlugin(vistaTime, utcFormat));
mcwsClient.configure(config);
openmct.install(MultipleHistoricalSessions(config.tablePerformanceOptions));
openmct.install(RealtimeSessions());
openmct.install(new HistoricalTelemetryPlugin(config));
openmct.install(new RealtimeTelemetryPlugin(vistaTime, config));
openmct.install(new TypePlugin());
openmct.install(new TaxonomyPlugin(config.taxonomy));
openmct.install(new LinkPlugin(config));
openmct.install(new VenuePlugin(config));
openmct.install(FrameWatchViewPlugin(config.tablePerformanceOptions));
openmct.install(FrameEventFilterViewPlugin(config.tablePerformanceOptions));
openmct.install(new ChannelTablePlugin(config.tablePerformanceOptions));
openmct.install(new ChannelTableSetPlugin());
openmct.install(new ChannelLimitsPlugin());
openmct.install(new FrameAccountabilityPlugin(config));
openmct.install(EVRViewPlugin(config));
openmct.install(new AlarmsViewPlugin(config.tablePerformanceOptions));
openmct.install(MCWSIndicatorPlugin());
if (config.messageStreamUrl && config.messageStreamUrl !== '') {
openmct.install(
new MessageStreamProcessor(config.messageStreamUrl, {
clearData: ['StartOfSession', 'EndOfSession'],
suspectChannels: ['SuspectChannels']
})
);
}
if (config.customFormatters.length) {
openmct.install(CustomFormatterPlugin(config.customFormatters));
}
openmct.install(CustomFormsPlugin());
openmct.install(
new ExportDataAction([
'table',
'telemetry.plot.overlay',
'telemetry.plot.stacked',
'vista.channel',
'vista.channelGroup',
'vista.chanTableGroup',
'vista.evr',
'vista.evrModule',
'vista.evrSource',
'vista.evrView'
])
);
openmct.install(ActionModifiersPlugin());
openmct.install(new PacketQueryPlugin());
if (config.globalFilters) {
openmct.install(new GlobalFilters(config.globalFilters));
}
openmct.user.setProvider(new IdentityProvider(openmct));
if (!config.useDeveloperStorage) {
openmct.install(MCWSPersistenceProviderPlugin(config.namespaces));
}
openmct.branding({ aboutHtml: insertBuildInfo(AboutTemplate) });
// do not show telemetry if it falls out of bounds
// even if there is no new telemetry
openmct.telemetry.greedyLAD(false);
// expose the config to the window
window.openmctMCWSConfig = config;
// load the css file
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = `${config.mcwsPluginAssetPath}/openmct-mcws-plugin.css`;
document.head.appendChild(link);
};
/**
* Replaces placeholders in the HTML with build info provided by webpack.
* Build info is defined in webpack config, and is exposed as global
* JavaScript variables
* @param {*} markup
*/
function insertBuildInfo(markup) {
return markup
.replace(/\$\{project\.version\}/g, __OMM_VERSION__)
.replace(/\$\{timestamp\}/g, __OMM_BUILD_DATE__)
.replace(/\$\{buildNumber\}/g, __OMM_REVISION__)
.replace(/\$\{branch\}/g, __OMM_BUILD_BRANCH__);
}
}