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

App: Connected ListRSE #357

Merged
merged 1 commit into from
Sep 21, 2023
Merged
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
29 changes: 28 additions & 1 deletion src/app/(rucio)/rse/list/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
'use client';
import { ListRSE as ListRSEStory } from "@/component-library/Pages/RSE/ListRSE";
import { RSEViewModel } from "@/lib/infrastructure/data/view-model/rse";
import useComDOM from "@/lib/infrastructure/hooks/useComDOM";
import { HTTPRequest } from "@/lib/sdk/http";
import { mockUseComDOM, fixtureRSEViewModel } from "test/fixtures/table-fixtures";
export default function Page() {

const setRSEQuery = async (rseExpression: string) => {
await RSESearchComDOM.setRequest({
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-rses`),
method: 'GET',
headers: new Headers({
'Content-Type': 'application/json',
} as HeadersInit),
params: {
"rseExpression": rseExpression
},
} as HTTPRequest)
}

const RSESearchComDOM = useComDOM<RSEViewModel>(
'list-rse-query',
[],
false,
Infinity,
200,
true
)

return (
<ListRSEStory
comdom={mockUseComDOM(Array.from({ length: 100 }, () => fixtureRSEViewModel()))} // replace with ViewModel
comdom={RSESearchComDOM}
setRSEQuery={setRSEQuery}
/>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/component-library/Pages/RSE/ListRSE.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ const Template: StoryFn<typeof L> = (args) => <L {...args} />;

export const ListRSE = Template.bind({});
ListRSE.args = {
comdom: mockUseComDOM(Array.from({ length: 100 }, () => fixtureRSEViewModel()))
comdom: mockUseComDOM(Array.from({ length: 100 }, () => fixtureRSEViewModel())),
setRSEQuery: (rseExpression: string) => { },
};
51 changes: 49 additions & 2 deletions src/component-library/Pages/RSE/ListRSE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ import useReponsiveHook from "../../Helpers/ResponsiveHook";
import { Body } from "../Helpers/Body";
import { Heading } from "../Helpers/Heading";
import { RSEViewModel } from "@/lib/infrastructure/data/view-model/rse";
import { TextInput } from "@/component-library/Input/TextInput";
import { useState } from "react";
import { Button } from "@/component-library/Button/Button";

export const ListRSE = (
props: {
comdom: UseComDOM<RSEViewModel>
setRSEQuery: (rseExpression: string) => void
}
) => {

const [rseSearchQuery, setRSESearchQuery] = useState<string>("")

const columnHelper = createColumnHelper<RSEViewModel>()
const tablecolumns = [
columnHelper.accessor("name", {
Expand All @@ -36,7 +43,7 @@ export const ListRSE = (
},
cell: info => {
return (
<TableInternalLink href={"/rse/" + info.getValue()}>
<TableInternalLink href={"/rse/page/" + info.getValue()}>
{info.getValue()}
</TableInternalLink>
)
Expand Down Expand Up @@ -120,7 +127,47 @@ export const ListRSE = (
>
<Heading
title="List RSEs"
/>
>
<form
className={twMerge(
"flex flex-col sm:flex-row sm:space-x-2 sm:items-end w-full",
)}
aria-label="RSE Search"
>
<label
className={twMerge(
"w-fit flex-none",
"text-black dark:text-white"
)}
htmlFor='rse-search-pattern'
>
RSE Search Pattern
</label>
<TextInput
onBlur={(event: any) => { setRSESearchQuery(event.target.value) }}
onEnterkey={async (e: any) => {
e.preventDefault()
await props.setRSEQuery(e.target.value)
setRSESearchQuery(e.target.value)
props.comdom.start()
}}
id="rse-search-pattern"
/>
<Button
type="button"
label="Search"
onClick={async (e: any) => {
e.preventDefault()
await props.setRSEQuery(rseSearchQuery)
props.comdom.start()
}}
className={twMerge(
"w-full mt-2 sm:mt-0 sm:w-24 sm:grow-0"
)}
id="rse-button-search"
/>
</form>
</Heading>
<Body>
<StreamedTable<RSEViewModel>
tablecomdom={props.comdom}
Expand Down