Skip to content

Commit 04359b5

Browse files
authored
Merge pull request #57 from oslabs-beta/cedar/types
Migrated interfaces/types to root folder.
2 parents 9ab4ce2 + ea0ac1d commit 04359b5

35 files changed

+543
-716
lines changed

src/components/Authentication.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import React from 'react';
22
import { Navigate } from 'react-router-dom';
33
import { useSelector } from 'react-redux';
4+
import { RootState } from '../../types'
45

5-
interface RootState {
6-
session: {
7-
isLoggedIn: boolean
8-
}
9-
}
106

117
const Authentication = () => {
128
// grab session information from state
13-
const session: boolean = useSelector((state: RootState) => state.session.isLoggedIn);
9+
const session: any = useSelector((state: RootState) => state.session.isLoggedIn);
1410
// if session is false navigate to login, if session is true navigate to outlet
1511
return (
1612
session ? <Navigate to='/app' /> : <Navigate to='/login' />

src/components/Login.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,10 @@
1616

1717
// @ts-ignore
1818
import Docketeer from '../../assets/docketeer-title.png';
19+
20+
// import interface
21+
import { UserInfo } from '../../types';
1922

20-
interface UserInfo {
21-
_id: number,
22-
username: string,
23-
email: string,
24-
phone: string,
25-
role: string,
26-
role_id: number,
27-
contact_pref: string | null,
28-
mem_threshold: number,
29-
cpu_threshold: number,
30-
container_stops: boolean,
31-
token: string
32-
}
3323

3424
const Login = () => {
3525
const navigate = useNavigate();

src/components/RenderViews.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import { useSelector } from 'react-redux';
44
import AdminView from './views/Admin';
55
import UserView from './views/UserView';
66
import SysAdminView from './views/SysAdmin';
7-
8-
interface RootState {
9-
session: {
10-
role: string
11-
}
12-
}
7+
import { RootState } from '../../types';
138

149
const RenderViews = ():any => {
1510
// grab current user's role

src/components/debug/debugRouter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class DebugRouter extends Router {
88
this.history.listen((location, action)=>{
99
console.log(
1010
`The current URL is ${location.pathname}${location.search}${location.hash}`
11-
)
11+
);
1212
console.log(`The last navigation action was ${action}`, JSON.stringify(this.history, null,2));
1313
});
1414
}

src/components/display/AccountDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @module AccountDisplay
33
* @description Account Display for Settings tab, this will host any forms to update account details such as email, passwords, etc.
44
*/
5-
import React, { useEffect, useState } from "react";
6-
import { useSelector, useDispatch } from "react-redux";
5+
import React from "react";
6+
import { useSelector } from "react-redux";
77

88
// Material UI Imports
99
import Button from "@mui/material/Button";

src/components/display/LineChartDisplay.tsx

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as helper from "../helper/commands";
77
import { DataGrid } from "@mui/x-data-grid";
88
import { FormControlLabel, Checkbox } from "@mui/material";
99
import { RootState } from "../../renderer/store";
10-
import { AnyAction } from "redux";
10+
import { auxObjType, obType } from '../../../types';
1111

1212
/**
1313
* Displays linegraph and github metrics
@@ -26,10 +26,10 @@ const LineChartDisplay = () => {
2626
const readIO = useSelector((state: RootState) => state.graphs["graphReadIO"]);
2727
const axis = useSelector((state: RootState) => state.graphs["graphAxis"]);
2828
const runningList = useSelector(
29-
(state: RootState) => state.containersList.runningList
29+
(state: RootState) => state.containersList['runningList']
3030
);
3131
const stoppedList = useSelector(
32-
(state: RootState) => state.containersList.stoppedList
32+
(state: RootState) => state.containersList['stoppedList']
3333
);
3434

3535
const dispatch = useDispatch();
@@ -64,7 +64,7 @@ const LineChartDisplay = () => {
6464
labels: axis,
6565
datasets: cpu,
6666
};
67-
const writtenIOObj = {
67+
const writtenIOObj = {
6868
labels: axis,
6969
datasets: writtenIO,
7070
};
@@ -145,27 +145,7 @@ const LineChartDisplay = () => {
145145

146146
const containerMetrics = await getContainerMetrics();
147147

148-
interface auxObjType {
149-
container?: ContainerInterface;
150-
currentContainer?: any;
151-
containerName?: string;
152-
}
153-
154-
interface ContainerInterface {
155-
memory?: any;
156-
cpu?: any;
157-
writtenIO?: any;
158-
readIO?: any;
159-
}
160-
161-
// interface ContainerNameInterface{
162-
163-
// }
164-
165-
//const container: keyof auxObjType = 'container'
166-
167148
const auxObj: auxObjType = {};
168-
//const container: keyof typeof auxObj;
169149
Object.keys(activeContainers).forEach((container) => {
170150
auxObj[container as keyof typeof auxObj] = {
171151
memory: buildLineGraphObj(container),
@@ -207,7 +187,7 @@ const LineChartDisplay = () => {
207187
buildAxis(timeStamp);
208188
});
209189

210-
let longest = 0; // 32
190+
let longest = 0;
211191

212192
Object.keys(auxObj).forEach((containerName: string) => {
213193
if (
@@ -248,9 +228,6 @@ const LineChartDisplay = () => {
248228
});
249229
};
250230

251-
interface obType {
252-
containerName?: any;
253-
}
254231

255232
//Fetching the data from github API and turning it into an object with keys of objects that contain the data of each container
256233
const fetchGitData = async (containerName: string) => {
@@ -273,7 +250,7 @@ const LineChartDisplay = () => {
273250
new URLSearchParams({
274251
since: `${date}`,
275252
});
276-
//need an actual url to test this, right now it can't connect
253+
//need a url to test this, right now it can't connect
277254
const data = await fetch(url);
278255
const jsonData = await data.json();
279256

@@ -322,10 +299,6 @@ const LineChartDisplay = () => {
322299
{ field: "message", headerName: "Message", width: 525, align: "left" },
323300
];
324301

325-
// interface elType {
326-
// name: {};
327-
// }
328-
329302
gitData = gitUrls.map((el, index: any) => {
330303
const name = Object.keys(el);
331304
type rowsType = any[];
@@ -399,9 +372,9 @@ const LineChartDisplay = () => {
399372
const result: any[] = [];
400373
const completeContainerList = [...runningList, ...stoppedList];
401374
completeContainerList.forEach((container, index) => {
402-
const containerNameKey = container.Name
403-
? container.Name
404-
: container.Names;
375+
const containerNameKey = container['Name']
376+
? container['Name']
377+
: container['Names'];
405378
result.push(
406379
<FormControlLabel
407380
key={`formControl-${index}`}

0 commit comments

Comments
 (0)