Skip to content

Commit

Permalink
Merge pull request #107 from aldbr/main_FEAT_url-saved-state
Browse files Browse the repository at this point in the history
feat: save/restore filters in URL
  • Loading branch information
aldbr authored Apr 10, 2024
2 parents ca52bac + bd4e332 commit 436f183
Show file tree
Hide file tree
Showing 32 changed files with 1,029 additions and 689 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ Open [http://localhost:8000](http://localhost:8000) with your browser to see the
- Want to discuss about UX/UI design?
Share your [Design idea](https://github.com/DIRACGrid/diracx-web/discussions/categories/design-ideas).

## Testing

Unit tests can be started with:

```
npm test
```

End-to-end tests are launched through `cypress` such as:

```
export CYPRESS_BASE_URL=<ip address used by diracx-charts>
npx cypress open
```

## Learn More

To learn more about Next.js, take a look at the following resources:
Expand Down
Binary file added public/showcase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/showcase1.png
Binary file not shown.
Binary file removed public/showcase2.png
Binary file not shown.
17 changes: 0 additions & 17 deletions src/app/dashboard/layout.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/app/dashboard/page.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Inter } from "next/font/google";
import { OIDCConfigurationProvider } from "@/contexts/OIDCConfigurationProvider";
import { ThemeProvider } from "@/contexts/ThemeProvider";
import Dashboard from "@/components/layout/Dashboard";
import { OIDCSecure } from "@/components/layout/OIDCSecure";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -22,7 +24,9 @@ export default function RootLayout({
<html lang="en">
<body className={inter.className}>
<OIDCConfigurationProvider>
<ThemeProvider>{children}</ThemeProvider>
<ThemeProvider>
<OIDCSecure>{children}</OIDCSecure>
</ThemeProvider>
</OIDCConfigurationProvider>
</body>
</html>
Expand Down
4 changes: 2 additions & 2 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Showcase from "@/components/applications/Showcase";
import UserDashboard from "@/components/applications/UserDashboard";

export default function Page() {
return <Showcase />;
return <UserDashboard />;
}
5 changes: 3 additions & 2 deletions src/components/applications/JobMonitor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Box } from "@mui/material";
import { useMUITheme } from "@/hooks/theme";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { JobDataTable } from "../ui/JobDataTable";
import Dashboard from "../layout/Dashboard";

/**
* Build the Job Monitor application
Expand All @@ -14,7 +15,7 @@ export default function JobMonitor() {
const theme = useMUITheme();

return (
<React.Fragment>
<Dashboard>
<MUIThemeProvider theme={theme}>
<CssBaseline />
<Box
Expand All @@ -27,6 +28,6 @@ export default function JobMonitor() {
<JobDataTable />
</Box>
</MUIThemeProvider>
</React.Fragment>
</Dashboard>
);
}
27 changes: 13 additions & 14 deletions src/components/applications/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Button from "@mui/material/Button";
import Autocomplete from "@mui/material/Autocomplete";
import TextField from "@mui/material/TextField";
import { useMetadata, Metadata } from "@/hooks/metadata";
import NextLink from "next/link";
import Image from "next/image";
import { CssBaseline, Stack } from "@mui/material";
import { useMUITheme } from "@/hooks/theme";
Expand Down Expand Up @@ -42,6 +41,13 @@ export function LoginForm() {
}
}, [configuration, isAuthenticated, login]);

useEffect(() => {
// Redirect to dashboard if already authenticated
if (isAuthenticated) {
router.push("/");
}
}, [isAuthenticated, router]);

// Get default group
const getDefaultGroup = (data: Metadata | undefined, vo: string): string => {
if (!data) {
Expand Down Expand Up @@ -84,11 +90,6 @@ export function LoginForm() {
});
}
};
// Redirect to dashboard if already authenticated
if (isAuthenticated) {
router.push("/dashboard");
return null;
}

if (isLoading) {
return <div>Loading...</div>;
Expand Down Expand Up @@ -129,14 +130,12 @@ export function LoginForm() {
paddingBottom: "10%",
}}
>
<NextLink href="/">
<Image
src="/DIRAC-logo-minimal.png"
alt="DIRAC logo"
width={150}
height={150}
/>
</NextLink>
<Image
src="/DIRAC-logo-minimal.png"
alt="DIRAC logo"
width={150}
height={150}
/>
</Box>
{singleVO ? (
<Typography
Expand Down
105 changes: 0 additions & 105 deletions src/components/applications/Showcase.tsx

This file was deleted.

9 changes: 7 additions & 2 deletions src/components/applications/UserDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useMUITheme } from "@/hooks/theme";
import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles";
import { useOidcAccessToken } from "@axa-fr/react-oidc";
import { useOIDCContext } from "@/hooks/oidcConfiguration";
import Dashboard from "../layout/Dashboard";

/**
* Build the User Dashboard page
Expand All @@ -16,8 +17,12 @@ export default function UserDashboard() {
const { configuration } = useOIDCContext();
const { accessTokenPayload } = useOidcAccessToken(configuration?.scope);

if (!accessTokenPayload) {
return <div>Not authenticated</div>;
}

return (
<React.Fragment>
<Dashboard>
<MUIThemeProvider theme={theme}>
<CssBaseline />
<Box
Expand All @@ -31,6 +36,6 @@ export default function UserDashboard() {
<p>To start with, select an application in the side bar</p>
</Box>
</MUIThemeProvider>
</React.Fragment>
</Dashboard>
);
}
13 changes: 7 additions & 6 deletions src/components/layout/OIDCSecure.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import React from "react";
import React, { useEffect } from "react";
import { useRouter } from "next/navigation";
import { useOidc } from "@axa-fr/react-oidc";
import { useOIDCContext } from "@/hooks/oidcConfiguration";
Expand All @@ -18,11 +18,12 @@ export function OIDCSecure({ children }: OIDCProps) {
const { isAuthenticated } = useOidc(configuration?.scope);
const router = useRouter();

// Redirect to login page if not authenticated
if (!isAuthenticated) {
router.push("/auth");
return null;
}
useEffect(() => {
// Redirect to login page if not authenticated
if (!isAuthenticated) {
router.push("/auth");
}
}, [isAuthenticated, router]);

return <>{children}</>;
}
29 changes: 0 additions & 29 deletions src/components/ui/DashboardButton.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/ui/DashboardDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const userSections: Record<
string,
{ icon: React.ComponentType; path: string }
> = {
Dashboard: { icon: Dashboard, path: "/dashboard" },
"Job Monitor": { icon: MonitorIcon, path: "/dashboard/jobmonitor" },
"File Catalog": { icon: FolderCopy, path: "/dashboard/filecatalog" },
Dashboard: { icon: Dashboard, path: "/" },
"Job Monitor": { icon: MonitorIcon, path: "/jobmonitor" },
"File Catalog": { icon: FolderCopy, path: "/filecatalog" },
};

interface DashboardDrawerProps {
Expand Down
Loading

0 comments on commit 436f183

Please sign in to comment.