@@ -9,11 +9,10 @@ export const HealthContext = React.createContext<any>(null);
9
9
10
10
/**
11
11
* MANAGES THE FOLLOWING DATA AND ACTIONS:
12
- * @property {Object } datalist At most, 50 points of health data
13
- * @property {Object } timelist Health data timestamps
12
+ * @property {Object } healthData
14
13
* @method setServices
15
- * @method setDataList
16
- * @method setTimeList
14
+ * @method setHealthData
15
+
17
16
*/
18
17
19
18
const HealthContextProvider : React . FC = React . memo ( ( { children } ) => {
@@ -43,26 +42,14 @@ const HealthContextProvider: React.FC = React.memo(({ children }) => {
43
42
let temp : any [ ] = [ ] ;
44
43
45
44
Promise . all (
46
- serv . map ( ( service : string ) =>
47
- new Promise ( ( resolve , reject ) => {
45
+ serv . map ( ( service : string ) => {
46
+ // if(service !== 'kafkametrics'){
47
+
48
+ return new Promise ( ( resolve , reject ) => {
48
49
console . log ( 'serv in healthcontext:' , JSON . stringify ( serv ) ) ;
49
50
ipcRenderer . send ( 'healthRequest' , service ) ;
50
51
ipcRenderer . on ( 'healthResponse' , ( event : Electron . Event , data : string ) => {
51
-
52
-
53
- //second query customers
54
- // [
55
- // {
56
- // customers: [
57
- // { metric: "disk_usage", category: "Memory", time: 1, value: 10 },
58
- // { metric: "disk_usage", category: "Memory", time: 2, value: 20 },
59
- // { metric: "clockSpeed", category: "Memory", time: 1, value: 8 },
60
- // { metric: "clockSpeed", category: "Memory", time: 2, value: 16 },
61
- // { metric: "cpu_temp", category: "CPU", time: 1, value: 100 },
62
- // { metric: "cpu_temp", category: "CPU", time: 2, value: 200 },
63
- // ],
64
- // },
65
- // ]
52
+
66
53
let result : any [ ] ;
67
54
if ( tryParseJSON ( data ) ) {
68
55
console . log ( "data in HealthContext:" , data ) ;
@@ -76,33 +63,11 @@ const HealthContextProvider: React.FC = React.memo(({ children }) => {
76
63
} ) ;
77
64
78
65
} ) . then ( ( dt : any ) => {
79
- temp . push ( dt ) ;
80
- console . log ( "temp is:" , JSON . stringify ( temp ) ) ;
81
- // temp = [
82
- // {
83
- // "chronos-mon": [
84
- // { metric: 'disk_usage', category: 'Memory', time: 1, value: 10 },
85
- // { metric: 'disk_usage', category: 'Memory', time: 2, value: 20 },
86
- // { metric: 'clockSpeed', category: 'Memory', time: 1, value: 8 },
87
- // { metric: 'clockSpeed', category: 'Memory', time: 2, value: 16 },
88
- // { metric: 'cpu_temp', category: 'CPU', time: 1, value: 100 },
89
- // { metric: 'cpu_temp', category: 'CPU', time: 2, value: 200 },
90
- // ],
91
- // },
92
- // {
93
- // "chronos-mon-2": [
94
- // { metric: 'disk_usage', category: 'Memory', time: 1, value: 10000 },
95
- // { metric: 'disk_usage', category: 'Memory', time: 2, value: 20000 },
96
- // { metric: 'clockSpeed', category: 'Memory', time: 1, value: 8000 },
97
- // { metric: 'clockSpeed', category: 'Memory', time: 2, value: 16000 },
98
- // { metric: 'cpu_temp', category: 'CPU', time: 1, value: 10000 },
99
- // { metric: 'cpu_temp', category: 'CPU', time: 2, value: 20000 },
100
- // ],
101
- // },
102
- // ];
66
+ if ( service !== 'kafkametrics' ) {
67
+ temp . push ( dt ) ;
68
+ console . log ( "temp is:" , JSON . stringify ( temp ) ) ;
69
+ }
103
70
if ( checkServicesComplete ( temp , serv ) ) {
104
-
105
- // if (temp.length === serv.length) {
106
71
107
72
setServices ( serv ) ;
108
73
let transformedData : any = { } ;
@@ -111,13 +76,11 @@ const HealthContextProvider: React.FC = React.memo(({ children }) => {
111
76
console . log ( "serv" , serv ) ;
112
77
console . log ( 'transformedData:' , JSON . stringify ( transformedData ) ) ;
113
78
setHealthData ( transformedData ) ;
114
- // setTimeList(transformedData[1]);
115
- // setDataList(transformedData[0]);
116
-
117
-
118
79
119
80
}
120
81
} )
82
+ }
83
+ // }
121
84
)
122
85
) ;
123
86
} , [ ] ) ;
@@ -132,8 +95,6 @@ const HealthContextProvider: React.FC = React.memo(({ children }) => {
132
95
arr1 . push ( Object . keys ( temp [ i ] ) [ 0 ] ) ;
133
96
134
97
}
135
- console . log ( "arr1" , arr1 . sort ( ) . toString ( ) ) ;
136
- console . log ( "serv:" , serv ) ;
137
98
return arr1 . sort ( ) . toString ( ) === serv . sort ( ) . toString ( )
138
99
139
100
} ;
0 commit comments