|
1 | 1 | /* eslint-disable react/jsx-one-expression-per-line */ |
2 | 2 | import React, { useState } from 'react'; |
3 | | -import Modal from './Modal.jsx'; |
| 3 | +// import Modal from './Modal.jsx'; |
| 4 | +import GraphsContainer from '../containers/GraphsContainer.jsx'; |
4 | 5 |
|
5 | 6 | // Renders charts created with health and communication data for a selected database. |
6 | 7 | const ServiceDetails = (props) => { |
7 | 8 | // Renders health info detail buttons |
8 | 9 | const { service } = props; |
9 | | - // console.log(service); |
10 | | - // Hook used to toggle whether or not the Modal component renders |
11 | | - const [modalDisplay, toggleModalDisplay] = useState(false); |
12 | | - // Hook used to set the chart that the Modal displays. The |
13 | | - // modalDisplay state is drilled into the Modal component. |
14 | | - const [modalChart, setModalChart] = useState(); |
15 | | - // Hook used to set the Modal Component title. The "alt" attribute |
16 | | - // is grabbed from the onClick event via event.path[0].alt |
17 | | - const [chartTitle, setChartTitle] = useState(); |
18 | | - |
19 | | - // Dictionary used by the healthInfoButtons loop below |
20 | | - |
21 | | - const buttonProperties = [ |
22 | | - { id: 'Request', alt: 'Request Data', src: 'app/assets/pieChart.png' }, |
23 | | - { id: 'Response', alt: 'Response Data', src: 'app/assets/pieChart.png' }, |
24 | | - { id: 'Speed', alt: 'Speed Data', src: 'app/assets/speedChart.png' }, |
25 | | - { |
26 | | - id: 'Processes', |
27 | | - alt: 'Processes Data', |
28 | | - src: 'app/assets/processingChart.png', |
29 | | - }, |
30 | | - { id: 'Latency', alt: 'Latency Data', src: 'app/assets/latencyChart.png' }, |
31 | | - { |
32 | | - id: 'Temperature', |
33 | | - alt: 'Temperature Data', |
34 | | - src: 'app/assets/tempChart.png', |
35 | | - }, |
36 | | - { id: 'Memory', alt: 'Memory Data', src: 'app/assets/memoryChart.png' }, |
37 | | - ]; |
38 | | - |
39 | | - // Create the Health Info buttons and their associated properties. Each time a button is clicked, |
40 | | - // setChartTitle will grab a title to render in the Modal component, setModalChart will grab the |
41 | | - // correct chart to render, and toggleModalDisplay will actually render the Modal display |
42 | | - const healthInfoButtons = []; |
43 | | - for (let i = 0; i < buttonProperties.length; i += 1) { |
44 | | - healthInfoButtons.push( |
45 | | - <div> |
46 | | - <div className="healthChartContainer"> |
47 | | - <input |
48 | | - onClick={() => { |
49 | | - setChartTitle(event.path[0].alt); |
50 | | - setModalChart(event.path[0].id); |
51 | | - toggleModalDisplay(!modalDisplay); |
52 | | - }} |
53 | | - service={service} |
54 | | - type="image" |
55 | | - id={buttonProperties[i].id} |
56 | | - src={buttonProperties[i].src} |
57 | | - width="60px" |
58 | | - alt={buttonProperties[i].alt} |
59 | | - /> |
60 | | - <br /> |
61 | | - <div>{buttonProperties[i].id}</div> |
62 | | - </div> |
63 | | - </div> |
64 | | - ); |
65 | | - } |
66 | | - |
| 10 | + |
67 | 11 | return ( |
68 | 12 | <div id="serviceDetailsContainer"> |
69 | | - {modalDisplay ? ( |
70 | | - <Modal |
71 | | - chartTitle={chartTitle} |
72 | | - service={service} |
73 | | - modalChart={modalChart} |
74 | | - toggleModalDisplay={toggleModalDisplay} |
75 | | - onClick={() => { |
76 | | - toggleModalDisplay(!modalDisplay); |
77 | | - }} |
78 | | - /> |
79 | | - ) : null} |
80 | | - |
81 | 13 | <h3 id="microserviceHealthTitle">Microservice Health - {service}</h3> |
82 | | - <div id="healthGrid">{healthInfoButtons}</div> |
83 | | - <button |
84 | | - className="backButton" |
85 | | - type="button" |
86 | | - onClick={() => { |
87 | | - // document.location.reload() |
88 | | - console.log('should clear data'); |
89 | | - // setDetails(null); |
90 | | - }} |
91 | | - > |
92 | | - Clear Health Data |
93 | | - </button> |
| 14 | + <GraphsContainer service={service} /> |
94 | 15 | </div> |
95 | 16 | ); |
96 | 17 | }; |
|
0 commit comments