Skip to content

Commit 9d957d4

Browse files
committed
working version, communications now working, no glitches
1 parent dafe935 commit 9d957d4

18 files changed

Lines changed: 404 additions & 205 deletions
Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import React, { useContext, useEffect } from 'react';
1+
import {
2+
IconButton,
3+
Modal,
4+
Card,
5+
CardHeader,
6+
CardContent,
7+
Button,
8+
Typography
9+
} from '@material-ui/core';
10+
import { Theme, makeStyles } from '@material-ui/core/styles';
11+
import { BaseCSSProperties } from '@material-ui/core/styles/withStyles';
12+
import React, { useContext } from 'react';
213
// import OverviewContext from '../context/OverviewContext';
314
import { CommsContext } from '../context/CommsContext';
415
// import { log } from 'console';
516
import Graph from 'react-graph-vis';
617

718
const RouteLocations = props => {
819
const communicationsData = useContext(CommsContext).commsData;
9-
10-
useEffect(() => {
11-
const parentNode = document.querySelector('div.chart');
12-
const childNode = document.querySelectorAll('canvas')[0];
13-
if (parentNode && childNode) {
14-
parentNode.append(childNode);
15-
childNode.id = `canvasGraph`
16-
}
17-
return childNode;
18-
})
19-
2020
console.log('commdata=======>', communicationsData);
2121
console.log('try again');
2222

@@ -88,19 +88,63 @@ const RouteLocations = props => {
8888
const tracePoints = Object.values(resObj).filter(subArray => subArray.length > 1);
8989
console.log('tracepoints =======>', tracePoints);
9090

91+
const useStyles = makeStyles(theme => ({
92+
paper: {
93+
height: 280,
94+
width: 280,
95+
textAlign: 'center',
96+
color: '#888888',
97+
whiteSpace: 'nowrap',
98+
backgroundColor: '#ffffff',
99+
borderRadius: 8,
100+
border: '0',
101+
boxShadow: '0 6px 6px 0 rgba(153, 153, 153, 0.14), 0 6px 6px -2px rgba(153, 153, 153, 0.2), 0 6px 8px 0 rgba(153, 153, 153, 0.12)',
102+
'&:hover, &.Mui-focusVisible': {
103+
backgroundColor: `#ccd8e1`,
104+
color: '#ffffff',
105+
},
106+
},
107+
hover: {
108+
boxShadow: 'none',
109+
color: 'transparent'
110+
},
111+
btnStyle: {
112+
position: 'absolute',
113+
top: -10,
114+
left: -10,
115+
margin: '0',
116+
color: '#eeeeee',
117+
borderRadius: '0',
118+
backgroundColor: 'transparent',
119+
'&:hover': {
120+
backgroundColor: 'none'
121+
}
122+
},
123+
icon: {
124+
width: '75px',
125+
height: '75px',
126+
boxShadow: 'none',
127+
},
128+
}));
129+
const classes = useStyles({});
130+
131+
132+
133+
// ======Graphs logic =======//
91134
const nodeListObj = {};
92135
const edgeList = [];
93136
for (let route of tracePoints) {
94137
for (let i = 0; i < route.length; i += 1) {
138+
const colors = ['#75b6d7', '#cc000', '#fce356', '#888888', '#ccd8e1']
95139
// check if node exists if not then add node
96140
let id = route[i].microservice
97141
if (nodeListObj[id] === undefined) {
98-
nodeListObj[id] = { id: id, label: id, color: '#e04141' }
142+
nodeListObj[id] = { id: id, label: id, color: { background: '#24d2f1', border: 'white', hover: { background: '#4d55ec', border: 'white' } }, shape: 'circle' }
99143
}
100144
// add edge from node 1 to node 2 (repeat til end)
101145
if (i !== 0) {
102-
let duration = new Date(route[i].time) - new Date(route[i-1].time);
103-
let edge = { from: route[i - 1].microservice, to: id, label: `${duration} ms`}
146+
let duration = new Date(route[i].time) - new Date(route[i - 1].time);
147+
let edge = { from: route[i - 1].microservice, to: id, label: `${duration * 100} ms` }
104148
edgeList.push(edge)
105149
}
106150
}
@@ -124,15 +168,20 @@ const RouteLocations = props => {
124168
// edges: [{ from: 4, to: 2, label: 'hello' }, { from: 'one', to: 3 }, { from: 2, to: 4 }, { from: 2, to: 5 }]
125169
// };
126170
const options = {
171+
172+
height: '400px',
173+
width: '400px',
174+
style: 'surface',
127175
layout: {
128176
hierarchical: false
129177
},
130178
edges: {
131179
color: "#000000",
132-
physics: false,
180+
physics: true,
133181
smooth: {
134182
type: "curvedCCW",
135-
forceDirection: "none"
183+
forceDirection: "none",
184+
roundness: 0.3
136185
}
137186
},
138187
};
@@ -147,10 +196,11 @@ const RouteLocations = props => {
147196
}
148197
};
149198

150-
199+
151200
return (
152-
<div className="chart">
153-
<Graph id="visGraph" graph={graph} options={options} events={events} style={{ height: "640px" }} />
201+
<div className='traceContainer'>
202+
<span id='trace'>Traces</span>
203+
<Graph className={classes.paper} graph={graph} options={options} events={events} style={{ fontSize: '8px', color: '#555555', fontFamily: 'Open Sans', boxShadow: '0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)', backgroundColor: 'white' }} />
154204
</div>
155205
);
156206
};

app/components/About.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ const About: React.FC = () => {
55
return (
66
<div className="home">
77
<div className="blurb">
8-
<h3 className="para">About</h3>
9-
<p className="para">
8+
<h3 className="mainTitle">About</h3>
9+
<p className="text">
1010
The Chronos Team has always had passion for Open Source endeavors that would greatly benefit
1111
the developer community. With many existing paid options being difficult to use and expensive to operate, Chronos was
1212
born. Chronos is an all-in-one network and health monitoring tool for your application or
1313
microservice, containerized or not!
1414
</p>
1515
<div className="doya">
16-
<h3 className="para">Team Doya</h3><span id="sproutSpan"><img className="sprout" src="../assets/clean-sprout.gif" alt="sprout"></img></span>
16+
<h3 className="title">Team Doya</h3><span><img className="sprout" id="sproutSpan" src="../assets/clean-sprout.gif" alt="sprout"></img></span>
1717
<br/>
1818
<div>
19-
<span className="para">Grace </span><br />
20-
<span className="para">Jen </span><br />
21-
<span className="para">Patty </span><br />
22-
<span className="para">Stella </span><br /><br />
19+
<span className="text">Grace </span><br />
20+
<span className="text">Jen </span><br />
21+
<span className="text">Patty </span><br />
22+
<span className="text">Stella </span><br /><br />
2323
</div>
2424
</div>
25-
<h3 className="para">Contributors</h3>
26-
<p className="para">Michael, Ronelle, Todd, Greg
25+
<h3 className="title">Contributors</h3>
26+
<p className="text">Michael, Ronelle, Todd, Greg
2727
Brianna, Brian, Alon, Alan
2828
Ousman, Ben, Chris, Jenae, Tim</p>
2929
</div>

app/components/Contact.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ const Contact: React.FC = () => {
3333
<label htmlFor="subject">Subject: &nbsp;</label>
3434
<input type="text" id="subject" name="subject" placeholder="Subject" />
3535
<br />
36-
<label htmlFor="message">Message:
37-
<span>
36+
<label id="messageLabel" htmlFor="message">Message: <span>
3837
<textarea id="message" name="message" placeholder="Write something.."></textarea>
3938
</span>
4039
</label>

app/components/Copyright.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const Copyright = () => {
1515
}))
1616
const classes = useStyles();
1717
return (
18-
<Typography className={classes.copyright} variant="body2" color="textSecondary" align="center">
18+
<Typography className={classes.copyright} variant="body2" align="center">
1919
{'Copyright © '}
2020
<Link color="inherit" href="https://chronoslany.com/" target="_blank">
2121
Team Chronos

app/components/Header.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React, { useContext } from 'react';
2-
import { useHistory } from 'react-router-dom';
3-
import ListIcon from '@material-ui/icons/Search';
2+
import { useHistory, Link } from 'react-router-dom';
3+
import ListIcon from '@material-ui/icons/List';
44
import { ApplicationContext } from '../context/ApplicationContext';
55
import '../stylesheets/Header.scss';
6-
import '../stylesheets/Occupied.scss';
76

87
export interface HeaderProps {
98
app: string[];
@@ -30,8 +29,14 @@ const Header: React.SFC<HeaderProps> = ({ app, service, setLive, live }) => {
3029
communications
3130
</option>
3231
</select>
33-
<div className="header-btns">
34-
<button onClick={() => history.goBack()}><ListIcon className="icon" id="returnToAppIcon" />Return to Applications</button>
32+
<div className="header">
33+
<Link className="link" id="return" to="/applications">
34+
<span>
35+
<ListIcon className="icon" id="returnIcon" />
36+
</span>
37+
<p id="returnToDash">Dashboard</p>
38+
</Link>
39+
{/* <button id="returnButton" onClick={() => history.goBack()}><ListIcon className="icon" id="returnIcon" /></button> */}
3540
<button onClick={() => setLive(!live)}>
3641
{live ? (
3742
<div>

app/components/Occupied.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useEffect, useState, useRef } from 'react';
1+
import React, { useContext, useEffect, useState, useRef, forwardRef } from 'react';
22

33
// MATERIAL UI METHODS
44
import {
@@ -39,13 +39,13 @@ interface StyleProps {
3939
};
4040
type ClickEvent = React.MouseEvent<HTMLElement>;
4141

42-
const Occupied: React.FC = () => {
42+
const Occupied: React.FC = React.memo(function Occupied (props) {
4343
const { applications, getApplications, deleteApp } = useContext(DashboardContext);
4444
const [open, setOpen] = useState<boolean>(false);
4545
const [addOpen, setAddOpen] = useState<boolean>(false);
4646
const [index, setIndex] = useState<number>(0);
4747
const [app, setApp] = useState<string>('');
48-
48+
const [searchTerm, setSearchTerm] = useState<string>('Search...');
4949
// Dynamic refs
5050
const delRef = useRef<any>([]);
5151

@@ -108,18 +108,9 @@ const Occupied: React.FC = () => {
108108
}));
109109

110110
const classes = useStyles({} as StyleProps);
111-
112-
// function append(parent:any, child:any) {
113-
// const parentNode: HTMLElement = document.querySelector(parent);
114-
// const childNode: HTMLElement = document.querySelector(child);
115-
// return parentNode.append(childNode);
116-
// };
117111

118112
return (
119-
120113
<div className="entireArea">
121-
<div className="sidebarArea">
122-
</div>
123114
<div className="dashboardArea">
124115
<header className="mainHeader">
125116
<section className="header" id="leftHeader">
@@ -129,7 +120,7 @@ const Occupied: React.FC = () => {
129120
<section className="header" id="rightHeader">
130121
<form className="form">
131122
<label className="inputContainer">
132-
<input className="form" id="textInput" value="Search..." type="text" name="search" />
123+
<input className="form" id="textInput" placeholder={searchTerm} onChange={e => setSearchTerm(e.target.value)} type="text" name="search" />
133124
<hr />
134125
</label>
135126
<button className="form" id="submitBtn" type="submit">
@@ -149,7 +140,7 @@ const Occupied: React.FC = () => {
149140
</Button>
150141
</div>
151142
{applications.map((app: string[], i: number | any | string | undefined) => (
152-
<div className="card" id={`card-${i}`}>
143+
<div className="card" key={`card-${i}`} id={`card-${i}`}>
153144
<Card
154145
key={`card-${i}`}
155146
className={classes.paper}
@@ -178,12 +169,12 @@ const Occupied: React.FC = () => {
178169
<AddModal setOpen={setAddOpen} />
179170
</Modal>
180171
<Modal open={open} onClose={() => setOpen(false)}>
181-
<ServicesModal i={index} app={app} />
172+
<ServicesModal key={`key-${index}`} i={index} app={app} />
182173
</Modal>
183174
</div>
184175
</div>
185176
</div>
186177
);
187-
};
178+
});
188179

189180
export default Occupied;

app/components/Settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React from 'react';
77
const Settings: React.FC = () => {
88
return (
99
<div className="home">
10-
<p>Contact the Chronos Team for anything you'd like to see</p>
10+
<p id="settings"></p>
1111
</div>
1212
);
1313
};

app/containers/GraphsContainer.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import RequestTypesChart from '../charts/RequestTypesChart';
1414
import ResponseCodesChart from '../charts/ResponseCodesChart';
1515
import TrafficChart from '../charts/TrafficChart';
1616
import DockerChart from '../charts/DockerChart';
17-
import RouteChart from '../charts/RouteChart';
17+
import RouteCopy from '../charts/RouteCopy';
1818
import '../stylesheets/GraphsContainer.scss';
1919

2020
export interface Params {
@@ -32,7 +32,7 @@ export interface GraphsContainerProps {
3232
}
3333

3434
const GraphsContainer: React.SFC<GraphsContainerProps> = () => {
35-
const { app, service } = useParams();
35+
const { app, service } = useParams<any>();
3636
const [live, setLive] = useState<boolean>(false);
3737
const [intervalID, setIntervalID] = useState<NodeJS.Timeout | null>(null);
3838

@@ -73,19 +73,19 @@ const GraphsContainer: React.SFC<GraphsContainerProps> = () => {
7373
<RequestTypesChart />
7474
<ResponseCodesChart />
7575
<TrafficChart />
76-
<RouteChart />
76+
<RouteCopy />
7777
</div>
7878
) : (
79-
<div className="graphs">
80-
<SpeedChart />
81-
<TemperatureChart />
82-
<LatencyChart />
83-
<MemoryChart />
84-
<ProcessesChart />
85-
<DockerChart />
86-
{/* <RouteChart /> */}
87-
</div>
88-
)}
79+
<div className="graphs">
80+
<SpeedChart />
81+
<TemperatureChart />
82+
<LatencyChart />
83+
<MemoryChart />
84+
<ProcessesChart />
85+
<DockerChart />
86+
{/* <RouteCopy /> */}
87+
</div>
88+
)}
8989
</div>
9090
</>
9191
);

app/containers/SidebarContainer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { Link } from 'react-router-dom';
33

44
import HomeSharpIcon from '@material-ui/icons/HomeSharp';
5+
import ListIcon from '@material-ui/icons/List';
56
import InfoIcon from '@material-ui/icons/Info';
67
import ContactSupportIcon from '@material-ui/icons/ContactSupport';
78
import SettingsIcon from '@material-ui/icons/Settings';
@@ -45,6 +46,15 @@ const SidebarContainer: React.FC = (): JSX.Element => (
4546
}} />
4647
&emsp;Home
4748
</Link>
49+
<Link className="sidebar-link" to="/applications" id="dash">
50+
<ListIcon style={{
51+
WebkitBoxSizing: 'content-box',
52+
boxShadow: 'none',
53+
width: '35px',
54+
height: '35px',
55+
}} />
56+
&emsp;Dashboard
57+
</Link>
4858
<Link className="sidebar-link" to="/about" id="about">
4959
<InfoIcon style={{
5060
WebkitBoxSizing: 'content-box',

0 commit comments

Comments
 (0)