11/* eslint-disable no-bitwise */
22import React , { useEffect , useState , useContext } from 'react' ;
33import { useParams } from 'react-router-dom' ;
4- import { ApplicationContext } from '../context/ApplicationContext' ;
5- import { HealthContext } from '../context/HealthContext' ;
6- import { CommsContext } from '../context/CommsContext' ;
7- import { DockerContext } from '../context/DockerContext' ;
8- import { EventContext } from '../context/EventContext' ;
9- import Header from '../components/Header' ;
10- import RequestTypesChart from '../charts/RequestTypesChart' ;
11- import ResponseCodesChart from '../charts/ResponseCodesChart' ;
12- import TrafficChart from '../charts/TrafficChart' ;
13- import RouteChart from '../charts/RouteChart' ;
14- import LogsTable from '../charts/LogsTable' ;
15- import EventContainer from './EventContainer' ;
16- import TransferColumns from '../components/TransferColumns' ;
17- import HealthContainer from './HealthContainer' ;
18- import ModifyMetrics from './ModifyMetricsContainer' ;
19- import * as DashboardContext from '../context/DashboardContext' ;
20- import lightAndDark from '../components/Styling' ;
21- import DockerHealthContainer from './DockerHealthContainer' ;
4+ import { ApplicationContext } from '../../ context/ApplicationContext' ;
5+ import { HealthContext } from '../../ context/HealthContext' ;
6+ import { CommsContext } from '../../ context/CommsContext' ;
7+ import { DockerContext } from '../../ context/DockerContext' ;
8+ import { EventContext } from '../../ context/EventContext' ;
9+ import Header from '../../ components/Header' ;
10+ import RequestTypesChart from '../../ charts/RequestTypesChart' ;
11+ import ResponseCodesChart from '../../ charts/ResponseCodesChart' ;
12+ import TrafficChart from '../../ charts/TrafficChart' ;
13+ import RouteChart from '../../ charts/RouteChart' ;
14+ import LogsTable from '../../ charts/LogsTable' ;
15+ import EventContainer from '.. /EventContainer' ;
16+ import TransferColumns from '../../ components/TransferColumns' ;
17+ import HealthContainer from '.. /HealthContainer' ;
18+ import ModifyMetrics from '.. /ModifyMetricsContainer' ;
19+ import * as DashboardContext from '../../ context/DashboardContext' ;
20+ import lightAndDark from '../../ components/Styling' ;
21+ import DockerHealthContainer from '.. /DockerHealthContainer' ;
2222
23- import GraphNavBar from '../components/GraphNavBar' ;
23+ import GraphNavBar from '../../ components/GraphNavBar' ;
2424
25- import '../stylesheets/GraphsContainer.scss' ;
26- import Inspect from './Inspect' ;
25+ import '../../ stylesheets/GraphsContainer.scss' ;
26+ import Inspect from '.. /Inspect' ;
2727
2828interface Params {
2929 app : any ;
@@ -94,48 +94,25 @@ const GraphsContainer: React.FC = React.memo(() => {
9494 //random variable to hold the light or dark mode of the display?..ok....sure
9595 const currentMode = mode === 'light' ? lightAndDark . lightModeText : lightAndDark . darkModeText ;
9696
97- const stringToColour = ( string : string , recurses = 0 ) => {
98- if ( recurses > 20 ) return string ;
99- function hashString ( str : string ) {
100- let hash = 0 ;
101- for ( let i = 0 ; i < str . length ; i ++ ) {
102- hash = str . charCodeAt ( i ) + ( ( hash << 5 ) - hash ) ;
103- }
104- let colour = '#' ;
105- for ( let i = 0 ; i < 3 ; i ++ ) {
106- const value = ( hash >> ( i * 8 ) ) & 0xff ;
107- colour += `00${ value . toString ( 16 ) } ` . substring ( - 2 ) ;
108- }
109- return colour ;
110- }
111- function contrastYiq ( color : string ) {
112- const num = parseInt ( color . slice ( 1 ) , 16 ) ;
113- const r = ( num >>> 16 ) & 0xff ;
114- const g = ( num >>> 8 ) & 0xff ;
115- const b = num & 0xff ;
116- const yiq = ( r * 299 + g * 587 + b * 114 ) / 1000 ;
117- return yiq <= 50 ? stringToColour ( color , recurses + 1 ) : color ;
118- }
119- for ( let salt = 0 ; salt < 5 ; salt ++ ) string = hashString ( string ) ;
120- return contrastYiq ( string ) ;
121- } ;
122-
12397 return (
12498 < >
99+
125100 < GraphNavBar
126101 chart = { chart }
127102 setChart = { setChart }
128103 dockerData = { dockerData }
129104 inspect = { inspect }
130105 setInspect = { setInspect }
131106 />
132- < Header
107+ < Header
133108 app = { app }
134109 service = { service }
135110 live = { live }
136111 setLive = { setLive }
137112 />
113+
138114 { inspect && < Inspect /> }
115+
139116 < div className = "graphs-container" >
140117 { chart === 'communications' ? (
141118 < div className = "graphs" >
@@ -155,22 +132,25 @@ const GraphsContainer: React.FC = React.memo(() => {
155132 ) }
156133 { chart . startsWith ( 'health_' ) && (
157134 < HealthContainer
158- colourGenerator = { stringToColour }
159135 sizing = "solo"
160136 category = { chart . substring ( 7 ) }
161- currentService = { service }
162137 />
163138 ) }
164139 { chart . startsWith ( 'event_' ) && (
165140 < >
166- < EventContainer colourGenerator = { stringToColour } sizing = "solo" />
141+ < EventContainer
142+ sizing = "solo"
143+ />
167144 </ >
168145
169146 ) }
170147 { /* docker charts */ }
171148 { chart . startsWith ( 'docker_' ) && (
172149 < >
173- < DockerHealthContainer colourGenerator = { stringToColour } sizing = "solo" category = { chart . substring ( 7 ) } />
150+ < DockerHealthContainer
151+ sizing = "solo"
152+ category = { chart . substring ( 7 ) }
153+ />
174154 </ >
175155
176156 ) }
0 commit comments