Refactor ChronoTrack API entry management and remove deprecated functions

This commit streamlines the entry management process within the ChronoTrack API by removing deprecated functions related to entry withdrawal and deletion. The admin interface is updated to eliminate unused actions, enhancing clarity and usability. Additionally, comments are refined to improve code readability. These changes aim to simplify the codebase and improve the overall user experience in managing entries.
This commit is contained in:
2026-07-03 12:47:49 -04:00
parent 2370a2b344
commit 57912b60ae
4 changed files with 2 additions and 735 deletions

View File

@ -232,15 +232,6 @@ function fxChronotrackApiAdminRenderPushPanel($intEveId, $blnClosed = false) {
echo '<i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;Actualiser</button> ';
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" disabled>';
echo '<i class="fa fa-user-times" aria-hidden="true"></i>&nbsp;Retirer entries CT (WITHDRAWN)</button> ';
echo '<button type="button" class="btn btn-outline-warning btn-sm" id="ct_api_btn_probe_withdraw" disabled>';
echo '<i class="fa fa-flask" aria-hidden="true"></i>&nbsp;Sonde WITHDRAWN (1 entry)</button>';
echo '<span class="text-muted small d-block mt-1">';
echo 'Remise à zéro pour tests : passe les entries en <code>WITHDRAWN</code> via POST <code>event/{id}/entry</code> ';
echo '(même API que le push — DELETE est refusé par ChronoTrack). MS1 intact ; un push remet <code>CONF</code>.</span>';
echo '</div>';
echo '<div id="ct_api_push_result" class="small mt-2"></div>';
echo '</div></div>';
}
@ -754,8 +745,6 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
var intAlreadyCt = res.already_in_ct || 0;
var intWillCreate = res.will_create || res.to_create || 0;
var intCtTotal = res.ct_total || 0;
var intCtActive = (typeof res.ct_active !== 'undefined') ? res.ct_active : intCtTotal;
var intCtWithdrawn = res.ct_withdrawn || 0;
var html = '<p class="small text-muted mb-2">Avant le prochain push — lecture MS1 + ChronoTrack Live :</p>';
html += '<div class="ct-api-stat-row mb-2">';
@ -764,10 +753,7 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
html += '<div class="ct-api-stat ' + (intBlocked > 0 ? 'text-danger' : 'text-muted') + '">';
html += '<strong>' + intBlocked + '</strong><span class="small">exclus</span></div>';
html += '<div class="ct-api-stat text-info"><strong>' + intAlreadyCt + '</strong><span class="small">déjà sur CT Live</span></div>';
html += '<div class="ct-api-stat text-secondary"><strong>' + intCtActive + '</strong><span class="small">entries CT actives</span></div>';
if (intCtWithdrawn > 0) {
html += '<div class="ct-api-stat text-muted"><strong>' + intCtWithdrawn + '</strong><span class="small">WITHDRAWN</span></div>';
}
html += '<div class="ct-api-stat text-secondary"><strong>' + intCtTotal + '</strong><span class="small">entries CT (total)</span></div>';
html += '</div>';
if (intTransfer > 0) {
@ -794,10 +780,6 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
$sum.html(html);
renderBlockedPanel(res);
$btn.prop('disabled', intTransfer <= 0);
var intCtActiveBtn = (objPushPreview && typeof objPushPreview.ct_active !== 'undefined')
? objPushPreview.ct_active : intCtTotal;
$('#ct_api_btn_ct_wipe').prop('disabled', intCtActiveBtn <= 0);
$('#ct_api_btn_probe_withdraw').prop('disabled', intCtActiveBtn <= 0);
}
function renderPushResult(res, strTitle) {
@ -819,40 +801,6 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
});
strHtml += '</ul>';
}
if (res && res.delete_probe && res.delete_probe.attempts && res.delete_probe.attempts.length) {
strHtml += '<p class="small text-muted mb-1 mt-2">Sonde DELETE (entry '
+ escHtml(String(res.delete_probe.entry_id || '')) + ') :</p>';
strHtml += '<ul class="small mb-0 pl-3">';
$.each(res.delete_probe.attempts, function (_, att) {
var strLine = escHtml(att.label || '') + ' → HTTP ' + escHtml(String(att.http || 0));
if (att.message && att.message !== 'OK') {
strLine += ' — ' + escHtml(att.message);
}
strHtml += '<li>' + strLine + '</li>';
});
strHtml += '</ul>';
}
if (res && typeof res.found_before !== 'undefined') {
strHtml += '<p class="small text-muted mb-0 mt-2">';
if (typeof res.active_before !== 'undefined') {
strHtml += 'Actives avant : <strong>' + escHtml(String(res.active_before)) + '</strong>';
if (typeof res.active_after !== 'undefined' && res.active_after >= 0) {
strHtml += ' · actives après : <strong>' + escHtml(String(res.active_after)) + '</strong>';
}
} else {
strHtml += 'Entries API avant : <strong>' + escHtml(String(res.found_before)) + '</strong>';
if (typeof res.remaining_after !== 'undefined' && res.remaining_after >= 0) {
strHtml += ' · après : <strong>' + escHtml(String(res.remaining_after)) + '</strong>';
}
}
if (res.wipe_method) {
strHtml += ' · méthode : ' + escHtml(String(res.wipe_method));
}
if (res.ct_event_id) {
strHtml += ' · event CT #' + escHtml(String(res.ct_event_id));
}
strHtml += '</p>';
}
$res.html(strHtml);
}
@ -907,75 +855,6 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
});
});
$('#ct_api_btn_probe_withdraw').on('click', function () {
if (!window.confirm('Tester POST WITHDRAWN sur la première entry active ?\n\nSi ça réussit, cette entry sera retirée (statut WITHDRAWN).')) {
return;
}
var $btn = $(this);
var $res = $('#ct_api_push_result');
$btn.prop('disabled', true);
$res.html(waitHtml('Sonde WITHDRAWN (1 entry)…'));
$.post(strAjaxUrl, { a: 'sync_probe_withdraw', eve_id: intEveId }, function (res) {
if (rejectIfSessionLost(res)) {
return;
}
var strClass = (res && (res.state === 'ok' || res.state === 'warning')) ? 'text-success' : 'text-danger';
if (res && res.state === 'warning') {
strClass = 'text-warning';
}
var strHtml = '<div class="' + strClass + '"><strong>Sonde WITHDRAWN</strong> — '
+ escHtml((res && res.message) ? res.message : 'Erreur') + '</div>';
if (res && res.payload) {
strHtml += '<pre class="small bg-light p-2 mt-2 mb-1" style="max-height:200px;overflow:auto;">'
+ escHtml(JSON.stringify(res.payload, null, 2)) + '</pre>';
}
if (res && res.status_before) {
strHtml += '<p class="small text-muted mb-0">Statut : '
+ escHtml(res.status_before) + ' → ' + escHtml(res.status_after || '?') + '</p>';
}
if (res && res.response_body) {
strHtml += '<pre class="small bg-light p-2 mb-0" style="max-height:200px;overflow:auto;">'
+ escHtml(res.response_body) + '</pre>';
}
$res.html(strHtml);
if (res && res.state === 'ok') {
loadPushPreview();
}
}, 'json').fail(function () {
$res.html('<div class="text-danger">Erreur réseau (sonde WITHDRAWN).</div>');
}).always(function () {
$btn.prop('disabled', false);
});
});
$('#ct_api_btn_ct_wipe').on('click', function () {
var intCtId = (objPushPreview && objPushPreview.ct_event_id) ? objPushPreview.ct_event_id : intLinkedCtEventId;
var intCtActive = (objPushPreview && typeof objPushPreview.ct_active !== 'undefined')
? objPushPreview.ct_active : ((objPushPreview && objPushPreview.ct_total) ? objPushPreview.ct_total : 0);
var strConfirm = 'Retirer via l\'API (POST WITHDRAWN) toutes les entries actives ?\n\n';
strConfirm += 'Event CT ID : ' + intCtId + '\n';
strConfirm += 'Entries actives (CONF, etc.) : ' + intCtActive + '\n\n';
strConfirm += 'MS1 ne sera pas modifié. Un push ultérieur remettra CONF.';
if (!window.confirm(strConfirm)) {
return;
}
var $btn = $(this);
var $res = $('#ct_api_push_result');
$btn.prop('disabled', true);
$res.html(waitHtml('Retrait WITHDRAWN des entries ChronoTrack Live…'));
$.post(strAjaxUrl, { a: 'sync_ct_wipe', eve_id: intEveId }, function (res) {
if (rejectIfSessionLost(res)) {
return;
}
renderPushResult(res, 'Retirer entries CT');
loadPushPreview();
}, 'json').fail(function () {
$res.html('<div class="text-danger">Erreur réseau (vider CT).</div>');
}).always(function () {
$btn.prop('disabled', false);
});
});
$('#ct_api_btn_push').on('click', function () {
if (!window.confirm('Envoyer les participants éligibles vers ChronoTrack ?\n\nMS1 ne sera pas modifié.')) {
return;