Skip to content

Commit

Permalink
feat(prediction): make non predicted path less visible (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
csouchet authored Jul 20, 2023
1 parent ee87374 commit 069dfdc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
15 changes: 13 additions & 2 deletions demo/predictions/css/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
--stroke-path-predicted: 0.18rem;
}

/* ================================================================================================================== */
/* ALREADY EXECUTED */
/* ================================================================================================================== */

/* parallel gateway icon */
.bpmn-parallel-gateway.state-already-executed > path:nth-child(2),
/* message flow arrow */
Expand All @@ -29,12 +33,17 @@
/* message event icon */
.bpmn-event-def-message.state-already-executed > rect,
.bpmn-event-def-message.state-already-executed > path,
/* event stroke */
.bpmn-type-event.state-already-executed > ellipse {
/* event */
.bpmn-type-event.state-already-executed > * {
filter: blur(2px);
stroke: var(--color-path-executed);
}

/* end event center circle */
.bpmn-type-event.state-already-executed > ellipse:nth-child(2) {
fill: var(--color-path-executed);
}

/* labels (the selector applies to all div, not the only one that contains text, but this is ok.
Use important to override the color set inline in the style attribute of the label div */
.bpmn-label.state-already-executed > g div {
Expand All @@ -43,6 +52,7 @@
filter: blur(1px);
}


/* ================================================================================================================== */
/* INFO */
/* ================================================================================================================== */
Expand Down Expand Up @@ -170,3 +180,4 @@
color: var(--color-path-predicted-on-time) !important;
font-weight: bold;
}

18 changes: 15 additions & 3 deletions demo/predictions/js/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ class ExecutionData {

_executedElements;

_nonPredictedElements;

_runningElementWithPrediction;

_predictedPaths;

#runningElementsWithoutPrediction = [this._vendorWhereIsMyPizzaId, this._customerEvtBasedGwId];
_runningElementsWithoutPrediction = [this._vendorWhereIsMyPizzaId, this._customerEvtBasedGwId];

_pathResolver;

Expand All @@ -41,12 +43,16 @@ class ExecutionData {
return this._runningElementWithPrediction;
}

get runningElementsWithoutPrediction() {
return this._runningElementsWithoutPrediction;
}

get predictedPaths() {
return this._predictedPaths;
}

get runningElementsWithoutPrediction() {
return this.#runningElementsWithoutPrediction;
get nonPredictedElements() {
return this._nonPredictedElements;
}
}

Expand All @@ -67,6 +73,9 @@ class PredicatedLateExecutionData extends ExecutionData {
this._vendorWhereIsMyPizzaId,
'_6-695', // 'Calm customer'
]);

const allCustomizedElements = [...this._executedElements, this._runningElementWithPrediction, ...this._predictedPaths];
this._nonPredictedElements = pathResolver.flatAllPaths().filter(id=> !allCustomizedElements.includes(id));
}
}

Expand All @@ -87,6 +96,9 @@ class PredictedOnTimeExecutionData extends ExecutionData {
// vendor elements
'_6-565', // 'Receive payment'
]);

const allCustomizedElements = [...this._executedElements, this._runningElementWithPrediction, ...this._predictedPaths];
this._nonPredictedElements = pathResolver.flatAllPaths().filter(id=> !allCustomizedElements.includes(id));
}

}
12 changes: 12 additions & 0 deletions demo/predictions/js/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ class PathResolver {
return [...shapeIds, ...this.#paths.filter(path => shapeIds.includes(path.sourceId) ).map(path => path.edgeId)];
}

flatAllPaths(){
const flatPaths = new Set();

for (const path of this.#paths) {
flatPaths.add(path.edgeId);
flatPaths.add(path.sourceId);
flatPaths.add(path.targetId);
}

return Array.from(flatPaths);
}

#buildPaths(edges) {
return edges.map(edge => {
const bpmnSemantic = edge.bpmnSemantic;
Expand Down
1 change: 1 addition & 0 deletions demo/predictions/js/prediction-use-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class PredicatedLateUseCase extends UseCase {
const highlightPredictedPath = () => {
this._style.toggleHighlightRunningElementsWithoutPrediction(runningElementsWithoutPrediction);
this._style.toggleHighlightPredictedPath(predictedPath);
this._style.toggleReduceVisibilityOfNonPredictedElements(this._executionData.nonPredictedElements);
}

elementTogglingPath.htmlElement.addEventListener('mouseenter', highlightPredictedPath);
Expand Down
7 changes: 7 additions & 0 deletions demo/predictions/js/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class Style {
this._bpmnElementsRegistry.addCssClasses(ids, 'state-already-executed');
}

/**
* @param {string[]} ids
*/
toggleReduceVisibilityOfNonPredictedElements(ids) {
this._bpmnElementsRegistry.toggleCssClasses(ids, 'state-already-executed');
}

/**
* @param {string[]} ids
*/
Expand Down

0 comments on commit 069dfdc

Please sign in to comment.