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

Fix issue #123 #124

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
39 changes: 24 additions & 15 deletions resources/scripts/routers/AdminIpamRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ export const routes: Route[] = [
},
{
path: ':poolId',
loader: ({ params }) =>
query(getPoolKey(parseInt(params.poolId!)), () =>
getAddressPool(parseInt(params.poolId!))
),
loader: async ({ params }) => {
try {
const poolId = parseInt(params.poolId!);
const pool = await query(getPoolKey(poolId), () => getAddressPool(poolId));
return pool;
} catch (error) {
return null;
}
},
element: lazyLoad(lazy(() => import('./AdminIpamRouter'))),
handle: {
crumb: data => ({
Expand All @@ -49,17 +54,21 @@ export const routes: Route[] = [
},
{
path: 'addresses',
loader: ({ params }) => {
const id = parseInt(params.poolId!)
const page = params.page ? parseInt(params.page) : 1

return query(getAddressesKey(id, page, ''), () =>
getAddresses(id, {
page,
query: '',
include: ['server'],
})
)
loader: async ({ params }) => {
try {
const id = parseInt(params.poolId!)
const page = params.page ? parseInt(params.page) : 1
const addresses = await query(getAddressesKey(id, page, ''), () =>
getAddresses(id, {
page,
query: '',
include: ['server'],
})
)
return addresses
} catch (error) {
return null
}
},
element: lazyLoad(
lazy(
Expand Down
13 changes: 9 additions & 4 deletions resources/scripts/routers/AdminNodeRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ export const routes: Route[] = [
},
{
path: ':nodeId',
loader: ({ params }) =>
query(getPoolKey(parseInt(params.nodeId!)), () =>
getNode(parseInt(params.nodeId!))
),
loader: async ({ params }) => {
try {
const nodeId = parseInt(params.nodeId!);
const node = await query(getPoolKey(nodeId), () => getNode(nodeId));
return node;
} catch (error) {
return null;
}
},
element: lazyLoad(
lazy(() => import('@/routers/AdminNodeRouter'))
),
Expand Down
13 changes: 9 additions & 4 deletions resources/scripts/routers/AdminUserRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ export const routes: Route[] = [
{
path: ':id',
element: lazyLoad(lazy(() => import('./AdminUserRouter'))),
loader: ({ params }) =>
query(getKey(parseInt(params.id!)), () =>
getUser(parseInt(params.id!))
),
loader: async ({ params }) => {
try {
const id = parseInt(params.id!);
const user = await query(getKey(id), () => getUser(id));
return user;
} catch (error) {
return null;
}
},
children: [
{
path: 'settings',
Expand Down