Skip to content

Commit

Permalink
api: hookup mock endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
maany committed Nov 28, 2023
1 parent c0e5358 commit 1aa6649
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/app/(rucio)/rule/list/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

'use client';

import { ListRule } from "@/component-library/Pages/Rule/ListRule";
Expand Down
20 changes: 18 additions & 2 deletions src/app/(rucio)/rule/page/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,29 @@ export default function PageRule({ params }: { params: { id: string } }) {
)
}, [])
const [meta, setMeta] = useState<RuleMetaViewModel>({} as RuleMetaViewModel)

useEffect(() => {
setMeta({ ...fixtureRuleMetaViewModel(), id: params.id })
// TODO get from mock endpoint
fetch(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/mock-get-rule-meta`)
.then(res => {
if (res.ok) {
return res.json()
}
throw new Error(res.statusText)
})
.then(data => {
setMeta({ ...data, id: params.id })
})
.catch(err => {
console.error(err)
})
// setMeta({ ...fixtureRuleMetaViewModel(), id: params.id })
}, [])

useEffect(() => {
const runQuery = async () => {
const request: HTTPRequest = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/rulepagelockentry`),
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/mock-list-rule-page-lock`),
method: "GET",
headers: new Headers({
'Content-Type': 'application/json'
Expand Down
9 changes: 6 additions & 3 deletions src/component-library/Pages/Rule/CreateRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ export const CreateRule = (
let DIDSearchString = explicitDIDSearchExpression ? explicitDIDSearchExpression : Page0State.selectDIDDataPattern
// build request for comdom
const request: HTTPRequest = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/listdids`),
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/list-dids`),
method: "GET",
headers: new Headers({
'Content-Type': 'application/json'
} as HeadersInit),
body: null,
params: {
query: DIDSearchString,
type: DIDType.ALL
},
}
// run query
await props.didListComDOM.setRequest(request)
Expand Down Expand Up @@ -187,7 +190,7 @@ export const CreateRule = (
var RSEExpression = explicitRSEExpression ? explicitRSEExpression : Page1State.RSEExpression
// build request for comdom
const request: HTTPRequest = {
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/rseaccountusage`),
url: new URL(`${process.env.NEXT_PUBLIC_WEBUI_HOST}/api/feature/mock-list-rse-account-usage`),
method: "GET",
headers: new Headers({
'Content-Type': 'application/json'
Expand Down
5 changes: 0 additions & 5 deletions src/component-library/Pages/Rule/ListRule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { UseComDOM } from "@/lib/infrastructure/hooks/useComDOM";
import { Rule, RuleState } from "@/lib/core/entity/rucio";
import { StreamedTable } from "../../StreamedTables/StreamedTable";
import { Button } from "../../Button/Button";
import { H3 } from "../../Text/Headings/H3";
import useReponsiveHook from "../../Helpers/ResponsiveHook";
import { createColumnHelper } from "@tanstack/react-table";
import { TableFilterString } from "../../StreamedTables/TableFilterString";
import { TableInternalLink } from "../../StreamedTables/TableInternalLink";
Expand All @@ -15,9 +13,6 @@ import { RuleStateTag } from "../../Tags/RuleStateTag";
import { TableFilterDiscrete } from "../../StreamedTables/TableFilterDiscrete";
import { HiDotsHorizontal } from "react-icons/hi";
import { TextInput } from "../../Input/TextInput";
import { LabelledInput } from "../Login/LabelledInput";
import { MouseEventHandler } from "react";
import { AreaInput } from "../../Input/AreaInput";
import { Contenttd, Generaltable, Titleth } from "../../Helpers/Metatable";
import { Dropdown } from "../../Input/Dropdown";
import { DateInput } from "../../Input/DateInput";
Expand Down
1 change: 0 additions & 1 deletion src/pages/api/feature/mock-get-validated-dids.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { withAuthenticatedSessionRoute } from "@/lib/infrastructure/auth/session-utils";
import { NextApiRequest, NextApiResponse } from "next";
import { fixtureRuleMetaViewModel, generateSequenceArray } from "test/fixtures/table-fixtures";

async function endpoint(req: NextApiRequest, res: NextApiResponse, rucioAuthToken: string) {
if(req.method !== 'POST') {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/feature/mock-update-subscription.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { withAuthenticatedSessionRoute } from "@/lib/infrastructure/auth/session-utils";
import { NextApiRequest, NextApiResponse } from "next";
import { fixtureRuleViewModel, fixtureSubscriptionRuleStatesViewModel, fixtureSubscriptionViewModel, generateSequenceArray } from "test/fixtures/table-fixtures";
import { fixtureSubscriptionViewModel } from "test/fixtures/table-fixtures";
import { Readable } from "stream";

async function endpoint(req: NextApiRequest, res: NextApiResponse, rucioAuthToken: string) {
Expand Down

0 comments on commit 1aa6649

Please sign in to comment.