From 3d202a04b99f0e61b6ccf8b7a5610e1a15ca58e7 Mon Sep 17 00:00:00 2001
From: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Date: Mon, 11 Feb 2019 14:54:12 +0100
Subject: Add sdnr wt odlux

Add complete sdnr wireless transport app odlux core and apps

Change-Id: I5dcbfb8f3b790e3bda7c8df67bd69d81958f65e5
Issue-ID: SDNC-576
Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
---
 .../apps/connectApp/src/views/connectView.tsx      | 93 ++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx

(limited to 'sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx')

diff --git a/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx
new file mode 100644
index 000000000..b73eb39d7
--- /dev/null
+++ b/sdnr/wt/odlux/apps/connectApp/src/views/connectView.tsx
@@ -0,0 +1,93 @@
+import * as React from 'react';
+
+import connect, { IDispatcher, Connect } from '../../../../framework/src/flux/connect';
+import { Panel } from '../../../../framework/src/components/material-ui';
+
+import { requiredNetworkElementsReloadAction } from '../handlers/requiredNetworkElementsHandler';
+import { loadAllMountedNetworkElementsAsync } from '../actions/mountedNetworkElementsActions';
+import { connectionStatusLogReloadAction } from '../handlers/connectionStatusLogHandler';
+
+import { RequiredNetworkElementsList } from '../components/requiredNetworkElements';
+import { ConnectionStatusLog } from '../components/connectionStatusLog';
+import { UnknownNetworkElementsList } from '../components/unknownNetworkElements';
+
+const mapDispatcher = (dispatcher: IDispatcher) => ({
+  onLoadUnknownNetworkElements: () => {
+    dispatcher.dispatch(loadAllMountedNetworkElementsAsync);
+  },
+  onLoadRequiredNetworkElements: () => {
+    dispatcher.dispatch(requiredNetworkElementsReloadAction);
+  },
+  onLoadConnectionStatusLog: () => {
+    dispatcher.dispatch(connectionStatusLogReloadAction);
+  }
+});
+
+type PanelId = null | "RequiredNetworkElements" | "UnknownNetworkElements" | "ConnectionStatusLog";
+
+type ConnectApplicationComponentProps = Connect<undefined, typeof mapDispatcher> ;
+
+type ConnectApplicationComponentState = {
+  activePanel: PanelId;
+};
+
+class ConnectApplicationComponent extends React.Component<ConnectApplicationComponentProps, ConnectApplicationComponentState>{
+  /**
+   * Initialises this instance
+   */
+  constructor(props: ConnectApplicationComponentProps) {
+    super(props);
+    
+    this.state = {
+      activePanel: null
+    };
+  }
+  private onTogglePanel = (panelId: PanelId) => {
+    const nextActivePanel = panelId === this.state.activePanel ? null : panelId;
+    this.setState({
+      activePanel: nextActivePanel
+    }, () => {
+      switch (nextActivePanel) {
+        case 'RequiredNetworkElements':
+          this.props.onLoadRequiredNetworkElements();
+          break;
+        case 'UnknownNetworkElements':
+          // todo: should we update the application state ?
+          break;
+        case 'ConnectionStatusLog':
+          this.props.onLoadConnectionStatusLog();
+          break;
+        case null:
+          // do nothing if all panels are closed
+          break;
+        default:
+          console.warn("Unknown nextActivePanel [" + nextActivePanel + "] in connectView");
+          break;
+      }
+    });
+  };
+
+  render(): JSX.Element {
+    const { activePanel } = this.state;
+    
+    return (
+      <>
+        <Panel activePanel={ activePanel } panelId={ 'RequiredNetworkElements' } onToggle={ this.onTogglePanel } title={ "Required Network Elements" }>
+          <RequiredNetworkElementsList />
+        </Panel>
+        <Panel activePanel={ activePanel } panelId={ 'UnknownNetworkElements' } onToggle={ this.onTogglePanel } title={ "Unknown Network Elements" }>
+          <UnknownNetworkElementsList />
+        </Panel>
+        <Panel activePanel={ activePanel } panelId={ 'ConnectionStatusLog' } onToggle={ this.onTogglePanel } title={ "Connection Status Log" }>
+          <ConnectionStatusLog />
+        </Panel>
+      </>
+    );
+  };
+  public componentDidMount() {
+    this.props.onLoadUnknownNetworkElements();
+  }
+}
+
+export const ConnectApplication = (connect(undefined, mapDispatcher)(ConnectApplicationComponent));
+export default ConnectApplication;
\ No newline at end of file
-- 
cgit 1.2.3-korg

