Skip to content

Commit d0a998e

Browse files
committed
Fixed Add Service Rendering
1 parent a277819 commit d0a998e

6 files changed

Lines changed: 23 additions & 116 deletions

File tree

app/AComp/Microservices.jsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import OverviewContext from '../context/OverviewContext';
33
import HealthInformationContext from '../context/DetailsContext';
44
import ServiceDetails from '../components/ServiceDetails.jsx';
55

6-
76
const { ipcRenderer } = window.require('electron');
87

98
const Microservices = (props) => {
10-
const { index, setDetails, setSelection } = props;
9+
const { index, setDetails } = props;
1110
// Overview state used to create service buttons
1211
const [overviewState, setOverviewState] = useState([]);
1312
// const [detailsSelected, setDetails] = useState();
@@ -55,9 +54,8 @@ const Microservices = (props) => {
5554
healthdata.detailData = Object.values(JSON.parse(data));
5655
// Updates state. Triggers rerender.
5756
setDetails(
58-
<ServiceDetails service={element.currentmicroservice} />
57+
<ServiceDetails service={element.currentmicroservice} />
5958
);
60-
6159
});
6260
// setSelection(<Monitoring detailsSelected={detailsSelected} />);
6361
}}
@@ -79,16 +77,15 @@ const Microservices = (props) => {
7977
key={`serviceItem${index}${i}`}
8078
onClick={() => {
8179
ipcRenderer.send('detailsRequest', index);
82-
80+
8381
// IPC listener responsible for retrieving infomation from asynchronous main process message.
8482
ipcRenderer.on('detailsResponse', (event, data) => {
8583
// Adds returned data to context.
8684
healthdata.detailData = Object.values(JSON.parse(data));
8785
// Updates state. Triggers rerender.
8886
setDetails(
8987
<ServiceDetails service={element.currentMicroservice} />
90-
91-
);
88+
);
9289
});
9390
}}
9491
>
@@ -103,7 +100,7 @@ const Microservices = (props) => {
103100
}
104101
// If there's no data, return 'No data present', else return microservices button
105102
if (componentButtons.length === 0) {
106-
return <p>No data present</p>;
103+
return <p>Loading</p>;
107104
}
108105
return componentButtons;
109106
};

app/AComp/MonitorHeader.jsx

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/containers/DashboardContainer.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import SidebarContainer from './SideBarContainer.jsx';
55
import '../stylesheets/dashboard.css';
66

