đồng bộ dữ liệu từ cloud

This commit is contained in:
2020-12-10 14:46:52 +07:00
parent 75073b956d
commit 7ff0f1b976
4 changed files with 213 additions and 2 deletions

View File

@@ -358,4 +358,78 @@ function _sync(e) {
alert("Mất kết nối tới thiết bị");
}
});
}
function _syncFromServerForm(e) {
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
success: function (data) {
common.modalBlock(false);
common.modalOpenFullScreen(data.form, data.title);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
common.ajaxError();
}
});
}
var progress = 0;
var totals = 0;
function _syncFromServer(e) {
var lists = [];
$.each($("#sync-lists").find(".success"), function () {
lists.push($(this).attr("data-id"));
});
if (lists.length == 0) {
alert("Không có dữ liệu đồng bộ!");
return;
}
common.modalBlock(true);
$("#progress-totals").html(lists.length);
$("#progress-form").removeClass("hidden");
totals = lists.length;
for (var i = 0; i < lists.length; i++) {
syncFeature(lists[i]);
}
}
function syncFeature(id) {
$.ajax({
url: $("input[name='sync_feature_url']").val(),
type: 'POST',
data: {
id: id
},
success: function (data) {
console.log(data);
progress++;
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
var percent = parseInt(progress / totals * 100);
$("#progress").attr("aria-valuenow", percent);
$("#progress").attr("style", "width: " + percent + "%");
$("#progress").html(percent + "%");
if (percent >= 100) {
common.modalBlock(false);
updateFeature();
progress = 0;
}
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}
function updateFeature() {
console.log("abc");
$.ajax({
url: $("input[name='update_feature_url']").val(),
type: 'POST',
success: function (data) {
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
}