Skip to content

Commit

Permalink
change result of stopping notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
molotgor committed Jun 26, 2024
1 parent 59a6ff5 commit 81f5aef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/api/ApiSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export interface JSONViewerApiSchema {
getParameters: (path: string) => Promise<NotebookParameters>;
getResults: (taskId: string) => Promise<{ status: string; result: string }>;
launchNotebook: (path: string, parameters?: Object) => Promise<{ path: string; task_id: string }>;
stopNotebook: (taskId: string) => Promise<Object>;
stopNotebook: (taskId: string) => Promise<boolean>;
}

export interface SSESchema {
Expand Down
5 changes: 3 additions & 2 deletions src/api/JSONViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ const JSONViewerHttpApi: JSONViewerApiSchema = {
method: 'POST',
});
if (res.ok) {
return res.json();
return true;
}
return {};
notificationsStore.handleRequestError(res);
return false;
},
};

Expand Down
12 changes: 7 additions & 5 deletions src/components/JSONViewer/NotebookParamsCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 81f5aef

Please sign in to comment.