Skip to content

Commit

Permalink
feat(orchestrator): workflow instance result page (janus-idp#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilzi authored Jan 16, 2024
1 parent e8bc892 commit ea1b67e
Show file tree
Hide file tree
Showing 33 changed files with 3,899 additions and 251 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ site
# build cache
.webpack-cache

.idea/
.tmp
24 changes: 23 additions & 1 deletion plugins/orchestrator-backend/src/service/DataIndexService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, fetchExchange } from '@urql/core';
import { Client, fetchExchange, gql } from '@urql/core';
import { Logger } from 'winston';

import {
Expand Down Expand Up @@ -35,6 +35,28 @@ export class DataIndexService {
});
}

public async abortWorkflowInstance(workflowId: string) {
this.logger.info(`Aborting workflow instance ${workflowId}`);
const ProcessInstanceAbortMutationDocument = gql`
mutation ProcessInstanceAbortMutation($id: String) {
ProcessInstanceAbort(id: $id)
}
`;

const result = await this.client
.mutation(ProcessInstanceAbortMutationDocument, { id: workflowId })
.toPromise();

if (result.error) {
this.logger.error(
`Error aborting workflow instance ${workflowId}: ${result.error}`,
);
}

this.logger.debug(`Successfully aborted workflow instance ${workflowId}`);
return result;
}

public async getWorkflowDefinition(
definitionId: string,
): Promise<WorkflowInfo> {
Expand Down
18 changes: 17 additions & 1 deletion plugins/orchestrator-backend/src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,22 @@ function setupInternalRoutes(
});
});

router.delete('/workflows/:workflowId/abort', async (req, res) => {
const {
params: { workflowId },
} = req;

const result = await dataIndexService.abortWorkflowInstance(workflowId);

if (result.error) {
res.status(500).json(result.error);
return;
}

res.status(200).json(result.data);
return;
});

router.post('/workflows/:workflowId/execute', async (req, res) => {
const {
params: { workflowId },
Expand Down Expand Up @@ -382,7 +398,7 @@ function setupInternalRoutes(

router.get('/specs', async (_, res) => {
const specs = await workflowService.listStoredSpecs();
res.json(specs).status(200).send();
res.status(200).json(specs);
});
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/orchestrator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.45",
"@monaco-editor/react": "^4.6.0",
"@mui/icons-material": "^5.15.3",
"@rjsf/core-v5": "npm:@rjsf/[email protected]",
"@rjsf/material-ui-v5": "npm:@rjsf/[email protected]",
"@rjsf/utils": "5.7.3",
"@rjsf/validator-ajv8": "5.7.3",
"classnames": "^2.5.1",
"json-schema": "^0.4.0",
"moment": "^2.29.4",
"monaco-editor": "^0.39.0",
Expand Down
112 changes: 112 additions & 0 deletions plugins/orchestrator/src/__fixtures__/fakeNodeInstances.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { NodeInstance } from '@janus-idp/backstage-plugin-orchestrator-common';

export const fakeNodeInstances: NodeInstance[] = [
{
id: '5e33c387-1235-41cd-a7af-6d9e11c4381d',
nodeId: '2',
definitionId: '_jbpm-unique-352',
type: 'EndNode',
name: 'End',
enter: new Date('2024-01-07T11:02:44.264Z'),
exit: new Date('2024-01-07T11:02:44.264Z'),
},
{
id: 'b1602034-979e-49ce-99f6-b4222f799f6d',
nodeId: '6',
definitionId: '_jbpm-unique-356',
type: 'CompositeContextNode',
name: 'GreetPerson',
enter: new Date('2024-01-07T11:02:39.204Z'),
exit: new Date('2024-01-07T11:02:44.264Z'),
},
{
id: '57d01c6a-7dc7-4c85-86f3-db46d148bd15',
nodeId: '12',
definitionId: '_jbpm-unique-361',
type: 'EndNode',
name: 'EmbeddedEnd',
enter: new Date('2024-01-07T11:02:44.263Z'),
exit: new Date('2024-01-07T11:02:44.263Z'),
},
{
id: 'dbb08e15-13e7-47db-b8a9-0924cc288885',
nodeId: '10',
definitionId: '_jbpm-unique-359',
type: 'ActionNode',
name: 'Script',
enter: new Date('2024-01-07T11:02:44.262Z'),
exit: new Date('2024-01-07T11:02:44.263Z'),
},
{
id: '4b5cf2ef-32e3-4720-952a-90158cb8259d',
nodeId: '9',
definitionId: '_jbpm-unique-358',
type: 'ActionNode',
name: 'greetFunction',
enter: new Date('2024-01-07T11:02:44.261Z'),
exit: new Date('2024-01-07T11:02:44.262Z'),
},
{
id: '54b25b60-b03a-4c76-bd69-648ce73ab3cf',
nodeId: '11',
definitionId: '11',
type: 'TimerNode',
name: 'TimerNode_11',
enter: new Date('2024-01-07T11:02:39.205Z'),
exit: new Date('2024-01-07T11:02:44.26Z'),
},
{
id: 'dac8b5a1-d918-4e01-b538-58ca440e9f05',
nodeId: '7',
definitionId: '_jbpm-unique-357',
type: 'StartNode',
name: 'EmbeddedStart',
enter: new Date('2024-01-07T11:02:39.204Z'),
exit: new Date('2024-01-07T11:02:39.205Z'),
},
{
id: 'c52c291b-b9c8-4fa1-a586-a0ed9531feb0',
nodeId: '14',
definitionId: '_jbpm-unique-363',
type: 'Join',
name: 'Join-GreetPerson',
enter: new Date('2024-01-07T11:02:39.203Z'),
exit: new Date('2024-01-07T11:02:39.203Z'),
},
{
id: 'f5991057-3f73-493b-9be2-14a5069db99c',
nodeId: '4',
definitionId: '_jbpm-unique-354',
type: 'ActionNode',
name: 'GreetInEnglish',
enter: new Date('2024-01-07T11:02:39.197Z'),
exit: new Date('2024-01-07T11:02:39.203Z'),
},
{
id: 'd44679a4-ae8b-4481-b65b-2310da26af47',
nodeId: '13',
definitionId: '_jbpm-unique-362',
type: 'Join',
name: 'Join-GreetInEnglish',
enter: new Date('2024-01-07T11:02:39.196Z'),
exit: new Date('2024-01-07T11:02:39.197Z'),
},
{
id: '31ee04b6-ec89-4d69-9e48-f520a353abc3',
nodeId: '3',
definitionId: '3',
type: 'Split',
name: 'ChooseOnLanguage',
enter: new Date('2024-01-07T11:02:39.167Z'),
exit: new Date('2024-01-07T11:02:39.195Z'),
},
{
id: 'f571878c-c59f-4f59-8759-9be8bb51a68e',
nodeId: '1',
definitionId: '_jbpm-unique-351',
type: 'StartNode',
name: 'Start',
enter: new Date('2024-01-07T11:02:39.165Z'),
exit: new Date('2024-01-07T11:02:39.166Z'),
},
];
Loading

0 comments on commit ea1b67e

Please sign in to comment.