Skip to content

Commit 8aa34ba

Browse files
committed
login comp
1 parent 5f2e26a commit 8aa34ba

File tree

17 files changed

+81
-826
lines changed

17 files changed

+81
-826
lines changed

SetupApp/Setup/Setup.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

SetupApp/Setup/SetupDisplay.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

SetupApp/Setup/setup.css

Lines changed: 0 additions & 29 deletions
This file was deleted.

SetupApp/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
<div class="buttons">
7070
<h1>Set Up Your Kubernetes Cluster with Docketeer!</h1>
71+
<span>You only need to Install Prometheus Operator once!</span>
7172
<button id="prom">Install Prometheus Operator</button>
7273
<button id="metrics">Set Up Grafana</button>
7374
<button id="port">Launch Port Forwarding</button>

server/controllers/setupController.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { SetupController } from '../../types';
44

55
/**
66
* @description v12.0 implemented k8 cluster metrics! In order to set this up, run npm run dev, go to
7-
* localhost:/3000 click the three buttons in sequence, this will run the necessary shell lines on your host terminal.
8-
* Than you can compose up to see your k8 metrics.
7+
* http://localhost:4000/api/k8 click the three buttons in sequence, this will run the necessary shell lines on your host terminal.
8+
* Open up a new terminal, compose up and see your k8 metrics!
99
*/
1010

