1
0
mirror of https://github.com/janeczku/calibre-web synced 2025-10-27 21:37:40 +00:00

Fix confirm dialog database change

Gdrive setup basically working again
Moved basicconfig behind login
Database setup separated from other setup
Config page is using ajax (flask >2 and slow computers)
This commit is contained in:
Ozzie Isaacs
2021-05-26 13:35:35 +02:00
parent dcdb5e2a9e
commit a47d6cd937
16 changed files with 2402 additions and 725 deletions

View File

@@ -141,7 +141,7 @@ function confirmDialog(id, dialogid, dataValue, yesFn, noFn) {
$confirm.modal("hide");
});
$.ajax({
method:"get",
method:"post",
dataType: "json",
url: getPath() + "/ajax/loaddialogtexts/" + id,
success: function success(data) {
@@ -179,18 +179,6 @@ $("#delete_confirm").click(function() {
}
});
$("#books-table").bootstrapTable("refresh");
/*$.ajax({
method:"get",
url: window.location.pathname + "/../../ajax/listbooks",
async: true,
timeout: 900,
success:function(data) {
$("#book-table").bootstrapTable("load", data);
loadSuccess();
}
});*/
}
});
} else {
@@ -218,8 +206,6 @@ $("#deleteModal").on("show.bs.modal", function(e) {
$(e.currentTarget).find("#delete_confirm").data("ajax", $(e.relatedTarget).data("ajax"));
});
$(function() {
var updateTimerID;
var updateText;
@@ -556,6 +542,86 @@ $(function() {
this.closest("form").submit();
});
function handle_response(data) {
if (!jQuery.isEmptyObject(data)) {
data.forEach(function (item) {
$(".navbar").after('<div class="row-fluid text-center" style="margin-top: -20px;">' +
'<div id="flash_' + item.type + '" class="alert alert-' + item.type + '">' + item.message + '</div>' +
'</div>');
});
}
}
$('.collapse').on('shown.bs.collapse', function(){
$(this).parent().find(".glyphicon-plus").removeClass("glyphicon-plus").addClass("glyphicon-minus");
}).on('hidden.bs.collapse', function(){
$(this).parent().find(".glyphicon-minus").removeClass("glyphicon-minus").addClass("glyphicon-plus");
});
function changeDbSettings() {
$("#db_submit").closest('form').submit();
}
$("#db_submit").click(function(e) {
e.preventDefault();
e.stopPropagation();
this.blur();
$.ajax({
method:"post",
dataType: "json",
url: window.location.pathname + "/../../ajax/simulatedbchange",
data: {config_calibre_dir: $("#config_calibre_dir").val()},
success: function success(data) {
if ( data.change ) {
if ( data.valid ) {
confirmDialog(
"db_submit",
"GeneralChangeModal",
0,
changeDbSettings
);
}
else {
$("#InvalidDialog").modal('show');
}
} else {
changeDbSettings();
}
}
});
});
$("#config_submit").click(function(e) {
e.preventDefault();
e.stopPropagation();
this.blur();
window.scrollTo({top: 0, behavior: 'smooth'});
var request_path = "/../../admin/ajaxconfig";
var loader = "/../..";
$("#flash_success").remove();
$("#flash_danger").remove();
$.post(window.location.pathname + request_path, $(this).closest("form").serialize(), function(data) {
$('#config_upload_formats').val(data.config_upload);
if(data.reboot) {
$("#spinning_success").show();
var rebootInterval = setInterval(function(){
$.get({
url:window.location.pathname + "/../../admin/alive",
success: function (d, statusText, xhr) {
if (xhr.status < 400) {
$("#spinning_success").hide();
clearInterval(rebootInterval);
handle_response(data.result);
}
},
});
}, 1000);
} else {
handle_response(data.result);
}
});
});
$("#delete_shelf").click(function() {
confirmDialog(
$(this).attr('id'),
@@ -568,7 +634,6 @@ $(function() {
});
$("#fileModal").on("show.bs.modal", function(e) {
var target = $(e.relatedTarget);
var path = $("#" + target.data("link"))[0].value;
@@ -632,7 +697,6 @@ $(function() {
$(".update-view").click(function(e) {
var view = $(this).data("view");
e.preventDefault();
e.stopPropagation();
$.ajax({