-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d16e90b
commit c245081
Showing
6 changed files
with
237 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,20 @@ | ||
'use client'; | ||
'use client' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import "@/component-library/outputtailwind.css"; | ||
import "reflect-metadata"; | ||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; | ||
import { Layout as LayoutStory } from '@/component-library/Pages/Layout/Layout'; | ||
|
||
|
||
const queryClient = new QueryClient(); | ||
import '@/component-library/outputtailwind.css' | ||
import 'reflect-metadata' | ||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools' | ||
import { RucioAppLayout } from './rucio-app-layout' | ||
|
||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
|
||
return ( | ||
<LayoutStory | ||
LVM={{ | ||
accountActive: "test", | ||
accountsPossible: ["test", "test2"], | ||
rucioProjectLink: "rucio.cern.ch", | ||
experimentProjectLink: "atlas.cern", | ||
}} | ||
> | ||
<QueryClientProvider client={queryClient}> | ||
{children} | ||
</QueryClientProvider> | ||
</LayoutStory> | ||
<QueryClientProvider client={new QueryClient()}> | ||
<RucioAppLayout>{children}</RucioAppLayout> | ||
<ReactQueryDevtools initialIsOpen={false} /> | ||
</QueryClientProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React, { useState } from "react" | ||
import { Layout } from '@/component-library/Pages/Layout/Layout'; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { SiteHeaderViewModel } from "@/lib/infrastructure/data/view-model/site-header"; | ||
import { User } from "@/lib/core/entity/auth-models"; | ||
|
||
export interface QueryContextLayoutProps { | ||
children: React.ReactNode; | ||
|
||
} | ||
export const RucioAppLayout = (props: QueryContextLayoutProps) => { | ||
const [siteHeaderViewModel, setSiteHeaderViewModel] = useState<SiteHeaderViewModel>({ | ||
status: "error", | ||
homeUrl: "" | ||
}) | ||
const fetchAccounts = async () => { | ||
await fetch(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/get-site-header`) | ||
.then(res => { | ||
if (res.ok) { | ||
return res.json() | ||
} | ||
throw new Error(res.statusText) | ||
}) | ||
.then(viewModel => { | ||
setSiteHeaderViewModel(viewModel as SiteHeaderViewModel) | ||
}) | ||
.catch(error => { | ||
// do sth with error | ||
console.error("Error fetching data:", error); | ||
}) | ||
} | ||
|
||
const fetchAccountKey = ['fetchAccounts'] | ||
useQuery(fetchAccountKey,fetchAccounts) | ||
return ( | ||
<Layout | ||
LVM={{ | ||
accountActive: siteHeaderViewModel.activeAccount?.rucioAccount ?? "", | ||
accountsPossible: siteHeaderViewModel.availableAccounts?.map((user: User) => { return user.rucioAccount}) ?? [], | ||
rucioProjectLink: "rucio.cern.ch", | ||
experimentProjectLink: "atlas.cern", | ||
}} | ||
> | ||
{props.children} | ||
</Layout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.