From 02e8add28f4a19c1cc8c334803285a5b30eafa0b Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 18 Apr 2023 16:58:59 -0400 Subject: [PATCH] cleaing up the design a little bit so it looks pretty and in keeping with the rest of the site. --- .../routes/tasks_controller.py | 15 ++- .../services/process_instance_service.py | 1 + .../services/workflow_execution_service.py | 78 ++++++++------ .../public/interstitial/checkmark.png | Bin 0 -> 2995 bytes .../public/interstitial/clock.png | Bin 0 -> 4172 bytes .../src/routes/ProcessInterstitial.tsx | 97 ++++++++++++------ .../src/routes/TaskShow.tsx | 1 - 7 files changed, 123 insertions(+), 69 deletions(-) create mode 100644 spiffworkflow-frontend/public/interstitial/checkmark.png create mode 100644 spiffworkflow-frontend/public/interstitial/clock.png diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 53b62bfb4..2a2953a5f 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -358,9 +358,11 @@ def _render_instructions_for_end_user(spiff_task: SpiffTask, task: Task): if task.properties and "instructionsForEndUser" in task.properties: if task.properties["instructionsForEndUser"]: try: - task.properties["instructionsForEndUser"] = _render_jinja_template( + instructions = _render_jinja_template( task.properties["instructionsForEndUser"], spiff_task ) + task.properties["instructionsForEndUser"] = instructions + return instructions except WorkflowTaskException as wfe: wfe.add_note("Failed to render instructions for end user.") raise ApiError.from_workflow_exception("instructions_error", str(wfe), exp=wfe) from wfe @@ -393,19 +395,22 @@ def process_data_show( def interstitial(process_instance_id: int): process_instance = _find_process_instance_by_id_or_raise(process_instance_id) processor = ProcessInstanceProcessor(process_instance) - + reported_ids = [] # bit of an issue with end tasks showing as getting completed twice. def get_data(): spiff_task = processor.next_task() last_task = None while last_task != spiff_task: task = ProcessInstanceService.spiff_task_to_api_task(processor, processor.next_task()) - _render_instructions_for_end_user(spiff_task, task) - yield f'data: {current_app.json.dumps(task)} \n\n' + instructions = _render_instructions_for_end_user(spiff_task, task) + if instructions and spiff_task.id not in reported_ids: + reported_ids.append(spiff_task.id) + yield f'data: {current_app.json.dumps(task)} \n\n' last_task = spiff_task + processor.do_engine_steps(execution_strategy_name="run_until_user_message") processor.do_engine_steps(execution_strategy_name="one_at_a_time") spiff_task = processor.next_task() # Note, this has to be done in case someone leaves the page, - # which can cancel this function before saving. + # which can otherwise cancel this function and leave completed tasks un-registered. processor.save() # Fixme - maybe find a way not to do this on every method? return diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py index 98ef7c4d1..01ccfdde6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py @@ -443,6 +443,7 @@ class ProcessInstanceService: process_identifier=spiff_task.task_spec._wf_spec.name, process_instance_id=processor.process_instance_model.id, process_model_identifier=processor.process_model_identifier, + process_model_display_name=processor.process_model_display_name, properties=props, parent=parent_id, event_definition=serialized_task_spec.get("event_definition"), diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py index 6158d1dfd..fabdb350e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py @@ -50,11 +50,11 @@ class TaskModelSavingDelegate(EngineStepDelegate): """ def __init__( - self, - serializer: BpmnWorkflowSerializer, - process_instance: ProcessInstanceModel, - bpmn_definition_to_task_definitions_mappings: dict, - secondary_engine_step_delegate: Optional[EngineStepDelegate] = None, + self, + serializer: BpmnWorkflowSerializer, + process_instance: ProcessInstanceModel, + bpmn_definition_to_task_definitions_mappings: dict, + secondary_engine_step_delegate: Optional[EngineStepDelegate] = None, ) -> None: self.secondary_engine_step_delegate = secondary_engine_step_delegate self.process_instance = process_instance @@ -132,12 +132,12 @@ class TaskModelSavingDelegate(EngineStepDelegate): # excludes COMPLETED. the others were required to get PP1 to go to completion. # process FUTURE tasks because Boundary events are not processed otherwise. for waiting_spiff_task in bpmn_process_instance.get_tasks( - TaskState.WAITING - | TaskState.CANCELLED - | TaskState.READY - | TaskState.MAYBE - | TaskState.LIKELY - | TaskState.FUTURE + TaskState.WAITING + | TaskState.CANCELLED + | TaskState.READY + | TaskState.MAYBE + | TaskState.LIKELY + | TaskState.FUTURE ): # these will be removed from the parent and then ignored if waiting_spiff_task._has_state(TaskState.PREDICTED_MASK): @@ -243,6 +243,7 @@ class GreedyExecutionStrategy(ExecutionStrategy): if non_human_waiting_task is not None: self.run_until_user_input_required(exit_at) + class RunUntilServiceTaskExecutionStrategy(ExecutionStrategy): """For illustration purposes, not currently integrated. @@ -264,22 +265,29 @@ class RunUntilServiceTaskExecutionStrategy(ExecutionStrategy): self.delegate.after_engine_steps(bpmn_process_instance) -class RunUntilUserMessageExecutionStrategy(ExecutionStrategy): +class RunUntilUserTaskOrMessageExecutionStrategy(ExecutionStrategy): """When you want to run tasks until you hit something to report to the end user, or until there are no other engine steps to complete.""" + def get_engine_steps(self, bpmn_process_instance: BpmnWorkflow) -> List[SpiffTask]: + return list([t for t in bpmn_process_instance.get_tasks(TaskState.READY) \ + if t.task_spec.spec_type not in ["User Task", "Manual Task"] and + not (hasattr(t.task_spec, "extensions") and + t.task_spec.extensions.get("instructionsForEndUser", None)) + ]) + def spiff_run(self, bpmn_process_instance: BpmnWorkflow, exit_at: None = None) -> None: - engine_steps = self.get_ready_engine_steps(bpmn_process_instance) + + engine_steps = self.get_engine_steps(bpmn_process_instance) while engine_steps: - for spiff_task in engine_steps: - self.delegate.will_complete_task(spiff_task) - spiff_task.run() - self.delegate.did_complete_task(spiff_task) - if spiff_task.task_spec.properties.get("instructionsForEndUser", None) is not None: - break - engine_steps = self.get_ready_engine_steps(bpmn_process_instance) + for task in engine_steps: + self.delegate.will_complete_task(task) + task.run() + self.delegate.did_complete_task(task) + engine_steps = self.get_engine_steps(bpmn_process_instance) self.delegate.after_engine_steps(bpmn_process_instance) + class OneAtATimeExecutionStrategy(ExecutionStrategy): """When you want to run only one engine step at a time.""" @@ -297,7 +305,7 @@ def execution_strategy_named(name: str, delegate: EngineStepDelegate) -> Executi cls = { "greedy": GreedyExecutionStrategy, "run_until_service_task": RunUntilServiceTaskExecutionStrategy, - "run_until_user_message": RunUntilUserMessageExecutionStrategy, + "run_until_user_message": RunUntilUserTaskOrMessageExecutionStrategy, "one_at_a_time": OneAtATimeExecutionStrategy, }[name] @@ -307,16 +315,17 @@ def execution_strategy_named(name: str, delegate: EngineStepDelegate) -> Executi ProcessInstanceCompleter = Callable[[BpmnWorkflow], None] ProcessInstanceSaver = Callable[[], None] + class WorkflowExecutionService: """Provides the driver code for workflow execution.""" def __init__( - self, - bpmn_process_instance: BpmnWorkflow, - process_instance_model: ProcessInstanceModel, - execution_strategy: ExecutionStrategy, - process_instance_completer: ProcessInstanceCompleter, - process_instance_saver: ProcessInstanceSaver, + self, + bpmn_process_instance: BpmnWorkflow, + process_instance_model: ProcessInstanceModel, + execution_strategy: ExecutionStrategy, + process_instance_completer: ProcessInstanceCompleter, + process_instance_saver: ProcessInstanceSaver, ): """__init__.""" self.bpmn_process_instance = bpmn_process_instance @@ -366,7 +375,8 @@ class WorkflowExecutionService: for bpmn_message in bpmn_messages: message_instance = MessageInstanceModel( process_instance_id=self.process_instance_model.id, - user_id=self.process_instance_model.process_initiator_id, # TODO: use the correct swimlane user when that is set up + user_id=self.process_instance_model.process_initiator_id, + # TODO: use the correct swimlane user when that is set up message_type="send", name=bpmn_message.name, payload=bpmn_message.payload, @@ -392,12 +402,12 @@ class WorkflowExecutionService: for event in waiting_message_events: # Ensure we are only creating one message instance for each waiting message if ( - MessageInstanceModel.query.filter_by( - process_instance_id=self.process_instance_model.id, - message_type="receive", - name=event["name"], - ).count() - > 0 + MessageInstanceModel.query.filter_by( + process_instance_id=self.process_instance_model.id, + message_type="receive", + name=event["name"], + ).count() + > 0 ): continue diff --git a/spiffworkflow-frontend/public/interstitial/checkmark.png b/spiffworkflow-frontend/public/interstitial/checkmark.png new file mode 100644 index 0000000000000000000000000000000000000000..6467b220ca806199b59f43a13b315f2efcd967ba GIT binary patch literal 2995 zcmZuzc{tQ-8y==+tXV>6@H5GhWo9f{vr8ytD@$mMVdfY!V`dDpWQvr?5|VvvCFev@ zIJU_aO7>4>-=YXvB9w2`IoJ2kcU`~d_g>fY-1l=o&wagrytgmdTJrNq@_;}feycO) z_UzMnKe!<5e?TfylYMZL&$v)QAP8f)Ne!^a`{Mq`#r-Pz1QH1U zfYks;9F~FwXgGGTg#r9Nm&Dd0phEz~-zor{ibH#og5dgqKiV4$_)^$45|I!B_>d?7 z9Z$u3;R$$Jh*D}d=@NT8+5PRz*!%9U1~}sVu^@FMQb!eqR8>Feh(hYIKP}yjNMaWo zZ1daiKney6!qI4CsvZJCB4ddd0-lVf(DqG7cw=d3JOP2y)j?_?{*U3RULmUgI83$A z#u%~NI{%u1L=K_s8vrshLjo59y$E;=U{3N!kAATNU$bVmg*>us?}N z{iRI)#qs_{L0rXBNC=b~645qY|DAn(^sLNH9D}pIWM4~6a}s@JR9n9IjF(R>k$Iqh z=ELVGeru-w-~rddbG?GwG4ioR(GD(YwvGdN1y~16qjw+8^=PU}KI=`y_4JeGOwH6} z*B*fYlxgC@i{zl4>AK~`X?pkC2sL-7uDe!aCtJ69rJ?)OW@vY4?#^@;b-79LG%D8a z5l%6a#nr4c@th@+R}aT9JSK#$_=XIeRx1V%!69Kn;*K-os$}9o;W}91 zeiQA0mti^7sQKcoauHIB;moy;)>tYquCQ^bKSwF!u;tK88uAxI3gN)=pm>(aM0At^ z*nr!Bp;@VI`J)UR;a1Xrq#L{z`H(W;Cho(z3|)fIF$-F1A>8i{g-Pf@aq46|H0R`h zh6J*X^ema8gq$G+Q?8F%e`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NOx+ilXSsvs&+sb%%VO15jo6tekw-`qM+}`cm5W!sF;CR>+}dwzANl>OGMo zo%sQ7;`u$-OM6KY?g`ZbI}V-aE$9~6w=ne??=^10n#MSGgjrRC*tyV%Gm8N~+t@s}n z$5yn~>9B%ym^LD-qbD#%EhI~FT*RwIbAqE!VfeK*=F&^}NKH$}kRKkuNK*lJ8m97B zhu`RAF4jt%w3m6+_#sJF)_=h;^3Sx-JZp)s6Z_*vViqSc3Klzg{8p$gz2V*%)pJ$F z^Tto^c6~SlGc_P+__0c)bStwrrUl?JE@1^9i_iu?U%ri)ab31SO2a#hH7HMe^>+6% zSm5?TZ7(v%i`tL`S)qjmp}C~i8z=d>NB;yxFuw4td3e{U5~z+dPyE!q%4egbc8sEQ zE`5XF!y)<>6ac7~ylit{0Au$*95Mwbt!_k5(d0yxTijiu2(m1^hA{GIM^EKg$zdC5 z$e2^G@&ZT!9(pZT)Y2ma;cbI>Bfmu^IvZ93iZrRKp@#h8QL z3&uU1310-ys^wR`q(SpQ`^?C*X;ATub^0;8WvSF_Rml_&FOdTAR>jYJd*F>LwpQC4 TDyHn08pz7R*8GX-mFxcnUld#B literal 0 HcmV?d00001 diff --git a/spiffworkflow-frontend/public/interstitial/clock.png b/spiffworkflow-frontend/public/interstitial/clock.png new file mode 100644 index 0000000000000000000000000000000000000000..3e4e5119aed2d2d74588b5645800ca2d89cddc37 GIT binary patch literal 4172 zcmW+(c|26#8y-tSL`d19?7M7b%PvONv4tW#V;N)YjkRo148>q`V3BZNZyy9mUtdAUGStoA*ImdUDBzKAppb#5hp+o1gl|xwkPiX@Q?m0RcgQA^#SWhy8z!$N#6uM|r}7>l-LQM>GZ6XS19|Tx( zjpxVYzu<{qa2L5O%>L4*w#4DS9HUP7Rf z#N#4BVxTOP)E|&P=mgYA=fh|A4rI=hpiuc@Wj#+h!6XUfz&w8kgaygaCgI1bA3S() zy!%=35pMd?`^lZ@pe`Dao4flXMYO9TIx{mfZfVKm$OeDt!bQ+l$6x`8!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` zi)`9dAzRqU@W{wwC}zV1aF0KbM;M#lNYwf%A5};#k(_DgURhV?ZD8<3%#f9V&eYV@ z^P|Z6xdP%Rpp+&hCqqZnZrsq5)7wx%opD*h4Moo4$@BjI=8S8iXu^$aaX(_5>>;b& z-JrpNfp*@&UV^{s?`QIznQ8FMc6o_^`4JW^y4_g)=5c>Nwqf6GV@Q>1=*s}Pq82bZmHZ&yZRU>Rck37+k7}QA-!(y?K3q9v1 zWi5c?!0ha7O>ON8Ur;;#pGYGwI9gj-WzCG1$3{4@8P|$Y3T$2jW(+WbA$pjXrbQrP z{3|{|!8)#C!T^DJc#~!p`z)-=3yDNNUO{_Pr>5T6?>)I{KVcMFlnsNY%lx{CI?F12 zm64G#^yNztLa|&D0OOaXUwA82QFd3wMPu@t-mnGy?$6IHZhdJc;$h1JFa7Yp{Y8qI z??5;~1OwDESj)%X-$Pe7UTn~|#2SH6zQD|U43q__D#KPbDKz$q1t$Z+86^PjXqeur zsjQq&V&$VwZEVQ)efk9d`6)y5@o_y4_xbn!coCK+N`SlR{Oh?@I7}S_lzC-8DD+W- z!|>Qx(&1qk@nRA~A`PG!;?~yInHWq432QH`qy!A0Sro?g<{#;2vFRqyz&e$wAPW)MIdAR8&qpBw4v(XJ2+Rx|G1%m-1=$DMUb zvh50^!AJ4PwC{J>cfwoQHZMHSGCG%yT=Gz@6;zA76{ka4y9hew=w<>H)79S_^TB|V zE24VpQ`pQfY`F1OrW?rzRul7KFHg?Lg_Mob&hzQA^Pl*{aK^tuLzZ)7GLB=f&O{~1 Ul-wu*4*4JxLvw>#J=cW)0YkePV*mgE literal 0 HcmV?d00001 diff --git a/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx b/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx index 9f8a94bd7..3e7311a53 100644 --- a/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessInterstitial.tsx @@ -1,14 +1,19 @@ -import { useEffect, useState } from 'react'; -import {useNavigate, useParams} from 'react-router-dom'; +import React, { useEffect, useState } from 'react'; +import { useNavigate, useParams } from 'react-router-dom'; import { fetchEventSource } from '@microsoft/fetch-event-source'; +// @ts-ignore +import { Loading, Grid, Column } from '@carbon/react'; import { BACKEND_BASE_URL } from '../config'; import { getBasicHeaders } from '../services/HttpService'; -import {Task} from '../interfaces'; + +// @ts-ignore import InstructionsForEndUser from '../components/InstructionsForEndUser'; +import ProcessBreadcrumb from '../components/ProcessBreadcrumb'; export default function ProcessInterstitial() { const [data, setData] = useState([]); const [lastTask, setLastTask] = useState(null); + const [status, setStatus] = useState('running'); const params = useParams(); const navigate = useNavigate(); @@ -24,7 +29,8 @@ export default function ProcessInterstitial() { setLastTask(task); }, onclose() { - console.log("Connection Closed by the Server"); + setStatus('closed'); + console.log('Connection Closed by the Server'); }, } ); @@ -42,30 +48,63 @@ export default function ProcessInterstitial() { return undefined; }, [lastTask]); + const processStatusImage = () => { + if (status !== 'running') { + setStatus(lastTask.state); + } + console.log(`Status is : ${status}}`); + console.log('last task is : ', lastTask); + switch (status) { + case 'running': + return ( + + ); + case 'WAITING': + return Waiting ....; + case 'COMPLETED': + return Completed; + default: + return null; + } + }; + if (lastTask) { + return ( + <> + +

+ {processStatusImage()} + {lastTask.process_model_display_name}: {lastTask.process_instance_id} +

- return ( -
-

React - Display a list of items

- - - - - - - - {data && - data.map((d) => ( - - - - - - - ))} - -
Task Title
{d.title}{d.state}{d.type} - -
-
- ); + + + + + {data && + data.map((d) => ( + + + + + ))} + +

{d.title}

+ +
+
+
+ + ); + } + return null; } diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index de15aa3c2..231f80f8a 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -17,7 +17,6 @@ import { import MDEditor from '@uiw/react-md-editor'; // eslint-disable-next-line import/no-named-as-default import Form from '../themes/carbon'; -import Loading from '../themes/carbon'; import HttpService from '../services/HttpService'; import useAPIError from '../hooks/UseApiError'; import { modifyProcessIdentifierForPathParam } from '../helpers';