Skip to content
Snippets Groups Projects
Commit 1a852a08 authored by ml bonhomme's avatar ml bonhomme :bee: Committed by Erwan Rouchet
Browse files

add clear process button

parent ab6f7aa3
No related branches found
No related tags found
1 merge request!1275add clear process button
......@@ -317,6 +317,9 @@ export const createProcessTemplate = unique(async ({ id, payload }) => (await ax
// Apply a process template on a process
export const applyProcessTemplate = unique(async ({ id, payload }) => (await axios.post(`/process/${id}/apply/`, payload)).data)
// Clear a process (remove all worker runs and templates)
export const clearProcess = unique(async id => await axios.delete(`/imports/${id}/clear/`))
// Run a file import process from files
export const importFromFiles = async payload => (await axios.post('/imports/fromfiles/', payload)).data
......
......@@ -323,6 +323,11 @@ export const actions = {
commit('removeWorkerRun', { dataImportId, workerRunId })
},
async clearProcess ({ commit }, { dataImportId }) {
await api.clearProcess(dataImportId)
commit('removeWorkerRuns', { dataImportId })
},
async listProcesses ({ commit }, params) {
try {
const data = await api.listProcesses(removeEmptyStrings(params))
......
......@@ -9,6 +9,7 @@ import {
workerTypesSample,
workerConfigurationsSample,
workerVersionsSample,
workerRunSample,
workerRunsSample,
workerSample,
processSample,
......@@ -1097,6 +1098,31 @@ describe('process', () => {
})
})
describe('clearProcess', () => {
it('removes all worker runs from a process', async () => {
store.state.process.workerRuns = { test_process_id: workerRunsSample, other_process_id: [workerRunSample] }
mock.onDelete('/imports/test_process_id/clear/').reply(204)
await store.dispatch('process/clearProcess', { dataImportId: 'test_process_id' })
assert.deepStrictEqual(store.history, [
{ action: 'process/clearProcess', payload: { dataImportId: 'test_process_id' } },
{
mutation: 'process/removeWorkerRuns',
payload: {
dataImportId: 'test_process_id'
}
}
])
assert.deepStrictEqual(mock.history.all.map(req => pick(req, ['method', 'url'])), [
{
method: 'delete',
url: '/imports/test_process_id/clear/'
}
])
assert.deepStrictEqual(store.state.process.workerRuns, { test_process_id: {}, other_process_id: [workerRunSample] })
})
})
describe('startProcess', () => {
it('starts a specific process', async () => {
store.state.process.processes = processesSample
......
......@@ -30,6 +30,16 @@
:disabled="thumbnails"
/>
</div>
<div v-if="hasWorkerRuns" class="control">
<button
title="Remove all worker runs from this process"
class="button"
v-on:click="clearProcess"
>
<i class="icon-trash mr-2"></i>
Clear process
</button>
</div>
</div>
<p v-if="fieldErrors.model_version" class="notification is-danger">{{ fieldErrors.model_version }}</p>
<WorkerRunWithParents
......@@ -319,6 +329,19 @@ export default {
} finally {
this.processStarting = false
}
},
async clearProcess () {
if (!this.hasWorkerRuns) return
if (this.processStarting) return
this.processLoading = true
try {
await this.$store.dispatch('process/clearProcess', { dataImportId: this.id })
} catch (e) {
this.notify({ type: 'error', text: errorParser(e) })
} finally {
this.processLoading = false
}
}
},
watch: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment