Refactor ChronoTrack API event handling and synchronization logic
This commit updates the ChronoTrack API to improve event handling and synchronization features. Changes include enhanced messaging for closed events, adjustments to the push panel functionality, and refined status handling for event synchronization. The logic for managing event states is streamlined, allowing for clearer user interactions and better management of synchronization processes. These improvements aim to enhance the overall usability and effectiveness of the ChronoTrack API in event management.
This commit is contained in:
@ -65,7 +65,8 @@ function fxChronotrackApiAdminRenderEventPage($intEveId, $strLangue = 'fr', $bln
|
||||
}
|
||||
|
||||
if ($blnClosed) {
|
||||
echo '<div class="alert alert-secondary">Cet événement est <strong>fermé</strong>. Aucune modification ni sync automatique.</div>';
|
||||
echo '<div class="alert alert-secondary">Statut <strong>fermé</strong> : plus de sync auto ni modification du lien/mapping. ';
|
||||
echo 'Le <strong>push manuel</strong> reste disponible ci-dessous.</div>';
|
||||
}
|
||||
|
||||
$blnEventLinked = ($arrConfig !== null && intval($arrConfig['ct_event_id'] ?? 0) > 0);
|
||||
@ -73,7 +74,7 @@ function fxChronotrackApiAdminRenderEventPage($intEveId, $strLangue = 'fr', $bln
|
||||
fxChronotrackApiAdminRenderEventLinkPicker($blnClosed);
|
||||
}
|
||||
|
||||
if ($arrConfig !== null && !$blnClosed) {
|
||||
if ($arrConfig !== null) {
|
||||
fxChronotrackApiAdminRenderStatusActions($intEveId, $strStatus, $blnEventLinked);
|
||||
}
|
||||
|
||||
@ -81,8 +82,8 @@ function fxChronotrackApiAdminRenderEventPage($intEveId, $strLangue = 'fr', $bln
|
||||
fxChronotrackApiAdminRenderRaceMapping($intEveId, $arrConfig, $strLangue, $blnClosed, $blnEventLinked);
|
||||
}
|
||||
|
||||
if ($arrConfig !== null && $blnEventLinked && $blnConfigured && !$blnClosed) {
|
||||
fxChronotrackApiAdminRenderPushPanel($intEveId);
|
||||
if ($arrConfig !== null && $blnEventLinked && $blnConfigured) {
|
||||
fxChronotrackApiAdminRenderPushPanel($intEveId, $blnClosed);
|
||||
}
|
||||
|
||||
if ($blnEventLinked && $blnConfigured) {
|
||||
@ -101,7 +102,7 @@ function fxChronotrackApiAdminRenderEventPage($intEveId, $strLangue = 'fr', $bln
|
||||
function fxChronotrackApiAdminRenderStatusActions($intEveId, $strStatus, $blnEventLinked = true) {
|
||||
$strStep = $blnEventLinked ? '1' : '2';
|
||||
echo '<div class="card mb-4"><div class="card-header">' . $strStep . '. Cycle de vie sync</div><div class="card-body">';
|
||||
echo '<p class="small text-muted">Activer avant la course ; <strong>Terminer</strong> après la course pour bloquer tout envoi vers ChronoTrack.</p>';
|
||||
echo '<p class="small text-muted">Activer avant la course ; <strong>Terminer</strong> après la course pour bloquer la sync auto et les changements de config.</p>';
|
||||
echo '<div class="btn-group" role="group">';
|
||||
if ($strStatus === MSIN_API_CHRONOTRACK_SYNC_LIE) {
|
||||
echo '<button type="button" class="btn btn-warning btn-sm ct-api-set-status" data-status="' . MSIN_API_CHRONOTRACK_SYNC_ACTIF . '">Activer la sync</button>';
|
||||
@ -110,6 +111,10 @@ function fxChronotrackApiAdminRenderStatusActions($intEveId, $strStatus, $blnEve
|
||||
echo '<span class="badge badge-success align-self-center mr-2">Sync active</span>';
|
||||
echo '<button type="button" class="btn btn-danger btn-sm ct-api-set-status" data-status="' . MSIN_API_CHRONOTRACK_SYNC_FERME . '">Terminer / Déconnecter</button>';
|
||||
}
|
||||
if ($strStatus === MSIN_API_CHRONOTRACK_SYNC_FERME) {
|
||||
echo '<span class="badge badge-secondary align-self-center mr-2">Fermé</span>';
|
||||
echo '<button type="button" class="btn btn-outline-primary btn-sm ct-api-set-status" data-status="' . MSIN_API_CHRONOTRACK_SYNC_LIE . '">Rouvrir (Lié)</button>';
|
||||
}
|
||||
echo '</div></div></div>';
|
||||
}
|
||||
|
||||
@ -194,10 +199,13 @@ function fxChronotrackApiAdminRenderRaceMapping($intEveId, $arrConfig, $strLangu
|
||||
echo '</div></div></div>';
|
||||
}
|
||||
|
||||
function fxChronotrackApiAdminRenderPushPanel($intEveId) {
|
||||
function fxChronotrackApiAdminRenderPushPanel($intEveId, $blnClosed = false) {
|
||||
echo '<div class="card mb-4 border-primary" id="ct_api_push_card">';
|
||||
echo '<div class="card-header">3. Synchronisation manuelle (participants)</div>';
|
||||
echo '<div class="card-body">';
|
||||
if ($blnClosed) {
|
||||
echo '<div class="alert alert-warning py-2 small mb-2">Événement fermé — push manuel autorisé pour tests ou rattrapage.</div>';
|
||||
}
|
||||
echo '<p class="small text-muted mb-2">Lit <code>resultats_participants</code> (comme le rapport chrono). ';
|
||||
echo 'External ID = <code>par_id_original</code>. POST vers ChronoTrack — aucune modification MS1.</p>';
|
||||
echo '<div id="ct_api_push_summary" class="mb-2"><span class="text-muted">Chargement…</span></div>';
|
||||
@ -322,9 +330,14 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
|
||||
|
||||
$('.ct-api-set-status').on('click', function () {
|
||||
var strStatus = $(this).data('status');
|
||||
var strConfirm = (strStatus === 'ferme')
|
||||
? 'Terminer la course ? Aucun changement ne sera plus envoyé à ChronoTrack.'
|
||||
: 'Activer la synchronisation automatique pour cet événement ?';
|
||||
var strConfirm;
|
||||
if (strStatus === 'ferme') {
|
||||
strConfirm = 'Terminer la course ? La sync auto et les changements de config seront bloqués (push manuel toujours possible).';
|
||||
} else if (strStatus === 'lie') {
|
||||
strConfirm = 'Rouvrir cet événement ChronoTrack (statut Lié) ?';
|
||||
} else {
|
||||
strConfirm = 'Activer la synchronisation automatique pour cet événement ?';
|
||||
}
|
||||
if (!window.confirm(strConfirm)) {
|
||||
return;
|
||||
}
|
||||
@ -584,7 +597,7 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
|
||||
|
||||
function loadPushPreview() {
|
||||
var $sum = $('#ct_api_push_summary');
|
||||
if (!$sum.length || blnClosed) {
|
||||
if (!$sum.length) {
|
||||
return;
|
||||
}
|
||||
$sum.html('<span class="text-muted">Calcul du diff MS1 ↔ ChronoTrack…</span>');
|
||||
@ -595,7 +608,7 @@ function fxChronotrackApiAdminRenderPageScript($intEveId, $arrConfig, $blnClosed
|
||||
});
|
||||
}
|
||||
|
||||
if ($('#ct_api_push_card').length && !blnClosed) {
|
||||
if ($('#ct_api_push_card').length) {
|
||||
loadPushPreview();
|
||||
|
||||
$('#ct_api_btn_push_refresh').on('click', function () {
|
||||
|
||||
Reference in New Issue
Block a user