Skip to content

Commit

Permalink
Merge pull request #185 from abes-esr/ITEM-331-BOUTON-STOP-TRAITEMENT
Browse files Browse the repository at this point in the history
Item 331 bouton stop traitement
  • Loading branch information
EryneKL authored Dec 5, 2024
2 parents 659541b + 96ed613 commit caa287e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/components/MenuDownloadFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const isEnrichiAvailable = computed(() =>
(idEtatCurrentDemande.value >= 4 && props.demande.type === 'MODIF') ||
(idEtatCurrentDemande.value >= 5 && props.demande.type === 'SUPP')
)
const isResultatAvailable = computed(() => idEtatCurrentDemande.value >= 7 && idEtatCurrentDemande.value !== 8)
const isSauvegardeAvailable = computed(() => idEtatCurrentDemande.value >= 7)
const isResultatAvailable = computed(() => idEtatCurrentDemande.value >= 7 && idEtatCurrentDemande.value !== 8 && props.demande.pourcentageProgressionTraitement > 0)
const isSauvegardeAvailable = computed(() => idEtatCurrentDemande.value >= 7 && props.demande.pourcentageProgressionTraitement > 0)
onMounted(() => {
itemService.getEtatsDemande()
Expand Down
25 changes: 25 additions & 0 deletions src/components/Supp/BtnStop.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<v-btn icon="mdi-stop" variant="plain" @click="click">
</v-btn>
<dialog-confirmation-stop v-model="dialog" :id="id" @stop="emits('stop')">
</dialog-confirmation-stop>
</template>
<script setup>
import DialogConfirmationStop from "@/components/Supp/DialogConfirmationStop.vue";
import {ref} from "vue";
const emits = defineEmits(['stop'])
const props = defineProps({
id:{
required:true,
type:Number
}
})
const dialog = ref(false);
function click() {
dialog.value = true
}
</script>
33 changes: 33 additions & 0 deletions src/components/Supp/DialogConfirmationStop.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<template>
<v-dialog v-model="dialog" width="500">
<v-card>
<v-card-title>Confirmation</v-card-title>
<v-card-text>
Voulez vous vraiment stopper le traitement sur la demande N°{{id}} ?
</v-card-text>
<v-card-actions>
<v-btn @click="dialog=false">Refuser</v-btn>
<v-btn @click="stopDemande">Confirmer</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup>
import itemService from "@/service/ItemService";
const emits = defineEmits(['stop'])
const dialog = defineModel();
const props = defineProps({
id:{
required:true,
type:Number
}
})
function stopDemande(){
itemService.stopDemande(props.id).finally(() => {
dialog.value = false;
emits('stop');
});
}
</script>
7 changes: 5 additions & 2 deletions src/plugins/vuetify.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const itemLightTheme = {
disabled: '#808080',
archived: '#795548',
saisised: '#333333',
waited: '#EC6839'
waited: '#FFC400',
stopped: '#EC6839'
},
variables: {
'border-color': '#000000',
Expand Down Expand Up @@ -86,7 +87,8 @@ const itemDarkTheme = {
disabled: '#808080',
archived: '#795548',
saisised: '#333333',
waited: '#EC6839'
waited: '#FFC400',
stopped: '#EC6839'
},
variables: {
'border-color': '#FFFFFF',
Expand Down Expand Up @@ -129,6 +131,7 @@ const itemRngTheme = {
archived: generateRandomHexColor(),
saisised: generateRandomHexColor(),
waited: generateRandomHexColor(),
stopped: generateRandomHexColor()
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/service/ItemService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class ItemService {
}

login(login, password) {
const url = import.meta.env.VITE_API_URL + `signin`;
//console.info('appel:' + url);

return this.client.post(`signin`, {username: login, password: password})
Expand Down Expand Up @@ -167,6 +166,10 @@ export class ItemService {
return response.data
})
}

stopDemande(id) {
return this.client.patch('stopDemandeSupp/' + id);
}
}

export default new ItemService()
26 changes: 17 additions & 9 deletions src/views/Suppression/SuppTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<v-chip color="success" variant="flat" v-else-if="item.etatDemande === 'Terminé'">Terminé</v-chip>
<v-chip color="archived" variant="flat" v-else-if="item.etatDemande === 'Archivé'">Archivé</v-chip>
<v-chip color="error" variant="flat" v-else-if="item.etatDemande === 'En erreur'">En erreur</v-chip>
<v-chip color="stopped" variant="flat" v-else-if="item.etatDemande === 'Interrompue'">Interrompue</v-chip>
<v-chip color="info" variant="flat" v-else>{{ item.etatDemande }}</v-chip>
<!-- Cas : ne correspont à aucun cas -->
</td>
Expand All @@ -106,6 +107,7 @@
</td>
<td class="text-center">
<!-- Colonne Action -->
<btn-stop v-if="canStop(item)" :id="item.id" @stop="loadItems('SUPP', isArchiveDemandesDisplayed)"></btn-stop>
<v-btn v-if="canArchive(item)" variant="plain" icon="mdi-archive" @click="archiverDemande(item)"></v-btn>
<v-btn v-else-if="canCancel(item)" variant="plain" icon="mdi-delete" @click="supprimerDemande(item)"></v-btn>
</td>
Expand All @@ -125,6 +127,7 @@ import DialogCommentaire from '@/components/Dialog/DialogCommentaire.vue';
import MenuDownloadFile from '@/components/MenuDownloadFile.vue';
import moment from 'moment/moment';
import {useAuthStore} from "@/store/authStore";
import BtnStop from "@/components/Supp/BtnStop.vue";
//Emit
const emit = defineEmits(['backendError', 'backendSuccess']);
Expand Down Expand Up @@ -230,7 +233,8 @@ const listStatut = [
'En attente',
'En cours de traitement',
'Terminé',
'En erreur'
'En erreur',
'Interrompue'
];
const listTypeTraitement = ref([]);
const contentsDemandesFromServer = ref([]);
Expand Down Expand Up @@ -345,11 +349,15 @@ function isAvailableFile(demandeNumber, filename) {
//Action d'archivage ou suppression selon état de la demande dans le TDB
function canArchive(item) {
return item.etatDemande === 'Terminé';
return item.etatDemande === 'Terminé' || item.etatDemande === 'Interrompue';
}
function canCancel(item) {
return item.etatDemande !== 'Terminé' && item.etatDemande !== 'En cours de traitement' && item.etatDemande !== 'En attente';
return item.etatDemande !== 'Terminé' && item.etatDemande !== 'En cours de traitement' && item.etatDemande !== 'En attente' && item.etatDemande !== 'Interrompue';
}
function canStop(item) {
return item.etatDemande === 'En cours de traitement' || item.etatDemande === 'En attente'
}
//Suppression d'une demande
Expand Down Expand Up @@ -389,12 +397,12 @@ function throwError(error) {
}
function colorProgressBar(item) {
if (item.pourcentageProgressionTraitement === 100) {
if (item.etatDemande === 'Terminé') {
return 'success';
} else if (item.etatDemande === 'En erreur') {
return 'error';
}
if (item.etatDemande === 'Terminé') {
return 'success';
} else if (item.etatDemande === 'En erreur') {
return 'error';
} else if (item.etatDemande === 'Interrompue') {
return 'stopped';
}
return 'grey-lighten-1';
}
Expand Down

0 comments on commit caa287e

Please sign in to comment.