diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml index cbd21576..9f3c03ab 100755 --- a/spiffworkflow-backend/src/spiffworkflow_backend/api.yml +++ b/spiffworkflow-backend/src/spiffworkflow_backend/api.yml @@ -926,6 +926,35 @@ paths: items: $ref: "#/components/schemas/Task" + /tasks/for-my-open-processes: + parameters: + - name: page + in: query + required: false + description: The page number to return. Defaults to page 1. + schema: + type: integer + - name: per_page + in: query + required: false + description: The page number to return. Defaults to page 1. + schema: + type: integer + get: + tags: + - Process Instances + operationId: spiffworkflow_backend.routes.process_api_blueprint.task_list_for_my_open_processes + summary: returns the list of tasks for given user's open process instances + responses: + "200": + description: list of tasks + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Task" + /process-instance/{process_instance_id}/tasks: parameters: - name: process_instance_id diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index e37f2d0b..49dc03d3 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -13,6 +13,7 @@ from typing import Union import connexion # type: ignore import flask.wrappers import jinja2 +from spiffworkflow_backend.models.group import GroupModel import werkzeug from flask import Blueprint from flask import current_app @@ -989,6 +990,42 @@ def task_list_my_tasks(page: int = 1, per_page: int = 100) -> flask.wrappers.Res return make_response(jsonify(response_json), 200) +# @process_api_blueprint.route("/v1.0/tasks", methods=["GET"]) +def task_list_for_my_open_processes(page: int = 1, per_page: int = 100) -> flask.wrappers.Response: + user_id = g.user.id + active_tasks = ( + ActiveTaskModel.query.order_by(desc(ActiveTaskModel.id)) # type: ignore + .join(ProcessInstanceModel) + .filter_by(process_initiator_id=user_id) + .outerjoin(GroupModel) + # just need this add_columns to add the process_model_identifier. Then add everything back that was removed. + .add_columns( + ProcessInstanceModel.process_model_identifier, + ProcessInstanceModel.status, + ProcessInstanceModel.updated_at_in_seconds, + ProcessInstanceModel.created_at_in_seconds, + GroupModel.identifier.label("group_identifier"), + ActiveTaskModel.task_name, + ActiveTaskModel.task_title, + ActiveTaskModel.process_model_display_name, + ActiveTaskModel.process_instance_id, + ) + .paginate(page=page, per_page=per_page, error_out=False) + ) + # tasks = [ActiveTaskModel.to_task(active_task) for active_task in active_tasks.items] + + response_json = { + "results": active_tasks.items, + "pagination": { + "count": len(active_tasks.items), + "total": active_tasks.total, + "pages": active_tasks.pages, + }, + } + + return make_response(jsonify(response_json), 200) + + def process_instance_task_list( process_instance_id: int, all_tasks: bool = False, spiff_step: int = 0 ) -> flask.wrappers.Response: diff --git a/spiffworkflow-frontend/src/App.tsx b/spiffworkflow-frontend/src/App.tsx index 2561c2a8..2d59f0de 100644 --- a/spiffworkflow-frontend/src/App.tsx +++ b/spiffworkflow-frontend/src/App.tsx @@ -6,8 +6,7 @@ import { BrowserRouter, Routes, Route } from 'react-router-dom'; import ErrorContext from './contexts/ErrorContext'; import NavigationBar from './components/NavigationBar'; -import HomePage from './routes/HomePage'; -import TaskShow from './routes/TaskShow'; +import HomePageRoutes from './routes/HomePageRoutes'; import ErrorBoundary from './components/ErrorBoundary'; import AdminRoutes from './routes/AdminRoutes'; import { ErrorForDisplay } from './interfaces'; @@ -54,17 +53,9 @@ export default function App() { {errorTag} - } /> - } /> + } /> + } /> } /> - } - /> - } - /> diff --git a/spiffworkflow-frontend/src/routes/HomePageRoutes.tsx b/spiffworkflow-frontend/src/routes/HomePageRoutes.tsx new file mode 100644 index 00000000..fa0be5fd --- /dev/null +++ b/spiffworkflow-frontend/src/routes/HomePageRoutes.tsx @@ -0,0 +1,45 @@ +import { useContext, useEffect, useState } from 'react'; +import { Route, Routes, useLocation, useNavigate } from 'react-router-dom'; +// @ts-ignore +import { Tabs, TabList, Tab } from '@carbon/react'; +import TaskShow from './TaskShow'; +import ErrorContext from '../contexts/ErrorContext'; +import MyTasks from './MyTasks'; + +export default function HomePageRoutes() { + const location = useLocation(); + const setErrorMessage = (useContext as any)(ErrorContext)[1]; + const [selectedTabIndex, setSelectedTabIndex] = useState(0); + const navigate = useNavigate(); + + useEffect(() => { + setErrorMessage(null); + }, [location, setErrorMessage]); + + // selectedIndex={selectedTabIndex} + // onChange={(event: any) => { + // setSelectedTabIndex(event.selectedIndex); + // }} + return ( + <> +

HELO

+ + + navigate('http://www.google.com')}> + Tab Label 1 + + Tab Label 2 + Tab Label 3 + + Tab Label 4 with a very long long title + + Tab Label 5 + + + + } /> + } /> + + + ); +} diff --git a/spiffworkflow-frontend/src/routes/HomePage.tsx b/spiffworkflow-frontend/src/routes/MyTasks.tsx similarity index 99% rename from spiffworkflow-frontend/src/routes/HomePage.tsx rename to spiffworkflow-frontend/src/routes/MyTasks.tsx index 71fda73f..6b6eabd2 100644 --- a/spiffworkflow-frontend/src/routes/HomePage.tsx +++ b/spiffworkflow-frontend/src/routes/MyTasks.tsx @@ -12,7 +12,7 @@ import { PaginationObject, RecentProcessModel } from '../interfaces'; const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5; -export default function HomePage() { +export default function MyTasks() { const [searchParams] = useSearchParams(); const [tasks, setTasks] = useState([]); const [pagination, setPagination] = useState(null);