Skip to content

Commit 94e7adb

Browse files
committed
working docker example, breaks other examples (probably)
1 parent a69b7c1 commit 94e7adb

File tree

8 files changed

+66
-47
lines changed

8 files changed

+66
-47
lines changed

app/components/TransferColumns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ const TransferColumns = React.memo(() => {
146146

147147
// makes the column titles for the selection grid
148148
const columns = [
149-
{ field: 'id', headerName: 'ID', width: 100 },
149+
{ field: 'id', headerName: 'ID', flex: 1 },
150150
{
151151
field: 'tag',
152152
headerName: 'Category',

app/context/EventContext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const EventContextProvider: React.FC<Props> = React.memo(({ children }) => {
5656
if (tryParseJSON(data)) {
5757
const result: object[] = JSON.parse(data);
5858
if (result && result.length > 0) {
59+
console.log('EventContext ln 59 result data: ', result)
5960
const transformedData: object = eventTransformer(result[0][arg]);
6061
setEventData(transformedData);
6162
}

app/context/HealthContext.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,34 @@ const HealthContextProvider: React.FC<Props> = React.memo(({ children }) => {
6161
let promises = await Promise.all(serv.map( async (service: string) => {
6262

6363
try {
64-
const newPromise = await new Promise((resolve, reject) => {
64+
const newPromise: any = await new Promise((resolve, reject) => {
6565
ipcRenderer.send('healthRequest', `${service}-containerinfos`);
6666
ipcRenderer.on('healthResponse', (event: Electron.Event, data: string) => {
6767
let result: object[];
6868
if (JSON.stringify(data) !== '{}' && tryParseJSON(data)) {
6969
result = JSON.parse(data);
7070
console.log('HealthContext.tsx line 68 result: ', result, 'service', service, 'Obj key', Object.keys(result[0])[0]);
71-
// if (result && result.length && service === Object.keys(result[0])[0]) {
71+
//result exists, has a length prop, and the service name and database name are same
72+
if (result && result.length && `${service}-containerinfos` === Object.keys(result[0])[0]) {
7273
resolve(result[0]);
73-
// }
74+
}
7475
}
7576
});
7677
})
77-
console.log('HealthContext.tsx line 75 newPromise: ', newPromise);
78-
// temp.push(newPromise);
79-
// if (checkServicesComplete(temp, serv)) {
80-
// setServices(serv);
81-
// let transformedData: any = {};
82-
// console.log('original healthData before transformation: ', temp);
83-
// transformedData = healthTransformer(temp);
84-
// console.log('healthData after tranformation: ', transformedData);
85-
// setHealthData(transformedData);
86-
// }
78+
temp.push(newPromise);
79+
console.log('HealthContext.tsx line 80 temp populates?: ', temp, serv)
80+
if (checkServicesComplete(temp, [`${service}-containerinfos`])) {
81+
setServices([`${service}-containerinfos`]);
82+
let transformedData: any = {};
83+
console.log('original healthData before transformation: ', temp);
84+
// transformedData = {
85+
// healthDataList: [1,2,3,4,5],
86+
// healthTimeList: [1,2,3,4,5]
87+
// } //testing typescript, transformedDATA of type 2 arrays with basic entries?
88+
transformedData = healthTransformer(temp); //must match the setHealthData STATE format
89+
console.log('healthData after tranformation: ', transformedData);
90+
setHealthData(transformedData);
91+
}
8792
} catch (err) {
8893
console.log("healthcontext.tsx ERROR: ", err);
8994
};
@@ -135,6 +140,7 @@ const HealthContextProvider: React.FC<Props> = React.memo(({ children }) => {
135140
for (let i = 0; i < temp.length; i++) {
136141
arr1.push(Object.keys(temp[i])[0]);
137142
}
143+
console.log('in checkServicesComplete line 139: ', arr1)
138144
return arr1.sort().toString() === serv.sort().toString();
139145
};
140146

app/context/helpers.ts

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,52 @@ interface HealthDataObject {
3838
// Transforms health data into a nested object based on service name
3939
export function healthTransformer(healthData: HealthDataObject[]) {
4040
// make an object for storing different services' metrics data
41-
const serviceMetricsObject = {};
41+
const serviceMetricsObject = {}; //books:..., customers:..., orders:..., frontend:...
4242
// loop through the services in the healthData array
43-
healthData.forEach(serviceObj => {
43+
healthData.forEach(serviceObj => { //books
4444
// grab the key string from the current service object
45-
const serviceName = Object.keys(serviceObj)[0];
46-
const serviceElements = serviceObj[serviceName];
47-
console.log('helpers.ts ln 47 serviceElements: ', serviceElements);
45+
const serviceName = Object.keys(serviceObj)[0]; //books-containerinfos
4846
// add the serviceName as a key on the serviceMetricsObject and assign it an empty object
49-
serviceMetricsObject[serviceName] = {};
47+
serviceMetricsObject[serviceName] = {}; //add key service Name to object
48+
const serviceElements = serviceObj[serviceName]; //array of metric objects IN heatlhdataObj @ serviceName
49+
console.log('serviceElements: ', serviceElements);
5050
// loop through the elements of the current service
51-
serviceElements.forEach(dataObject => {
52-
// if it doesn't exist, generate a key for that object that matches the category value of the current dataObject
53-
if (!serviceMetricsObject[serviceName][dataObject.category]) {
54-
serviceMetricsObject[serviceName][dataObject.category] = {};
51+
serviceElements.forEach((dataObject:any) => { //--v12 --make it an object typscript?
52+
console.log('raw dataOBJ LN 53', dataObject);
53+
// !containerName exist, generate a key for that object that matches the category value of the current dataObject
54+
let containerName = dataObject.containername;
55+
if (!serviceMetricsObject[serviceName][containerName]) {
56+
serviceMetricsObject[serviceName][containerName] = {};
57+
console.log('line 58 if category ', [containerName])
5558
}
56-
// in that nested object, assign a key using the current dataObject's metric value and assign its value an empty object
57-
if (!serviceMetricsObject[serviceName][dataObject.category][dataObject.metric]) {
58-
serviceMetricsObject[serviceName][dataObject.category][dataObject.metric] = {};
59-
}
60-
// if the 'value' key doesn't exist in the previous object assign a key of 'value' with the value of an array that includes the value of value
61-
if (!serviceMetricsObject[serviceName][dataObject.category][dataObject.metric].value) {
62-
serviceMetricsObject[serviceName][dataObject.category][dataObject.metric].value = [dataObject.value];
63-
} else { // if it does exist, push the value of the current dataObject's time key onto the array
64-
serviceMetricsObject[serviceName][dataObject.category][dataObject.metric].value.push(
65-
dataObject.value
66-
);
67-
}
68-
// in that same object, if the key 'time' doesn't exist yet, assign a key of 'time' with the value as an array that includes the time value
69-
if (!serviceMetricsObject[serviceName][dataObject.category][dataObject.metric].time) {
70-
serviceMetricsObject[serviceName][dataObject.category][dataObject.metric].time = [dataObject.time];
71-
} else { // if it does exist aready, push the current time value into the time array
72-
serviceMetricsObject[serviceName][dataObject.category][dataObject.metric].time.push(
73-
dataObject.time
74-
);
59+
60+
for (let metric in dataObject) { //loop the data object for metric names and values
61+
// in containerName nested object, assign a key using the current dataObject's metric value and assign its value an empty object
62+
if (!serviceMetricsObject[serviceName][containerName][metric]) {
63+
serviceMetricsObject[serviceName][containerName][metric] = {};
64+
console.log('line 60 if metric ', metric)
65+
}
66+
// if the 'value' key doesn't exist in the previous object assign a key of 'value' with the value of an array that includes the value of value
67+
if (!serviceMetricsObject[serviceName][containerName][metric].value) {
68+
serviceMetricsObject[serviceName][containerName][metric].value = [dataObject[metric]];
69+
console.log('line 65 if value ', dataObject[metric])
70+
} else { // if it does exist, push the value of the current dataObject's time key onto the array
71+
serviceMetricsObject[serviceName][containerName][metric].value.push(
72+
dataObject[metric]
73+
);
74+
console.log('line 68 else value ', dataObject[metric])
75+
}
76+
// in that same object, if the key 'time' doesn't exist yet, assign a key of 'time' with the value as an array that includes the time value
77+
if (!serviceMetricsObject[serviceName][containerName][metric].time) {
78+
serviceMetricsObject[serviceName][containerName][metric].time = [dataObject.time];
79+
console.log('line 75 if time ', [dataObject.time])
80+
} else { // if it does exist aready, push the current time value into the time array
81+
serviceMetricsObject[serviceName][containerName][metric].time.push(
82+
dataObject.time
83+
);
84+
console.log('line 78 else time ', [dataObject.time])
85+
}
86+
console.log('serviceMetricsOBJ LN83: ', serviceMetricsObject)
7587
}
7688
});
7789
})

app/modals/ServicesModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface IService {
2121
// servicesModal is re-rendered depending on i and application passed in...
2222
const ServicesModal: React.FC<ServicesModalProps> = React.memo(({ i, app }) => {
2323
//console.log('Hi, inside ServicesModal. Memoize function invoked in ServicesModal.');
24-
console.log('ServicesModal current props (index, app): ', i, ' ', app);
24+
//console.log('ServicesModal current props (index, app): ', i, ' ', app);
2525

2626
const { user, applications } = useContext(DashboardContext);
2727
const { servicesData, connectToDB } = useContext(ApplicationContext);

electron/databases/mongo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import mongoose from 'mongoose';
22
// import { MongoError } from 'mongodb';
3-
const testURL = 'mongodb+srv://<username>:<password>@cluster0.axo7iyw.mongodb.net/';
3+
const testURL = '';
44
// Mongoose connection wrapped in function that takes the index of the selected database as the parameter. This index is used to target the correct database for querying.
55
const connectMongoose = async (i:number, URI: string) => {
66
try {

electron/routes/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ ipcMain.on('healthRequest', async (message: Electron.IpcMainEvent, service: stri
181181
message.sender.send('healthResponse', JSON.stringify(result));
182182
} catch (error) {
183183
// Catch errors
184-
console.log('error sending result to healthresponse in healthrequest')
184+
console.log('error sending result to healthresponse in healthrequest', error)
185185
// console.log(' event', message);
186186
// message.sender.send('healthResponse', {});
187187
}

examples/docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Peform the following steps in each of the _books_, _customers_, _frontend_, and
2727
1. Add a `.env` file to *each* folder with the following key/value pairs:
2828
- **NOTE**: Ensure that there are no quotes surrounding any of the keys and values.
2929

30-
>>>New collaboration group - testing all 5 added to each .env// --> testing now...<<<
30+
>>>New collaboration group - testing all 5 url added to each .env// --> testing now...<<<
3131
3232
```
3333
CHRONOS_DB = MongoDB or PostgreSQL

0 commit comments

Comments
 (0)