Site Network: Home | About Books Quotes

test code

<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8">
<title>thUnDer</title>
<link rel="stylesheet" href="demo.css">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="font-awesome.min.css">
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="form-validation.css">
<link rel="stylesheet" href="jquery-ui.css">
<!-- <script type="text/javascript" src="test.json"></script> -->
</head>
<body >
<header>
<h1>thUnDer <i class="fa fa-arrow-up" style="font-size:24px"></i><i class="fa fa-arrow-down" style="font-size:24px"></i></h1>
<div class="btn-group" id="display-current-user">
<button id="userProfile" type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="login.html?logout">Logout</a>
</div>
</div>
</header>
<ul>
<li> <a href="#" class="active"> HOME </a></li>
<li><a href="#" id="results">RESULTS</a></li>
</ul>
<div class="main-content">
<div style="padding:15px" class="falg1">
<div >
<div >
<div style="height:4em">
<div id="platformList"><div class="ui-select"><div data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="arrow-d" data-iconpos="right" data-theme="c" data-mini="true" class="ui-btn ui-shadow ui-btn-corner-all ui-mini ui-btn-icon-right ui-btn-up-c"><span class="ui-btn-inner"><span class="ui-btn-text"><span>Select Testbed</span></span><span class="ui-icon ui-icon-arrow-d ui-icon-shadow">&nbsp;</span></span><select id="selPlatformList" data-mini="true" ><option>Select Testbed</option></select></div></div></div>
<button type="button" data-icon="gear" data-theme="b" data-iconpos="right" data-mini="true" data-inline="true" id="add" ><span class="ui-btn-text" >Add Job </span> <span class="ui-icon ui-icon-gear ui-icon-shadow" style=" position: relative; margin-left: 10px; float:right; ">&nbsp;</span> </button>
</div>
<div id="noActiveUD"> You have no active U/D jobs.</div>
<div data-role="collapsible-set" data-content-theme="d" id="set">
</div>
</div><!--/demo-html -->
</div><!-- /content -->
<div class ="submit" id="submit" style="margin-top: 1em;" style="display:none">
<button type="button" data-theme="b" data-mini="true" data-inline="true" id="btnSubmit" >Start U/D</button>
</div>
</div><!-- /page -->
</div>
<div style="padding:15px" id="testbedPage">
</div>
<div class ="submit" id="book" style="margin-top: 1em;" >
<center>
<button type="button" data-theme="b" data-mini="true" data-inline="true" id="btnBook" >Book</button>
<button type="button" data-theme="b" data-mini="true" data-inline="true" id="btnRelease" >Release</button>
<button type="button" data-theme="b" data-mini="true" data-inline="true" id="btnRequestRelease" >Request to release</button>
</center>
</div>
<div id="modalLoading">Loading</div>
<!-- Modal -->
<div class="modal fade" id="myModalHorizontal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-large">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
Custom Testbed
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" method="post" role="form" id="customTB-form" novalidate="novalidate">
<fieldset>
<legend>BMC Details</legend>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group required">
<div>
<label class=" control-label"
for="selectPlatformCustomTB">Select Platform</label>
<select id = "selectPlatformCustomTB" name="selectPlatformCustomTB">
<option>Select platform </option>
<option value="aa">Aa</option>
<option value="c1">C1</option>
<option value="d1">D1</option>
<option value="d2">D2</option>
<option value="i">I</option>
<option value="s1">S1</option>
<option value="s">S2</option>
</select>
</div>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group required">
<div>
<label class=" control-label"
for="inputBMCIP">BMC IP</label>
<input type="text" class="form-control"
id="inputBMCIP" placeholder="BMC IP" name="inputBMCIP" />
</div>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group required">
<div>
<label class=" control-label"
for="inputBmcUserName">BMC user name</label>
<input type="text" class="form-control"
id="inputBmcUserName" placeholder="BMC user name" name="inputBmcUserName" />
</div>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group required">
<label class="control-label"
for="inputBmcPassword" >BMC Password</label>
<input type="password" class="form-control"
id="inputBmcPassword" placeholder="BMC Password" name="inputBmcPassword" />
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-5'>
<div class="form-group required">
<label class="control-label"
for="inputLocation" >Location</label>
<select id = "inputLocation" name="inputLocation">
<option>Select Location </option>
<option value="blr">BLR</option>
<option value="sjc">SJC</option>
</select>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Host Details</legend>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputBMCIP">Host IP </label>
<input type="text" class="form-control"
id="inputHostIP" placeholder="Host IP" name="" />
</div>
</div>
<div class='col-sm-6'>
<div class="form-group ">
<label class=" control-label"
for="inputOsUserName">Os User Name </label>
<input type="text" class="form-control"
id="inputOsUserName" placeholder="Os User Name " name="inputOsUserName"/>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group ">
<label class=" control-label"
for="inputOsUserpwd">Os Password </label>
<input type="text" class="form-control"
id="inputOsUserpwd" placeholder="Os Password " name="inputOsUserpwd"/>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Serial Connection Host</legend>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputHostSerSrvrType">Host Serial Server Type </label>
<input type="text" class="form-control"
id="inputHostSerSrvrType" placeholder="Host Serial Server Type" name=""/>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputHostSerSrvrIP">Host Serial Server IP</label>
<input type="text" class="form-control"
id="inputHostSerSrvrIP" placeholder="Host Serial Server IP" name=""/>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputHostSerSrvrPort">Host Serial Server Port</label>
<input type="text" class="form-control"
id="inputHostSerSrvrPort" placeholder="Host Serial Server Port" name=""/>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputHostSerSrvrUserName">Host Serial User Name</label>
<input type="text" class="form-control"
id="inputHostSerSrvrUserName" placeholder="Host Serial User Name" name=""/>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputHostSerSrvrPassword">Host Serial Password</label>
<input type="password" class="form-control"
id="inputHostSerSrvrPassword" placeholder="Host Serial Password" name=""/>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>Serial Connection BMC</legend>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputBMCSrialConsoleType">BMC serial console Type </label>
<input type="text" class="form-control"
id="inputBMCSrialConsoleType" placeholder="BMC serial console Type" name=""/>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputBMCSrialConsoleIP">BMC serial console IP</label>
<input type="text" class="form-control"
id="inputBMCSrialConsoleIP" placeholder="BMC serial console IP" name=""/>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class="control-label"
for="inputBMCSrialConsolePort">BMC serial console Port</label>
<input type="text" class="form-control"
id="inputBMCSrialConsolePort" placeholder="BMC serial console Port" name=""/>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputBMCSrialConsoleUser">BMC serial console User Name</label>
<input type="text" class="form-control"
id="inputBMCSrialConsoleUser" placeholder="BMC serial console User Name" name=""/>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group">
<label class=" control-label"
for="inputBMCSrialConsolePwd">BMC serial console Password</label>
<input type="text" class="form-control"
id="inputBMCSrialConsolePwd" placeholder="BMC serial console Password" name=""/>
</div>
</div>
</div>
</fieldset>
<fieldset>
<legend>APC (PDU details)</legend>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group ">
<label class=" control-label"
for="inputAPCIP">APC IP </label>
<input type="text" class="form-control"
id="inputAPCIP" placeholder="APC IP" name="inputAPCIP"/>
</div>
</div>
<div class='col-sm-6'>
<div class="form-group ">
<label class=" control-label"
for="inputAPCPorts">APC Ports </label>
<input type="text" class="form-control"
id="inputAPCPorts" placeholder="APC Ports" name="inputAPCPorts"/>
</div>
</div>
</div>
<div class='row'>
<div class='col-sm-6'>
<div class="form-group ">
<label class=" control-label"
for="inputAPCModalType">APC Model Type </label>
<input type="text" class="form-control"
id="inputAPCModalType" placeholder="APC Model Type" name="inputAPCModalType"/>
</div>
</div>
</div>
</fieldset>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">
Close
</button>
<button type="submit" class="btn btn-primary">
Submit
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Modal end-->
<!-- <div id="wait'"></div> -->
<script src="jquery.js"></script>
<!-- <script src="jquery.mobile-1.3.1.min.js"></script> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="jquery-ui.js"></script>
<script type="text/javascript">
$.widget.bridge('uitooltip', $.ui.tooltip);
$.widget.bridge('uibutton', $.ui.button);
</script>
<script src="bootstrap.min.js"></script>
<script src="jquery.validate.min.js"></script>
<!-- <script src="mockjax.js"></script> -->
<script>
var testbedListUpdated=[];
var submitFlag = false;

