in ui-modules/app-inspector/app/views/main/inspect/activities/detail/detail.controller.js [128:235]
function processWorkflowData(wResponse2) {
// change the workflow object so widgets get refreshed
vm.model.workflow = { ...vm.model.workflow, data: wResponse2.data };
vm.model.workflow.isError = !!(vm.model.workflow.data.status && vm.model.workflow.data.status.startsWith("ERROR"));
const replays = (vm.model.workflow.data.replays || []);
vm.model.workflow.runMultipleTimes = replays.length > 1;
let workflowReplayId = activityId;
if (!replays.find(r => r.taskId === workflowReplayId)) {
let submittedById = ((vm.model.activity.submittedByTask || {}).metadata || {}).id;
if (replays.find(r => r.taskId === submittedById)) workflowReplayId = submittedById;
else workflowReplayId = null;
}
if (workflowReplayId) {
vm.model.workflow.runReplayId = workflowReplayId;
vm.model.workflow.runIsLatest = workflowReplayId == (replays[replays.length - 1] || {}).taskId;
vm.model.workflow.runIsOld = !vm.model.workflow.runIsLatest;
}
if (vm.model.workflow.runIsOld && vm.redirectToWorkflowLatestRun) {
vm.redirectToWorkflowLatestRun = false;
$state.go('main.inspect.activities.detail', {
applicationId: applicationId,
entityId: entityId,
activityId: (replays[replays.length - 1] || {}).taskId,
});
}
let osi = vm.model.workflow.data.oldStepInfo;
vm.model.workflow.finishedWithNoSteps = ((osi["-2"] || {}).previous || [])[0] == -1;
$scope.actions.workflowReplays = [];
if (vm.model.workflow.data.status !== 'RUNNING') {
$scope.actions.workflowReplays = [];
const stepIndex = (vm.model.workflow.tag || {}).stepIndex; // selected by user
const currentStepIndex = vm.model.workflow.data.currentStepIndex; // of workflow
let replayableDisabled = vm.model.workflow.data.replayableDisabled;
let replayableFromStart = vm.model.workflow.data.replayableFromStart && !replayableDisabled,
replayableFromLastStep = vm.model.workflow.data.replayableLastStep>=0 && !replayableDisabled;
if (replayableFromLastStep) {
let msg = 'Replay from last replay point (step '+(vm.model.workflow.data.replayableLastStep+1)+')';
$scope.actions.workflowReplays.push({ targetId: 'last', reason: msg+' from UI', label: msg });
}
// get current step, replay from that step
if (stepIndex>=0) {
const osi = vm.model.workflow.data.oldStepInfo[stepIndex] || {};
if (osi.replayableFromHere && !replayableDisabled) {
$scope.actions.workflowReplays.push({ targetId: ''+stepIndex, reason: 'Replay from step '+(stepIndex+1)+' from UI',
label: 'Replay from here (step '+(stepIndex+1)+')' });
} else {
$scope.actions.workflowReplays.push({ targetId: ''+stepIndex, reason: 'Force replay from step '+(stepIndex+1)+' from UI',
label: 'Force replay from here (step '+(stepIndex+1)+')', force: true });
}
}
if (replayableFromStart) {
let w1 = 'Replay from start', w2 = '(no other replay points)';
if (stepIndex<0 || (_.isNil(stepIndex) && vm.model.workflow.data.replayableLastStep==-2)) { w1 = 'Run'; w2 = 'again'; }
else if (replayableFromLastStep) w2 = '';
else if (_.isNil(stepIndex)) { w2 = '(did not start)'; }
$scope.actions.workflowReplays.push({targetId: 'start', reason: 'Replay from start from UI',
label: w1+' '+w2});
}
if (currentStepIndex>=0 && currentStepIndex < vm.model.workflow.data.stepsDefinition.length) {
let msg = 'eplay resuming (at step ' + (currentStepIndex + 1);
if (!replayableDisabled) {
$scope.actions.workflowReplays.push({ targetId: 'last', label: 'R'+msg+' if possible)', reason: 'R'+msg+') from UI' });
}
$scope.actions.workflowReplays.push({ targetId: 'last', label: 'Force r'+msg+')', reason: 'Force r'+msg+') from UI', force: true });
}
if (!replayableFromStart) {
$scope.actions.workflowReplays.push({targetId: 'start', reason: 'Force replay from start from UI',
label: 'Force replay from start', force: true});
}
// force replays
$scope.actions.workflowReplays.forEach(r => {
// could prompt for a reason
r.action = () => {
const opts = {};
opts.reason = r.reason;
if (r.force) opts.force = true;
entityApi.replayWorkflow(applicationId, entityId, $scope.workflowId, r.targetId, opts)
.then(response => {
console.log("Replay requested", response);
$state.go('main.inspect.activities.detail', {
applicationId: applicationId,
entityId: entityId,
activityId: response.data.id,
});
}).catch(error => {
console.log("Replay failed", error);
});
};
});
}
if (!$scope.actions.workflowReplays.length) delete $scope.actions['workflowReplays'];
onActivityOrWorkflowUpdate();
}