77
const DashboardContainer = () => {
8-
// Used to hold the buttons created for each database found in context.
9-
const [serviceSelected, setSelection] = useState();
8+
109
const [detailsSelected, setDetails] = useState();
1110

1211
return (
1312
<div className="servicesDashboardContainer">
14-
<SidebarContainer setSelection={setSelection} setDetails={setDetails} />
13+
<SidebarContainer setDetails={setDetails} />
1514
<div className="databsaseList">
16-
{serviceSelected || <Monitoring detailsSelected={detailsSelected} />}
15+
<Monitoring detailsSelected={detailsSelected} />
1716
</div>
1817
</div>
1918
);

app/containers/MonitoringContainer.jsx

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,8 @@
1-
import React, { useState, useContext } from 'react';
2-
import MonitorHeader from '../AComp/MonitorHeader.jsx';
3-
import Modal from '../components/Modal.jsx';
4-
import OverviewContext from '../context/OverviewContext';
5-
import HealthInformationContext from '../context/DetailsContext';
6-
import routeChart from '../assets/routeChart.png';
1+
import React from 'react';
72

83
const MonitoringContainer = (props) => {
94
const { detailsSelected } = props;
105

11-
// Contexts have data added to them following successful IPC return. Data is later used to create charts.
12-
const serviceComponents = useContext(OverviewContext);
13-
const healthdata = useContext(HealthInformationContext);
14-
15-
// Hook used to toggle whether or not the Modal component renders
16-
const [modalDisplay, toggleModalDisplay] = useState(false);
17-
// Hook used to set the chart that the Modal displays. The
18-
// modalDisplay state is drilled into the Modal component.
19-
const [modalChart, setModalChart] = useState();
20-
// Hook used to set the Modal Component title. The "alt" attribute
21-
// is grabbed from the onClick event via event.path[0].alt
22-
const [chartTitle, setChartTitle] = useState();
23-
24-
// route button AND traffic button property
25-
const routeButtonProperty = {
26-
traffic: {
27-
id: 'Traffic',
28-
alt: 'Microservice Traffic',
29-
src: 'app/assets/chartModal.png',
30-
},
31-
routes: { id: 'routesImage', alt: 'Route Trace', src: routeChart },
32-
};
33-
34-
// declare routes array to display routes when modal is toggled
35-
const routes = [];
36-
// declare traffic array to display traffic when modal is toggled
37-
const traffic = [];
38-
39-
// push traffic component logic traffic
40-
traffic.push(
41-
<div className="healthChartContainer">
42-
<input
43-
onClick={() => {
44-
setChartTitle(event.path[0].alt);
45-
setModalChart(event.path[0].id);
46-
toggleModalDisplay(!modalDisplay);
47-
}}
48-
type="image"
49-
id={routeButtonProperty.traffic.id}
50-
src={routeButtonProperty.traffic.src}
51-
width="60px"
52-
alt={routeButtonProperty.traffic.alt}
53-
/>
54-
<br />
55-
<div style={{ color: 'white', paddingLeft: '7px' }}>
56-
{routeButtonProperty.traffic.id}
57-
</div>
58-
</div>
59-
);
60-
61-
// push routes component logic traffic
62-
routes.push(
63-
<div className="healthChartContainer">
64-
<input
65-
onClick={() => {
66-
setChartTitle(event.path[0].alt);
67-
setModalChart(event.path[0].id);
68-
toggleModalDisplay(!modalDisplay);
69-
}}
70-
type="image"
71-
id={routeButtonProperty.routes.id}
72-
src="app/assets/routeChart.png"
73-
width="60px"
74-
alt={routeButtonProperty.routes.alt}
75-
/>
76-
<br />
77-
<div style={{ color: 'white', paddingLeft: '7px' }}>Routes</div>
78-
</div>
79-
);
80-
816
return (
827
<div className="mainContainer">
838
{detailsSelected || null}

app/containers/SideBarContainer.jsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useContext } from 'react';
2-
import Header from '../AComp/Header.jsx';
2+
import Header from '../AComp/SidebarHeader.jsx';
33
import Extras from '../AComp/Extras.jsx';
44
import SetupContext from '../context/SetupContext';
55
import DashboardContext from '../context/DashboardContext';
@@ -9,23 +9,19 @@ import AddService from '../components/AddService.jsx';
99
import DeleteService from '../components/DeleteService.jsx';
1010
import '../stylesheets/sidebar.css';
1111

12-
const { ipcRenderer } = window.require('electron');
13-
1412
const SidebarContainer = (props) => {
15-
// const { setSelection, setDetails } = props;
13+
const { setDetails } = props;
14+
1615
// Used to toggle setup required if user wants to add a new database.
1716
const setup = useContext(SetupContext);
1817

19-
const { setSelection, setDetails } = props;
20-
21-
2218
// List of the databases saved by users to track microservices.
2319
const serviceList = useContext(DashboardContext);
2420

25-
26-
27-
21+
// Setting index of service selected
2822
const [index, setIndex] = useState();
23+
24+
// Checking to see if service clicked to display Microservices
2925
const [isclicked, setClicked] = useState('false');
3026

3127
// Helper function to check if Clicked toggles
@@ -37,17 +33,21 @@ const SidebarContainer = (props) => {
3733
const ServicesClick = (e) => {
3834
clickToggle(e);
3935
setIndex(e.target.id);
40-
36+
setDetails(null);
4137
// setSelection(<Monitoring detailsSelected={detailsSelected} />);
4238
};
4339
// Click function for AddService
4440
const AddClick = () => {
4541
setup.setupRequired = setup.toggleSetup(false);
46-
setSelection(<AddService />);
42+
setDetails(<AddService />);
4743
};
44+
45+
// Click fn for Delete Service
4846
const DeleteClick = () => {
49-
setSelection(<DeleteService />);
47+
setDetails(<DeleteService />);
5048
};
49+
50+
// Click fn for Refresh
5151
const RefreshClick = () => {
5252
location.reload();
5353
};
@@ -62,11 +62,7 @@ const SidebarContainer = (props) => {
6262
isclicked={isclicked}
6363
/>
6464
{isclicked === 'true' ? (
65-
<Microservices
66-
setSelection={setSelection}
67-
index={index}
68-
setDetails={setDetails}
69-
/>
65+
<Microservices index={index} setDetails={setDetails} />
7066
) : null}
7167
<Extras
7268
AddClick={AddClick}

0 commit comments

Comments
 (0)