Skip to content

Commit

Permalink
remove list rest tasks from slice (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
pplonski committed May 8, 2024
1 parent a624216 commit 2e49a89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
10 changes: 1 addition & 9 deletions frontend/src/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React, { useContext } from "react";
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { listRestTasks, scrapeSlidesHash } from "../slices/tasksSlice";
import { scrapeSlidesHash } from "../slices/tasksSlice";
import CheckboxWidget from "../widgets/Checkbox";
import NumericWidget from "../widgets/Numeric";
import RangeWidget from "../widgets/Range";
Expand Down Expand Up @@ -53,7 +53,6 @@ import {
import ButtonWidget from "../widgets/Button";
import RunButton from "./RunButton";
import BlockUi from "react-block-ui";
import { getSiteId } from "../slices/sitesSlice";

type SideBarProps = {
notebookTitle: string;
Expand Down Expand Up @@ -100,7 +99,6 @@ export default function SideBar({
const workerState = useSelector(getWorkerState);
const widgetsInitialized = useSelector(getWidgetsInitialized);
const urlValuesUsed = useSelector(getUrlValuesUsed);
const siteId = useSelector(getSiteId);
const ws = useContext(WebSocketContext);

const runNb = () => {
Expand Down Expand Up @@ -133,12 +131,6 @@ export default function SideBar({
}
};

useEffect(() => {
if (siteId !== undefined && notebookId !== undefined) {
dispatch(listRestTasks(siteId, notebookId));
}
}, [dispatch, notebookId, siteId]);

useEffect(() => {
if (widgetsInitialized && urlValuesUsed) {
execNb();
Expand Down
32 changes: 1 addition & 31 deletions frontend/src/slices/tasksSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ export interface ITask {
result: string;
}

export interface IRestTask {
id: number;
state: "CREATED" | "RECEIVED" | "DONE" | "ERROR";
params: string;
response: string;
session_id: string;
created_at: Date;
updated_at: Date;
}

const initialState = {
currentTask: {} as ITask,
historicTask: {} as ITask,
Expand All @@ -40,7 +30,6 @@ const initialState = {
exportToPDFJobId: '',
exportToPDFCounter: 0,
executionHistory: [] as ITask[],
restTasks: [] as IRestTask[],
};

const tasksSlice = createSlice({
Expand Down Expand Up @@ -84,9 +73,6 @@ const tasksSlice = createSlice({
},
clearExecutionHistory(state) {
state.executionHistory = [];
},
setRestTasks(state, action: PayloadAction<IRestTask[]>) {
state.restTasks = action.payload;
}
},
});
Expand All @@ -105,8 +91,7 @@ export const {
increaseExportToPDFCounter,
stopPDFExport,
setExecutionHistory,
clearExecutionHistory,
setRestTasks
clearExecutionHistory
} = tasksSlice.actions;

export const getShowCurrent = (state: RootState) => state.tasks.showCurrent;
Expand All @@ -117,7 +102,6 @@ export const getExportingToPDF = (state: RootState) => state.tasks.exportingToPD
export const getExportToPDFJobId = (state: RootState) => state.tasks.exportToPDFJobId;
export const getExportToPDFCounter = (state: RootState) => state.tasks.exportToPDFCounter;
export const getExecutionHistory = (state: RootState) => state.tasks.executionHistory;
export const getRestTasks = (state: RootState) => state.tasks.restTasks;

export const fetchCurrentTask =
(notebookId: number) =>
Expand Down Expand Up @@ -265,17 +249,3 @@ export const fetchExecutionHistory =

};


export const listRestTasks =
(siteId: number, notebookId: number) =>
async (dispatch: Dispatch<AnyAction>) => {
try {
dispatch(setRestTasks([]));
const url = `/api/v1/${siteId}/${notebookId}/list-rest-tasks/`;
const { data } = await axios.get(url);
dispatch(setRestTasks(data));
} catch (error) {
dispatch(setRestTasks([]));
}
};

0 comments on commit 2e49a89

Please sign in to comment.