@@ -26,30 +26,32 @@ const HealthContainer: React.FC<HealthContainerProps> = React.memo(props => {
2626 useEffect ( ( ) => {
2727 const temp : JSX . Element [ ] = [ ] ;
2828 let counter : number = 0 ;
29- const datalist : any [ ] = healthData . healthDataList ;
30- const timelist : any [ ] = healthData . healthTimeList ;
31- // dataList and timeList are the EXACT same thing . An array of 4 objects. [Memory, CPU, Processes, Latency]
29+ const dataList : any [ ] = healthData . healthdataList ;
30+ const timeList : any [ ] = healthData . healthTimeList ;
31+ // dataList and timeList are structured the same, but time holds timestamps . An array of 4 objects. [Memory, CPU, Processes, Latency]
3232 // Each element has all its metrics.
3333 console . log ( 'healthData object in state: ' , healthData ) ;
34- console . log ( 'datalist in healthcontainer is:' , datalist ) ; //array of healthDataList
35- console . log ( 'timelist in healthcontainer is:' , timelist ) ;
34+ console . log ( 'dataList in healthcontainer is:' , dataList ) ; //array of healthdataList
35+ console . log ( 'timelist in healthcontainer is:' , timeList ) ;
3636
37- if ( healthData && datalist && timelist && datalist . length > 0 && timelist . length > 0 ) {
37+ if ( healthData && dataList && timeList && dataList . length > 0 && timeList . length > 0 ) {
3838 let selectedMetricsList : string [ ] = [ ] ;
3939 selectedMetrics . forEach ( element => {
4040 if ( Object . keys ( element ) [ 0 ] === category ) {
4141 selectedMetricsList = element [ category ] ;
4242 }
4343 } ) ;
44+ // temporary solution to getting the list of times for our single chart
45+ const times : string [ ] = timeList [ 0 ] . Memory [ 0 ] . books [ 0 ] . activememory_in_bytes ;
4446
45- datalist . forEach ( ( element : { } ) => {
47+ dataList . forEach ( ( element : { } ) => {
4648 const categoryName : string = Object . keys ( element ) [ 0 ] ;
4749 /*
48- 'element' is the category found in the datalist response from the server query for metrics data.
50+ 'element' is the category found in the dataList response from the server query for metrics data.
4951 The above forEach method loops through the different categories.
5052 The 'category' variable is the specific category passed in to HealthContainer via prop drilling.
5153 The 'category' is the string Memory, CPU, or others that are in the Category column of the Query Selector interface.
52- The 'categoryName' is the string that is Memory/CPU/other inside the metrics data response ('datalist ' or 'timelist').
54+ The 'categoryName' is the string that is Memory/CPU/other inside the metrics data response ('dataList ' or 'timelist').
5355 When the 'element'/'categoryName' matches the 'category' selected in the Query Selection interface...
5456 ... it will dive into that Category object to pull out a chart for each metric selected in the selection interface.
5557 selectedMetricsList is derived from the selectedMetrics that were in the QueryContext.
@@ -58,33 +60,52 @@ const HealthContainer: React.FC<HealthContainerProps> = React.memo(props => {
5860 */
5961 if ( category === categoryName ) {
6062 const categoryObj : [ ] = element [ categoryName ] ;
63+ let filteredMetrics ;
6164 for ( const metricObj of categoryObj ) {
65+ // serviceName = category (ex. books)
6266 const serviceName : string = Object . keys ( metricObj ) [ 0 ] ;
67+ /* serviceMetricsArr = array of ALL objects
68+ [0: {
69+ total-availle-memory-in-bytes: [numbers, more numbers, nums, woo]
70+ }]
71+ */
6372 const serviceMetricsArr : any [ ] = Object . values ( metricObj ) . flat ( ) ;
73+ // const serviceTimesArr: any[] = Object.values();
6474 console . log ( 'serviceMetricsArr: ' , serviceMetricsArr ) ; // -> array of objects.
65- for ( const serviceMetric of serviceMetricsArr ) {
66- const metric : string = Object . keys ( serviceMetric ) [ 0 ] ;
67- const valueList = Object . values ( serviceMetric ) [ 0 ] ;
68- const newTimeList : any = getTime ( timelist , serviceName , metric , categoryName ) ;
69- // console.log('valueList is', valueList); //-> 50 values in an array
70- // console.log('newTimeList array is:', newTimeList); //-> 50 values in an array
71- if ( selectedMetricsList . includes ( metric ) ) {
72- const re = / _ / g;
73- const newHealthChart = (
74- < HealthChart
75- key = { `Chart${ counter } ` }
76- renderService = { serviceName }
77- metric = { metric . replace ( re , " " ) }
78- timeList = { newTimeList }
79- valueList = { valueList }
80- sizing = { props . sizing }
81- colourGenerator = { props . colourGenerator }
82- />
83- ) ;
84- counter ++ ;
85- temp . push ( newHealthChart ) ;
86- }
87- }
75+ // filter through the desired metrics and pass them down to HealthChart
76+ selectedMetricsList . forEach ( selected => {
77+ filteredMetrics = serviceMetricsArr . filter ( metric => {
78+ metric [ selected ] ;
79+ } ) ;
80+ } ) ;
81+
82+ // serviceMetricsArr.filter(...selectedMetricsList)
83+
84+ // for (const serviceMetric of serviceMetricsArr) {
85+ // const metric: string = Object.keys(serviceMetric)[0];
86+ // const valueList = Object.values(serviceMetric)[0];
87+ // const newTimeList: any = getTime(timelist, serviceName, metric, categoryName);
88+ // console.log('valueList is', valueList); //-> 50 values in an array
89+ // console.log('newTimeList array is:', newTimeList); //-> 50 values in an array
90+ // if (selectedMetricsList.includes(metric)) {
91+ const re = / _ / g;
92+ const newHealthChart = (
93+ < HealthChart
94+ key = { `Chart${ counter } ` }
95+ categoryName = { categoryName }
96+ serviceName = { serviceName }
97+ // metric={metric.replace(re, " ")}
98+ metrics = { filteredMetrics }
99+ timeList = { times }
100+ // valueList={valueList}
101+ sizing = { props . sizing }
102+ colourGenerator = { props . colourGenerator }
103+ />
104+ ) ;
105+ counter ++ ;
106+ temp . push ( newHealthChart ) ;
107+ // }
108+ // }
88109 }
89110 }
90111 } ) ;
0 commit comments