feat: add option to remove a background process of queue while it is not started #538

This commit is contained in:
vnmedeiros 2021-09-10 16:41:14 -03:00
parent 90b8a7e3db
commit de84102e11
4 changed files with 30 additions and 29 deletions

View File

@ -215,6 +215,21 @@
class="icon has-text-gray"> class="icon has-text-gray">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-waiting"/> <i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-waiting"/>
</span> </span>
<span
v-tooltip="{
delay: {
show: 500,
hide: 300,
},
content: $i18n.get('label_delete_process'),
autoHide: false, classes: ['tooltip', 'repository-tooltip'],
placement: 'auto-start'
}"
v-if=" bgProcess.status === 'waiting' "
class="icon has-text-gray"
@click.prevent.stop="deleteOneProcess(index)">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-delete"/>
</span>
<span <span
v-tooltip="{ v-tooltip="{
delay: { delay: {
@ -386,38 +401,17 @@
for (let i = 0; i < this.selected.length; i++) for (let i = 0; i < this.selected.length; i++)
this.selected.splice(i, 1, !this.allOnPageSelected); this.selected.splice(i, 1, !this.allOnPageSelected);
}, },
deleteOneProcess(processId) { deleteOneProcess(index) {
this.$buefy.modal.open({ this.$buefy.modal.open({
parent: this, parent: this,
component: CustomDialog, component: CustomDialog,
props: { props: {
icon: 'alert', icon: 'alert',
title: this.$i18n.get('label_warning'), title: this.$i18n.get('label_warning'),
message: this.$i18n.get('info_warning_Process_delete'), message: this.$i18n.get('info_warning_process_delete'),
onConfirm: () => { onConfirm: () => {
this.deleteProcess({ processId: processId }) const processId = this.processes[index].ID;
.then(() => { this.deleteProcess(processId);
// this.$buefy.toast.open({
// duration: 3000,
// message: this.$i18n.get('info_taxonomy_deleted'),
// position: 'is-bottom',
// type: 'is-secondary',
// queue: true
// });
for (let i = 0; i < this.selected.length; i++) {
if (this.selected[i].id === this.taxonomyId)
this.selected.splice(i, 1);
}
})
.catch(() => {
// this.$buefy.toast.open({
// duration: 3000,
// message: this.$i18n.get('info_error_deleting_taxonomy'),
// position: 'is-bottom',
// type: 'is-danger',
// queue: true
// });
});
} }
}, },
trapFocus: true, trapFocus: true,

View File

@ -99,7 +99,7 @@ export const cleanProcesses = ({ commit }) => {
export const deleteProcess = ({ commit }, id) => { export const deleteProcess = ({ commit }, id) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.tainacan.delete('/bg-process/' + id).then( res => { axios.tainacan.delete('/bg-processes/' + id).then( res => {
commit('deleteProcess', { id: id }); commit('deleteProcess', { id: id });
resolve( res ); resolve( res );
}).catch((error) => { }).catch((error) => {

View File

@ -18,6 +18,13 @@ export const setProcess = ( state, bgProcess ) => {
state.bg_process = bgProcess; state.bg_process = bgProcess;
} }
export const deleteProcess = ( state, bgProcess ) => {
let index = state.bg_processes.findIndex(newProcess => newProcess.ID == bgProcess.id);
if ( index >= 0){
state.bg_processes.splice(index, 1);
}
}
export const setProcessLog = ( state, log ) => { export const setProcessLog = ( state, log ) => {
state.log = log; state.log = log;
} }
@ -25,4 +32,3 @@ export const setProcessLog = ( state, log ) => {
export const setProcessErrorLog = ( state, errorLog ) => { export const setProcessErrorLog = ( state, errorLog ) => {
state.error_log = errorLog; state.error_log = errorLog;
} }

View File

@ -380,7 +380,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'label_process_paused' => __( 'Process paused', 'tainacan' ), 'label_process_paused' => __( 'Process paused', 'tainacan' ),
'label_process_waiting' => __( 'Process waiting', 'tainacan' ), 'label_process_waiting' => __( 'Process waiting', 'tainacan' ),
'label_stop_process' => __( 'Stop process', 'tainacan' ), 'label_stop_process' => __( 'Stop process', 'tainacan' ),
'label_stop_process' => __( 'Stop process', 'tainacan' ), 'label_delete_process' => __( 'Delete process', 'tainacan' ),
'label_process_failed' => __( 'Process failed', 'tainacan' ), 'label_process_failed' => __( 'Process failed', 'tainacan' ),
'label_max_options_to_show' => __( 'Max options to show', 'tainacan' ), 'label_max_options_to_show' => __( 'Max options to show', 'tainacan' ),
'label_unamed_process' => __( 'Unamed process', 'tainacan' ), 'label_unamed_process' => __( 'Unamed process', 'tainacan' ),
@ -834,7 +834,8 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_process_status_cancelled' => __( 'Cancelled', 'tainacan'), 'info_process_status_cancelled' => __( 'Cancelled', 'tainacan'),
'info_process_status_paused' => __( 'Paused', 'tainacan'), 'info_process_status_paused' => __( 'Paused', 'tainacan'),
'info_process_status_running' => __( 'Running', 'tainacan'), 'info_process_status_running' => __( 'Running', 'tainacan'),
'info_warning_process_cancelled' => __( 'Are you sure? This process will be cancelled', 'tainacan' ), 'info_warning_process_delete' => __( 'Are you sure? This process will be deleted.', 'tainacan'),
'info_warning_process_cancelled' => __( 'Are you sure? This process will be cancelled.', 'tainacan' ),
'info_empty' => __( 'empty', 'tainacan' ), 'info_empty' => __( 'empty', 'tainacan' ),
'info_url_copied' => __( 'URL link copied', 'tainacan' ), 'info_url_copied' => __( 'URL link copied', 'tainacan' ),
'info_other_options' => __( 'Other options: ', 'tainacan'), 'info_other_options' => __( 'Other options: ', 'tainacan'),