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">
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-waiting"/>
</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
v-tooltip="{
delay: {
@ -386,38 +401,17 @@
for (let i = 0; i < this.selected.length; i++)
this.selected.splice(i, 1, !this.allOnPageSelected);
},
deleteOneProcess(processId) {
deleteOneProcess(index) {
this.$buefy.modal.open({
parent: this,
component: CustomDialog,
props: {
icon: 'alert',
title: this.$i18n.get('label_warning'),
message: this.$i18n.get('info_warning_Process_delete'),
message: this.$i18n.get('info_warning_process_delete'),
onConfirm: () => {
this.deleteProcess({ processId: processId })
.then(() => {
// 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
// });
});
const processId = this.processes[index].ID;
this.deleteProcess(processId);
}
},
trapFocus: true,

View File

@ -99,7 +99,7 @@ export const cleanProcesses = ({ commit }) => {
export const deleteProcess = ({ commit }, id) => {
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 });
resolve( res );
}).catch((error) => {

View File

@ -18,6 +18,13 @@ export const setProcess = ( state, 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 ) => {
state.log = log;
}
@ -25,4 +32,3 @@ export const setProcessLog = ( state, log ) => {
export const setProcessErrorLog = ( state, 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_waiting' => __( 'Process waiting', '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_max_options_to_show' => __( 'Max options to show', '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_paused' => __( 'Paused', '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_url_copied' => __( 'URL link copied', 'tainacan' ),
'info_other_options' => __( 'Other options: ', 'tainacan'),