đồng bộ dữ liệu giữa các thiết bị

This commit is contained in:
2020-12-10 16:36:24 +07:00
parent fbc48fca53
commit 94215e4e80
6 changed files with 100 additions and 58 deletions

View File

@@ -332,7 +332,9 @@ function checkAllSync(stt) {
}
}
function _sync(e) {
var progress = 0;
var totals = 0;
function _sync() {
var lists = [];
$.each($("#sync-lists").find(".success"), function () {
lists.push($(this).attr("data-id"));
@@ -342,16 +344,34 @@ function _sync(e) {
return;
}
common.modalBlock(true);
$("#progress-totals").html(lists.length);
$("#progress-form").removeClass("hidden");
totals = lists.length;
for (var i = 0; i < lists.length; i++) {
syncFeatureFromDevice(lists[i]);
}
}
function syncFeatureFromDevice(id) {
$.ajax({
url: $(e).attr("data-href"),
url: $("input[name='sync_feature_from_device_url']").val(),
type: 'POST',
data: {
lists: lists
id: id,
ip: $("input[name='SyncIP']").val()
},
success: function (data) {
common.modalBlock(false);
alert("Đồng bộ dữ liệu thành công!");
window.location.reload(true);
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) {
common.modalBlock(false);
@@ -375,9 +395,8 @@ function _syncFromServerForm(e) {
}
});
}
var progress = 0;
var totals = 0;
function _syncFromServer(e) {
function _syncFromServer() {
var lists = [];
$.each($("#sync-lists").find(".success"), function () {
lists.push($(this).attr("data-id"));
@@ -403,7 +422,6 @@ function syncFeature(id) {
id: id
},
success: function (data) {
console.log(data);
progress++;
$("#progress-current").html(parseInt($("#progress-current").html()) + 1);
var percent = parseInt(progress / totals * 100);