mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-02-01 04:35:46 +00:00
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
|
type: boolean
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- Process Instances
|
- Process Instance Events
|
||||||
operationId: spiffworkflow_backend.routes.process_instances_controller.process_instance_log_list
|
operationId: spiffworkflow_backend.routes.process_instance_events_controller.log_list
|
||||||
summary: returns a list of logs associated with the process instance
|
summary: returns a list of logs associated with the process instance
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
@ -1972,6 +1972,20 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/ProcessInstanceLog"
|
$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:
|
/secrets:
|
||||||
parameters:
|
parameters:
|
||||||
- name: page
|
- 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 log_list(
|
||||||
def process_instance_log_list(
|
|
||||||
modified_process_model_identifier: str,
|
modified_process_model_identifier: str,
|
||||||
process_instance_id: int,
|
process_instance_id: int,
|
||||||
page: int = 1,
|
page: int = 1,
|
||||||
per_page: int = 100,
|
per_page: int = 100,
|
||||||
detailed: bool = False,
|
detailed: bool = False,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
"""Process_instance_log_list."""
|
|
||||||
# to make sure the process instance exists
|
# to make sure the process instance exists
|
||||||
process_instance = _find_process_instance_by_id_or_raise(process_instance_id)
|
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)
|
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="/processes"))
|
||||||
permissions_to_assign.append(PermissionToAssign(permission="read", target_uri="/service-tasks"))
|
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="/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="create", target_uri="/users/exists/by-username"))
|
||||||
permissions_to_assign.append(
|
permissions_to_assign.append(
|
||||||
PermissionToAssign(permission="read", target_uri="/process-instances/find-by-id/*")
|
PermissionToAssign(permission="read", target_uri="/process-instances/find-by-id/*")
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
ButtonSet,
|
ButtonSet,
|
||||||
Button,
|
Button,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
ComboBox,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
} from '@carbon/react';
|
} from '@carbon/react';
|
||||||
import {
|
import {
|
||||||
@ -44,6 +45,10 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||||||
const [taskName, setTaskName] = useState<string>('');
|
const [taskName, setTaskName] = useState<string>('');
|
||||||
const [taskIdentifier, setTaskIdentifier] = 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 { targetUris } = useUriListForPermissions();
|
||||||
const isDetailedView = searchParams.get('detailed') === 'true';
|
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}`,
|
path: `${targetUris.processInstanceLogListPath}?per_page=${perPage}&page=${page}&detailed=${isDetailedView}`,
|
||||||
successCallback: setProcessInstanceLogListFromResult,
|
successCallback: setProcessInstanceLogListFromResult,
|
||||||
});
|
});
|
||||||
|
HttpService.makeCallToBackend({
|
||||||
|
path: `/v1.0/logs/types`,
|
||||||
|
successCallback: (result: any) => {
|
||||||
|
setTaskTypes(result.task_types)
|
||||||
|
setEventTypes(result.event_types)
|
||||||
|
},
|
||||||
|
});
|
||||||
}, [
|
}, [
|
||||||
searchParams,
|
searchParams,
|
||||||
params,
|
params,
|
||||||
@ -209,6 +221,15 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||||||
setSearchParams(searchParams);
|
setSearchParams(searchParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const shouldFilterTaskType = (options: any) => {
|
||||||
|
const taskTypeOption = options.item
|
||||||
|
let { inputValue } = options;
|
||||||
|
if (!inputValue) {
|
||||||
|
inputValue = '';
|
||||||
|
}
|
||||||
|
return taskTypeOption.toLowerCase().includes(inputValue.toLowerCase())
|
||||||
|
}
|
||||||
|
|
||||||
const filterOptions = () => {
|
const filterOptions = () => {
|
||||||
if (!showFilterOptions) {
|
if (!showFilterOptions) {
|
||||||
return null;
|
return null;
|
||||||
@ -239,6 +260,21 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
|
|||||||
setTaskIdentifier(newValue);
|
setTaskIdentifier(newValue);
|
||||||
addDebouncedSearchParams(newValue, 'bpmn_identifier');
|
addDebouncedSearchParams(newValue, 'bpmn_identifier');
|
||||||
}}
|
}}
|
||||||
|
/>
|
||||||
|
</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>
|
</Column>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user