Skip to content

Commit 5a7d32f

Browse files
jesslleeJustinlkirkastholdenwilliamowen65
committed
Created new files(FirstLaunch, LandingPageContainer). Attempting to create a landing page for first-time users to choose to either start as an enterprise or start as an individual. Issues with dashboard.ts: ipcRenderer.sendSync.
Co-authored-by: Justin Kirk <[email protected]> Co-authored-by: Alexander Holden <[email protected]> Co-authored-by: William Owen <[email protected]>
1 parent 4cf8847 commit 5a7d32f

13 files changed

+80
-35
lines changed

.eslintrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"globals": {
3+
"NodeJS": true,
4+
"JSX": true,
5+
"Electron": true
6+
},
27
"plugins": ["react", "prettier"],
38
"parser": "babel-eslint",
49
"parserOptions": {

app/components/FirstLaunch.tsx

Whitespace-only changes.

app/components/Home.tsx app/components/SignUp.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const adminUser = {
2626
};
2727

2828
// removed props as it was not being used
29-
const Home = React.memo(() => {
29+
const SignUp = React.memo(() => {
3030
// const [open, setOpen] = useState<boolean>(false);
3131
const [loginInfo, setLoginInfo] = React.useState<PersonProps>({
3232
email: '',
@@ -59,7 +59,7 @@ const Home = React.memo(() => {
5959
return (
6060
<div className="home">
6161
<p className="welcomeMessage">
62-
Welcome Back To Chronos! Your all-in-one application monitoring tool
62+
Welcome back to Chronos! Your all-in-one application monitoring tool
6363
</p>
6464

6565
<form className="form" onSubmit={submitLogin}>
@@ -98,4 +98,4 @@ const Home = React.memo(() => {
9898
);
9999
});
100100

101-
export default Home;
101+
export default SignUp;

app/containers/Archived.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const GraphsContainer = ({ match }: IMatch) => {
8181
useEffect(() => {
8282
if (live) {
8383
setIntervalID(
84-
setInterval(function () {
84+
setInterval(() => {
8585
fetchCommsData();
8686
fetchHealthData(service);
8787
fetchDockerData(service);
@@ -110,7 +110,8 @@ const GraphsContainer = ({ match }: IMatch) => {
110110
<button onClick={() => setLive(!live)}>
111111
{live ? (
112112
<div>
113-
<span className="dot"></span>Live
113+
<span className="dot" />
114+
Live
114115
</div>
115116
) : (
116117
<div>Gather Live Data</div>

app/containers/GraphsContainer.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface GraphsContainerProps {
3232
};
3333
}
3434

35-
const GraphsContainer: React.FC<GraphsContainerProps> = React.memo(function GraphsContainer (props) {
35+
const GraphsContainer: React.FC<GraphsContainerProps> = React.memo(props => {
3636
const { app, service } = useParams<any>();
3737
const [live, setLive] = useState<boolean>(false);
3838
const [intervalID, setIntervalID] = useState<NodeJS.Timeout | null>(null);
@@ -44,7 +44,7 @@ const GraphsContainer: React.FC<GraphsContainerProps> = React.memo(function Grap
4444
useEffect(() => {
4545
if (live) {
4646
setIntervalID(
47-
setInterval(function () {
47+
setInterval(() => {
4848
fetchCommsData(app, live);
4949
fetchHealthData(service);
5050
fetchDockerData(service);
@@ -78,15 +78,15 @@ const GraphsContainer: React.FC<GraphsContainerProps> = React.memo(function Grap
7878
<LogsTable />
7979
</div>
8080
) : (
81-
<div className="graphs">
82-
<SpeedChart />
83-
<TemperatureChart />
84-
<LatencyChart />
85-
<MemoryChart />
86-
<ProcessesChart />
87-
<DockerChart />
88-
</div>
89-
)}
81+
<div className="graphs">
82+
<SpeedChart />
83+
<TemperatureChart />
84+
<LatencyChart />
85+
<MemoryChart />
86+
<ProcessesChart />
87+
<DockerChart />
88+
</div>
89+
)}
9090
</div>
9191
</>
9292
);
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, { useContext, useEffect } from 'react';
2+
import { Route, Switch } from 'react-router-dom';
3+
4+
import SignUp from '../components/SignUp';
5+
import { DashboardContext } from '../context/DashboardContext';
6+
7+
const LandingPageContainer = React.memo(() => {
8+
const { landingPage, getLandingPage } = useContext(DashboardContext);
9+
10+
// useEffect(() => {
11+
// console.log('LP', landingPage);
12+
// getLandingPage();
13+
// }, []);
14+
// console.log('LP2', landingPage);
15+
16+
return <SignUp />;
17+
});
18+
19+
export default LandingPageContainer;

app/containers/MainContainer.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { useContext } from 'react';
1+
import React, { useContext, useEffect } from 'react';
22
import { Route, Switch } from 'react-router-dom';
33

44
// import GraphsContainer from './Archived';
5-
import Home from '../components/Home';
5+
import LandingPageContainer from './LandingPageContainer';
66
import About from '../components/About';
77
import Contact from '../components/Contact';
88
import Settings from '../components/Settings';
@@ -21,11 +21,12 @@ const MainContainer = React.memo(() => {
2121
const { mode } = useContext(DashboardContext);
2222
const currentModeCSS =
2323
mode === 'light mode' ? lightAndDark.lightModeMain : lightAndDark.darkModeMain;
24+
2425
return (
2526
<div className="main-container" style={currentModeCSS}>
2627
<div className="main-routes">
2728
<Switch>
28-
<Route exact path="/" component={Home} />
29+
<Route exact path="/" component={LandingPageContainer} />
2930
<Route exact path="/about" component={About} />
3031
<Route exact path="/contact" component={Contact} />
3132
<Route exact path="/settings" component={Settings} />

app/context/DashboardContext.tsx

+26-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,27 @@ export const DashboardContext = createContext<any>(null);
2626
const DashboardContextProvider = React.memo(({ children }: Props) => {
2727
const [applications, setApplications] = useState<string[]>([]);
2828
const [mode, setMode] = useState<string>('');
29-
/**
29+
const [landingPage, setLandingPage] = useState<string>('before');
30+
31+
/*
32+
* Sends a request for the existing landing page belonging to the
33+
* organization and sets landing page to it.
34+
*/
35+
const getLandingPage = useCallback(() => {
36+
console.log('36');
37+
const result = ipcRenderer.sendSync('getLP');
38+
console.log('38');
39+
console.log(result);
40+
setLandingPage(result[0]);
41+
}, []);
42+
43+
/*
3044
* Sends a request for all existing applications belonging to a user
3145
* and sets the applications state to the list of app names
3246
* Also sends a request for the previously saved theme/mode
3347
* and sets the mode state to the retrieved settings
3448
*/
49+
3550
const getApplications = useCallback(() => {
3651
const result = ipcRenderer.sendSync('getApps');
3752
setApplications(result[0]);
@@ -74,7 +89,16 @@ const DashboardContextProvider = React.memo(({ children }: Props) => {
7489
}, []);
7590
return (
7691
<DashboardContext.Provider
77-
value={{ applications, getApplications, addApp, deleteApp, mode, changeMode }}
92+
value={{
93+
landingPage,
94+
getLandingPage,
95+
applications,
96+
getApplications,
97+
addApp,
98+
deleteApp,
99+
mode,
100+
changeMode,
101+
}}
78102
>
79103
{children}
80104
</DashboardContext.Provider>

app/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import './stylesheets/index.scss';
4-
import App from './App';
54
import { createMuiTheme, ThemeProvider } from '@material-ui/core';
5+
import App from './App';
66

77
const theme = createMuiTheme({
88
typography: {

electron/databases/mongo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const connectMongoose = async (i: number, URI: string) => {
1616
);
1717
// console.log(`${__dirname}/mongo.ts/connectMongoose: connected!`);
1818
return db;
19-
} catch(err) {
19+
} catch (err) {
2020
console.log(`${__dirname}/mongo.ts/connectMongoose: ${err}`);
2121
}
2222
};

electron/routes/dashboard.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import fs from 'fs';
99
*/
1010

1111
// Loads existing settings JSON and update settings to include new services entered by the user on 'submit' request
12+
ipcMain.on('getLP', message => {
13+
message.returnValue = ['after'];
14+
});
1215

1316
ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
14-
// Retrives file contents from settings.json
17+
// Retrieves file contents from settings.json
1518
const state = JSON.parse(
1619
fs.readFileSync(path.resolve(__dirname, '../user/settings.json')).toString('utf8')
1720
);
@@ -41,7 +44,7 @@ ipcMain.on('addApp', (message: IpcMainEvent, application: any) => {
4144
// Load settings.json and returns updated state back to the render process on ipc 'dashboard' request
4245

4346
ipcMain.on('getApps', message => {
44-
// Retrives file contents from settings.json for current Apps
47+
// Retrieves file contents from settings.json for current Apps
4548
const state = JSON.parse(
4649
fs.readFileSync(path.resolve(__dirname, '../user/settings.json')).toString('utf8')
4750
);

electron/routes/data.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ let currentDatabaseType: string;
2121
*/
2222
ipcMain.on('connect', async (message: Electron.IpcMainEvent, index: number) => {
2323
try {
24-
2524
// Extract databaseType and URI from settings.json at particular index
2625
// get index from application context
2726
const fileContents = fs.readFileSync(path.resolve(__dirname, '../user/settings.json'), 'utf8');
@@ -53,8 +52,6 @@ ipcMain.on('connect', async (message: Electron.IpcMainEvent, index: number) => {
5352
*/
5453
ipcMain.on('servicesRequest', async (message: Electron.IpcMainEvent) => {
5554
try {
56-
57-
5855
let result: any;
5956

6057
// Mongo Database
@@ -84,8 +81,6 @@ ipcMain.on('servicesRequest', async (message: Electron.IpcMainEvent) => {
8481
*/
8582
ipcMain.on('commsRequest', async (message: Electron.IpcMainEvent) => {
8683
try {
87-
88-
8984
let result: any;
9085

9186
// Mongo Database
@@ -117,7 +112,6 @@ ipcMain.on('commsRequest', async (message: Electron.IpcMainEvent) => {
117112
*/
118113
ipcMain.on('healthRequest', async (message: Electron.IpcMainEvent, service: string) => {
119114
try {
120-
121115
let result: any;
122116

123117
// Mongo Database
@@ -159,14 +153,12 @@ ipcMain.on('healthRequest', async (message: Electron.IpcMainEvent, service: stri
159153
*/
160154
ipcMain.on('dockerRequest', async (message, service) => {
161155
try {
162-
163156
let result: any;
164157
// Mongo Database
165158
if (currentDatabaseType === 'MongoDB') {
166159
// Get document count
167160
let num = await DockerModelFunc(service).countDocuments();
168-
169-
//Get last 50 documents. If less than 50 documents, get all
161+
// Get last 50 documents. If less than 50 documents, get all
170162
num = Math.max(num, 50);
171163
result = await DockerModelFunc(service).find().skip(num - 50);
172164
}

electron/user/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
"Jul 3, 2020 7:12AM"
1717
]
1818
],
19-
"mode":"light mode",
19+
"mode":"dark mode",
2020
"splash": true
2121
}

0 commit comments

Comments
 (0)