added home page routes and some tab stuff w/ burnettk
This commit is contained in:
parent
4d98fafe57
commit
0f5d2855d4
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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}
|
||||
<ErrorBoundary>
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/tasks" element={<HomePage />} />
|
||||
<Route path="/" element={<HomePageRoutes />} />
|
||||
<Route path="/tasks/*" element={<HomePageRoutes />} />
|
||||
<Route path="/admin/*" element={<AdminRoutes />} />
|
||||
<Route
|
||||
path="/tasks/:process_instance_id/:task_id"
|
||||
element={<TaskShow />}
|
||||
/>
|
||||
<Route
|
||||
path="/tasks/:process_instance_id/:task_id"
|
||||
element={<TaskShow />}
|
||||
/>
|
||||
</Routes>
|
||||
</ErrorBoundary>
|
||||
</Content>
|
||||
|
|
|
@ -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<number>(0);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
setErrorMessage(null);
|
||||
}, [location, setErrorMessage]);
|
||||
|
||||
// selectedIndex={selectedTabIndex}
|
||||
// onChange={(event: any) => {
|
||||
// setSelectedTabIndex(event.selectedIndex);
|
||||
// }}
|
||||
return (
|
||||
<>
|
||||
<h1>HELO</h1>
|
||||
<Tabs>
|
||||
<TabList aria-label="List of tabs">
|
||||
<Tab onClick={() => navigate('http://www.google.com')}>
|
||||
Tab Label 1
|
||||
</Tab>
|
||||
<Tab>Tab Label 2</Tab>
|
||||
<Tab disabled>Tab Label 3</Tab>
|
||||
<Tab title="Tab Label 4 with a very long long title">
|
||||
Tab Label 4 with a very long long title
|
||||
</Tab>
|
||||
<Tab>Tab Label 5</Tab>
|
||||
</TabList>
|
||||
</Tabs>
|
||||
<Routes>
|
||||
<Route path="/" element={<MyTasks />} />
|
||||
<Route path=":process_instance_id/:task_id" element={<TaskShow />} />
|
||||
</Routes>
|
||||
</>
|
||||
);
|
||||
}
|
|
@ -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<PaginationObject | null>(null);
|
Loading…
Reference in New Issue