Browse Source

delay icon update

master
Pascal Gloor 5 years ago
parent
commit
29b7a68c32
1 changed files with 28 additions and 20 deletions
  1. 28
    20
      www/js/autodoc.js

+ 28
- 20
www/js/autodoc.js View File

var docid = $('#autodoc_tab_document').data('docid'); var docid = $('#autodoc_tab_document').data('docid');
var pageid = $('.autodoc_document_image').data('pageid'); var pageid = $('.autodoc_document_image').data('pageid');


conf.busy++;
loader_icon_on();
$.ajax({ $.ajax({
type: "PATCH", type: "PATCH",
url: conf.openapi + "/documents/" + docid + "?primarypage=" + pageid, url: conf.openapi + "/documents/" + docid + "?primarypage=" + pageid,
success: function () { success: function () {
conf.busy--;
loader_icon_off();
$('.autodoc_document_btn_primary').removeClass('disabled'); $('.autodoc_document_btn_primary').removeClass('disabled');
} }
}); });
url += tagId; url += tagId;
} }


conf.busy++;
loader_icon_on();
$.ajax({ $.ajax({
type: method, type: method,
url: url + '?' + urlparam, url: url + '?' + urlparam,
success: function () { success: function () {
conf.busy--;
loader_icon_off();
location.reload(); location.reload();
} }
}); });
var tagId = $('.autodoc_tag_id').val(); var tagId = $('.autodoc_tag_id').val();


if (tagId != "") { if (tagId != "") {
conf.busy++;
loader_icon_on();
$.ajax({ $.ajax({
type: "DELETE", type: "DELETE",
url: conf.openapi + "/tags/" + tagId, url: conf.openapi + "/tags/" + tagId,
success: function () { success: function () {
conf.busy--;
loader_icon_off();
location.reload(); location.reload();
} }
}); });


$('.autodoc_document_image').attr('src',''); $('.autodoc_document_image').attr('src','');


conf.busy++;
loader_icon_on();
$.getJSON( $.getJSON(
conf.openapi + "/documents/" + docid, conf.openapi + "/documents/" + docid,
function (doc) { function (doc) {
conf.busy--;
loader_icon_off();
$('span.autodoc_document_name').html(doc.name); $('span.autodoc_document_name').html(doc.name);
$('input.autodoc_document_name').val(doc.name); $('input.autodoc_document_name').val(doc.name);


function page_load_tags() { function page_load_tags() {
// update tag list // update tag list
conf.busy++;
loader_icon_on();
$.getJSON(conf.openapi + "/tags", function (tags) { $.getJSON(conf.openapi + "/tags", function (tags) {
conf.busy--;
loader_icon_off();
$.each(tags, function (n, tag) { $.each(tags, function (n, tag) {
$('.autodoc_tag_list').append( $('.autodoc_tag_list').append(
'<option data="' + tag.color + '" value="' + tag.id + '">' + '<option data="' + tag.color + '" value="' + tag.id + '">' +
.find(".autodoc_template_home_row") .find(".autodoc_template_home_row")
.clone(); .clone();


conf.busy++;
loader_icon_on();
$.getJSON( $.getJSON(
conf.openapi + conf.openapi +
"/documents?pageSize=" + "/documents?pageSize=" +
null, null,
function (data, textStatus, jqXHR) { function (data, textStatus, jqXHR) {
// last document was loaded, stop scrolling // last document was loaded, stop scrolling
conf.busy--;
loader_icon_off();
if (data.length < conf.home.width) { if (data.length < conf.home.width) {
conf.home.end = 1; conf.home.end = 1;
} }
console.log("upload_handler"); console.log("upload_handler");
if (temp.documentid == null) { if (temp.documentid == null) {
console.log("creating documentId"); console.log("creating documentId");
conf.busy++;
loader_icon_on();
$.post(conf.openapi + "/documents", {}, function (data) { $.post(conf.openapi + "/documents", {}, function (data) {
conf.busy--;
loader_icon_off();
temp.documentid = data.id; temp.documentid = data.id;
}); });
stop = 0; stop = 0;


temp.upload[e.data]['progress'] = 50; temp.upload[e.data]['progress'] = 50;


conf.busy++;
loader_icon_on();
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: conf.openapi + "/documents/" + temp.documentid + "/data", url: conf.openapi + "/documents/" + temp.documentid + "/data",
return xhr; return xhr;
}, },
success: function (data, status, xhr) { success: function (data, status, xhr) {
conf.busy--;
loader_icon_off();
temp.upload[this.id].progress = 100; temp.upload[this.id].progress = 100;


} }
} }


function home_modal_open(docid) { function home_modal_open(docid) {
conf.busy++;
loader_icon_on();
$.getJSON(conf.openapi + "/documents/" + docid, function (data) { $.getJSON(conf.openapi + "/documents/" + docid, function (data) {
conf.busy--;
loader_icon_off();
$('#autodoc_home_modal').data('document', data); $('#autodoc_home_modal').data('document', data);
$('#autodoc_home_modal').data('documentid', docid); $('#autodoc_home_modal').data('documentid', docid);


} }


function document_update_name(docid, name) { function document_update_name(docid, name) {
conf.busy++;
loader_icon_on();
$.ajax({ $.ajax({
type: "PATCH", type: "PATCH",
url: conf.openapi + "/documents/" + docid + "?name=" + encodeURIComponent(name), url: conf.openapi + "/documents/" + docid + "?name=" + encodeURIComponent(name),
success: function (data) { success: function (data) {
conf.busy--;
loader_icon_off();
$('span.autodoc_home_modal_name').removeClass('d-none'); $('span.autodoc_home_modal_name').removeClass('d-none');
$('input.autodoc_home_modal_name').addClass('d-none'); $('input.autodoc_home_modal_name').addClass('d-none');
home_modal_open(docid); home_modal_open(docid);
}); });
} }


function loader_icon_on() {
conf.busy++;
}

function load_icon_off() {
setTimeout(function() { conf.busy--; }, 1000);
}

function loader_icon_update() { function loader_icon_update() {
if ( conf.busy > 0 ) { if ( conf.busy > 0 ) {
$('.autodoc_ajax_on').removeClass('d-none'); $('.autodoc_ajax_on').removeClass('d-none');

Loading…
Cancel
Save