get logs from device
This commit is contained in:
@@ -373,3 +373,66 @@ function syncStaffs(data, ip) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var progressLogs = 0;
|
||||
var totalsLogs = 0;
|
||||
function _getLogs(e) {
|
||||
var lists = [];
|
||||
$.each($("input[name='checkbox-device']:checked"), function () {
|
||||
lists.push($(this).val());
|
||||
});
|
||||
if (lists.length == 0) {
|
||||
alert("Vui lòng lựa chọn đối tượng!");
|
||||
return;
|
||||
}
|
||||
common.modalBlock(true);
|
||||
$.ajax({
|
||||
url: $(e).attr('data-href'),
|
||||
type: 'POST',
|
||||
data: {
|
||||
lists: lists
|
||||
},
|
||||
success: function (data) {
|
||||
common.modalBlock(false);
|
||||
common.modalOpen(data.form, false, data.title);
|
||||
$("#close-modal").attr("disabled", true);
|
||||
$("#modalHeader").find("button").remove();
|
||||
totalsLogs = data.lists.length;
|
||||
for (var i = 0; i < data.lists.length; i++) {
|
||||
syncLogs(data.lists[i]);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.modalBlock(false);
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function syncLogs(data) {
|
||||
$.ajax({
|
||||
url: $("input[name='get_logs_sync_url']").val(),
|
||||
type: 'POST',
|
||||
data: {
|
||||
data: data
|
||||
},
|
||||
success: function (data) {
|
||||
var html = "";
|
||||
html = "<span class='text-green'><i class='fa fa-check'></i> Đồng bộ thành công <b>" + data.totals + "</b> sự kiện từ thiết bị <b>" + data.IP + "</b>.</span><br>";
|
||||
$("#logs-response").append(html);
|
||||
progressLogs++;
|
||||
var percent = parseInt(progressLogs / totalsLogs * 100);
|
||||
$("#progress").attr("aria-valuenow", percent);
|
||||
$("#progress").attr("style", "width: " + percent + "%");
|
||||
$("#progress").html(percent + "%");
|
||||
if (percent >= 100) {
|
||||
progressLogs = 0;
|
||||
$("#close-modal").attr("disabled", false);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
common.ajaxError();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user