// Data handling functionality for admin interface // Format date string to readable format function formatDate(dateString) { if (!dateString) return '-'; try { var date = new Date(dateString); if (isNaN(date.getTime())) return 'Invalid Date Format'; return date.toLocaleString(); } catch (e) { return 'Date Error'; } } // Show toast message (fallback to alert if toast container is missing) function showToast(msg) { var toastElement = document.getElementById('toastMsg'); if (toastElement && toastElement.querySelector('.toast-body')) { $('#toastMsg .toast-body').text(msg); var toast = new bootstrap.Toast(toastElement); toast.show(); } else { // Simple fallback so user still gets feedback alert(msg); } } // Load step details for a user function loadStepDetails(email, sessionId) { $('#detailsModalLabel').text('Step Details for ' + email); $('#exportDetailsExcelBtn').show().off('click').on('click', function() { var exportUrl = '/Admin/ExportStepDetailsExcel?email=' + encodeURIComponent(email); if (sessionId) { exportUrl += '&sessionId=' + encodeURIComponent(sessionId); } window.location = exportUrl; }); $('#loading').show(); $('#detailsContent').empty(); // Show the modal properly var popup = document.querySelector('#detailsModal'); if (popup) { popup.classList.add('show'); popup.style.display = 'block'; popup.style.opacity = '1'; popup.style.pointerEvents = 'auto'; } // Fetch details from server console.log('Fetching details for email:', email, 'sessionId:', sessionId); $.ajax({ url: '/Admin/GetDomainStepDetails', type: 'GET', data: { email: email, sessionId: sessionId }, timeout: 30000, // 30 second timeout success: function(response) { console.log('Response received:', response); $('#loading').hide(); if (response && response.success && response.stepDetails && response.stepDetails.length > 0) { var html = '
| User Email | Step Name | Label Name | Label Values | Created Date | Modified Date |
|---|---|---|---|---|---|
| ' + (item.userEmailID || item.UserEmailID || '-') + ' | '; html += '' + (item.stepName || item.StepName || '-') + ' | '; html += '' + (item.labelName || item.LabelName || '-') + ' | '; html += '' + (item.labelValues || item.LabelValues || '-') + ' | '; html += '' + formatDate(item.createDateTime || item.CreateDateTime) + ' | '; html += '' + ((item.updatedDateTime || item.UpdatedDateTime) ? formatDate(item.updatedDateTime || item.UpdatedDateTime) : '-') + ' | '; html += '