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

component: add List Rule page #381 #382

Merged
merged 1 commit into from
Oct 9, 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
22 changes: 19 additions & 3 deletions src/app/(rucio)/rule/list/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@

'use client';

import { ListRule } from "@/component-library/Pages/Rule/ListRule";
import { RuleViewModel } from "@/lib/infrastructure/data/view-model/rule";
import useComDOM from "@/lib/infrastructure/hooks/useComDOM";
import { HTTPRequest } from "@/lib/sdk/http";
import { useEffect, useState } from "react";

export default function Page() {
const comDOM = useComDOM<RuleViewModel>(
'list-rule-query',
[],
false,
Infinity,
200,
true
)
return (
<div>
<h1>Page</h1>
</div>
<ListRule
comdom={comDOM}
webui_host={process.env.NEXT_PUBLIC_WEBUI_HOST ?? "http://localhost:3000"}
/>
)
}

19 changes: 18 additions & 1 deletion src/component-library/Pages/Rule/ListRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useState } from "react";
import { Heading } from "../Helpers/Heading";
import { Body } from "../Helpers/Body";
import { RuleViewModel } from "@/lib/infrastructure/data/view-model/rule";
import { HTTPRequest } from "@/lib/sdk/http";

type ListRuleUserDefineQuery = Partial<{
account: string
Expand All @@ -38,6 +39,7 @@ type ListRuleUserDefineQuery = Partial<{
export const ListRule = (
props: {
comdom: UseComDOM<RuleViewModel>
webui_host: string
}
) => {
const columnHelper = createColumnHelper<Rule>()
Expand Down Expand Up @@ -205,6 +207,21 @@ export const ListRule = (
from_date: undefined,
to_date: undefined,
})

const listRuleRequest = async () => {
const request: HTTPRequest = {
method: "GET",
url: props.webui_host + "/api/feature/mock-list-rules",
params: {
rse_expression: userdefinequery.rse_expression ?? "",
activity: userdefinequery.activity ?? "",
state: userdefinequery.state ?? RuleState.UNKNOWN,
from_date: userdefinequery.from_date?.toUTCString() ?? "",
to_date: userdefinequery.to_date?.toUTCString() ?? "",
}
}
await props.comdom.start(request)
}
return (
<div
className={twMerge(
Expand Down Expand Up @@ -299,7 +316,7 @@ export const ListRule = (
<Button
label="Search"
type="submit"
onClick={(e: any) => { e.preventDefault(); console.log(userdefinequery) }}
onClick={(e: any) => {listRuleRequest}}
/>
</form>
</Heading>
Expand Down