Skip to content
Snippets Groups Projects
Verified Commit 93f6d61a authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Add DeleteModal when deleting a workflow execution

#40
parent db63fb7f
No related branches found
No related tags found
1 merge request!43Resolve "Create List Workflow Executions Page"
This commit is part of merge request !43. Comments created here will be created in the context of that merge request.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"generate-s3-client": "openapi --input https://clowm-staging.bi.denbi.de/api/s3proxy-service/openapi.json --output src/client/s3proxy --client axios", "generate-s3-client": "openapi --input https://clowm-staging.bi.denbi.de/api/s3proxy-service/openapi.json --output src/client/s3proxy --client axios",
"generate-auth-client": "openapi --input https://clowm-staging.bi.denbi.de/api/auth-service/openapi.json --output src/client/auth --client axios", "generate-auth-client": "openapi --input https://clowm-staging.bi.denbi.de/api/auth-service/openapi.json --output src/client/auth --client axios",
"generate-workflow-client": "openapi --input http://localhost:9999/api/workflow-service/openapi.json --output src/client/workflow --client axios" "generate-workflow-client": "openapi --input https://clowm-staging.bi.denbi.de/api/workflow-service/openapi.json --output src/client/workflow --client axios"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-s3": "^3.290.0", "@aws-sdk/client-s3": "^3.290.0",
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
WorkflowVersionService, WorkflowVersionService,
} from "@/client/workflow"; } from "@/client/workflow";
import dayjs from "dayjs"; import dayjs from "dayjs";
import DeleteModal from "@/components/modals/DeleteModal.vue";
const userStore = useAuthStore(); const userStore = useAuthStore();
...@@ -19,12 +20,14 @@ const executionsState = reactive<{ ...@@ -19,12 +20,14 @@ const executionsState = reactive<{
workflowExecutions: WorkflowExecutionOut[]; workflowExecutions: WorkflowExecutionOut[];
loading: boolean; loading: boolean;
mappingLoading: boolean; mappingLoading: boolean;
executionToDelete?: WorkflowExecutionOut;
}>({ }>({
workflowMapping: {}, workflowMapping: {},
versionMapping: {}, versionMapping: {},
workflowExecutions: [], workflowExecutions: [],
loading: true, loading: true,
mappingLoading: true, mappingLoading: true,
executionToDelete: undefined,
}); });
const statusToColorMapping = { const statusToColorMapping = {
...@@ -49,13 +52,36 @@ const sortedExecutions = computed<WorkflowExecutionOut[]>(() => { ...@@ -49,13 +52,36 @@ const sortedExecutions = computed<WorkflowExecutionOut[]>(() => {
const tempList = [...executionsState.workflowExecutions]; const tempList = [...executionsState.workflowExecutions];
tempList.sort((a, b) => { tempList.sort((a, b) => {
// sort by start time descending // sort by start time descending
const a_date = dayjs(a.start_time); return dayjs(a.start_time).isBefore(dayjs(b.start_time)) ? 1 : -1;
const b_date = dayjs(b.start_time);
return a_date.isBefore(b_date) ? 1 : -1;
}); });
return tempList; return tempList;
}); });
const deleteModalString = computed<string>(() => {
if (executionsState.executionToDelete === undefined) {
return "";
} else if (
!executionsState.executionToDelete.workflow_version_id ||
!executionsState.executionToDelete.workflow_id
) {
return `Workflow Execution from ${dayjs(
executionsState.executionToDelete.start_time
).format("DD.MM.YYYY HH:mm")}`;
} else {
return `Workflow Execution ${
executionsState.workflowMapping[
executionsState.executionToDelete.workflow_id
]
}@${
executionsState.versionMapping[
executionsState.executionToDelete.workflow_version_id
]
} from ${dayjs(executionsState.executionToDelete.start_time).format(
"DD.MM.YYYY HH:mm"
)}`;
}
});
// Functions // Functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function updateExecutions() { function updateExecutions() {
...@@ -153,15 +179,17 @@ function workflowExecutionCancable(status: WorkflowExecutionStatus): boolean { ...@@ -153,15 +179,17 @@ function workflowExecutionCancable(status: WorkflowExecutionStatus): boolean {
].includes(status); ].includes(status);
} }
function deleteWorkflowExecution(executionId: string) { function deleteWorkflowExecution(executionId?: string) {
WorkflowExecutionService.workflowExecutionDeleteWorkflowExecution( if (executionId) {
executionId WorkflowExecutionService.workflowExecutionDeleteWorkflowExecution(
).then(() => { executionId
executionsState.workflowExecutions = ).then(() => {
executionsState.workflowExecutions.filter( executionsState.workflowExecutions =
(execution) => execution.execution_id !== executionId executionsState.workflowExecutions.filter(
); (execution) => execution.execution_id !== executionId
}); );
});
}
} }
function cancelWorkflowExecution(executionId: string) { function cancelWorkflowExecution(executionId: string) {
...@@ -186,8 +214,20 @@ onMounted(() => { ...@@ -186,8 +214,20 @@ onMounted(() => {
</script> </script>
<template> <template>
<div class="row m-2 border-bottom border-light mb-4"> <delete-modal
<h1 class="mb-2 text-light">My Workflow Executions</h1> modal-i-d="deleteWorkflowExecutionModal"
:object-name-delete="deleteModalString"
@confirm-delete="
deleteWorkflowExecution(executionsState.executionToDelete?.execution_id)
"
/>
<div
class="row m-2 border-bottom border-light mb-4 justify-content-between align-items-center"
>
<h1 class="mb-2 text-light w-fit">My Workflow Executions</h1>
<router-link :to="{ name: 'workflows' }" class="btn btn-primary w-fit"
>Start Workflow Execution</router-link
>
</div> </div>
<table <table
class="table table-dark table-striped table-hover caption-top align-middle" class="table table-dark table-striped table-hover caption-top align-middle"
...@@ -241,7 +281,7 @@ onMounted(() => { ...@@ -241,7 +281,7 @@ onMounted(() => {
</td> </td>
</tr> </tr>
</template> </template>
<template v-else> <template v-else-if="executionsState.workflowExecutions.length > 0">
<tr v-for="execution in sortedExecutions" :key="execution.execution_id"> <tr v-for="execution in sortedExecutions" :key="execution.execution_id">
<td <td
v-if="executionsState.mappingLoading" v-if="executionsState.mappingLoading"
...@@ -304,7 +344,9 @@ onMounted(() => { ...@@ -304,7 +344,9 @@ onMounted(() => {
<button <button
class="dropdown-item text-danger align-middle" class="dropdown-item text-danger align-middle"
type="button" type="button"
@click="deleteWorkflowExecution(execution.execution_id)" data-bs-toggle="modal"
data-bs-target="#deleteWorkflowExecutionModal"
@click="executionsState.executionToDelete = execution"
> >
<font-awesome-icon icon="fa-solid fa-trash" /> <font-awesome-icon icon="fa-solid fa-trash" />
<span class="ms-1">Delete</span> <span class="ms-1">Delete</span>
...@@ -312,10 +354,12 @@ onMounted(() => { ...@@ -312,10 +354,12 @@ onMounted(() => {
</li> </li>
</ul> </ul>
</div> </div>
<!-- Show delete button when row is a folder -->
</td> </td>
</tr> </tr>
</template> </template>
<tr v-else>
<td colspan="5" class="text-center"><i>No workflow executions</i></td>
</tr>
</tbody> </tbody>
</table> </table>
</template> </template>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment