From 81f5aeffb6244ca24b33d679b2b2120059be1225 Mon Sep 17 00:00:00 2001 From: molotgor Date: Wed, 26 Jun 2024 14:50:50 +0400 Subject: [PATCH] change result of stopping notebook --- src/api/ApiSchema.ts | 2 +- src/api/JSONViewer.ts | 5 +++-- src/components/JSONViewer/NotebookParamsCell.tsx | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/api/ApiSchema.ts b/src/api/ApiSchema.ts index afd9cb0b..da076168 100644 --- a/src/api/ApiSchema.ts +++ b/src/api/ApiSchema.ts @@ -113,7 +113,7 @@ export interface JSONViewerApiSchema { getParameters: (path: string) => Promise; getResults: (taskId: string) => Promise<{ status: string; result: string }>; launchNotebook: (path: string, parameters?: Object) => Promise<{ path: string; task_id: string }>; - stopNotebook: (taskId: string) => Promise; + stopNotebook: (taskId: string) => Promise; } export interface SSESchema { diff --git a/src/api/JSONViewer.ts b/src/api/JSONViewer.ts index 97bd3fab..90bad127 100644 --- a/src/api/JSONViewer.ts +++ b/src/api/JSONViewer.ts @@ -55,9 +55,10 @@ const JSONViewerHttpApi: JSONViewerApiSchema = { method: 'POST', }); if (res.ok) { - return res.json(); + return true; } - return {}; + notificationsStore.handleRequestError(res); + return false; }, }; diff --git a/src/components/JSONViewer/NotebookParamsCell.tsx b/src/components/JSONViewer/NotebookParamsCell.tsx index 0bf0eb4a..9435ee28 100644 --- a/src/components/JSONViewer/NotebookParamsCell.tsx +++ b/src/components/JSONViewer/NotebookParamsCell.tsx @@ -97,15 +97,17 @@ const NotebookParamsCell = ({ notebook }: { notebook: string }) => { const runNotebook = async () => { if (isRunLoading) { - setIsRunLoading(false); - if (taskId) { - api.jsonViewer.stopNotebook(taskId); - setTaskId(null); - } if (timer) { clearTimeout(timer); setTimer(null); } + if (taskId) { + const stopAttempt = await api.jsonViewer.stopNotebook(taskId); + setTaskId(null); + setIsRunLoading(stopAttempt); + } else { + setIsRunLoading(false); + } return; } setIsRunLoading(true);