Skip to content

Commit b3eba5f

Browse files
committed
feat: add manual refresh button to ai gateway logs
1 parent cac7519 commit b3eba5f

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

  • src/client/routes/aiGateway/$gatewayId

src/client/routes/aiGateway/$gatewayId/index.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Loading } from '@/components/Loading';
1717
import { useCurrentWorkspaceId, useHasAdminPermission } from '@/store/user';
1818
import { routeAuthBeforeLoad } from '@/utils/route';
1919
import { useNavigate } from '@tanstack/react-router';
20-
import { LuPencil, LuTrash } from 'react-icons/lu';
20+
import { LuPencil, LuTrash, LuRefreshCw } from 'react-icons/lu';
2121
import { message } from 'antd';
2222
import { NotFoundTip } from '@/components/NotFoundTip';
2323
import { useEvent } from '@/hooks/useEvent';
@@ -139,7 +139,10 @@ function PageComponent() {
139139
<div className="flex h-full w-full flex-col overflow-auto rounded-lg border p-4">
140140
<div className="mb-2 flex items-center justify-between">
141141
<h3 className="text-lg font-medium">{t('Gateway Logs')}</h3>
142-
<RealtimeUpdateButton gatewayId={gatewayId} />
142+
<div className="flex items-center space-x-2">
143+
<ManualRefreshButton gatewayId={gatewayId} />
144+
<RealtimeUpdateButton gatewayId={gatewayId} />
145+
</div>
143146
</div>
144147
<AIGatewayLogTable gatewayId={gatewayId} />
145148
</div>
@@ -154,6 +157,39 @@ interface RealtimeUpdateButtonProps {
154157
gatewayId: string;
155158
}
156159

160+
interface ManualRefreshButtonProps {
161+
gatewayId: string;
162+
}
163+
164+
function ManualRefreshButton({ gatewayId }: ManualRefreshButtonProps) {
165+
const workspaceId = useCurrentWorkspaceId();
166+
const utils = trpc.useUtils();
167+
const [isRefreshing, setIsRefreshing] = useState(false);
168+
169+
const handleRefresh = useEvent(async () => {
170+
setIsRefreshing(true);
171+
try {
172+
await utils.aiGateway.logs.refetch({
173+
workspaceId,
174+
gatewayId,
175+
});
176+
} finally {
177+
setIsRefreshing(false);
178+
}
179+
});
180+
181+
return (
182+
<Button
183+
variant="outline"
184+
size="icon"
185+
onClick={handleRefresh}
186+
disabled={isRefreshing}
187+
Icon={LuRefreshCw}
188+
loading={isRefreshing}
189+
/>
190+
);
191+
}
192+
157193
function RealtimeUpdateButton({ gatewayId }: RealtimeUpdateButtonProps) {
158194
const { t } = useTranslation();
159195
const workspaceId = useCurrentWorkspaceId();

0 commit comments

Comments
 (0)