Skip to content

Commit fd6604f

Browse files
committed
Merge branch 'dev' into brisa_example_testing
2 parents af1232e + 040d547 commit fd6604f

File tree

7 files changed

+65
-60
lines changed

7 files changed

+65
-60
lines changed

app/charts/HealthChart.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,34 @@ const HealthChart: React.FC<HealthChartProps> = React.memo(props => {
3939
};
4040

4141
// pulls the current service names to be shown in the graph title from chartData
42-
const serviceNamesAsString = (chartData: object): string => {
42+
const serviceNamesAsString = (chartDataObject: object): string => {
4343
let serviceNameString = '';
44-
for (const serviceName in chartData) {
44+
for (const serviceName in chartDataObject) {
4545
serviceNameString += `${serviceName} | `;
4646
}
4747
return serviceNameString;
4848
};
4949

5050
// generates an array of plotly data objects to be passed into our plotly chart's data prop
51-
const generatePlotlyDataObjects = (chartData: object): object[] => {
51+
const generatePlotlyDataObjects = (chartDataObj: object): object[] => {
5252
const arrayOfPlotlyDataObjects: PlotlyData[] = [];
5353
// iterate through the chartData
54-
for (const serviceName in chartData) {
54+
for (const serviceName in chartDataObj) {
55+
console.log('SERVICENAME: ', serviceName);
5556
// define the metrics for this service
56-
const metrics = chartData[serviceName];
57+
const metrics = chartDataObj[serviceName];
58+
console.log('METRICS: ', metrics);
5759
// loop through the list of metrics for the current service
5860
for (const metricName in metrics) {
61+
console.log('METRICNAME: ', metricName);
5962
// define the value and time arrays; allow data to be reassignable in case we need to convert the bytes data into megabytes
6063
let dataArray = metrics[metricName].value;
64+
console.log('DATAARRAY: ', dataArray);
6165
const timeArray = metrics[metricName].time;
66+
console.log('TIMEARRAY: ', timeArray);
6267
// specifically for `Megabyte` types, convert the original data of bytes into a value of megabytes before graphing
63-
if (dataType === 'Memory in Megabytes' || 'Cache in Megabytes') {
68+
if (dataType === 'Memory in Megabytes' || dataType === 'Cache in Megabytes') {
69+
console.log('DATATYPE: ', dataType);
6470
dataArray = dataArray.map(value => (value / 1000000).toFixed(2));
6571
}
6672
// create the plotly object
@@ -74,6 +80,7 @@ const HealthChart: React.FC<HealthChartProps> = React.memo(props => {
7480
colors: ['#fc4039', '#4b54ea', '#32b44f', '#3788fc', '#9c27b0', '#febc2c'],
7581
},
7682
};
83+
console.log('PLOTLYDATAOBJECT: ', plotlyDataObject)
7784
// push the dataObject into the arrayOfPlotlyDataObjects
7885
arrayOfPlotlyDataObjects.push(plotlyDataObject);
7986
}

app/components/Splash.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import '../stylesheets/Splash.scss';
33

4-
//Chronos logo when first starting the electron app. Has the picture for 4 seconds.
4+
//Chronos logo when first starting the electron app. Has the picture for 4 seconds.
55
const Splash: React.FC = React.memo(props => {
66
const [visible, setVisible] = useState(true);
77

@@ -13,7 +13,7 @@ const Splash: React.FC = React.memo(props => {
1313
<>
1414
{visible && (
1515
<div id="splash">
16-
<img id="splashLogo" src="../assets/logo.svg" alt="Chronos" />
16+
<img id="splashLogo" src="assets/logo.svg" alt="Chronos" />
1717
</div>
1818
)}
1919
</>

app/containers/HealthContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const HealthContainer: React.FC<HealthContainerProps> = React.memo(props => {
133133
typeGroupedObject[metricType][serviceName][metric] = metrics[metric];
134134
}
135135
}
136-
console.log('typeGroupedObject: ', typeGroupedObject);
136+
137137
return typeGroupedObject;
138138
};
139139

app/containers/SidebarContainer.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,31 @@ import { AwsContext } from '../context/AwsContext';
1212

1313
const SidebarContainer = React.memo(props => {
1414
// Extract invervalID from ApplicationContext. Initival value: intervalID = null
15-
const { intervalID } = useContext (ApplicationContext);
15+
const { intervalID } = useContext(ApplicationContext);
1616
// Extract isLoading and setLoading state from AwsContext. Initial value: isLoading = true
17-
const { isLoading, setLoadingState } = useContext(AwsContext);
17+
const { isLoading, setLoadingState } = useContext(AwsContext);
1818

1919
// clear interval and set loading state to true when leaving graph containers
2020

2121
/**
22-
* @function handleCLick - check if the 'intervalID' exists. If so, theres a timer running and the fuunction clears the timer using @function clearInterval - function.
23-
* Checks if variable 'isLoading' is false and if so the content is not loading and therefore, sets it to true using the setLoadingState function.
22+
* @function handleCLick - check if the 'intervalID' exists. If so, theres a timer running and the fuunction clears the timer using @function clearInterval - function.
23+
* Checks if variable 'isLoading' is false and if so the content is not loading and therefore, sets it to true using the setLoadingState function.
2424
*/
2525
const handleClick = () => {
26-
if(intervalID) clearInterval(intervalID);
27-
if(!isLoading) setLoadingState(true);
28-
}
26+
if (intervalID) clearInterval(intervalID);
27+
if (!isLoading) setLoadingState(true);
28+
};
2929

3030
return (
3131
<div className="sidebar-container" id="mySidebar">
3232
<div className="sidebar">
3333
<div className="firstRow">
3434
<span>
35-
<img alt="C" id="C" src="../assets/C.svg" />
35+
{/* Attempting to change the path by taking out the ../ */}
36+
<img alt="C" id="C" src="assets/C.svg" />
3637
</span>
3738
<span>
38-
<img alt="Chronos" id="logo" src="../assets/logo.svg" />
39+
<img alt="Chronos" id="logo" src="assets/logo.svg" />
3940
</span>
4041
</div>
4142
<hr className="line" id="firstLine" />
@@ -87,7 +88,7 @@ const SidebarContainer = React.memo(props => {
8788
</div>
8889
</div>
8990
</div>
90-
)
91+
);
9192
});
9293

9394
export default SidebarContainer;

electron/Main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const createWindow = () => {
2222
nodeIntegration: true,
2323
contextIsolation: false,
2424
},
25-
2625
});
2726

2827
if (process.env.NODE_ENV === 'development') {
@@ -33,7 +32,7 @@ const createWindow = () => {
3332
win.webContents.openDevTools();
3433
} else {
3534
// Production
36-
win.loadFile(path.resolve(__dirname, '../index.html'));
35+
win.loadFile(path.join(app.getAppPath(), 'index.html'));
3736
}
3837

3938
ipcMain.on('max', () => {
Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import KafkaModel from '../models/KafkaModel';
22
import HealthModelFunc from '../models/HealthModel';
3+
import { Pool } from 'pg';
34

4-
const fetchData = {};
5+
interface fetchData {
6+
mongoFetch: (serviceName: string) => Promise<Array<{ [key: string]: any[] }>>;
7+
postgresFetch: (serviceName: string, pool: Pool) => Promise<Array<{ [key: string]: any[] }>>;
8+
}
59

6-
const aggregator = [
10+
const aggregator: any[] = [
711
{
812
$setWindowFields: {
913
partitionBy: '$metric',
@@ -24,10 +28,9 @@ const aggregator = [
2428
},
2529
];
2630

27-
// healthModelFunc creates a model based on the serviceName
28-
// Create an aggregator based on the aggregator variable
29-
// return the result
30-
fetchData.mongoFetch = async function (serviceName) {
31+
const mongoFetch = async (
32+
serviceName: string
33+
): Promise<Array<{ [key: string]: any[] }> | undefined> => {
3134
try {
3235
const testModel = HealthModelFunc(serviceName);
3336
let result = await testModel.aggregate(aggregator);
@@ -38,17 +41,18 @@ fetchData.mongoFetch = async function (serviceName) {
3841
}
3942
};
4043

41-
fetchData.postgresFetch = async function (serviceName, pool) {
44+
const postgresFetch = async (
45+
serviceName: string,
46+
pool: Pool
47+
): Promise<Array<{ [key: string]: any[] }> | undefined> => {
4248
const query = `
43-
WITH
44-
temp
45-
AS (
49+
WITH temp AS (
4650
SELECT
4751
metric, value, category, time,
4852
row_number() OVER(PARTITION BY metric ORDER BY time DESC) AS rowNumber
4953
FROM
5054
${serviceName}
51-
)
55+
)
5256
SELECT
5357
metric, value, category, time
5458
FROM
@@ -57,12 +61,19 @@ fetchData.postgresFetch = async function (serviceName, pool) {
5761
rowNumber <= 50
5862
;`;
5963

60-
let result = await pool.query(query);
61-
// console.log('result.rows in dataHelpers postgresFetch:', JSON.stringify(result.rows));
62-
result = result.rows;
63-
result = [{ [serviceName]: result }];
64-
// console.log('result with servicename in dataHelpers postgresFetch:', JSON.stringify(result));
65-
return result;
64+
try {
65+
let result = await pool.query(query);
66+
result = result.rows;
67+
result = [{ [serviceName]: result }];
68+
return result;
69+
} catch (error) {
70+
console.log('Query error in postgresFetch(): ', error);
71+
}
72+
};
73+
74+
const fetchData = {
75+
mongoFetch,
76+
postgresFetch,
6677
};
6778

6879
export { fetchData };

utilities/copyDist.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
// THIS IS THE OLD BUILD CODE IN THE PACKAGE.JSON:
2-
/* "prepareDist": "npm run deleteDist && tsc -v && tsc -p . && npm run build &&
3-
npm run copyAssetsDist &&
4-
npm run copyPackageJsonDist &&
5-
npm run copyBuildDist &&
6-
npm run copyBuildDBDist &&
7-
npm run copyBuildModelsDist &&
8-
npm run copyBuildRoutesDist &&
9-
npm run copyBuildUtilitiesDist &&
10-
npm run copySettingsDist &&
11-
npm run installDep",
12-
*/
13-
14-
151
/* Use this to prepare packaging the electron app into an executable
162
tsc compiled the electron "backend" code into the /build folder
173
webpack compiled the react "frontend" code into the /dist folder
@@ -22,18 +8,19 @@ of the /dist folder, so copy the required code into this folder
228
const fse = require('fs-extra');
239
const path = require('path');
2410

25-
console.log('Copying files into the /dist folder prior to electron packaging')
11+
console.log('Copying files into the /dist folder prior to electron packaging');
2612

2713
let sourceDir;
2814
let destDir;
2915

30-
// "copyAssetsDist": "echo D | xcopy app\\assets dist\\assets",
31-
// sourceDir = path.resolve(__dirname, '../app/assets');
32-
// destDir = path.resolve(__dirname, '../dist/assets');
33-
// if (!fse.existsSync(destDir)) {
34-
// fse.mkdirSync(destDir);
35-
// }
36-
// fse.copySync(sourceDir, destDir);
16+
// Copy assets from app/assets into dist
17+
// so that assets load in package build
18+
sourceDir = path.resolve(__dirname, '../app/assets');
19+
destDir = path.resolve(__dirname, '../dist/assets');
20+
if (!fse.existsSync(destDir)) {
21+
fse.mkdirSync(destDir);
22+
}
23+
fse.copySync(sourceDir, destDir);
3724

3825
// Copy package.json from root directory into webpack's /dist folder
3926
// so that the necessary node modules can get installed

0 commit comments

Comments
 (0)