mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
[cancel zip task] fixup & improvement; also added it for 'shared dir view' page
This commit is contained in:
@@ -33,4 +33,4 @@ class CancelZipTaskView(APIView):
|
|||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||||
|
|
||||||
return Response()
|
return Response({'success': True})
|
||||||
|
@@ -207,7 +207,8 @@ $('.shared-dir-zip, .download-dir').on('click', function (e) {
|
|||||||
var cur_download_dir_path;
|
var cur_download_dir_path;
|
||||||
var interval,
|
var interval,
|
||||||
zip_token,
|
zip_token,
|
||||||
queryZipProgress;
|
queryZipProgress,
|
||||||
|
cancelZipTask;
|
||||||
var packagingTip = "{% trans "Packaging..." %}";
|
var packagingTip = "{% trans "Packaging..." %}";
|
||||||
var $tip = $('<p></p>');
|
var $tip = $('<p></p>');
|
||||||
|
|
||||||
@@ -242,13 +243,35 @@ $('.shared-dir-zip, .download-dir').on('click', function (e) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cancelZipTask = function() {
|
||||||
|
$.ajax({
|
||||||
|
url: '{% url 'api-v2.1-cancel-zip-task' %}',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {'token': zip_token},
|
||||||
|
beforeSend: prepareCSRFToken,
|
||||||
|
success: function() {
|
||||||
|
// do nothing
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '{% url 'api-v2.1-share-link-zip-task' %}' + '?share_link_token=' + share_link_token + '&path=' + encodeURIComponent(cur_download_dir_path),
|
url: '{% url 'api-v2.1-share-link-zip-task' %}' + '?share_link_token=' + share_link_token + '&path=' + encodeURIComponent(cur_download_dir_path),
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
zip_token = data['zip_token'];
|
zip_token = data['zip_token'];
|
||||||
$tip.html(packagingTip).modal();
|
$tip.html(packagingTip).modal({
|
||||||
|
onClose: function() {
|
||||||
|
clearInterval(interval); // stop querying the progress
|
||||||
|
cancelZipTask();
|
||||||
|
$.modal.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#simplemodal-container').css({'width':'auto'});
|
$('#simplemodal-container').css({'width':'auto'});
|
||||||
queryZipProgress();
|
queryZipProgress();
|
||||||
interval = setInterval(queryZipProgress, 1000);
|
interval = setInterval(queryZipProgress, 1000);
|
||||||
|
@@ -1058,14 +1058,18 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var cancelZipTask = function(){
|
var cancelZipTask = function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: _this.getUrl({name: 'cancel_zip_task'}) + '?token=' + zip_token,
|
url: _this.getUrl({name: 'cancel_zip_task'}),
|
||||||
success: function(date) {
|
type: 'POST',
|
||||||
clearInterval(interval);
|
dataType: 'json',
|
||||||
|
data: {'token': zip_token},
|
||||||
|
beforeSend: _this.prepareCSRFToken,
|
||||||
|
success: function() {
|
||||||
|
// do nothing
|
||||||
},
|
},
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
_this.ajaxErrorHandler(xhr);
|
// do nothing
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1083,9 +1087,14 @@ define([
|
|||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
zip_token = data['zip_token'];
|
zip_token = data['zip_token'];
|
||||||
$tip.html(packagingTip).modal();
|
$tip.html(packagingTip).modal({
|
||||||
|
onClose: function() {
|
||||||
|
clearInterval(interval); // stop querying the progress
|
||||||
|
cancelZipTask();
|
||||||
|
$.modal.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#simplemodal-container').css({'width':'auto'});
|
$('#simplemodal-container').css({'width':'auto'});
|
||||||
$('.simplemodal-close').click(function(){ cancelZipTask(); });
|
|
||||||
queryZipProgress();
|
queryZipProgress();
|
||||||
interval = setInterval(queryZipProgress, 1000);
|
interval = setInterval(queryZipProgress, 1000);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user