| Line 173... |
Line 173... |
| 173 |
processData: false,
|
173 |
processData: false,
|
| 174 |
contentType: false,
|
174 |
contentType: false,
|
| 175 |
success: function (response) {
|
175 |
success: function (response) {
|
| 176 |
$btn.prop('disabled', false).text('Upload & Process');
|
176 |
$btn.prop('disabled', false).text('Upload & Process');
|
| 177 |
var data = response.response || response;
|
177 |
var data = response.response || response;
|
| 178 |
var html = '<div class="alert alert-' + (data.errors > 0 ? 'warning' : 'success') + '">';
|
178 |
var hasErrors = (data.errors || 0) > 0 || data.status === false;
|
| - |
|
179 |
var html;
|
| - |
|
180 |
if (!hasErrors) {
|
| - |
|
181 |
// Clean import — zero errors, every row persisted.
|
| - |
|
182 |
html = ''
|
| - |
|
183 |
+ '<div class="alert alert-success" style="font-size:13px;">'
|
| - |
|
184 |
+ '<i class="fa fa-check-circle" style="font-size:18px;margin-right:6px;"></i>'
|
| - |
|
185 |
+ '<strong>' + (data.beatsCreated || 0) + ' beat(s) created successfully.</strong>'
|
| - |
|
186 |
+ '</div>';
|
| 179 |
html += '<strong>Done!</strong> ' + data.beatsCreated + ' beat(s) created.';
|
187 |
alert('✓ ' + (data.beatsCreated || 0) + ' beat(s) created successfully.');
|
| 180 |
if (data.errors > 0) {
|
188 |
} else {
|
| - |
|
189 |
// All-or-nothing failure — nothing persisted, list every issue.
|
| 181 |
html += ' ' + data.errors + ' error(s).';
|
190 |
var errs = data.errorMessages || [];
|
| - |
|
191 |
html = ''
|
| - |
|
192 |
+ '<div class="alert alert-danger" style="font-size:13px;">'
|
| - |
|
193 |
+ '<div style="font-size:14px;font-weight:600;margin-bottom:6px;">'
|
| - |
|
194 |
+ '<i class="fa fa-times-circle" style="margin-right:6px;"></i>'
|
| - |
|
195 |
+ 'No beats were created.'
|
| - |
|
196 |
+ '</div>'
|
| 182 |
html += '<ul style="margin-top:8px;font-size:12px;">';
|
197 |
+ '<div style="margin-bottom:8px;color:#b91c1c;">'
|
| - |
|
198 |
+ (data.message || 'Fix the issues below and re-upload the file.')
|
| - |
|
199 |
+ '</div>'
|
| - |
|
200 |
+ '<div style="font-weight:600;color:#7f1d1d;margin-bottom:4px;">'
|
| - |
|
201 |
+ errs.length + ' issue(s) found:'
|
| - |
|
202 |
+ '</div>'
|
| - |
|
203 |
+ '<ol style="margin:0;padding-left:22px;line-height:1.6;color:#7f1d1d;">';
|
| 183 |
(data.errorMessages || []).forEach(function (msg) {
|
204 |
errs.forEach(function (msg) {
|
| 184 |
html += '<li>' + msg + '</li>';
|
205 |
html += '<li>' + msg + '</li>';
|
| 185 |
});
|
206 |
});
|
| 186 |
html += '</ul>';
|
207 |
html += '</ol></div>';
|
| - |
|
208 |
|
| - |
|
209 |
// Modal alert with the first few issues so the user can't miss it
|
| - |
|
210 |
// even if the result panel is below the fold.
|
| - |
|
211 |
var preview = errs.slice(0, 5).map(function (m, i) {
|
| - |
|
212 |
return (i + 1) + '. ' + m;
|
| - |
|
213 |
}).join('\n');
|
| - |
|
214 |
var more = errs.length > 5 ? '\n\n…and ' + (errs.length - 5) + ' more — see the panel below.' : '';
|
| - |
|
215 |
alert('✗ No beats created.\n\n' + errs.length + ' issue(s) found:\n\n' + preview + more);
|
| 187 |
}
|
216 |
}
|
| 188 |
html += '</div>';
|
- |
|
| 189 |
$('#beat-bulk-result').html(html).show();
|
217 |
$('#beat-bulk-result').html(html).show();
|
| 190 |
},
|
218 |
},
|
| 191 |
error: function (xhr) {
|
219 |
error: function (xhr) {
|
| 192 |
$btn.prop('disabled', false).text('Upload & Process');
|
220 |
$btn.prop('disabled', false).text('Upload & Process');
|
| 193 |
$('#beat-bulk-result').html('<div class="alert alert-danger">Error: ' + (xhr.responseText || xhr.statusText) + '</div>').show();
|
221 |
$('#beat-bulk-result').html('<div class="alert alert-danger">Error: ' + (xhr.responseText || xhr.statusText) + '</div>').show();
|