1111
const setupController: SetupController = {

src/App.tsx

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Routes, Route, Navigate } from 'react-router-dom';
2+
import { Routes, Route, Navigate, useNavigate } from 'react-router-dom';
33
import Login from './components/Login/Login';
44
import SignUp from './components/SignUp/SignUp';
55
import Home from './components/Home/Home';
66
import Metrics from './components/Metrics/Metrics';
77
import Images from './components/Images/Images';
88
import Containers from './components/Containers/Containers';
99
import Settings from './components/Settings/Settings';
10-
import Users from './components/Users/Users';
1110
import VolumeHistory from './components/VolumeHistory/VolumeHistory';
1211
import ProcessLogs from './components/ProcessLogs/ProcessLogs';
1312
import SharedLayout from './components/SharedLayout/SharedLayout';
@@ -20,29 +19,42 @@ const App = () => {
2019
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2120
const { updateSession } = useSurvey();
2221
const { checkCookie } = useHelper();
23-
const location = useLocation();
22+
const navigate = useNavigate();
23+
2424
const [loading, setLoading] = useState(true);
2525
const [session, setSession] = useState<boolean | undefined>(undefined);
26-
27-
useEffect(() => {
28-
const checkLogin = async () => {
29-
try {
30-
const data = await checkCookie();
31-
if (data) {
32-
updateSession();
33-
setSession(true);
34-
} else {
35-
setSession(false);
36-
}
37-
setLoading(false);
38-
} catch (err) {
39-
console.log('Cannot get uid key or API key:', err);
26+
/**
27+
* updates user session to check if user is logged in by invoking checkCookie
28+
* @method
29+
* @params none
30+
* @returns {Promise<void>} returns a promise when successfully setting the session absed on cookies
31+
*/
32+
const checkLogin = async () => {
33+
try {
34+
const data = await checkCookie();
35+
if (data) {
36+
updateSession();
37+
setSession(true);
38+
39+
} else {
4040
setSession(false);
41-
setLoading(false);
4241
}
43-
};
42+
setLoading(false);
43+
} catch (err) {
44+
console.log('Cannot get uid key or API key:', err);
45+
setSession(false);
46+
setLoading(false);
47+
}
48+
};
49+
50+
useEffect(() => {
4451
checkLogin();
45-
}, [location.pathname, checkCookie, updateSession]);
52+
}, [checkCookie, updateSession]);
53+
54+
const navigateToHome = async () => {
55+
await checkLogin();
56+
navigate('/home');
57+
};
4658

4759
if (loading) {
4860
return <div>Loading...</div>;
@@ -52,15 +64,20 @@ const App = () => {
5264
<Route
5365
path="/"
5466
element={session ? <Navigate to="/home" /> : <Navigate to="/login" />}
55-
/>:
56-
<Route path="/login" element={<Login />} />
67+
/>
68+
:
69+
<Route
70+
path="/login"
71+
element={<Login navigateToHome={navigateToHome} />}
72+
/>
5773
<Route path="/userSignup" element={<SignUp />} />
58-
<Route path="/home" element={session ? <SharedLayout /> :
59-
<Navigate to="/login" />}>
74+
<Route
75+
path="/home"
76+
element={session ? <SharedLayout /> : <Navigate to="/login" />}
77+
>
6078
<Route index element={<Home />} />
6179
<Route path="/home/volume" element={<VolumeHistory />} />
6280
<Route path="/home/metrics" element={<Metrics key={1} />} />
63-
<Route path="/home/users" element={<Users />} />
6481
<Route path="/home/logs" element={<ProcessLogs key={1} />} />
6582
<Route path="/home/about" element={<About />} />
6683
<Route path="/home/images" element={<Images />} />

src/components/About/About.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const About = () => {
2222
real-time tracking of metrics and logs is essential for staying ahead
2323
of potential issues and optimizing your workflows.<p></p>
2424
Our application provides you with the tools you need to take control
25-
of your Docker images, containers, volumes, and logs. With an
26-
intuitive interface and powerful administrative features, you can
27-
easily make the necessary adjustments to ensure a smooth journey
28-
through the cosmos of your Docker environment.
25+
of your Docker images, containers, volumes, and logs, along with the
26+
tools to view your Kubernetes cluster metrics. With an intuitive
27+
interface, you can easily make the necessary adjustments to ensure a
28+
smooth journey through the cosmos of your Docker environment.
2929
</p>
3030
</div>
3131
<div className={styles.section}>
@@ -72,14 +72,15 @@ const About = () => {
7272

7373
<a className={styles.footerIcons} href="mailto:[email protected]">
7474
<svg
75-
width="32"
76-
height="32"
7775
xmlns="http://www.w3.org/2000/svg"
78-
fillRule="evenodd"
79-
clipRule="evenodd"
80-
className="fill-current"
76+
width="42"
77+
height="42"
78+
fill="white"
79+
className="bi bi-envelope-at-fill"
80+
viewBox="0 0 24 24"
8181
>
82-
<path d="M22.288 21h-20.576c-.945 0-1.712-.767-1.712-1.712v-13.576c0-.945.767-1.712 1.712-1.712h20.576c.945 0 1.712.767 1.712 1.712v13.576c0 .945-.767 1.712-1.712 1.712zm-10.288-6.086l-9.342-6.483-.02 11.569h18.684v-11.569l-9.322 6.483zm8.869-9.914h-17.789l8.92 6.229s6.252-4.406 8.869-6.229z" />
82+
<path d="M2 2A2 2 0 0 0 .05 3.555L8 8.414l7.95-4.859A2 2 0 0 0 14 2H2Zm-2 9.8V4.698l5.803 3.546L0 11.801Zm6.761-2.97-6.57 4.026A2 2 0 0 0 2 14h6.256A4.493 4.493 0 0 1 8 12.5a4.49 4.49 0 0 1 1.606-3.446l-.367-.225L8 9.586l-1.239-.757ZM16 9.671V4.697l-5.803 3.546.338.208A4.482 4.482 0 0 1 12.5 8c1.414 0 2.675.652 3.5 1.671Z" />
83+
<path d="M15.834 12.244c0 1.168-.577 2.025-1.587 2.025-.503 0-1.002-.228-1.12-.648h-.043c-.118.416-.543.643-1.015.643-.77 0-1.259-.542-1.259-1.434v-.529c0-.844.481-1.4 1.26-1.4.585 0 .87.333.953.63h.03v-.568h.905v2.19c0 .272.18.42.411.42.315 0 .639-.415.639-1.39v-.118c0-1.277-.95-2.326-2.484-2.326h-.04c-1.582 0-2.64 1.067-2.64 2.724v.157c0 1.867 1.237 2.654 2.57 2.654h.045c.507 0 .935-.07 1.18-.18v.731c-.219.1-.643.175-1.237.175h-.044C10.438 16 9 14.82 9 12.646v-.214C9 10.36 10.421 9 12.485 9h.035c2.12 0 3.314 1.43 3.314 3.034v.21Zm-4.04.21v.227c0 .586.227.8.581.8.31 0 .564-.17.564-.743v-.367c0-.516-.275-.708-.572-.708-.346 0-.573.245-.573.791Z" />
8384
</svg>
8485
</a>
8586

src/components/Login/Login.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import useHelper from '../../helpers/commands';
1515
* @module | Login
1616
* @description | Login component which renders a login page, and sign-up modal. This is the first component that users are routed to if there are no active sessions.
1717
**/
18-
19-
const Login = (): JSX.Element => {
18+
interface loginProps{
19+
navigateToHome: () => void;
20+
}
21+
const Login = (props: loginProps): JSX.Element => {
2022
const navigate = useNavigate();
2123
const { updateUser, updateSession } = useSurvey();
2224
const updateUserSession = () => updateSession();
@@ -26,14 +28,20 @@ const Login = (): JSX.Element => {
2628

2729
const [username, setUsername] = useState<string>('');
2830
const [password, setPassword] = useState<string>('');
31+
2932

3033
const handleLogin = (e: React.FormEvent<HTMLFormElement>): void => {
3134
// prevent default form submission action
3235
e.preventDefault();
3336
authenticateUser(username, password);
3437
};
3538

36-
// send a fetch request to the backend to login
39+
/*
40+
authenticates users username and password
41+
@method
42+
@async
43+
@returns promise when sending a request to backend to login is successful, and updates users session and cookies
44+
*/
3745
const authenticateUser = async (
3846
username: string,
3947
password: string
@@ -70,8 +78,7 @@ const Login = (): JSX.Element => {
7078
)
7179
);
7280
// Navigate to root route
73-
console.log(data);
74-
navigate('/');
81+
props.navigateToHome();
7582
} catch (err) {
7683
// Alert user upon wrong username or password entry using an alert.
7784
window.alert(

src/components/Metrics/Metrics.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ const Metrics = (): JSX.Element => {
1111
const button = kubernetesOrNah === 1 ? 'Containers' : 'Kubernetes Cluster';
1212

1313
useEffect(() => {
14+
/*
15+
* Retrieves the API and UID key
16+
* @method
17+
* @async
18+
* @returns {promise} returns promise when api key and uid key is successfully set
19+
*/
1420
const fetchKey = async () => {
1521
try {
1622
const key = await getKey();
@@ -28,6 +34,13 @@ const Metrics = (): JSX.Element => {
2834
setFrame((prevFrame) => (prevFrame === 1 ? 2 : 1));
2935
};
3036

37+
/*
38+
* Changes the container metrics dashboard to the kubernetes dashboard
39+
* @method
40+
* @params {string} dashboard, new dashboard page to set to as the current page
41+
* @async
42+
* @returns {promise} returns promise when dashboard and uid key is successfully set
43+
*/
3144
const changePage = async (dashboard) => {
3245
setCurrentPage(dashboard);
3346
const uid = await getUid(apiKey, dashboard);

src/components/NewUserDisplay/NewUserDisplay.tsx

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)