2 import { faPlug } from '@fortawesome/free-solid-svg-icons';
4 import applicationManager from '../../../framework/src/services/applicationManager';
5 import { subscribe, IFormatedMessage } from '../../../framework/src/services/notificationService';
7 import connectAppRootHandler from './handlers/connectAppRootHandler';
8 import ConnectApplication from './views/connectView';
9 import { RemoveMountedNetworkElement, addMountedNetworkElementAsyncActionCreator } from './actions/mountedNetworkElementsActions' ;
10 import { AddSnackbarNotification } from '../../../framework/src/actions/snackbarActions';
12 type ObjectNotification = {
19 export function register() {
20 const applicationApi = applicationManager.registerApplication({
23 rootComponent: ConnectApplication,
24 rootActionHandler: connectAppRootHandler,
25 menuEntry: "Connect App"
28 // subscribe to the websocket notifications
29 subscribe<ObjectNotification & IFormatedMessage>(["ObjectCreationNotification", "ObjectDeletionNotification"], (msg => {
30 const store = applicationApi && applicationApi.applicationStore;
31 if (msg && msg.notifType === "ObjectCreationNotification" && store) {
32 store.dispatch(addMountedNetworkElementAsyncActionCreator(msg.objectId));
33 store.dispatch(new AddSnackbarNotification({ message: `Adding network element [${ msg.objectId }]`, options: { variant: 'info' } }));
34 } else if (msg && msg.notifType === "ObjectDeletionNotification" && store) {
35 store.dispatch(new AddSnackbarNotification({ message: `Removing network element [${ msg.objectId }]`, options: { variant: 'info' } }));
36 store.dispatch(new RemoveMountedNetworkElement(msg.objectId));