console.js.status.server.servers_status_overview.js Maven / Gradle / Ivy
The newest version!
$(function() {
authorityControl();
renderServersOverview();
bindButtons();
});
function renderServersOverview() {
var jsonData = {
cache: false,
search: true,
showRefresh: true,
showColumns: true
};
var activated = false;
$.ajax({
url: "/api/registry-center/activated",
async: false,
success: function(data) {
activated = data;
}
});
if (activated) {
jsonData.url = "/api/servers";
}
$("#servers-overview-tbl").bootstrapTable({
columns: jsonData.columns,
url: jsonData.url,
cache: jsonData.cache
}).on("all.bs.table", function() {
doLocale();
});
}
function bindButtons() {
bindServerStatusDetailButton();
bindDisableServerButton();
bindEnableServerButton();
bindShutdownServerButton();
bindRemoveServerButton();
}
function generateOperationButtons(val, row) {
var detailButton = "";
var disableButton = "";
var enableButton = "";
var shutdownButton = "";
var removeButton = "";
if (row.instancesNum == 0) {
return removeButton;
}
var operationTd = "";
if (row.disabledJobsNum > 0) {
operationTd = detailButton + " " + enableButton + " " + shutdownButton;
} else if (row.instancesNum > 0) {
operationTd = detailButton + " " + disableButton + " " + shutdownButton;
}
return operationTd;
}
function bindServerStatusDetailButton() {
$(document).off("click", "button[operation='server-detail'][data-toggle!='modal']");
$(document).on("click", "button[operation='server-detail'][data-toggle!='modal']", function(event) {
var serverIp = $(event.currentTarget).attr("server-ip");
$("#index-server-ip").text(serverIp);
$("#content").load("html/status/server/server_status_detail.html", null, function(){
doLocale();
});
});
}
function bindDisableServerButton() {
$(document).off("click", "button[operation='disable-server'][data-toggle!='modal']");
$(document).on("click", "button[operation='disable-server'][data-toggle!='modal']", function(event) {
var serverIp = $(event.currentTarget).attr("server-ip");
$.ajax({
url: "/api/servers/" + serverIp + "/disable",
type: "POST",
success: function() {
showSuccessDialog();
$("#servers-overview-tbl").bootstrapTable("refresh");
}
});
});
}
function bindEnableServerButton() {
$(document).off("click", "button[operation='enable-server'][data-toggle!='modal']");
$(document).on("click", "button[operation='enable-server'][data-toggle!='modal']", function(event) {
var serverIp = $(event.currentTarget).attr("server-ip");
$.ajax({
url: "/api/servers/" + serverIp + "/disable",
type: "DELETE",
success: function() {
showSuccessDialog();
$("#servers-overview-tbl").bootstrapTable("refresh");
}
});
});
}
function bindShutdownServerButton() {
$(document).off("click", "button[operation='shutdown-server'][data-toggle!='modal']");
$(document).on("click", "button[operation='shutdown-server'][data-toggle!='modal']", function(event) {
showShutdownConfirmModal();
var serverIp = $(event.currentTarget).attr("server-ip");
$(document).off("click", "#confirm-btn");
$(document).on("click", "#confirm-btn", function() {
$.ajax({
url: "/api/servers/" + serverIp + "/shutdown",
type: "POST",
success: function () {
$("#confirm-dialog").modal("hide");
$(".modal-backdrop").remove();
$("body").removeClass("modal-open");
$("#servers-overview-tbl").bootstrapTable("refresh");
}
});
});
});
}
function bindRemoveServerButton() {
$(document).off("click", "button[operation='remove-server'][data-toggle!='modal']");
$(document).on("click", "button[operation='remove-server'][data-toggle!='modal']", function(event) {
showDeleteConfirmModal();
var serverIp = $(event.currentTarget).attr("server-ip");
$(document).off("click", "#confirm-btn");
$(document).on("click", "#confirm-btn", function() {
$.ajax({
url: "/api/servers/" + serverIp,
type: "DELETE",
success: function () {
$("#confirm-dialog").modal("hide");
$(".modal-backdrop").remove();
$("body").removeClass("modal-open");
refreshServerNavTag();
$("#servers-overview-tbl").bootstrapTable("refresh");
}
});
});
});
}