/**
* global variable
*/
var XcatmonTableId="XcatMonsettingTable";
var dataTables=new Object();
/**
* set datatable
*/
function setDatatable(id,obj){
dataTables[id]=obj;
}
/**
* get datatable from the given id
*/
function getDatatable(id){
return dataTables[id];
}
/**
* load xCAT monitor
*/
function loadXcatMon(){
//find the xcat mon tab
var xcatMonTab = $('#xcatmon');
xcatMonTab.append("
");
//show the content of the table monsetting
$.ajax({
url:'lib/cmd.php',
dataType: 'json',
data:{
cmd : 'tabdump',
tgt :'',
args : 'monsetting',
msg : ''
},
success: loadXcatMonSetting
});
}
function loadXcatMonSetting(data){
var apps; //contain the xcatmon apps config
var rsp=data.rsp;
var apps_flag=0; //is the apps is stored?
var ping; //contain the xcatmon ping-interval setting
var ping_flag=0;
//create a infoBar
var infoBar=createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are finished configuring the xCAT monitor, click on Apply.');
$('#xcatmonTable').append(infoBar);
//create xcatmonTable
var XcatmonTable= new DataTable(XcatmonTableId);
//create Datatable
var dTable;
//create the xcatmonTable header
var header=rsp[0].split(",");
header.splice(3,2);
header.splice(0,1);
header[0]="apps name";
header[1]="configure";
header.push('');
header.unshift('');
XcatmonTable.init(header); //create the table header
//create container of original table contents
var origCont= new Array();
origCont[0]=header; //table header
//create contariner for new contents use for update the monsetting table
var newCont =new Object();
newCont[0]=rsp[0].split(","); //table header
//create container for other monsetting lines not xcatmon
var otherCont =new Array();
$('#xcatmonTable').append(XcatmonTable.object()); //add table object
var m=1; //the count for origCont
var n=0;
for (var i=1;i');
cols.unshift('');
//add the column tho the table
XcatmonTable.add(cols);
origCont[m++]=cols;
} else{
if (!apps_flag){ //check the apps setting
if (rsp[i].indexOf("apps") > -1){ //check for is apps or not
apps=rsp[i].split(',');
for (var j=0;j -1){
ping=rsp[i].split(',');
//pair the semicolon
for (var j=0;j');
}
}
}
$(":checkbox").tooltip();
/*
$(':checkbox').hover(
function(){
$(this).append($("***"));
},
function(){
$(this).find("span:last").remove();
}
);
*/
//make the table editable
$('#'+XcatmonTableId+' td:not(td:nth-child(1),td:last-child)').editable(
function (value,settings){
var colPos=this.cellIndex;
var rowPos=dTable.fnGetPosition(this.parentNode);
dTable.fnUpdate(value,rowPos,colPos);
return (value);
},{
onblur : 'submit',
type : 'textarea',
placeholder: ' ',
height : '30px'
}
);
//save the datatable
dTable=$('#'+XcatmonTableId).dataTable();
//set the datatable to the global variables datatables
setDatatable(XcatmonTableId,dTable);
//create button bar
var addBar = $('');
$('#xcatmon').append(addBar);
//create the button add row
var addRowBtn=createButton('Add row');
//add the button to the page
addBar.append(addRowBtn);
//create the button apply
var ApplyBtn=createButton('Apply');
//add the apply button to the page
addBar.append(ApplyBtn);
//create the button Cancel
var CancelBtn=createButton('Cancel');
//add the cancel to the page
addBar.append(CancelBtn);
//button click function
//create a empty row
addRowBtn.bind('click', function(event){
//create the container of the new row
var row = new Array();
//add the delete button to the row
row.push('');
//add the xcatmon
//add the contain of the setting
for (var i =0;i');
//get the datatable of the table
var dTable=getDatatable(XcatmonTableId);
//add the new row to the datatable
dTable.fnAddData(row);
//make the datatable editable
$(":checkbox[title]").tooltip();
$('#'+XcatmonTableId+' td:not(td:nth-child(1),td:last-child)').editable(
function(value,settings){
var colPos=this.cellIndex;
var rowPos=dTable.fnGetPosition(this.parentNode);
dTable.fnUpdate(value,rowPos,colPos);
return (value);
},{
onblur : 'submit',
type : 'textarea',
placeholder: ' ',
height : '30px'
}
);
});
/**
* apply button
*
* the Apply button is used to store the contain of the table in the page to
* the monsetting table on the MN.
*/
ApplyBtn.bind('click', function(event){
//get the datatable of the page
var dTable=getDatatable(XcatmonTableId);
//get the rows of the datatable
var dRows=dTable.fnGetNodes();
var count=0;
//create the new container of the apps' value.
var appValue="";
var tableName="monsetting";
var tmp;
var tmp1;
var closeBtn=createButton("close");
//get the contain of the rows
for (var i =0; i< dRows.length;i++){
if (dRows[i]){
//get the columns fo the row
var cols=dRows[i].childNodes;
//create the container of the new column
var vals = new Array();
for (var j=1;j');
} else{
vals_orig.push('');
}
//push the delete button to the row
vals_orig.unshift('');
//add the row to the orignCont
origCont[i+1]=vals_orig;
//tmp1=origCont;
//tmp=newCont;
count=i+1;
//check the checkbox fo everyrow for merging the appName to the apps values
if (cols.item(cols.length-1).firstChild.checked){
//the new value for the apps.get the name fo every app.
appValue=appValue.concat(cols.item(2).firstChild.nodeValue+",");
}
}
}
count++;
//delete the last "," of the apps value
appValue=appValue.substring(0,(appValue.length-1));
apps[2]=appValue;
//newCont add the apps row
newCont[count++]=apps;
//newCont add the ping-interval row
newCont[count++]=ping;
//tmp=otherCont;
//add the other monitor setting of the mosetting
for(var j=0;jsaving the configuration ');
dialogSave.append(createLoader());
addBar.append(dialogSave);
//open the dialog..modal is true
$("#saveDialog").dialog({modal: true});
//hide the cross...
$('.ui-dialog-titlebar-close').hide();
//put the table name and the contain to the tabRestore.php
$.ajax({
type : 'POST',
url : 'lib/tabRestore.php',
dataType : 'json',
data : {
table : tableName,
cont : newCont
},
success : function(data){
//empty the dialog.add the close button
$("#saveDialog").empty().append('
The Configure has saved!
');
$("#saveDialog").append(closeBtn);
}
});
//close button function
closeBtn.bind('click', function(event){
$("#saveDialog").dialog("distroy");
$("#saveDialog").remove();
});
//clear the newCont
newCont=null;
newCont=new Object();
//just for tmp=newCont;
newCont[0]=rsp[0].split(",");
});
/**
* undo button
*/
CancelBtn.bind('click', function(event){
//get the datatable of the page
var dTable=getDatatable(XcatmonTableId);
//clear the datatable
dTable.fnClearTable();
//add the contain of the origCont to the datatable
for (var i=1;i