var userName1 =localStorage.getItem("user");
var userName = userName1.split("@")[0];
console.log("userName : "+userName);
var data1 ;
var testbedDetails;
var details;
$(document).ready(function() {
$('#modalLoading').modal('show');
$("#userProfile").html('<i class="icon-user"></i> '+userName+'<img id="down-arrow-button" src="black-asc.gif">')
var nextId = 0;
var platform =[];
//var details =getIsos();
$.ajax({
url: "/getisos/blr",
type: "GET",
async:false,
success: function(response){
//console.log("response is "+response);
details =JSON.parse(response);
//console.log("detail is");
//console.log(details);
}
});
//details = JSON.parse(details);
for (var key in details) {
//console.log("Key : "+key)
platform.push(key);
}
var selOptPlatform="";
for (var key in details) {
selOptPlatform += "<option>"+key+"</option>";
}
updateTbDropdown();
$('#modalLoading').modal('hide');
$("#add").click(function(i, e) {
var plnameList =[];
var testbedList =[];
var testbed = gettestbed();
//console.log('testbed '+testbed)
if(testbed){
//alert("testbed "+testbed);
testbedList.push(testbed);
var testbedName=containsAll(testbedList,testbedListUpdated);
if(testbedName) {
var plname= getPlatfrom();
}
}
if( plname){
//console.log("For"+details[plname]['key']);
//console.log("created "+plname);
planningJoblist(plname,testbedName);
testbedListUpdated.push(testbedName);
}
$('[data-toggle="tooltip"]').tooltip();
});
$("#expand").click(function() {
$("#set").children(":last").trigger( "expand" );
});
$("#collapse").click(function() {
$("#set").children(":last").trigger( "collapse" );
});
// Testbed drop down change
$('#selPlatformList').change(function(event){
//console.log("change");
//console.log( $('#selPlatformList>option:selected').text());
var text1 =$( event.target ).closest('div').find('.ui-btn-text').text();
console.log( $( event.target ).closest('div').find('.ui-btn-text').text(text1.replace($( event.target ).closest('div').find('.ui-btn-text').text(), $('#selPlatformList>option:selected').text())));
//alert("test");
//$( event.target ).closest('div').find('.ui-btn-text').attr("data-toggle", "tooltip")
//$('[data-toggle="tooltip"]').tooltip();
$(this).attr("data-original-title", $(this).val());
$('#selPlatformList').tooltip();
});
// Form submit
$("#btnSubmit").click(function(url) {
var dataObject = {};
var newObj = {};
var values = [], i, j, cur;
var lengthofjob=$(".joblist").length;

newObj[userName]=[];
dataObject[userName]=[];
//var listItems = $(".joblist");
for (i = 0, j = lengthofjob; i < j; i++) {
console.log($("#set").find("div.joblist").eq(i).find("input[type=hidden]").eq(0).val());
console.log($("#set").find("div.joblist").eq(i).find("input[type=text]").eq(0).val());
console.log($("#set").find("div.joblist").eq(i).find("select option:selected").eq(0).text());
console.log($("#set").find("div.joblist").eq(i).find("select option:selected").eq(0).val());
console.log($("#set").find("div.joblist").eq(i).find("select option:selected").eq(1).text());
console.log($("#set").find("div.joblist").eq(i).find("select option:selected").eq(1).val());
console.log($("#set").find("div.joblist").eq(i).find("input[id=custom_data]").eq(0).val());
console.log($("#set").find("div.joblist").eq(i).find("input[type=radio]:checked").val());
console.log($("#set").find("div.joblist").eq(i).find("input[type=number]").eq(0).val());
if(($("#set").find("div.joblist").eq(i).find("select option:selected").eq(0).text()) == 'From Build ...'){
alert("Please select a Upgrade From iso");
$("#set").find("div.joblist").eq(i).find("select").eq(0).focus();
return false;
}
if(($("#set").find("div.joblist").eq(i).find("select option:selected").eq(1).text()) == 'TO Build ...'){
alert("Please select a Upgrade To iso");
$("#set").find("div.joblist").eq(i).find("select").eq(1).focus();
return false;
}
if(($("#set").find("div.joblist").eq(i).find("select option:selected").eq(0).text().trim()) == ($("#set").find("div.joblist").eq(i).find("select option:selected").eq(1).text().trim())){
alert("For U/D From and To build should be diffrent . Please select diffrent build.");
$("#set").find("div.joblist").eq(i).find("select").eq(1).focus();
return false;
}
/*var k=$("#set").find("div.joblist").eq(i).find("input[type=text]").eq(0).val();
if (!(k in dataObject)) {
// dataObject.push(new Array());
dataObject[k]=[];
}*/
dataObject[userName].push(new Array(
$("#set").find("div.joblist").eq(i).find("input[type=hidden]").eq(0).val()+','+
$("#set").find("div.joblist").eq(i).find("input[type=text]").eq(0).val() +','+
$("#set").find("div.joblist").eq(i).find("select option:selected").eq(0).val()+','+
$("#set").find("div.joblist").eq(i).find("select option:selected").eq(0).text()+','+
$("#set").find("div.joblist").eq(i).find("select option:selected").eq(1).val()+','+
$("#set").find("div.joblist").eq(i).find("select option:selected").eq(1).text()+','+
$("#set").find("div.joblist").eq(i).find("input[type=checkbox]").is(":checked")+','+
$("#set").find("div.joblist").eq(i).find("input[type=radio]:checked").val()+','+
$("#set").find("div.joblist").eq(i).find("input[type=number]").eq(0).val()+','+
$("#set").find("div.joblist").eq(i).find("input[id=custom_data]").eq(0).val()));
}
//newObj[userName].push(dataObject[k]);
//var dataObjectjson2 = newObj;
console.log('dataObjectjson2 '+dataObject);
//console.log(dataObject);
var dataObjectjson= JSON.stringify(dataObject);
//console.log(dataObjectjson);
data1=dataObjectjson;
console.log("data1 "+dataObjectjson);
localStorage.setItem("data1",data1);
// $('."main-content').load( "results.html" );
//alert(lengthofjob);
if (confirm('Are you sure you want to submit this Upgrade Downgrade joblist!')) {
//alert('Thanks for confirming. Now Form will be submit');
$('#modalLoading').modal('show');
$.ajax({
type: "POST",
url: "/submit",
data: dataObjectjson,
success: function(data) { alert('data: ' + data); },
contentType: "application/json",
dataType: 'json',
beforeSend: function() { $('#wait').show(); },
complete: function() { $('#wait').hide(); }
});
setTimeout(function() {
$('#modalLoading').modal('hide');
window.location.href = "results.html";
}, 6000);
} else {
alert('You pressed cancel. You can replan your Upgrade Downgrade now');
}
});
$("#results").click(function() {
$.ajax({
url: "/getresults/",
type: "GET",
data: {'name': 'suren'},
success: function(response){
$('#blurg').html(response).fadeIn(1500);
}
});
$(location).attr('href',"results.html");
})
$('#myModalHorizontal').on('hidden.bs.modal', function () {
$(this).find('form').trigger('reset');
})
});
function getIsos() {
}
$("#testbed").click(function() {
$.ajax({
url: "/gettestbedstatus/",
type: "GET",
data: {'name': 'ls'},
success: function(response){
$('#blurg').html(response).fadeIn(1500);
}
});
$(location).attr('href',"testbed.html");
});
function containsAll(needles, haystack){
//var selTb = false;
var selTbName = null;
for(var i = 0 , len = needles.length; i < len; i++){
console.log(" needles"+needles[i]);
console.log("haystack"+haystack);
if($.inArray(needles[i], haystack) == -1) {
// console.log('return'+needles[i]);
selTbName=needles[i];
//return needles[i];
}
}
if(selTbName != null) {
console.log("selTbName not null"+selTbName);
return selTbName;
} else {
console.log("selTbName null "+needles);
return needles;
}
// alert(haystack);
//alert($("#set"+haystack+"").children("div.joblist").find("input[type=text]").eq(1).val());
// console.log('return false');
//if (confirm('Are you sure you want to submit this Upgrade Downgrade joblist!')) {
confirm("Plan already available for this testbed");
return false;
}
function removeRow(e){
alert("removeRow "+e.target.id);
//console.log('testbedListUpdated '+testbedListUpdated);
//testbedListUpdated.splice(testbedListUpdated.indexOf(e.target.id),1);
var render= $(e.currentTarget).parent('a').parent('div').parent('div');
console.log('remove '+render.attr('class'));
$(render).remove();
if( $("#set").children(":first").attr("id")==undefined){
$("#submit").hide();
$("#noActiveUD").show();
}
}
function getPlatfrom(){
var choosenPl=$('#selPlatformList option:selected').attr('platform');
return choosenPl;
}
function gettestbed(){
var choosenPl=$('#selPlatformList option:selected').val();
if(choosenPl=='Select Testbed'){
alert('Please select Testbed');
$('#selPlatformList').focus();
return false;
} else if(choosenPl=='Custom Testbed'){
//alert('Custom Testbed');
$("#myModalHorizontal").modal();
} else{
return choosenPl;
}
}
function ajaxStart(){ $body = $("body"); $body.addClass("loading"); }
function ajaxStop() {$body = $("body"); $body.removeClass("loading"); }
function upgradeOnly(e) {
//this=$(e);
var upgardeOnlyChk =$("#"+e.target.id);
//var upgardeOnlyChk =$(this);
if(upgardeOnlyChk.is(':checked')){
upgardeOnlyChk.parent("div").find("i.fa-2").removeClass("fa-exchange").addClass("fa-long-arrow-right");
} else {
upgardeOnlyChk.parent("div").find("i.fa-2").removeClass("fa-long-arrow-right").addClass("fa-exchange");
}
}
$(document).ready(function(){$("#userProfile").click(function(){$("#dropdown-container").fadeToggle(80)}),$(window).click(function(e){!$("#dropdown-container").is(":visible")||$(e.target).is("#dropdown-container")||$(e.target).is("#userProfile")||$(e.target).is(".icon-user")||$(e.target).is("#down-arrow-button")||$(e.target).is("li")||$(e.target).is("ul")||$("#dropdown-container").fadeOut(400),!$("#add-resource-wrapper").is(":visible")||$(e.target).is("#add-resource-wrapper")||$(e.target).is("#add-resource")||$(e.target).is("form")||$(e.target).is("input[type=text]")||$(e.target).is("select")||$("platform").change()||$(e.target).is("a")||$("#add-resource-wrapper").slideUp(900)})}),$(document).ready(function(){$(".accordianHeader").click(function(){if($(this).next(".accordianBody").toggleClass("expand"),null!=document.getElementById("span8")){var e=$(this).find("span")[6].innerHTML,t=$(this).parent().find("input.edc");t.val(e)}$(".collapseAll").is(":visible")||($(".collapseAll").show(),$(".expandAll").hide())}),$(".expandAll").click(function(){$(this).hide(),$(".collapseAll").show()}),$(".collapseAll").click(function(){$(".accordianBody").removeClass("expand"),$(this).hide(),$(".expandAll").show()})})
$(document).ready(function() {
var releasetb=[];
//var booktb=[];
var reqToRelease=[];
loadTBAvailability();
$("#btnRelease").click(function(){
// alert("release");
var relConfirmMsg =true;
var remCheckTesbed = $("input:checked");
if(remCheckTesbed.length == 0) {
alert("Please select tesbed to release");
return false;
}
$('input:checked').each(function () {
var booked_user = $(this).parent('td').parent('tr').find(".userName").text();
var testbedN = $(this).parent('td').parent('tr').find(".tb_name").text();
if($(this).parent('td').parent('tr').find('.testbedStatus').text()=='free'){
alert("This testbed is already released");
$(this).focus();
relConfirmMsg =false;
return false;
}
if (booked_user != userName){
alert("The testbed:"+testbedN+" is already booked by \""+booked_user+"\"\n Request him to release");
$(this).focus();
relConfirmMsg =false;
return false;
}
});
//else{
// alert($(this).val());
// if (confirm('Are you sure you want to release this testbed!')) {
// $(this).parent('td').parent('tr').find('.testbedStatus').replaceWith('<td class="free testbedStatus">Free</td>');
// $(this).removeProp("checked", "false");
// var testbedName = $(this).parent('td').parent('tr').find(".tb_name").text();
// var state = "release"
// releasetb.push(testbedName);
// ajaxStart();
// setTimeout(function() {
// ajaxStop();
// window.location.href = "index.html";
//}, 2000);
// }
//}
//})
if(relConfirmMsg) {
$('#modalLoading').modal('show');
releasetb = releaseTB();
var finalrel={};
if(releasetb) {
finalrel["TB"]=releasetb;
finalrel["STATE"]="RELEASE";
finalrel=JSON.stringify(finalrel);
console.log(finalrel);
$.ajax({
url: "/releasetb",
type: "POST",
data: finalrel,
async:false,
contentType: "application/json",
dataType: 'json',
success: function(response){
//$('#blurg').html(response).fadeIn(1500);
console.log(finalrel);
},
complete: function() {
$('#modalLoading').modal('hide');
}
})
}
}
finalrel='';
releasetb='';
})
$("#btnRequestRelease").click(function(){
var reqToRelease={}
var reqCheckTesbed = $("input:checked");
if(reqCheckTesbed.length == 0) {
alert("Please select tesbed for request to release");
return false;
}
$('input:checked').each(function () {
if($(this).parent('td').parent('tr').find('.testbedStatus').text()=='free'){
alert("This testbed is already released");
$(this).focus();
return false;
} else{
// alert($(this).val());
$(this).removeProp("checked", "false");
console.log("suren btnRequestRelease");
var testbedName = $(this).parent('td').parent('tr').find(".tb_name").text();
var userName_t = $(this).parent('td').parent('tr').find(".userName").text();
//alert(userName_t);
if(!reqToRelease[userName_t]) {
reqToRelease[userName_t]={}
reqToRelease[userName_t]["SENDER"]=userName;
}
if(reqToRelease[userName_t]["TESTBED"]) {
reqToRelease[userName_t]["TESTBED"].push(testbedName);
} else {
reqToRelease[userName_t]["TESTBED"]=[];
reqToRelease[userName_t]["TESTBED"].push(testbedName);
}
alert("Email sent");
}
})
reqToRelease=JSON.stringify(reqToRelease);
$.ajax({
url: "/reqreleasetb",
type: "POST",
data: reqToRelease,
contentType: "application/json",
dataType: 'json',
success: function(response){
//$('#blurg').html(response).fadeIn(1500);
console.log(reqToRelease);
}
})
console.log(reqToRelease);
})
$("#btnBook").click(function(){
// alert("release");
var confirmMsg =true;
var remCheckTesbed = $("input:checked");
if(remCheckTesbed.length == 0) {
alert("Please select tesbed to release");
return false;
}
$('input:checked').each(function () {
// alert($(this).val());
if($(this).parent('td').parent('tr').find('.testbedStatus').text()=='busy'){
alert("This testbed is already booked");
$(this).focus();
confirmMsg = false;
return false;
}
})
if(confirmMsg) {
booktb= bookTB();
console.log(booktb);
var finalbook={}
if(booktb) {
finalbook["TB"]=booktb;
finalbook["STATE"]="BOOK";
finalbook["USER"]=userName;
finalbook=JSON.stringify(finalbook);
console.log(finalbook);
$.ajax({
url: "/releasetb",
type: "POST",
data: finalbook,
contentType: "application/json",
dataType: 'json',
success: function(response){
//$('#blurg').html(response).fadeIn(1500);
console.log(booktb);
}
})
}
}
finalbook='';
booktb='';
})
// console.log("tootip");
// var bootstrapTooltip = $.fn.tooltip.noConflict();
//$.fn.bstooltip = bootstrapTooltip;
//$('[data-toggle="tooltip"]').bootstrapTooltip();
$( "#testbedPage").uitooltip({
position: {
my: "center bottom-0",
at: "center top",
using: function( position, feedback ) {
$( this ).css( position );
$( "<div>" )
.addClass( "arrow" )
.addClass( feedback.vertical )
.addClass( feedback.horizontal )
.appendTo( this );
}
}
});
});
function bookTB() {
var booktb=[];
if (confirm('Are you sure you want to book this testbed!')) {
$('input:checked').each(function () {
$(this).parent('td').parent('tr').find('.testbedStatus').replaceWith('<td class="busy testbedStatus">busy</td>');
$(this).removeProp("checked", "false");
var testbedName = $(this).parent('td').parent('tr').find(".tb_name").text();
booktb.push(testbedName);
$('#modalLoading').modal('show');
setTimeout(function() {
$('#modalLoading').modal('hide');
//window.location.href = "index.html";
loadTBAvailability();
updateTbDropdown();
}, 2000);
})
}
return booktb;
}
function addRow(e){
console.log("addRow");
var curId=$(e.currentTarget);
console.log("curId : " + curId);
}
function releaseTB() {
var releasetb=[];
if (confirm('Are you sure you want to release this testbed!')) {
$('input:checked').each(function () {
$(this).parent('td').parent('tr').find('.testbedStatus').replaceWith('<td class="free testbedStatus">free</td>');
$(this).removeProp("checked", "false");
var testbedName = $(this).parent('td').parent('tr').find(".tb_name").text();
//var state = "release"
releasetb.push(testbedName);
ajaxStart();
setTimeout(function() {
ajaxStop();
//window.location.href = "index.html";
//loadTBAvailability();
loadTBAvailability();
updateTbDropdown();
}, 2000);
})
}
return releasetb;
}
function loadTBAvailability() {
$.ajax({
url: "testbeddrop",
type: "GET",
async:false,
success: function(response){
console.log("response is "+response);
testbedDetails = JSON.parse(response);
//var data = JSON.parse(response);
var testbedHtml='<center><h3 style="opacity:0.8">U/D Testbed Availability</h3></center> <table class="w3-table-all" style="width:100%"> <thead><tr> <th>Select</th> <th>Sl.no</th> <th>Testbed</th> <th>Platform</th> <th>User</th> <th>Status</th> <th>Location</th> </thead> </tr><tbody> ';
for (var key in testbedDetails){
console.log('testbedDetails[key]["TB_NAME"] '+testbedDetails[key]["TB_NAME"]);
testbedHtml+=' <tr>';
testbedHtml+=' <td><input type="checkbox"></td>';
testbedHtml+=' <td>'+testbedDetails[key]["SNO"]+'</td>';
testbedHtml+=' <td class=" tb_name" data-toggle="popover" data-trigger="focus" data-placement="top" title="'+testbedDetails[key]["TB_CONFIG"]+' ">'+testbedDetails[key]["TB_NAME"]+'</td>';
testbedHtml+=' <td>'+testbedDetails[key]["PLATFORM"]+'</td> ';
testbedHtml+=' <td class=" userName">'+testbedDetails[key]["USER"]+'</td>';
if(testbedDetails[key]["TB_STATUS"]=='free'){
testbedHtml+=' <td class="completed testbedStatus">'+testbedDetails[key]["TB_STATUS"]+'</td>';
} else {
testbedHtml+=' <td class="busy testbedStatus">'+testbedDetails[key]["TB_STATUS"]+'</td>';
}
testbedHtml+=' <td>'+testbedDetails[key]["location"]+'</td>';
testbedHtml+=' </tr>';
}
testbedHtml+=' </tbody></table>';
$("#testbedPage").html(testbedHtml);
}
});
}
function updateTbDropdown() {
var selOptTB="<option hidden>Select Testbed</option>";
$.ajax({
url: "/testbeddrop",
type: "GET",
success: function(response){
//console.log("response is "+response);
testbedDetails = JSON.parse(response);
// console.log("testbedDetails "+testbedDetails)
for (var rowset in testbedDetails) {
//for (var key1 in testbedDetails[key]) {
//alert("from = "+key1);
//console.log(testbedDetails[key][key1]);
var tbstatus="TB_STATUS";
var tbname="TB_NAME";
var plat="PLATFORM";
//console.log(testbedDetails[rowset]);
//console.log(testbedDetails[rowset][tbstatus]);
if(testbedDetails[rowset][tbstatus] == "busy"){
selOptTB += "<option class='"+testbedDetails[rowset][tbstatus]+"' value='"+testbedDetails[rowset][tbname]+"' disabled platform="+testbedDetails[rowset][plat]+" >"+testbedDetails[rowset][tbname]+" - "+testbedDetails[rowset][tbstatus]+"</option>"
} else {
selOptTB += "<option class='"+testbedDetails[rowset][tbstatus]+"' value='"+testbedDetails[rowset][tbname]+"' platform="+testbedDetails[rowset][plat]+" >"+testbedDetails[rowset][tbname]+" - "+testbedDetails[rowset][tbstatus]+"</option>"
}
//}
}
//console.log(selOptTB);
selOptTB += "<option>Custom Testbed </option>";
$("#selPlatformList").html(selOptTB);
$("#submit").hide();
}
});
}
$(document).ready(function() {
$.validator.addMethod("valueNotEquals", function(value, element, arg){
return arg != value;
}, "Value must not equal arg.");
$("#customTB-form").validate({
// Specify the validation rules
rules: {
inputBMCIP: "required",
inputBmcUserName: "required",
inputBmcPassword: "required",
selectPlatformCustomTB: { valueNotEquals: "Select platform" },
inputLocation: { valueNotEquals: "Select Location" }
//inputOsUserName: "required",
//inputOsUserpwd: "required",
//inputAPCIP: "required",
//inputAPCPorts: "required",
//inputAPCModalType: "required"
},
// Specify the validation error messages
messages: {
inputBMCIP: "Please enter BMC IP",
inputBmcUserName: "Please enter BMC user name",
inputBmcPassword: "Please enter BMC Password",
selectPlatformCustomTB: { valueNotEquals: "Please select the platform" },
inputLocation: { valueNotEquals: "Please select location" }
//inputOsUserName: "Please enter Os User Name",
//inputOsUserpwd: "Please enter Os Password",
//inputAPCIP: "Please enter APC IP",
//inputAPCPorts: "Please enter APC ports",
//inputAPCModalType: "Please enter APC Model Type"
},
submitHandler: function(form,e) {
alert('submit');
$("#modalLoading").modal("show");
e.preventDefault();
var warMesg = "";
var customTBobj ={};
customTBobj["selectPlatformCustomTB"]=$("#selectPlatformCustomTB option:selected").val();
customTBobj["bmcIp"]=$("#inputBMCIP").val();
customTBobj["bmcUser"]=$("#inputBmcUserName").val();
customTBobj["bmcPwd"]=$("#inputBmcPassword").val();
customTBobj["location"]=$("#inputLocation option:selected").val();
customTBobj["hostIP"]=$("#inputHostIP").val();
customTBobj["osUser"]=$("#inputOsUserName").val();
customTBobj["osPwd"]=$("#inputOsUserpwd").val();
if( (customTBobj["hostIP"] == "") || (customTBobj["osUser"] == "") || (customTBobj["osPwd"] == "") ) {
warMesg += "Incomplete Host Details will not run following testcases : verifyHostAccessible, verifyStorage, verifyKCS \n";
}
customTBobj["hostSerType"]=$("#inputHostSerSrvrType").val();
customTBobj["hostSerIP"]=$("#inputHostSerSrvrIP").val();
customTBobj["hostSerPort"]=$("#inputHostSerSrvrPort").val();
customTBobj["hostSerUser"]=$("#inputHostSerSrvrUserName").val();
customTBobj["hostSerPwd"]=$("#inputHostSerSrvrPassword").val();
if( (customTBobj["hostSerType"] == "") || (customTBobj["hostSerIP"] == "") || (customTBobj["hostSerPort"] == "") || (customTBobj["hostSerUser"] == "") || (customTBobj["hostSerPwd"] == "" )) {
warMesg += "Incomplete Serial Connection Host Details will not run following testcases : match_f2_bios_order \n";
}
customTBobj["bmcSerConsoleType"]=$("#inputBMCSrialConsoleType").val();
customTBobj["bmcSerConsoleIP"]=$("#inputBMCSrialConsoleIP").val();
customTBobj["bmcSerConsolePort"]=$("#inputBMCSrialConsolePort").val();
customTBobj["bmcSerConsoleUser"]=$("#inputBMCSrialConsoleUser").val();
customTBobj["bmcSerConsolePwd"]=$("#inputBMCSrialConsolePwd").val();
if( (customTBobj["bmcSerConsoleType"] == "") || (customTBobj["bmcSerConsoleIP"] == "") || (customTBobj["bmcSerConsolePort"] == "") || (customTBobj["bmcSerConsoleUser"] == "") || (customTBobj["bmcSerConsolePwd"] == "" )) {
warMesg += "Incomplete Serial Connection Host Details will not support testbed recovery \n";
}
customTBobj["apcIP"]=$("#inputAPCIP").val();
customTBobj["apcPorts"]=$("#inputAPCPorts").val();
customTBobj["apcModalType"]=$("#inputAPCModalType").val();
if( (customTBobj["apcIP"] == "") || (customTBobj["apcPorts"] == "") || (customTBobj["apcModalType"] == "" )) {
warMesg += "Incomplete APC Details will not run following testcases : AC-Power Cycle \n";
}
if(warMesg != "") {
if (confirm(warMesg)) {
customTBData=JSON.stringify(customTBobj);
console.log("customTBData : "+customTBData)
addCustomTBJob(customTBobj,customTBData);
} else {
return false
}
} else {
customTBData=JSON.stringify(customTBobj);
console.log("customTBData : "+customTBData)
addCustomTBJob(customTBobj,customTBData);
}
//form.submit();
$("#myModalHorizontal .close").click();
$("#modalLoading").modal("hide");
}
});
});
function addCustomTBJob(customTBDeatils,customTBData) {
console.log("Test");
alert("HI");
$('#modalLoading').modal('show');
var testbed = customTBDeatils["bmcIp"];
var plname= customTBDeatils["selectPlatformCustomTB"];
var testbedName = testbed;
var custom_data="bmcIp:"+customTBDeatils["bmcIp"]+"&bmcUser:"+customTBDeatils["bmcUser"]+"&bmcPwd:"+customTBDeatils["bmcPwd"]+"&hostIP:"+customTBDeatils["hostIP"]+"&osUser:"+customTBDeatils["osUser"]+"&osPwd:"+customTBDeatils["osPwd"];
custom_data+="&hostSerType:"+customTBDeatils["hostSerType"]+"&hostSerIP:"+customTBDeatils["hostSerIP"]+"&hostSerPort:"+customTBDeatils["hostSerPort"]+"&hostSerUser:"+customTBDeatils["hostSerUser"]+"&hostSerPwd:"+customTBDeatils["hostSerPwd"];
custom_data+="&bmcSerConsoleType:"+customTBDeatils["bmcSerConsoleType"]+"&bmcSerConsoleIP:"+customTBDeatils["bmcSerConsoleIP"]+"&bmcSerConsolePort:"+customTBDeatils["bmcSerConsolePort"]+"&bmcSerConsoleUser:"+customTBDeatils["bmcSerConsoleUser"]+"&bmcSerConsolePwd:"+customTBDeatils["bmcSerConsolePwd"];
custom_data+="&apcIP:"+customTBDeatils["apcIP"]+"&apcPorts:"+customTBDeatils["apcPorts"]+"&apcModalType:"+customTBDeatils["apcModalType"]+"&location:"+customTBDeatils["location"];
console.log("customTBData : "+customTBData);
console.log("Custom_data: "+custom_data)
final_custom=JSON.stringify(customTBDeatils);
request = $.ajax({
url: "/setCustomTB",
type: "POST",
data: final_custom,
contentType: "application/json",
dataType: 'json',
async:false,
cache: false,
success: function(response){
//$('#blurg').html(response).fadeIn(1500);
//var testbedName=response
//alert(testbedName)
console.log(response.name);
testbedName = response.name;
iso_location = response.location;
$('#modalLoading').modal('hide');
alert("planningJoblist start");
console.log("testbedName "+testbedName);
}
});
request.error(function () {
console.log("Error : block`")
});
request.complete(function() {
$('#modalLoading').modal('hide');
alert("Inside Completed");
planningJoblist(plname,testbedName,custom_data,iso_location);
});
}
function planningJoblist(plname,testbedName,custom_data,iso_location) {
$('#modalLoading').modal('hide');
$('#modalLoading').modal('show');
console.log(iso_location);
$.ajax({
url: "/getisos/"+iso_location,
type: "GET",
contentType: "application/json",
async:false,
success: function(response){
console.log("response is "+response);
details =JSON.parse(response);
//deatils=response;
//console.log("detail is");
//console.log(details);
$('#modalLoading').modal('hide');
}
});
var selOptFrom = "";
var selOptTo = "";
//var selOptTB="";
var release=[];
for (var key1 in details[plname]) {
/// alert("from = "+key1);
selOptFrom +='<optgroup label="'+key1+'">';
for (var key2 in details[plname][key1]) {
selOptFrom += "<option value="+key1+">"+details[plname][key1][key2]+"</option>";
}
selOptFrom +='</optgroup>';
}
for (var key1 in details[plname]) {
//alert("from = "+key1);
selOptTo +='<optgroup label="'+key1+'">'
for (var key2 in details[plname][key1]) {
selOptTo += "<option value="+key1+">"+details[plname][key1][key2]+"</option>";
}
selOptTo +='</optgroup>';
}
var index = $( "#set").children("div:last").index()+1;
console.log("index is : "+index);
$("<div />", { "data-role": "collapsible", id: testbedName })
.append($("<div />", { "class": "joblist div"+plname })
.append($("<input />", { type: "hidden", value: plname, disabled : "disabled" }))
.append($("<input />", { type: "hidden", id: "custom_data", value: custom_data, disabled : "disabled" }))
.append($("<input />", { type: "text", value: testbedName, disabled : "disabled" }))
.append($("<select />", { id:"from"+testbedName, type: "text", value: testbedName, }).append($("<option >From Build ...</option >")).append(selOptFrom))
.append($("<i />", {class : "fa fa-exchange fa-2", "aria-hidden": "true" }))
.append($("<select />", { id:"to"+testbedName, type: "text", value: testbedName, }).append($("<option >To Build ...</option >")).append(selOptTo))
.append($("<input />", { id : "chkUpOnly"+testbedName+""+index,type: "checkbox", value: testbedName, onclick : "upgradeOnly(event)", class: "fancyCheckBox" }))
.append($("<label for =chkUpOnly"+testbedName+""+index+" class='chkUpOnly'>Only Upgrade</label>"))
.append($("<div />", {class : "pureCssRadio"})
.append($("<input type='radio' id=simple"+""+index+" name=udType"+""+index+" value='simple' />"))
.append($("<label for =simple"+""+index+" ><span><span></span></span>Simple</label>")))
.append($("<div />", {class : "pureCssRadio"})
.append($("<input type='radio' id=extensive"+""+index+" name=udType"+""+index+" value='extensive' checked='checked' />"))
.append($("<label for =extensive"+""+index+" ><span><span></span></span>Extensive</label>")))
.append($("<input />", {type : "number",id:"iteration"+""+index, name:"quantity",'data-toggle':"tooltip", 'data-placement':"top", title:"Iteration", value:1, min:"1", max:"100"}))
// .append($("<a />", {class:"btnAdd", href:"#", title:"Add", 'data-toggle':"tooltip", 'data-placement':"top", onclick:"addRow(event)"})
//.append($("<i />", { class:"glyphicon glyphicon-plus" })))
//iteration
.append($("<a />", {class:"btnRemove", href:"#", 'data-toggle':"tooltip", 'data-placement':"top", title:"Remove job"}).append($("<i />", {class: "glyphicon icon-remove-sign", id:testbedName+""+index, onclick:"removeRow(event)"}))))
.appendTo("#set");
$(".joblist > select").change(function() {
selId = $(this).attr("id");
//alert(selId);
$(this).attr("data-original-title", $('#'+selId+' option:selected').text());
$(this).tooltip();
//$(this).trigger("click");
})
//console.log("test"+$(".ui-collapsible-content").children("div:first").children(".btnRemove").html());
//$(".ui-collapsible-content").children("div:first").children(".btnRemove").hide();
if( $("#submit").hide()){$("#submit").show()};
$("#noActiveUD").hide();
alert("planningJoblist complete");
}
</script>
</body>
</html>

0 Comments:

Post a Comment