Update ChronoTrack API entry wipe functionality and enhance user feedback

This commit modifies the entry wipe functionality in the ChronoTrack API admin interface. The wipe button is now disabled when there are no entries to delete, and the confirmation prompt has been updated to clarify the action's scope. Additionally, the API response for the wipe action now returns a warning state when no entries are found, providing clearer messaging about the visibility of entries. These changes aim to improve user experience and ensure accurate communication regarding entry management.
This commit is contained in:
2026-07-03 12:16:48 -04:00
parent 88f0e8138e
commit 3a0161a0bb
2 changed files with 18 additions and 9 deletions

View File

@ -233,9 +233,12 @@ function fxChronotrackApiAdminRenderPushPanel($intEveId, $blnClosed = false) {
echo '<button type="button" class="btn btn-outline-warning btn-sm" id="ct_api_btn_probe_push">';
echo '<i class="fa fa-flask" aria-hidden="true"></i>&nbsp;Sonde (1 entry)</button>';
echo '<div class="mt-3 pt-2 border-top">';
echo '<button type="button" class="btn btn-outline-danger btn-sm" id="ct_api_btn_ct_wipe">';
echo '<i class="fa fa-trash" aria-hidden="true"></i>&nbsp;Vider ChronoTrack Live</button> ';
echo '<span class="text-muted small">Supprime toutes les entries CT de cet événement (MS1 intact).</span>';
echo '<button type="button" class="btn btn-outline-danger btn-sm" id="ct_api_btn_ct_wipe" disabled>';
echo '<i class="fa fa-trash" aria-hidden="true"></i>&nbsp;Supprimer entries (API)</button> ';
echo '<span class="text-muted small d-block mt-1">';
echo '<code>DELETE /api/entry/{id}</code> — doc CT : une entry à la fois, seulement celles visibles par ';
echo '<code>GET event/{id}/entry</code>. Import manuel CT ou autre événement : pas effaçable ici. ';
echo 'MS1 intact.</span>';
echo '</div>';
echo '<div id="ct_api_push_result" class="small mt-2"></div>';
echo '</div></div>';
@ -751,13 +754,16 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
$sum.html(html);
renderBlockedPanel(res);
$btn.prop('disabled', intTransfer <= 0);
$('#ct_api_btn_ct_wipe').prop('disabled', intCtTotal <= 0);
}
function renderPushResult(res, strTitle) {
var $res = $('#ct_api_push_result');
var strHeading = strTitle || 'Résultat du push';
var strClass = 'text-danger';
if (res && (res.state === 'ok' || res.state === 'partial')) {
if (res && res.state === 'warning') {
strClass = 'text-warning';
} else if (res && (res.state === 'ok' || res.state === 'partial')) {
strClass = res.state === 'ok' ? 'text-success' : 'text-warning';
}
var strHtml = '<div class="' + strClass + '"><strong>' + escHtml(strHeading) + '</strong> — '
@ -832,10 +838,11 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
$('#ct_api_btn_ct_wipe').on('click', function () {
var intCtId = (objPushPreview && objPushPreview.ct_event_id) ? objPushPreview.ct_event_id : intLinkedCtEventId;
var intCtTotal = (objPushPreview && objPushPreview.ct_total) ? objPushPreview.ct_total : 0;
var strConfirm = 'SUPPRIMER toutes les inscriptions ChronoTrack Live de cet événement ?\n\n';
var strConfirm = 'Supprimer via l\'API ChronoTrack toutes les entries listées par GET ?\n\n';
strConfirm += 'Event CT ID : ' + intCtId + '\n';
strConfirm += 'Entries actuelles : ' + intCtTotal + '\n\n';
strConfirm += 'Irréversible côté ChronoTrack. MS1 ne sera pas modifié.';
strConfirm += 'Entries visibles par l\'API : ' + intCtTotal + '\n\n';
strConfirm += 'Ne supprime PAS les inscrits visibles seulement dans l\'interface CT (import manuel, autre event).\n';
strConfirm += 'MS1 ne sera pas modifié.';
if (!window.confirm(strConfirm)) {
return;
}

View File

@ -686,9 +686,11 @@ function fxChronotrackApiSyncWipeCtEvent($intEveId) {
if ($intFoundBefore === 0) {
return array(
'state' => 'ok',
'state' => 'warning',
'message' => 'L\'API ne voit aucune entry pour l\'événement CT #' . $intCtEventId
. '. Si des inscrits apparaissent encore dans l\'interface ChronoTrack, vérifiez que c\'est le même événement (ID).',
. '. Rien n\'a été supprimé. Si des inscrits apparaissent dans l\'interface ChronoTrack, '
. 'ils ne sont probablement pas accessibles via GET event/' . $intCtEventId . '/entry '
. '(import manuel, autre événement, ou compte API différent). Effacement manuel dans CT Live requis.',
'ct_event_id' => $intCtEventId,
'found_before' => 0,
'deleted_ok' => 0,