From ed1e7ebe8195076618df07e452384926d7c87d84 Mon Sep 17 00:00:00 2001
From: Viktor Vorobev <vorobev@in.tum.de>
Date: Fri, 7 Jul 2023 21:48:21 +0000
Subject: [PATCH] Merged in NRRPLT-8492-nest-desktop (pull request #52)

[NRRPLT-8492] Add runtime configuration and NEST Desktop tab

* [NRRPLT-8492] Add runtime configuration and NEST Desktop tab

* [NRRPLT-8492] Ignore src/services/nrp-analytics-service.js in coverage

* Merged development into NRRPLT-8492-nest-desktop
* Merge branch 'development' into NRRPLT-8492-nest-desktop

* [NRRPLT-8492] Fix types
---
 public/app-config.js                          |  6 ++++
 public/index.html                             |  1 +
 .../experiment-tools-service.js               | 31 ++++++++++++++++---
 3 files changed, 34 insertions(+), 4 deletions(-)
 create mode 100644 public/app-config.js

diff --git a/public/app-config.js b/public/app-config.js
new file mode 100644
index 0000000..603329e
--- /dev/null
+++ b/public/app-config.js
@@ -0,0 +1,6 @@
+window.appConfig = {
+    nestDesktop: {
+        enabled: false,
+        url: "http://localhost:8000"
+    }
+}
\ No newline at end of file
diff --git a/public/index.html b/public/index.html
index 141a45a..0ec66c0 100644
--- a/public/index.html
+++ b/public/index.html
@@ -30,6 +30,7 @@
   <body>
     <noscript>You need to enable JavaScript to run this app.</noscript>
     <div id="root"></div>
+    <script type="text/javascript" src="%PUBLIC_URL%/app-config.js"></script>
     <!--
       This HTML file is a template.
       If you open it directly in the browser, you will see an empty page.
diff --git a/src/components/experiment-workbench/experiment-tools-service.js b/src/components/experiment-workbench/experiment-tools-service.js
index aa98743..11bc6db 100644
--- a/src/components/experiment-workbench/experiment-tools-service.js
+++ b/src/components/experiment-workbench/experiment-tools-service.js
@@ -3,6 +3,7 @@ import FlexLayout from 'flexlayout-react';
 import DescriptionIcon from '@material-ui/icons/Description';
 import ListAltIcon from '@material-ui/icons/ListAlt';
 
+const appConfig = window.appConfig;
 import NrpCoreDashboard from '../nrp-core-dashboard/nrp-core-dashboard';
 import TransceiverFunctionEditor from '../tf-editor/tf-editor';
 import XpraView from '../xpra/xpra-view';
@@ -111,8 +112,8 @@ ExperimentToolsService.CONSTANTS = Object.freeze({
 ExperimentToolsService.TOOLS = Object.freeze({
   // NEST_DESKTOP: {
   //   singleton: true,
+  //   type: ExperimentToolsService.CONSTANTS.TOOL_TYPE.FLEXLAYOUT_TAB,
   //   flexlayoutNode: {
-  //     'type': 'tab',
   //     'name': 'NEST Desktop',
   //     'component': 'nest-desktop'
   //   },
@@ -134,7 +135,7 @@ ExperimentToolsService.TOOLS = Object.freeze({
       'name': 'NRP-Core Docs',
       'component': 'nrp-core-docu'
     },
-    flexlayoutFactoryCb: () =>  {
+    flexlayoutFactoryCb: () => {
       return <iframe src='https://hbpneurorobotics.bitbucket.io/index.html'
         title='NRP-Core Documentation' />;
     },
@@ -187,8 +188,8 @@ ExperimentToolsService.TOOLS = Object.freeze({
       'name': 'Edit experiment files',
       'component': 'TransceiverFunctionEditor'
     },
-    flexlayoutFactoryCb: () =>  {
-      return <TransceiverFunctionEditor/>;
+    flexlayoutFactoryCb: () => {
+      return <TransceiverFunctionEditor />;
     },
     getIcon: () => {
       return <ListAltIcon/>;
@@ -196,7 +197,29 @@ ExperimentToolsService.TOOLS = Object.freeze({
     isShown: () => {
       return true;
     }
+  },
+  NEST_DESKTOP: {
+    singleton: true,
+    type: SIM_TOOL.TOOL_TYPE.FLEXLAYOUT_TAB,
+    flexlayoutNode: {
+      'name': 'NEST Desktop',
+      'component': 'nest-desktop'
+    },
+    flexlayoutFactoryCb: () =>  {
+      return <iframe src={appConfig.nestDesktop.url} title='NEST Desktop' />;
+    },
+    getIcon: () => {
+      return <div>
+        <img src={'https://www.nest-simulator.org/wp-content/uploads/2015/03/nest_logo.png'}
+          alt="NEST Desktop"
+          style={{width: 40+ 'px', height: 20 + 'px'}} />
+      </div>;
+    },
+    isShown: () => {
+      return appConfig && appConfig.nestDesktop && appConfig.nestDesktop.enabled;
+    }
   }
 });
 
+
 export default ExperimentToolsService;
-- 
GitLab