From 0fc003e2c5061e9ef91fef667165eeda71eb8b89 Mon Sep 17 00:00:00 2001
From: Max Frederiksen <maxfrederiksen@Maxs-MacBook-Air.local>
Date: Mon, 12 Aug 2024 16:58:51 +0200
Subject: [PATCH] Put host log stream + IOC log stream in SimpleAccordion

---
 .../IOC/IOCLiveStatus/IOCLiveStatus.js        | 23 +++++++----
 src/components/common/Loki/LokiContainer.js   |  8 +---
 src/views/host/details/HostDetailsView.js     | 38 ++++++++++++-------
 3 files changed, 41 insertions(+), 28 deletions(-)

diff --git a/src/components/IOC/IOCLiveStatus/IOCLiveStatus.js b/src/components/IOC/IOCLiveStatus/IOCLiveStatus.js
index 300b37fc..049bbcd6 100644
--- a/src/components/IOC/IOCLiveStatus/IOCLiveStatus.js
+++ b/src/components/IOC/IOCLiveStatus/IOCLiveStatus.js
@@ -19,7 +19,8 @@ export function IOCLiveStatus({ ioc }) {
   const [state, setState] = useUrlState(
     {
       procserv_log_open: "true",
-      records_open: "false"
+      records_open: "false",
+      log_stream_open: "false"
     },
     { navigateMode: "replace" }
   );
@@ -81,15 +82,23 @@ export function IOCLiveStatus({ ioc }) {
           allowedRoles={["DeploymentToolAdmin", "DeploymentToolIntegrator"]}
           renderNoAccess={() => <></>}
         >
-          <LokiContainer
-            hostName={liveIOC.activeDeployment?.host.hostName}
-            iocName={ioc.namingName}
-            isDeployed={isIocDeployed(ioc)}
-          />
+          <SimpleAccordion
+            summary="IOC log stream"
+            expanded={deserialize(state.log_stream_open)}
+            onChange={(_, expanded) =>
+              setState({ log_stream_open: serialize(expanded) })
+            }
+          >
+            <LokiContainer
+              hostName={liveIOC.activeDeployment?.host.hostName}
+              iocName={ioc.namingName}
+              isDeployed={isIocDeployed(ioc)}
+            />
+          </SimpleAccordion>
           <SimpleAccordion
             summary="Records"
             expanded={deserialize(state.records_open)}
-            onChange={(event, expanded) =>
+            onChange={(_, expanded) =>
               setState({ records_open: serialize(expanded) })
             }
           >
diff --git a/src/components/common/Loki/LokiContainer.js b/src/components/common/Loki/LokiContainer.js
index dd54dc4b..5a89ee39 100644
--- a/src/components/common/Loki/LokiContainer.js
+++ b/src/components/common/Loki/LokiContainer.js
@@ -1,4 +1,4 @@
-import { Box, Typography } from "@mui/material";
+import { Box } from "@mui/material";
 import { LokiPanel } from "./LokiPanel";
 
 export function LokiContainer({ hostName, iocName, isDeployed }) {
@@ -6,12 +6,6 @@ export function LokiContainer({ hostName, iocName, isDeployed }) {
     <>
       {hostName && (
         <Box sx={{ pt: 2 }}>
-          <Typography
-            sx={{ my: 2.5 }}
-            variant="h3"
-          >
-            IOC log stream
-          </Typography>
           <LokiPanel
             hostName={hostName}
             isSyslog={false}
diff --git a/src/views/host/details/HostDetailsView.js b/src/views/host/details/HostDetailsView.js
index 850da925..623e9c7e 100644
--- a/src/views/host/details/HostDetailsView.js
+++ b/src/views/host/details/HostDetailsView.js
@@ -37,6 +37,7 @@ export function HostDetailsView({ hostId, host, status }) {
       iocs_rows: 20,
       iocs_page: 0,
       details_open: false,
+      log_stream_open: false,
       job_log_open: false,
       job_log_rows: 20,
       job_log_page: 0
@@ -100,22 +101,31 @@ export function HostDetailsView({ hostId, host, status }) {
               <HostDetailsTable host={host} />
             </SimpleAccordion>
 
-            <Stack
-              gap={2}
-              sx={{ marginTop: "10px" }}
+            <SimpleAccordion
+              summary={
+                <Typography
+                  variant="h3"
+                  component="h2"
+                >
+                  Host log stream
+                </Typography>
+              }
+              expanded={deserialize(urlState.log_stream_open)}
+              onChange={(_, expanded) =>
+                setUrlState({ log_stream_open: serialize(expanded) })
+              }
             >
-              <Typography
-                variant="h3"
-                component="h2"
+              <Stack
+                gap={2}
+                sx={{ marginTop: "10px" }}
               >
-                Host log stream
-              </Typography>
-              <LokiPanel
-                hostName={host.name}
-                isSyslog
-                isDeployed
-              />
-            </Stack>
+                <LokiPanel
+                  hostName={host.name}
+                  isSyslog
+                  isDeployed
+                />
+              </Stack>
+            </SimpleAccordion>
           </AccessControl>
           <KeyValueTable
             obj={{
-- 
GitLab