Skip to content

Commit

Permalink
🎨 Improved
Browse files Browse the repository at this point in the history
  • Loading branch information
abdheshnayak committed Mar 10, 2024
1 parent ffa2aa9 commit 5e8482a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
17 changes: 11 additions & 6 deletions lib/client/helpers/socket/useWatch.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useEffect } from 'react';
import { useCallback } from 'react';
import { ISocketResp, useSubscribe } from './context';
import { useReload } from '../reloader';
import useDebounce from '../../hooks/use-debounce';

export const useSocketWatch = (
onUpdate: (v: ISocketResp<any>[]) => void,
Expand All @@ -27,11 +28,15 @@ export const useSocketWatch = (
[]
);

useEffect(() => {
if (subscribed) {
onUpdate(responses);
}
}, [responses]);
useDebounce(
() => {
if (subscribed) {
onUpdate(responses);
}
},
1000,
[responses]
);
};

export const useWatchReload = (topic: string | string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/client/hooks/use-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { useEffect } from 'react';

export const useLog = (data: any) => {
useEffect(() => {
console.trace(data);
console.log(data);
}, [data]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { useMapper } from '~/components/utils';
import { registryHost } from '~/lib/configs/base-url.cjs';
import { BottomNavigation } from '~/console/components/commons';
import { useOutletContext } from '@remix-run/react';
import { IAppContext } from '~/console/routes/_main+/$account+/$project+/$environment+/app+/$app+/_layout';
import { useLog } from '~/root/lib/client/hooks/use-log';
import { plans } from './datas';
import { IProjectContext } from '../../_layout';

const valueRender = ({
label,
Expand Down Expand Up @@ -49,7 +50,7 @@ const AppCompute = () => {
getImageTag,
} = useAppState();
const api = useConsoleApi();
const { cluster } = useOutletContext<IAppContext>();
const { cluster } = useOutletContext<IProjectContext>();

const {
data,
Expand All @@ -64,9 +65,19 @@ const AppCompute = () => {
isLoading: nodepoolLoading,
error: nodepoolLoadingError,
} = useCustomSwr('/nodepools', async () => {
return api.listNodePools({ clusterName: parseName(cluster) });
return api.listNodePools({
clusterName: parseName(cluster),
pagination: {
first: 100,
orderBy: 'updateTime',
sortDirection: 'DESC',
},
});
});

useLog(nodepoolData);
useLog(nodepoolLoadingError);

const { values, errors, handleChange, isLoading, submit } = useForm({
initialValues: {
imageUrl: app.spec.containers[activeContIndex]?.image || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import {
} from '~/console/server/utils/auth-utils';
import { IRemixCtx } from '~/root/lib/types/common';
import { getPagination, getSearch } from '~/console/server/utils/common';
import fake from '~/root/fake-data-generator/fake';
import HandleNodePool from './handle-nodepool';
import Tools from './tools';
import NodepoolResources from './nodepool-resources';
import fake from "~/root/fake-data-generator/fake";

export const loader = async (ctx: IRemixCtx) => {
ensureAccountSet(ctx);
Expand Down Expand Up @@ -49,7 +49,8 @@ const Nodepools = () => {
<LoadingComp
data={promise}
skeletonData={{
nodePoolData: fake.ConsoleListNodePoolsQuery.infra_listNodePools as any,
nodePoolData: fake.ConsoleListNodePoolsQuery
.infra_listNodePools as any,
}}
>
{({ nodePoolData }) => {
Expand Down

0 comments on commit 5e8482a

Please sign in to comment.