added api to get task types and added combo box w/ burnettk
This commit is contained in:
parent
3b91f0767e
commit
be15c01b2e
|
@ -1961,8 +1961,8 @@ paths:
|
|||
type: boolean
|
||||
get:
|
||||
tags:
|
||||
- Process Instances
|
||||
operationId: spiffworkflow_backend.routes.process_instances_controller.process_instance_log_list
|
||||
- Process Instance Events
|
||||
operationId: spiffworkflow_backend.routes.process_instance_events_controller.log_list
|
||||
summary: returns a list of logs associated with the process instance
|
||||
responses:
|
||||
"200":
|
||||
|
@ -1972,6 +1972,20 @@ paths:
|
|||
schema:
|
||||
$ref: "#/components/schemas/ProcessInstanceLog"
|
||||
|
||||
/logs/types:
|
||||
get:
|
||||
tags:
|
||||
- Process Instance Events
|
||||
operationId: spiffworkflow_backend.routes.process_instance_events_controller.types
|
||||
summary: returns a list of task types and event typs. useful for building log queries.
|
||||
responses:
|
||||
"200":
|
||||
description: list of types
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ProcessInstanceLog"
|
||||
|
||||
/secrets:
|
||||
parameters:
|
||||
- name: page
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
import flask.wrappers
|
||||
|
||||
from sqlalchemy import and_
|
||||
from spiffworkflow_backend.models.db import db
|
||||
from flask import make_response
|
||||
from flask import jsonify
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.models.bpmn_process_definition import BpmnProcessDefinitionModel
|
||||
from spiffworkflow_backend.models.task_definition import TaskDefinitionModel
|
||||
from spiffworkflow_backend.models.task import TaskModel # noqa: F401
|
||||
from spiffworkflow_backend.models.process_instance_event import ProcessInstanceEventModel, ProcessInstanceEventType
|
||||
from spiffworkflow_backend.routes.process_api_blueprint import (
|
||||
_find_process_instance_by_id_or_raise,
|
||||
)
|
||||
|
||||
|
||||
|
||||
def process_instance_log_list(
|
||||
def log_list(
|
||||
modified_process_model_identifier: str,
|
||||
process_instance_id: int,
|
||||
page: int = 1,
|
||||
per_page: int = 100,
|
||||
detailed: bool = False,
|
||||
) -> flask.wrappers.Response:
|
||||
"""Process_instance_log_list."""
|
||||
# to make sure the process instance exists
|
||||
process_instance = _find_process_instance_by_id_or_raise(process_instance_id)
|
||||
|
||||
|
@ -56,3 +68,10 @@ def process_instance_log_list(
|
|||
}
|
||||
|
||||
return make_response(jsonify(response_json), 200)
|
||||
|
||||
|
||||
def types() -> flask.wrappers.Response:
|
||||
query = db.session.query(TaskDefinitionModel.typename).distinct() # type: ignore
|
||||
task_types = [t.typename for t in query]
|
||||
event_types = ProcessInstanceEventType.list()
|
||||
return make_response(jsonify({'task_types': task_types, 'event_types': event_types}), 200)
|
||||
|
|
|
@ -567,6 +567,7 @@ class AuthorizationService:
|
|||
permissions_to_assign.append(PermissionToAssign(permission="read", target_uri="/processes"))
|
||||
permissions_to_assign.append(PermissionToAssign(permission="read", target_uri="/service-tasks"))
|
||||
permissions_to_assign.append(PermissionToAssign(permission="read", target_uri="/user-groups/for-current-user"))
|
||||
permissions_to_assign.append(PermissionToAssign(permission="read", target_uri="/logs/types"))
|
||||
permissions_to_assign.append(PermissionToAssign(permission="create", target_uri="/users/exists/by-username"))
|
||||
permissions_to_assign.append(
|
||||
PermissionToAssign(permission="read", target_uri="/process-instances/find-by-id/*")
|
||||
|
|
|
@ -9,6 +9,7 @@ import {
|
|||
ButtonSet,
|
||||
Button,
|
||||
TextInput,
|
||||
ComboBox,
|
||||
// @ts-ignore
|
||||
} from '@carbon/react';
|
||||
import {
|
||||
|
@ -44,6 +45,10 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||
const [taskName, setTaskName] = useState<string>('');
|
||||
const [taskIdentifier, setTaskIdentifier] = useState<string>('');
|
||||
|
||||
const [taskTypes, setTaskTypes] = useState<string[]>([])
|
||||
const [selectedTaskType, setSelectedTaskType] = useState<string | null>(null)
|
||||
const [eventTypes, setEventTypes] = useState<string[]>([])
|
||||
|
||||
const { targetUris } = useUriListForPermissions();
|
||||
const isDetailedView = searchParams.get('detailed') === 'true';
|
||||
|
||||
|
@ -82,6 +87,13 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||
path: `${targetUris.processInstanceLogListPath}?per_page=${perPage}&page=${page}&detailed=${isDetailedView}`,
|
||||
successCallback: setProcessInstanceLogListFromResult,
|
||||
});
|
||||
HttpService.makeCallToBackend({
|
||||
path: `/v1.0/logs/types`,
|
||||
successCallback: (result: any) => {
|
||||
setTaskTypes(result.task_types)
|
||||
setEventTypes(result.event_types)
|
||||
},
|
||||
});
|
||||
}, [
|
||||
searchParams,
|
||||
params,
|
||||
|
@ -209,6 +221,15 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||
setSearchParams(searchParams);
|
||||
};
|
||||
|
||||
const shouldFilterTaskType = (options: any) => {
|
||||
const taskTypeOption = options.item
|
||||
let { inputValue } = options;
|
||||
if (!inputValue) {
|
||||
inputValue = '';
|
||||
}
|
||||
return taskTypeOption.toLowerCase().includes(inputValue.toLowerCase())
|
||||
}
|
||||
|
||||
const filterOptions = () => {
|
||||
if (!showFilterOptions) {
|
||||
return null;
|
||||
|
@ -241,6 +262,21 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||
}}
|
||||
/>
|
||||
</Column>
|
||||
<Column md={4}>
|
||||
<ComboBox
|
||||
onChange={(value: any) => setSelectedTaskType(value.selectedItem)}
|
||||
id="task-type-select"
|
||||
data-qa="task-type-select"
|
||||
items={taskTypes}
|
||||
itemToString={(value: string) => {
|
||||
return value
|
||||
}}
|
||||
shouldFilterItem={shouldFilterTaskType}
|
||||
placeholder="Choose a process model"
|
||||
titleText="Task Type"
|
||||
selectedItem={selectedTaskType}
|
||||
/>
|
||||
</Column>
|
||||
</Grid>
|
||||
<Grid fullWidth className="with-bottom-margin">
|
||||
<Column sm={4} md={4} lg={8}>
|
||||
|
|
Loading…
Reference in New Issue