feat(system): ajouter filtre par statut dans la page Logs
All checks were successful
Deploy / deploy (push) Successful in 2m30s
All checks were successful
Deploy / deploy (push) Successful in 2m30s
- Filtre toolbar : Échecs / Terminés / Tous (défaut : Échecs) - Badge statut sur chaque LogItem (vert Terminé / rouge Échec) - deleteAllLogs respecte le filtre actif
This commit is contained in:
parent
8443120c2f
commit
ec4a8be934
@@ -3,6 +3,13 @@ import { ApiJobRepository } from '../../../activity/infrastructure/api/ApiJobRep
|
||||
|
||||
const jobRepository = new ApiJobRepository();
|
||||
|
||||
// Statuts disponibles par filtre
|
||||
const STATUS_MAP = {
|
||||
failed: ['failed'],
|
||||
completed: ['completed'],
|
||||
all: ['failed', 'completed'],
|
||||
};
|
||||
|
||||
export const useLogsStore = defineStore('logs', {
|
||||
state: () => ({
|
||||
logs: [],
|
||||
@@ -16,6 +23,7 @@ export const useLogsStore = defineStore('logs', {
|
||||
hasPreviousPage: false,
|
||||
sortBy: 'createdAt',
|
||||
sortOrder: 'DESC',
|
||||
statusFilter: 'failed', // 'failed' | 'completed' | 'all'
|
||||
}),
|
||||
|
||||
getters: {
|
||||
@@ -34,7 +42,7 @@ export const useLogsStore = defineStore('logs', {
|
||||
limit: this.limit,
|
||||
sortBy: this.sortBy,
|
||||
sortOrder: this.sortOrder,
|
||||
status: ['failed'],
|
||||
status: STATUS_MAP[this.statusFilter],
|
||||
type: 'scraping_job',
|
||||
});
|
||||
|
||||
@@ -65,6 +73,12 @@ export const useLogsStore = defineStore('logs', {
|
||||
await this.loadLogs(1);
|
||||
},
|
||||
|
||||
async setStatusFilter(filter) {
|
||||
this.statusFilter = filter;
|
||||
this.currentPage = 1;
|
||||
await this.loadLogs(1);
|
||||
},
|
||||
|
||||
async deleteLog(id) {
|
||||
try {
|
||||
await jobRepository.deleteJob(id);
|
||||
@@ -81,7 +95,10 @@ export const useLogsStore = defineStore('logs', {
|
||||
this.error = null;
|
||||
|
||||
try {
|
||||
await jobRepository.deleteJobs({ status: 'failed', type: 'scraping_job' });
|
||||
await jobRepository.deleteJobs({
|
||||
status: STATUS_MAP[this.statusFilter].join(','),
|
||||
type: 'scraping_job',
|
||||
});
|
||||
await this.loadLogs(1);
|
||||
} catch (error) {
|
||||
this.error = error.message;
|
||||
|
||||
Reference in New Issue
Block a user