97 lines
3.0 KiB
JavaScript
97 lines
3.0 KiB
JavaScript
$(function () {
|
|
$('.checkbox-use-subnetmask').iCheck({
|
|
checkboxClass: 'icheckbox_flat-red'
|
|
});
|
|
});
|
|
|
|
var progress = 0;
|
|
var totals = 0;
|
|
|
|
function _search(e) {
|
|
common.modalBlock(true);
|
|
$.ajax({
|
|
url: $(e).attr('data-href'),
|
|
type: 'POST',
|
|
data: {
|
|
SubnetMask: $("input[name='SubnetMask']").val()
|
|
},
|
|
success: function (data) {
|
|
common.modalBlock(false);
|
|
$("#table-device").html(data.form);
|
|
$("#totals").html(data.totals);
|
|
$("#add-button-enabled").removeClass("hidden");
|
|
$("#add-button-disabled").addClass("hidden");
|
|
common.checkboxInit("device");
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
common.modalBlock(false);
|
|
alert("Có lỗi xảy ra! hãy kiểm tra lại service!");
|
|
}
|
|
});
|
|
}
|
|
|
|
function _process(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();
|
|
totals = data.lists.length;
|
|
for (var i = 0; i < totals; i++) {
|
|
_import(data.lists[i]);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
common.modalBlock(false);
|
|
common.ajaxError();
|
|
}
|
|
});
|
|
}
|
|
|
|
function _import(data) {
|
|
$.ajax({
|
|
url: $("input[name='import_url']").val(),
|
|
type: 'POST',
|
|
data: {
|
|
data: data
|
|
},
|
|
success: function (data) {
|
|
var html = "";
|
|
if (data.status) {
|
|
html = "<span class='text-green'><i class='fa fa-check'></i> Thêm thiết bị <b>" + data.IP + "</b> thành công.</span><br>";
|
|
} else {
|
|
html = "<span class='text-red'><i class='fa fa-remove'></i> Thêm thiết bị <b>" + data.IP + "</b> thất bại.</span><br>";
|
|
}
|
|
$("#logs-response").append(html);
|
|
$("#checkbox-" + data.SN).html("");
|
|
$("#status-" + data.SN).find("label").removeClass("hidden");
|
|
progress++;
|
|
var percent = parseInt(progress / totals * 100);
|
|
$("#progress").attr("aria-valuenow", percent);
|
|
$("#progress").attr("style", "width: " + percent + "%");
|
|
$("#progress").html(percent + "%");
|
|
if (percent >= 100) {
|
|
progress = 0;
|
|
$("#close-modal").attr("disabled", false);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
common.ajaxError();
|
|
}
|
|
});
|
|
} |