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

This commit is contained in:
2020-12-09 10:40:35 +07:00
parent f694e9fe71
commit 4cb2f77598
6 changed files with 239 additions and 0 deletions

View File

@@ -303,6 +303,12 @@ common.reset = function (e) {
});
}
};
common.validateIp = function (Ip) {
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(Ip)) {
return true;
}
return false;
}
/**
* =========================
*/

View File

@@ -257,4 +257,80 @@ function _create(e) {
common.ajaxError();
}
});
}
function _syncForm(e) {
var ip = $("input[name='SyncIP']").val();
if (ip === "") {
common.error("ip", "Hãy nhập địa chỉ ip thiết bị muốn đồng bộ");
return;
}
if (!common.validateIp(ip)) {
common.error("ip", "Sai định dạng ip");
return;
}
common.success("ip");
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
data: {
ip: ip
},
success: function (data) {
common.modalBlock(false);
common.modalOpenFullScreen(data.form, data.title);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
alert("Không có kết nối tới thiết bị");
}
});
}
function choooseToSync(e) {
var stt = $(e).attr("data-stt");
if (stt === "false") {
$(e).addClass("success");
$(e).attr("data-stt", "true");
$("#totals-choose").html(parseInt($("#totals-choose").html()) + 1);
} else {
$(e).removeClass("success");
$(e).attr("data-stt", "false");
$("#totals-choose").html(parseInt($("#totals-choose").html()) - 1);
}
}
function checkAllSync(stt) {
if (stt) {
$("#sync-lists").find("tr").addClass("success").attr("data-stt", "true");
$("#totals-choose").html($("#sync-lists").find("tr").length);
} else {
$("#sync-lists").find("tr").removeClass("success").attr("data-stt", "false");
$("#totals-choose").html("0");
}
}
function _sync(e) {
var lists = [];
$.each($("#sync-lists").find(".success"), function () {
lists.push($(this).attr("data-id"));
});
common.modalBlock(true);
$.ajax({
url: $(e).attr("data-href"),
type: 'POST',
data: {
lists: lists
},
success: function (data) {
common.modalBlock(false);
alert("Đồng bộ dữ liệu thành công!");
window.location.reload(true);
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
alert("Mất kết nối tới thiết bị");
}
});
}