Amélioration affichage progression du refresh cache
Ajout d'une ligne de texte sous le bouton pour afficher la progression : - "Traitement : 10/50 projets (20%)" pendant le traitement - "50 projets mis à jour avec succès" à la fin - Tooltip aussi mis à jour avec la progression Le bouton affiche "En cours…" et la progression détaillée est en dessous. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
a57b0c203a
commit
4669f03f16
1 changed files with 14 additions and 3 deletions
|
|
@ -10,6 +10,9 @@
|
||||||
:disabled="isProcessing"
|
:disabled="isProcessing"
|
||||||
>{{ text }}</k-button
|
>{{ text }}</k-button
|
||||||
>
|
>
|
||||||
|
<div v-if="progressText" class="k-field-help" style="margin-top: 0.5rem; font-size: 0.875rem;">
|
||||||
|
{{ progressText }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -26,8 +29,12 @@ const text = ref("Rafraîchir");
|
||||||
const icon = ref("refresh");
|
const icon = ref("refresh");
|
||||||
const theme = ref("aqua-icon");
|
const theme = ref("aqua-icon");
|
||||||
const isProcessing = ref(false);
|
const isProcessing = ref(false);
|
||||||
|
const progressText = ref("");
|
||||||
|
|
||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
|
if (progressText.value) {
|
||||||
|
return progressText.value;
|
||||||
|
}
|
||||||
return lastCacheUpdate?.length > 0
|
return lastCacheUpdate?.length > 0
|
||||||
? "Dernière mise à jour : " + lastCacheUpdate
|
? "Dernière mise à jour : " + lastCacheUpdate
|
||||||
: "Mettre à jour le cache front";
|
: "Mettre à jour le cache front";
|
||||||
|
|
@ -52,6 +59,8 @@ async function refreshAllProjects() {
|
||||||
let hasMore = true;
|
let hasMore = true;
|
||||||
let total = 0;
|
let total = 0;
|
||||||
|
|
||||||
|
text.value = "En cours…";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
while (hasMore) {
|
while (hasMore) {
|
||||||
const init = {
|
const init = {
|
||||||
|
|
@ -77,23 +86,25 @@ async function refreshAllProjects() {
|
||||||
|
|
||||||
// Mise à jour de la progression
|
// Mise à jour de la progression
|
||||||
const progress = Math.round((json.processed / json.total) * 100);
|
const progress = Math.round((json.processed / json.total) * 100);
|
||||||
text.value = `${json.processed}/${json.total} (${progress}%)`;
|
progressText.value = `Traitement : ${json.processed}/${json.total} projets (${progress}%)`;
|
||||||
|
|
||||||
console.log(`Batch terminé : ${json.processed}/${json.total} projets`);
|
console.log(`Batch terminé : ${json.processed}/${json.total} projets`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Succès
|
// Succès
|
||||||
text.value = `Terminé (${total})`;
|
text.value = "Terminé";
|
||||||
|
progressText.value = `${total} projets mis à jour avec succès`;
|
||||||
icon.value = "check";
|
icon.value = "check";
|
||||||
theme.value = "green-icon";
|
theme.value = "green-icon";
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
location.href = location.href;
|
location.href = location.href;
|
||||||
}, 1500);
|
}, 2000);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
text.value = "Erreur";
|
text.value = "Erreur";
|
||||||
|
progressText.value = error.message || "Une erreur est survenue";
|
||||||
icon.value = "alert";
|
icon.value = "alert";
|
||||||
theme.value = "red-icon";
|
theme.value = "red-icon";
|
||||||
isProcessing.value = false;
|
isProcessing.value = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue