-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathloader.js
183 lines (165 loc) · 5.64 KB
/
loader.js
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
define([
'openmct',
'./src/AMMOSPlugins',
'./src/styles/sass/vista.scss',
'./src/commandEventsView/plugin',
'./src/messagesView/plugin',
'./src/product-status/plugin',
'./about.html',
'./src/metadataAction/plugin',
'./src/clearDataIndicator/plugin',
'./src/dictionaryView/plugin',
'./src/packetSummary/plugin',
'./src/containerView/plugin',
'services/identity/MCWSIdentityProvider',
'./src/persistence/plugin'
], function (
openmct,
AMMOSPlugins,
VistaStyles /** Do not delete, needed for webpack to compile scss file*/,
CommandEventsViewPlugin,
MessagesPlugin,
ProductStatusPlugin,
AboutTemplate,
MetadataActionPlugin,
ClearDataIndicator,
DictionaryViewPlugin,
PacketSummaryPlugin,
ContainerViewPlugin,
IdentityProvider,
MCWSPersistenceProviderPlugin
) {
const ALLOWED_OPTIONAL_PLUGINS = ['BarChart'];
function loader(config) {
let persistenceLoaded;
const persistenceLoadedPromise = new Promise((resolve) => {
persistenceLoaded = resolve;
});
openmct.setAssetPath(config.assetPath);
//Optional Themes
if (config.theme) {
openmct.install(openmct.plugins[config.theme]());
} else {
openmct.install(openmct.plugins.Snow());
}
openmct.install(
openmct.plugins.Filters([
'vista.alarmsView',
'telemetry.plot.overlay',
'table',
'vista.chanTableGroup',
'vista.commandEventsView',
'vista.messagesView',
'vista.evrView'
])
);
openmct.install(openmct.plugins.ObjectMigration());
openmct.install(
openmct.plugins.DisplayLayout({
showAsView: [
'summary-widget',
'vista.packetSummaryEvents',
'vista.dataProducts',
'vista.packets',
'vista.frameSummary',
'vista.frameWatch'
]
})
);
openmct.install(
openmct.plugins.ClearData(
[
'table',
'telemetry.plot.overlay',
'telemetry.plot.stacked',
'vista.packetSummaryEvents',
'vista.dataProducts',
'vista.packets',
'vista.frameSummary',
'vista.frameWatch',
'vista.chanTableGroup'
],
{
indicator: false
}
)
);
openmct.install(ClearDataIndicator.default(config.globalStalenessInterval));
openmct.install(CommandEventsViewPlugin.default(config.tablePerformanceOptions));
openmct.install(MessagesPlugin.default(config.tablePerformanceOptions));
openmct.install(ProductStatusPlugin.default(config.tablePerformanceOptions));
openmct.install(openmct.plugins.UTCTimeSystem());
openmct.install(openmct.plugins.Notebook());
openmct.install(MetadataActionPlugin.default());
openmct.install(DictionaryViewPlugin.default(config.tablePerformanceOptions));
openmct.install(PacketSummaryPlugin.default(config.tablePerformanceOptions));
openmct.install(ContainerViewPlugin.default());
openmct.install(openmct.plugins.Clock({ useClockIndicator: false }));
openmct.install(new AMMOSPlugins(config));
openmct.user.setProvider(new IdentityProvider.default(openmct));
if (config.useDeveloperStorage) {
openmct.install(openmct.plugins.LocalStorage());
openmct.install(openmct.plugins.MyItems());
persistenceLoaded();
} else {
const mcwsPersistenceProvider = MCWSPersistenceProviderPlugin.default(config.namespaces);
openmct.install(async (_openmct) => {
await mcwsPersistenceProvider(_openmct);
persistenceLoaded();
});
}
// install optional plugins, summary widget is handled separately as it was added long ago
if (config.plugins) {
if (
config.plugins.summaryWidgets === true ||
config.plugins.summaryWidgets?.enabled === true
) {
openmct.install(openmct.plugins.SummaryWidget());
}
const pluginErrors = [];
const pluginsToInstall = Object.entries(config.plugins).filter(([plugin, pluginConfig]) => {
const isSummaryWidget = plugin === 'summaryWidgets';
const allowedPlugin = ALLOWED_OPTIONAL_PLUGINS.includes(plugin);
const pluginEnabled = pluginConfig?.enabled;
if (!allowedPlugin && !isSummaryWidget) {
pluginErrors.push(plugin);
}
return allowedPlugin && pluginEnabled && !isSummaryWidget;
});
// Warn if any plugins are not supported
if (pluginErrors.length > 0) {
console.warn(
`Unable to install plugins: ${pluginErrors.join(', ')}. Please verify the plugin name is correct and is included in the supported plugins list. Available plugins: ${ALLOWED_OPTIONAL_PLUGINS.join(', ')}`
);
}
pluginsToInstall.forEach(([plugin, pluginConfig]) => {
const { configuration = [] } = pluginConfig;
openmct.install(openmct.plugins[plugin](...configuration));
});
}
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);
persistenceLoadedPromise.then(() => {
openmct.start();
window.openmct = openmct;
});
}
/**
* 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__);
}
return loader;
});