Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"react-scripts": "3.4.3",
"rxjs": "^6.6.3",
"socket.io-client": "^2.3.1",
"styled-components": "^5.2.1",
"xterm": "^4.9.0",
"xterm-addon-fit": "^0.4.0"
},
Expand All @@ -43,6 +44,7 @@
"@types/react-dom": "^16.9.8",
"@types/react-router-dom": "^5.1.5",
"@types/socket.io-client": "^1.4.34",
"@types/styled-components": "^5.1.7",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"cross-env": "^7.0.2",
Expand Down
51 changes: 27 additions & 24 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import CssBaseline from "@material-ui/core/CssBaseline";
import { Theme, withStyles } from "@material-ui/core/styles";
import { ThemeProvider } from "@material-ui/styles";
import { ThemeProvider } from "styled-components";
import { ThemeProvider as MaterialThemeProvider } from "@material-ui/styles";
import React, { ReactElement, useEffect } from "react";
import {
BrowserRouter as Router,
Redirect,
Route,
Switch,
} from "react-router-dom";
import ConnectionFailed from "./common/ConnectionFailed";
import NotFound from "./common/NotFound";
import Dashboard from "./dashboard/Dashboard";
import ConnectionFailed from "./common/connectionFailed";
import NotFound from "./common/notFound";
import Dashboard from "./dashboard";
import { Path } from "./router/Path";
import { darkTheme } from "./themes";
import { useElectronStore } from "./stores/electronStore";
Expand Down Expand Up @@ -86,26 +87,28 @@ function App(): ReactElement {

return (
<ThemeProvider theme={darkTheme}>
<CssBaseline />
<GlobalCss />
<Provider electronStore={electronStore} backupStore={backupStore}>
<Router>
<Switch>
<Route path={Path.CONNECTION_FAILED}>
<ConnectionFailed />
</Route>
<Route path={Path.DASHBOARD}>
<Dashboard />
</Route>
<Route exact path={Path.HOME}>
<Redirect to={Path.DASHBOARD} />
</Route>
<Route>
<NotFound />
</Route>
</Switch>
</Router>
</Provider>
<MaterialThemeProvider theme={darkTheme}>
<CssBaseline />
<GlobalCss />
<Provider electronStore={electronStore} backupStore={backupStore}>
<Router>
<Switch>
<Route path={Path.CONNECTION_FAILED}>
<ConnectionFailed />
</Route>
<Route path={Path.DASHBOARD}>
<Dashboard />
</Route>
<Route exact path={Path.HOME}>
<Redirect to={Path.DASHBOARD} />
</Route>
<Route>
<NotFound />
</Route>
</Switch>
</Router>
</Provider>
</MaterialThemeProvider>
</ThemeProvider>
);
}
Expand Down
42 changes: 0 additions & 42 deletions src/common/CenterEllipsis.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/common/Loader.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions src/common/NotFound.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions src/common/PageCircularProgress.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/common/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import FileCopyOutlinedIcon from "@material-ui/icons/FileCopyOutlined";
import React, { ReactElement } from "react";
import { copyToClipboard } from "./appUtil";
import CenterEllipsis from "./CenterEllipsis";
import CenterEllipsis from "./centerEllipsis";

export type TableRow = {
[key: string]: string | number | boolean | Date | ReactElement | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
Button,
CircularProgress,
createStyles,
makeStyles,
} from "@material-ui/core";
import { Button } from "@material-ui/core";
import React, { ReactElement } from "react";

//styles
import {
ButtonWrapper,
ButtonProgress
} from "./styles";

type ButtonWithLoadingProps = {
onClick: () => void;
text: string;
Expand All @@ -17,23 +18,7 @@ type ButtonWithLoadingProps = {
color?: "primary" | "secondary";
};

const useStyles = makeStyles(() =>
createStyles({
buttonWrapper: {
position: "relative",
},
buttonProgress: {
position: "absolute",
top: "50%",
left: "50%",
marginTop: -12,
marginLeft: -12,
},
})
);

const ButtonWithLoading = (props: ButtonWithLoadingProps): ReactElement => {
const classes = useStyles();
const {
onClick,
text,
Expand All @@ -46,7 +31,7 @@ const ButtonWithLoading = (props: ButtonWithLoadingProps): ReactElement => {
} = props;

return (
<div className={classes.buttonWrapper}>
<ButtonWrapper>
<Button
type={submitButton ? "submit" : "button"}
color={color || "primary"}
Expand All @@ -60,9 +45,9 @@ const ButtonWithLoading = (props: ButtonWithLoadingProps): ReactElement => {
{text}
</Button>
{loading && (
<CircularProgress size={24} className={classes.buttonProgress} />
<ButtonProgress size={24} />
)}
</div>
</ButtonWrapper>
);
};

Expand Down
20 changes: 20 additions & 0 deletions src/common/buttonWithLoading/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styled from "styled-components";
import { CircularProgress } from "@material-ui/core";

//types
type ButtonProgressType = {
size: number;
}

//styled
export const ButtonWrapper = styled.div`
position: relative;
`;

export const ButtonProgress = styled(CircularProgress)<ButtonProgressType>`
position: absolute;
top: 50%;
left: 50%;
margin-top: -12px;
margin-left: -12px;
`;
29 changes: 29 additions & 0 deletions src/common/centerEllipsis/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { ReactElement } from "react";

//styles
import {
Left,
Right
} from "./styles";

type PropsType = {
text: string;
};

function CenterEllipsis(props: PropsType): ReactElement {
const { text } = props;
const splitIndex =
text.length > 4 ? text.length - 4 : Math.round(text.length * 0.75);

const shrinkableText = text.slice(0, splitIndex);
const endText = text.slice(splitIndex);

return (
<>
<Left>{shrinkableText}</Left>
<Right>{endText}</Right>
</>
);
}

export default CenterEllipsis;
15 changes: 15 additions & 0 deletions src/common/centerEllipsis/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styled from "styled-components";

export const Left = styled.span`
flex: 0 1 auto;
overflow: hidden;
text-overflow: ellipsis;
white-space: pre;
`;

export const Right = styled.span`
flex: 1 0 auto;
overflow: hidden;
white-space: pre;
max-width: 40px;
`;
Loading