Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to Next js #686 #689

Closed
Closed
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ cdk.out
# AWS SAM
.aws-sam/

*.js
!config.js
!lib/inline-lambda/index.js
*.d.ts
Expand Down
31 changes: 17 additions & 14 deletions frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"plugin:import/warnings",
"plugin:prettier/recommended",
"plugin:react/recommended",
"prettier"
],
"extends": ["next/core-web-vitals","eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/typescript",
"plugin:import/warnings",
"plugin:prettier/recommended",
"plugin:react/recommended",
"prettier"],
"plugins": ["testing-library","@typescript-eslint", "import"],
"overrides": [
// Only uses Testing Library lint rules in test files
{
"files": ["**/*.tsx"],
"files": [
"**/__test__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"extends": ["plugin:testing-library/react"],
"rules": {
"react/prop-types": "off",
"@typescript-eslint/ban-ts-comment": "off"
Expand All @@ -25,4 +28,4 @@
"rules": {
"import/order": "error"
}
}
}
21 changes: 15 additions & 6 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@
# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# RADIS App logo type declaration
!./src/.radis.d.ts
# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
4 changes: 2 additions & 2 deletions frontend/src/App.test.tsx → frontend/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable react/react-in-jsx-scope */
import { render } from "@testing-library/react";
import App from "./App";
import App from "./app/App";
test("renders the page", () => {
render(<App />);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable react/react-in-jsx-scope */
import { render } from "@testing-library/react";
import App from "../App";
import App from "../app/App";
test("renders the page", () => {
render(<App />);
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable react/react-in-jsx-scope */
import { fireEvent, render, screen } from "@testing-library/react";
import App from "../App";
import { Database as TDatabase } from "../components/types";
import '@testing-library/jest-dom/extend-expect';
import App from "../app/App";
import { Database as TDatabase } from "../app/components/types";
describe("testing: rendering slit switch based on mode ", () => {
test("testing : when mode is absorbance* the simulate slit switch is not in the DOM", () => {
render(<App />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable react/react-in-jsx-scope */
import { render, screen } from "@testing-library/react";
import App from "../../App";
import App from "../../app/App";
describe("testing::equilibrium switch", () => {
test("testing: equilibrium switch is in the DOM", () => {
render(<App />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/react-in-jsx-scope */
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import user from "@testing-library/user-event";
import App from "../../App";
import App from "../../app/App";
describe("testing pathLength field ", () => {
test("testing pathLength field render with defaultValue and perfectly visible", () => {
render(<App />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/react-in-jsx-scope */
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import user from "@testing-library/user-event";
import App from "../../App";
import App from "../../app/App";
describe("testing pressure field ", () => {
test("testing pressure field render with defaultValue and perfectly visible", () => {
render(<App />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable react/react-in-jsx-scope */
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import user from "@testing-library/user-event";
import App from "../../App";
import App from "../../app/App";
describe("testing tgas field ", () => {
test("testing tgas field render with defaultValue and perfectly visible", () => {
render(<App />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,45 @@
/* eslint-disable react/react-in-jsx-scope */
import { fireEvent, render, screen } from "@testing-library/react";
import user from "@testing-library/user-event";
import App from "../../App";
import App from "../../app/App";

describe("testing trot field ", () => {
test("testing trot rendered but not visible if non-equilibrium-switch* is not checked", () => {
render(<App />);
const input = screen.queryByTestId("trot-testid") as HTMLElement;
const input = screen.queryByTestId("trot-testid");
expect(input).not.toBeInTheDocument();
});
test("testing trot rendered and visible if non-equilibrium-switch* is checked", () => {

test("testing trot rendered and visible if non-equilibrium-switch* is checked", async () => {
render(<App />);
const button = screen.getByTestId("non-equilibrium-switch-testid");
user.click(button);
const input = screen.queryByTestId("trot-testid") as HTMLElement;
// Use `waitFor` to wait for the input element to appear
const input = await screen.findByTestId("trot-testid");
expect(input).toBeVisible();
expect(input).toBeInTheDocument();
});
test("testing trot rendering with defaultValue if non-equilibrium-switch* is checked", () => {

test("testing trot rendering with defaultValue if non-equilibrium-switch* is checked", async () => {
render(<App />);
const button = screen.getByTestId("non-equilibrium-switch-testid");
user.click(button);
const input = screen.queryByTestId("trot-testid") as HTMLElement;
expect(input).toHaveValue(300);

// Use `waitFor` to wait for the input element to appear
const input = await screen.findByTestId("trot-testid");

expect(input).toHaveAttribute("value", "300");
});
test("testing trot rendered with user* given value if non-equilibrium-switch* is checked", () => {

test("testing trot rendered with user* given value if non-equilibrium-switch* is checked", async () => {
render(<App />);
const button = screen.getByTestId("non-equilibrium-switch-testid");
user.click(button);
const input = screen.queryByTestId("trot-testid") as HTMLElement;
fireEvent.input(input, {
target: { value: 100 },
});

// Use `waitFor` to wait for the input element to appear
const input = await screen.findByTestId("trot-testid");
fireEvent.input(input, { target: { value: 100 } });

expect(input).toHaveValue(100);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,38 @@
/* eslint-disable react/react-in-jsx-scope */
import { fireEvent, render, screen } from "@testing-library/react";
import user from "@testing-library/user-event";
import App from "../../App";
import App from "../../app/App";

describe("testing tvib field ", () => {
test("testing tvib rendered but not visible if non-equilibrium-switch* is not checked", () => {
render(<App />);
const input = screen.queryByTestId("tvib-testid") as HTMLElement;
const input = screen.queryByTestId("tvib-testid");
expect(input).not.toBeInTheDocument();
});
test("testing tvib rendered and visible if non-equilibrium-switch* is checked", () => {

test("testing tvib rendered and visible if non-equilibrium-switch* is checked", async () => {
render(<App />);
const button = screen.getByTestId("non-equilibrium-switch-testid");
user.click(button);
const input = screen.queryByTestId("tvib-testid") as HTMLElement;
// Use `waitFor` to wait for the input element to appear
const input = await screen.findByTestId("tvib-testid");
expect(input).toBeVisible();
expect(input).toBeInTheDocument();
});
test("testing tvib rendering with defaultValue if non-equilibrium-switch* is checked", () => {

test("testing tvib rendering with defaultValue if non-equilibrium-switch* is checked", async () => {
render(<App />);
const button = screen.getByTestId("non-equilibrium-switch-testid");
user.click(button);
const input = screen.queryByTestId("tvib-testid") as HTMLElement;
const input = await screen.findByTestId("tvib-testid");
expect(input).toHaveValue(300);
});
test("testing tvib rendered with user* given value if non-equilibrium-switch* is checked", () => {

test("testing tvib rendered with user* given value if non-equilibrium-switch* is checked", async () => {
render(<App />);
const button = screen.getByTestId("non-equilibrium-switch-testid");
user.click(button);
const input = screen.queryByTestId("tvib-testid") as HTMLElement;
const input = await screen.findByTestId("tvib-testid");
fireEvent.input(input, {
target: { value: 100 },
});
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/App.tsx → frontend/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ import InfoIcon from "@mui/icons-material/Info";
import GitHubIcon from "@mui/icons-material/GitHub";
import { createTheme, ThemeProvider, useTheme } from "@mui/material/styles";
import { makeStyles } from "@mui/styles";
import "fontsource-roboto";
// import "fontsource-roboto";
import ReactGA from "react-ga4";
import Brightness4Icon from "@mui/icons-material/Brightness4";
import Brightness7Icon from "@mui/icons-material/Brightness7";
import CssBaseline from "@mui/material/CssBaseline";
import Image from "next/image";
import { PlotSpectra } from "./components/PlotSpectra";
import { palette } from "./constants";
import logo from "./radis.png";

/*#########INITIALIZING_GOOGLE_ANALYTICS###############*/
ReactGA.initialize("G-V67HS7VB4R");
ReactGA.send(window.location.pathname);
// ReactGA.send(window.location.pathname);
/*#########INITIALIZING_GOOGLE_ANALYTICS###############*/

const ColorModeContext = React.createContext({
Expand Down Expand Up @@ -109,7 +110,7 @@ const Header: React.FC = () => {
<Container maxWidth="xl">
<Toolbar>
<Box m={1}>
<img src={logo} height={50} alt="Radish logo" />
<Image src={logo} height={50} alt="Radish logo" />
</Box>
<Typography variant="h6" className={classes.title}>
RADIS app
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react";
import Plotly from "react-plotly.js";
import { LayoutAxis } from "plotly.js";
// import Plotly from "react-plotly.js";
import dynamic from "next/dynamic";
const Plotly = dynamic(() => import("react-plotly.js"), { ssr: false });
import { LayoutAxis, UpdateMenu } from "plotly.js";
import { PlotSettings, Spectrum } from "../constants";
import { addSubscriptsToMolecule } from "../modules/molecule-subscripts";
import { Species } from "./types";
Expand Down Expand Up @@ -49,7 +51,7 @@ export const Plot_: React.FC<PlotProps> = ({
};

//buttons to switch between log scale and linear scale
const updatemenus = [
const updatemenus: Partial<UpdateMenu>[] = [
{
type: "buttons",
x: 0,
Expand Down Expand Up @@ -175,11 +177,9 @@ export const Plot_: React.FC<PlotProps> = ({
title: { text: waveLabel },
rangeslider: {
// TODO: Update typing in DefinitelyTyped
// @ts-ignore
autorange: true,
// @ts-ignore
// autorange: true,
yaxis: { rangemode: "auto" },
},
} as any,
type: "linear",
},
yaxis,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ export const Species: React.FC<SpeciesProps> = ({
{index === 0 ? (
<IconButton
color="primary"
onClick={() =>
append({ molecule: undefined, mole_fraction: undefined })
}
onClick={() => append({ molecule: "", mole_fraction: 0 })}
>
<AddIcon />
</IconButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ export const WavenumberRangeSlider: React.FC<WavelengthRangeSliderProps> = ({
setUpperRange(value[1]);
};
const handleBlur = () => {
if (lowerRange > upperRange) {
if (lowerRange === "" || upperRange === "") {
return;
}
if (lowerRange < minRange) {
const lower = Number(lowerRange);
const upper = Number(upperRange);
if (lower > upper) {
return;
}
if (lower < minRange) {
setLowerRange(minRange);
}
if (upperRange > maxRange) {
if (upper > maxRange) {
setUpperRange(maxRange);
}
};
Expand Down
File renamed without changes.
File renamed without changes.
Binary file added frontend/app/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/src/index.css → frontend/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ input::-webkit-inner-spin-button {

input[type=number] {
-moz-appearance: textfield;
}
}
Loading