{% extends "layout2.html" %}
{% load i18n %}
{% load static %}
{% block css_include %}
{% endblock %}
{% block js_include %}
{% endblock %}
{% block content %}
{% translate "Nodes" %}
';
break;
case "DOWN":
result += '
';
break;
case "MAINTENANCE":
result += '
';
break;
}
result += data+':'+row.state+'';
return result;
}
},
{
sTitle: '{% translate "Network Interfaces" %}',
name: "addresses", aTargets: [2],
defaultContent: "",
mData: "addresses",
mRender: function(data, type, row){
return data.join('
')
}
},
{
sTitle: '{% translate "MongoDB" %}',
name: "name", aTargets: [3],
defaultContent: "",
mData: "name",
mRender: function(data, type, row) {
buffer = '';
if (row.mongo_state === "PRIMARY") {
buffer = buffer + ' ';
}
else if (row.mongo_state === "SECONDARY") {
buffer = buffer + '';
}
else if (row.addresses) {
buffer = buffer + '';
}
else {
buffer = 'Not configured';
}
if (!row.is_master_mongo && !row.is_standalone) {
buffer = buffer + ' ';
}
else if (!row.is_master_mongo && row.is_standalone && row.addresses) {
buffer = buffer + ' ';
}
return buffer;
}
},
{
sTitle: '{% translate "Redis" %}',
name: "name", aTargets: [4],
defaultContent: "",
mData: "name",
mRender: function(data, type, row) {
buffer = '';
if (row.is_master_redis === true) {
buffer = buffer + '';
}
else if (row.is_master_redis === false) {
buffer = buffer + '';
}
else if (row.addresses) {
buffer = buffer + '';
}
else {
buffer = 'Not configured';
}
return buffer;
}
},
{
sTitle: '{% translate "Action" %}',
mData:"id",
aTargets: [5],
defaultContent: "",
mRender: function(data, type, row) {
result = '';
if ( !row.is_master_redis && !row.is_master_mongo) {
result += ' ';
}
return result;
}
}
];
var columns = [];
for (var i in aoColumns){
var col = aoColumns[i].mData;
columns.push(col);
}
var cluster_table = $("#node_list").dataTable({
bServerSide : true,
order : [[1, 'desc']],
iDisplayLength: 10,
bProcessing : true,
bSort : true,
sAjaxSource : '',
sServerMethod : 'POST',
aoColumnDefs: aoColumns,
language: language_datatable,
fnServerData : function(sSource, aoData, fnCallback){
aoData.push({
name: 'columns',
value: JSON.stringify(columns)
})
$.ajax({
type : "POST",
url : sSource,
data : aoData,
success: function(data, callback){
if (check_json_error(data))
fnCallback(data);
}
});
},
fnCreatedRow: function(nRow, aData, iDataIndex){
$(nRow).find(".btn-console").on('click', function(e){
e.stopPropagation();
})
/* REPL Step DOWN */
$(nRow).find("#stepdown").on("click", function(e) {
e.stopPropagation();
$('#node_msg').html('{% translate "Please wait ..." %}');
$("#modal_node").modal('show');
var id = aData['id'];
url = "/system/cluster/stepdown/" + id ;
$.ajax({
type : "GET",
url : url,
}).fail( function( jqXHR, textStatus ) {
$('#node_msg').html("{% translate 'Failure: '%}" + textStatus + "" +
"Status code : " + jqXHR.status + "" +
"Message : " + jqXHR.responseJSON.error);
}).done( function( msg ) {
$('#node_msg').html("{% translate 'Success: '%}
" +
"node " + id + " stepped down" );
});
});
/* REMOVE From Cluster */
$(nRow).find("#remove").on("click", function(e) {
e.stopPropagation();
$('#node_msg').html('{% translate "Please wait ..." %}');
$("#modal_node").modal('show');
var id = aData['id'];
url = "/system/cluster/remove/" + id ;
$.ajax({
type : "GET",
url : url,
}).fail( function( jqXHR, textStatus ) {
$('#node_msg').html("{% translate 'API request failure: '%}" + textStatus + "" +
"Status code : " + jqXHR.status + "" +
"Message : " + jqXHR.statusText);
}).done( function( msg ) {
$('#node_msg').html('
' + msg['message'] + '
') }); }); /* JOIN into Cluster */ $(nRow).find("#join").on("click", function(e) { e.stopPropagation(); $('#node_msg').html('{% translate "Please wait ..." %}'); $("#modal_node").modal('show'); var id = aData['id']; url = "/system/cluster/join/" + id ; $.ajax({ type : "GET", url : url, }).fail( function( jqXHR, textStatus ) { $('#node_msg').html("{% translate 'API request failure: '%}" + textStatus + "" + "Status code : " + jqXHR.status + "" + "Message : " + jqXHR.statusText); }).done( function( msg ) { $('#node_msg').html('' + msg['message'] + '
') }); }); /* Events binding to edit a cluster */ $(nRow).on('click', 'td', function(e) { if (e.target.tagName !== "TD") return; const url = "/system/cluster/edit/" + aData.id /* Open a cluster edition in a new tab with ctrl click */ if (e.ctrlKey || e.metaKey) { window.open(url, '_blank'); } else { window.location.href = url; } }); // /$(nRow).on('click', 'td' /* Open a cluster edition in a new tab with middle click */ $(nRow).on('mousedown', 'td', function(e){ if (e.target.tagName === "TD" && e.button === 1) { window.open("/system/cluster/edit/" + aData.id, '_blank'); } }); // /$(nRow).on('mousedown', 'td' }, // fnCreatedRow: function fnDrawCallback: function(settings){ datatableCanRedraw = true; }, // fnDrawCallback: function }); /* Reload table data every 5 seconds if previous one answered */ setInterval(function(){ if(datatableCanRedraw == true) { datatableCanRedraw = false; cluster_table.fnDraw(false); } }, 5000); {% endblock %}