mirror of
https://github.com/janeczku/calibre-web
synced 2025-10-20 18:17:40 +00:00
Made long running tasks cancellable. Added cancel button to cancellable tasks in the task list. Added APP_MODE env variable for determining if the app is running in development, test, or production.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* exported TableActions, RestrictionActions, EbookActions, responseHandler */
|
||||
/* exported TableActions, RestrictionActions, EbookActions, TaskActions, responseHandler */
|
||||
/* global getPath, confirmDialog */
|
||||
|
||||
var selections = [];
|
||||
@@ -42,6 +42,24 @@ $(function() {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
$("#cancel_task_confirm").click(function() {
|
||||
//get data-id attribute of the clicked element
|
||||
var taskId = $(this).data("task-id");
|
||||
$.ajax({
|
||||
method: "post",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
url: window.location.pathname + "/../ajax/canceltask",
|
||||
data: JSON.stringify({"task_id": taskId}),
|
||||
});
|
||||
});
|
||||
//triggered when modal is about to be shown
|
||||
$("#cancelTaskModal").on("show.bs.modal", function(e) {
|
||||
//get data-id attribute of the clicked element and store in button
|
||||
var taskId = $(e.relatedTarget).data("task-id");
|
||||
$(e.currentTarget).find("#cancel_task_confirm").data("task-id", taskId);
|
||||
});
|
||||
|
||||
$("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table",
|
||||
function (e, rowsAfter, rowsBefore) {
|
||||
var rows = rowsAfter;
|
||||
@@ -576,6 +594,7 @@ function handle_header_buttons () {
|
||||
$(".header_select").removeAttr("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
/* Function for deleting domain restrictions */
|
||||
function TableActions (value, row) {
|
||||
return [
|
||||
@@ -613,6 +632,19 @@ function UserActions (value, row) {
|
||||
].join("");
|
||||
}
|
||||
|
||||
/* Function for cancelling tasks */
|
||||
function TaskActions (value, row) {
|
||||
var cancellableStats = [0, 1, 2];
|
||||
if (row.id && row.is_cancellable && cancellableStats.includes(row.stat)) {
|
||||
return [
|
||||
"<div class=\"task-cancel\" data-toggle=\"modal\" data-target=\"#cancelTaskModal\" data-task-id=\"" + row.id + "\" title=\"Cancel\">",
|
||||
"<i class=\"glyphicon glyphicon-ban-circle\"></i>",
|
||||
"</div>"
|
||||
].join("");
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Function for keeping checked rows */
|
||||
function responseHandler(res) {
|
||||
$.each(res.rows, function (i, row) {
|
||||
|
Reference in New Issue
Block a user