Run Xtream imports in background to avoid long-held HTTP connections dropping silently
This commit is contained in:
+27
-15
@@ -1557,6 +1557,28 @@
|
||||
var displayPercent = Math.round(percentage * 100)
|
||||
$("#progress-bar").val(displayPercent);
|
||||
$("#progress-text").text(displayPercent + "%");
|
||||
|
||||
if (payload['completed']) {
|
||||
if (payload['id_playlist']) {
|
||||
$('#id_playlist_to_action').val(payload['id_playlist']);
|
||||
}
|
||||
if (payload['error']) {
|
||||
$('#add_playlist_alert').html('<div class="alert alert-danger" role="alert">' + payload['error'] + '</div>');
|
||||
} else {
|
||||
var num_channel = payload['num_channel'] || 0;
|
||||
if (num_channel > 0) {
|
||||
$('#add_playlist_alert').html('<div class="alert alert-success" role="alert">Imported items: ' + String(num_channel) + '</div>');
|
||||
update_list_playlist();
|
||||
$('#modal_add_playlist').modal('hide');
|
||||
} else {
|
||||
$('#add_playlist_alert').html('<div class="alert alert-danger" role="alert">No items returned by Xtream Codes.</div>');
|
||||
}
|
||||
}
|
||||
$("#progress-container").hide();
|
||||
playlistImportInFlight = false;
|
||||
playlistImportProgress = 0;
|
||||
$('#upload-button').prop('disabled', false).text('Save');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2850,22 +2872,12 @@
|
||||
xtream_username: xtreamUsername,
|
||||
xtream_password: xtreamPassword
|
||||
}).done(function(data){
|
||||
if (data.status === 'already_running') {
|
||||
$('#id_playlist_to_action').val(data.id_playlist || $('#id_playlist_to_action').val());
|
||||
$('#add_playlist_alert').html('<div class="alert alert-info" role="alert">' + (data.message || 'Xtream import already running...') + '</div>');
|
||||
playlistImportInFlight = true;
|
||||
$('#upload-button').prop('disabled', true).text('Importing...');
|
||||
return;
|
||||
}
|
||||
var num_channel = data.num_channel || 0;
|
||||
// The import runs in the background on the server; completion is reported
|
||||
// via the progress_analysis socket event, not this HTTP response.
|
||||
$('#id_playlist_to_action').val(data.id_playlist || $('#id_playlist_to_action').val());
|
||||
if (num_channel > 0) {
|
||||
$('#add_playlist_alert').html('<div class="alert alert-success" role="alert">Imported items: ' + String(num_channel) + '</div>');
|
||||
} else {
|
||||
$('#add_playlist_alert').html('<div class="alert alert-danger" role="alert">No items returned by Xtream Codes.</div>');
|
||||
}
|
||||
update_list_playlist();
|
||||
$('#modal_add_playlist').modal('hide');
|
||||
$('#add_playlist_alert').html('<div class="alert alert-info" role="alert">' + (data.message || 'Importing Xtream Codes playlist...') + '</div>');
|
||||
playlistImportInFlight = true;
|
||||
$('#upload-button').prop('disabled', true).text('Importing...');
|
||||
}).fail(function(xhr){
|
||||
var message = 'Xtream import failed.';
|
||||
if (xhr.responseJSON && xhr.responseJSON.error) {
|
||||
|
||||
Reference in New Issue
Block a user