Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 62 additions & 53 deletions webui/static/js/Common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ JavaScript Document
Author: Sean,Lin
E-mail: xiangx.lin@intel.com
Date:2015-09-10
Descrption:
Descrption:
**********************************/

//Create Data Table for Configuration
Expand All @@ -12,14 +12,14 @@ function CreateDataTableForConfiguration(jsonObj_Config,jsonObj_benchmark,reques
$("#div_Configuration_right_table_id").children("table").remove();
$("#div_Configuration_right_table_id").children("div").remove();

//(2) get the configuration table html, and get the benchmark table html when the request_type is benchmark
//(2) get the configuration table html, and get the benchmark table html when the request_type is benchmark
var tableHTML = CreateTableHtml_Configuation(jsonObj_Config);
//if this request_type is benchmark
//if this request_type is benchmark
if(request_type == "benchmark"){
tableHTML += CreateTableHTML_Benchmark(jsonObj_benchmark);
tableHTML += CreateTableHTML_Benchmark(jsonObj_benchmark);
}

//(3) add the table elemnet
//(3) add the table elemnet
$("#div_Configuration_right_table_id").append($(tableHTML));

//(4) set the tr's style
Expand All @@ -29,7 +29,7 @@ function CreateDataTableForConfiguration(jsonObj_Config,jsonObj_benchmark,reques
$.each(jsonObj_Config,function(index,val){
if(val.check == false){
$("#td_value_id_"+index).addClass("error");
}
}
});
}

Expand All @@ -45,7 +45,7 @@ function CreateTableHtml_Configuation(jsonObj){
tableHtml += "<tbody>";

//table head
tableHtml += "<tr>";
tableHtml += "<tr>";
tableHtml += "<th class='checkbox_td_class'>";
tableHtml += "<input type='checkbox' class = 'checkbox_all_configuration_class' id= 'checkbox_all_configuration_id' onclick= 'Check_ALL(&quot;configuration&quot;)' name='checkbox_all'>";
tableHtml += "</th>";
Expand Down Expand Up @@ -114,15 +114,20 @@ function CreateTableHTML_Benchmark(jsonObj){


tableHtml="<div id='div_benchmark_button_id'>";
tableHtml +="<button id='bnt_benchmark_delete_id' type='button' class='btn btn-primary' data-toggle='modal' data-target='#DeleteBenchmarkModal' data-whatever='@mdo' >Delete</button>";
tableHtml +="<button id='bnt_benchmark_add_id' type='button' class='btn btn-primary' data-toggle='modal' data-target='#BenchmarkModel' data-whatever='@mdo' >Add</button>";
if(GetDataByAjax(address-userrole) == 2){
tableHtml +="<button id='bnt_benchmark_delete_id' type='button' class='btn btn-primary' data-toggle='modal' data-target='#DeleteBenchmarkModal' data-whatever='@mdo' >Delete</button>";
tableHtml +="<button id='bnt_benchmark_add_id' type='button' class='btn btn-primary' data-toggle='modal' data-target='#BenchmarkModel' data-whatever='@mdo' >Add</button>";
}else{
tableHtml +="<button id='bnt_benchmark_delete_id' type='button' class='btn btn-primary' data-toggle='modal' data-target='#DeleteBenchmarkModal' data-whatever='@mdo' disabled='disabled'>Delete</button>";
tableHtml +="<button id='bnt_benchmark_add_id' type='button' class='btn btn-primary' data-toggle='modal' data-target='#BenchmarkModel' data-whatever='@mdo' disabled='disabled'>Add</button>";
}
tableHtml += "</div>"

tableHtml += "<table id='"+tableID+"' class='"+tableClass+"'>";
tableHtml += "<tbody>";

//table head
tableHtml += "<tr>";
tableHtml += "<tr>";
tableHtml += "<th class='checkbox_td_class'>";
tableHtml += "<input type='checkbox' class = 'checkbox_all_benchmark_class' id= 'checkbox_all_benchmark_id' onclick= 'Check_ALL(&quot;benchmark&quot;)' name='checkbox_all'>";
tableHtml += "</th>";
Expand Down Expand Up @@ -245,35 +250,35 @@ function CreateTableHTML_Benchmark(jsonObj){
tableHtml += "<td class='td_class' id='td_benchmark_id_"+index+"_12'>";
tableHtml += "<label style='display:none;'>"+index+"</label>";
if(val.additional_option == "restart"){
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='restart' onchange='Additional_option_change()'>";
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='restart' onchange='Additional_option_change()' disabled='disabled'>";
tableHtml += "<option>NULL</option>";
tableHtml += "<option selected>restart</option>";
tableHtml += "<option>redeploy</option>";
tableHtml += "<option>resetPerf</option>";
}
if(val.additional_option == "redeploy"){
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='redeploy' onchange='Additional_option_change()'>";
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='redeploy' onchange='Additional_option_change()' disabled='disabled'>";
tableHtml += "<option>NULL</option>";
tableHtml += "<option>restart</option>";
tableHtml += "<option selected>redeploy</option>";
tableHtml += "<option>resetPerf</option>";
}
if(val.additional_option == "resetPerf"){
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='redeploy' onchange='Additional_option_change()'>";
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='redeploy' onchange='Additional_option_change()' disabled='disabled'>";
tableHtml += "<option>NULL</option>";
tableHtml += "<option>restart</option>";
tableHtml += "<option>redeploy</option>";
tableHtml += "<option selected>resetPerf</option>";
}
if(val.additional_option == "NULL"){
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='null' onchange='Additional_option_change()'>";
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='null' onchange='Additional_option_change()' disabled='disabled'>";
tableHtml += "<option selected>NULL</option>";
tableHtml += "<option>restart</option>";
tableHtml += "<option>redeploy</option>";
tableHtml += "<option>resetPerf</option>";
}
if(val.additional_option == ""){
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='null' onchange='Additional_option_change()'>";
tableHtml += "<select name='select' id='additional_option_dropdown_"+index+"' class='form-control' value='null' onchange='Additional_option_change()' disabled='disabled'>";
tableHtml += "<option selected>NULL</option>";
tableHtml += "<option>restart</option>";
tableHtml += "<option>redeploy</option>";
Expand All @@ -295,18 +300,20 @@ function CreateTableHTML_Benchmark(jsonObj){
//------------------------------ Events Definition ----------------------------
//label click opertion
function Label_Click(count,value){
var rowNum = count;
olabel = document.getElementById("label_id_"+rowNum);
olabel.style.backgroundColor = "#cff";
if(GetDataByAjax(address-userrole) == 2){
var rowNum = count;
olabel = document.getElementById("label_id_"+rowNum);
olabel.style.backgroundColor = "#cff";

otd = document.getElementById("td_value_id_"+rowNum);
otd.removeChild(olabel);
otd = document.getElementById("td_value_id_"+rowNum);
otd.removeChild(olabel);

var strHtml = "<input class='text_class' id = 'text_id_"+rowNum+"' value = '"+value+"' type='text' name='fname'/>";
strHtml += "<input class='btn btn-primary btn-xs' style='margin-left:3px' id = 'bnt_ok_id_"+rowNum+"' type='button' value='OK' onclick= 'Ok_Apply("+rowNum+")' />";
strHtml += "<input class='btn btn-primary btn-xs' style='margin-left:3px' id = 'bnt_cancel_id_"+rowNum+"' type='button' value='Cancel' onclick= 'Cancel_Apply("+rowNum+",&quot;"+value+"&quot;)'/>";
var strHtml = "<input class='text_class' id = 'text_id_"+rowNum+"' value = '"+value+"' type='text' name='fname'/>";
strHtml += "<input class='btn btn-primary btn-xs' style='margin-left:3px' id = 'bnt_ok_id_"+rowNum+"' type='button' value='OK' onclick= 'Ok_Apply("+rowNum+")' />";
strHtml += "<input class='btn btn-primary btn-xs' style='margin-left:3px' id = 'bnt_cancel_id_"+rowNum+"' type='button' value='Cancel' onclick= 'Cancel_Apply("+rowNum+",&quot;"+value+"&quot;)'/>";

otd.innerHTML =strHtml;
otd.innerHTML =strHtml;
}
}

//edit value apply
Expand All @@ -317,7 +324,7 @@ function Ok_Apply(rowNum){
otd.innerHTML =" <label id = 'label_id_"+rowNum+"' class = 'label_class' onclick='Label_Click("+rowNum+", &quot;"+ valueStr+"&quot;)' >"+ valueStr +"</label>";

//--------set to ajax----------
var request_type,key,value;//set_config?request_type= &key= &value=
var request_type,key,value;//set_config?request_type= &key= &value=
request_type= $("#div_Configuration_right_top_titel_id").attr("title");
key = $("#td_value_id_"+rowNum).parent().children().eq(1).children("label").text();
value = $("#td_value_id_"+rowNum).parent().children().eq(2).children("label").text();
Expand All @@ -343,7 +350,7 @@ function Ok_Apply(rowNum){
Append_Row_to_Configuration(value)
});
}

CheckTableDataError();
ExecutvieCheckSync();
}
Expand All @@ -363,14 +370,16 @@ function Additional_option_change(){

//label click opertion
function Label_benchmark_Click(rowNum , colNum , value){
olabel = document.getElementById("label_benchmark_id_" + rowNum + "_" + colNum);
olabel.style.backgroundColor = "#cff";
otd = document.getElementById("td_benchmark_id_" + rowNum + "_" + colNum);
otd.removeChild(olabel);
var strHtml = "<input class='text_class' id = 'text_benchmark_id_"+rowNum+"_"+ colNum +"' value = '"+value+"' type='text' name='fname'/>";
strHtml += "<input class='btn btn-primary btn-xs' id='bnt_benchmark_ok_id_"+rowNum+"_"+colNum+"' type='button' value='OK' onclick= 'Ok_benchmark_Apply("+rowNum+","+ colNum+")' />";
strHtml += "<input class='btn btn-primary btn-xs' id='bnt_benchmark_cancel_id_"+rowNum+"_"+colNum+"' type='button' value='Cancel' onclick= 'Cancel_benchmark_Apply("+rowNum+","+colNum+",&quot;"+value+"&quot;)'/>";
otd.innerHTML =strHtml;
if(GetDataByAjax(address-userrole) == 2){
olabel = document.getElementById("label_benchmark_id_" + rowNum + "_" + colNum);
olabel.style.backgroundColor = "#cff";
otd = document.getElementById("td_benchmark_id_" + rowNum + "_" + colNum);
otd.removeChild(olabel);
var strHtml = "<input class='text_class' id = 'text_benchmark_id_"+rowNum+"_"+ colNum +"' value = '"+value+"' type='text' name='fname'/>";
strHtml += "<input class='btn btn-primary btn-xs' id='bnt_benchmark_ok_id_"+rowNum+"_"+colNum+"' type='button' value='OK' onclick= 'Ok_benchmark_Apply("+rowNum+","+ colNum+")' />";
strHtml += "<input class='btn btn-primary btn-xs' id='bnt_benchmark_cancel_id_"+rowNum+"_"+colNum+"' type='button' value='Cancel' onclick= 'Cancel_benchmark_Apply("+rowNum+","+colNum+",&quot;"+value+"&quot;)'/>";
otd.innerHTML =strHtml;
}
}

//edit value apply
Expand All @@ -388,7 +397,7 @@ function Ok_benchmark_Apply(rowNum , colNum ){
function Cancel_benchmark_Apply(rowNum , colNum ,value){
otd = document.getElementById("td_benchmark_id_"+rowNum+ "_" + colNum);
otext = document.getElementById("text_benchmark_id_"+rowNum+ "_" + colNum);
otd.innerHTML =" <label id='label_benchmark_id_"+rowNum+"_" + colNum +"' class = 'label_class' onclick='Label_benchmark_Click("+rowNum+", "+ colNum +" , &quot;"+ value+"&quot;)' >"+ value +"</label>";
otd.innerHTML =" <label id='label_benchmark_id_"+rowNum+"_" + colNum +"' class = 'label_class' onclick='Label_benchmark_Click("+rowNum+", "+ colNum +" , &quot;"+ value+"&quot;)' >"+ value +"</label>";
}

/********************************************************************************************************************************************************/
Expand All @@ -397,17 +406,17 @@ function Del(tableType){
if(tableType =="configuration"){
$(".checkbox_configuration_class").each(function(index,value){
if($(this).is(':checked')){
var request_type, key ;//del_config?request_type=& key =
var request_type, key ;//del_config?request_type=& key =
request_type = $("#div_Configuration_right_top_titel_id").attr("title");;
key = $(this).parent().parent().children().eq(1).children("label").text();

var data ={};
var data ={};
data.request_type= request_type;
data.key = key;

var result = GetDataByAjax_POST(address_Delete,data);

$(this).parent().parent().remove();
$(this).parent().parent().remove();
}
});
}
Expand All @@ -417,7 +426,7 @@ function Del(tableType){
$(".checkbox_benchmark_class").each(function(index,value){
if($(this).is(':checked')){
rowNum = index;
$(this).parent().parent().remove();
$(this).parent().parent().remove();
}
});
Submit_Benchmark();
Expand All @@ -435,7 +444,7 @@ function Del(tableType){
data.key = key;
var result = GetDataByAjax_POST(address_Report_Delete,data);

$(this).parent().parent().remove();
$(this).parent().parent().remove();
}
});
}
Expand Down Expand Up @@ -474,8 +483,8 @@ function GetTableRowsCount(id){
}

//select elements for classname by js code
function getElementsClass(classnames){
var classobj= new Array();
function getElementsClass(classnames){
var classobj= new Array();
var classint=0;
var tags=document.getElementsByTagName("*");
for(var i in tags){
Expand Down Expand Up @@ -582,10 +591,10 @@ function ConfigurationModal_OK(key, value, dsc){
$("#div_configuration_message_div").show();
}else{
//--------set to ajax----------
var request_type,key,value;//set_config?request_type= &key= &value=
var request_type,key,value;//set_config?request_type= &key= &value=
request_type= $("#div_Configuration_right_top_titel_id").attr("title");

var data ={};
var data ={};
data.request_type= request_type;
data.key = key;
data.value = value;
Expand All @@ -608,21 +617,21 @@ function Append_Row_to_Configuration(params){
html +="<td class='checkbox_td_class'>";
html +="<input type='checkbox' class = 'checkbox_configuration_class' id='checkbox_configuration_id'+ "+rows+" name='checkbox'>";
html +="</td>";

html += "<td class='td_key_class'>";
html += "<label>"+key+"</label>";
html += "</td>";

html += "<td class='td_value_class' id='td_value_id_"+rows+"'>"
html +="<label id = 'label_id_"+rows+"' class='label_class' onclick='Label_Click("+rows+",&quot;"+ value+"&quot;)'>"+ value +"</label>";
html +="</td>";

html += "<td class='td_value_class'id = 'td_dsc_id_"+rows+"'>";
html += "<label>"+dsc+"</label>";
html += "</td>";

html += "<tr>";
$("#table_id").append(html);
$("#table_id").append(html);
//if result check is false , add error sytle
if(check == false){
$("#td_value_id_"+rows).addClass("error");
Expand Down Expand Up @@ -775,14 +784,14 @@ function BenchMarkModel_OK(){

html += "<tr>";

$("#table_benchmark_id").append(html);
$("#table_benchmark_id").append(html);
Submit_Benchmark();
}
}
}

function Submit_Benchmark(){
var post_json = {}//set_config?request_type=testcase &key=testcase &value=
var post_json = {}//set_config?request_type=testcase &key=testcase &value=
var table_data= [];

var benchmark_driver,worker,container_size,io_pattern,block_size,work_depth,ramup_time,run_time,device,parameter,desc;
Expand All @@ -803,7 +812,7 @@ function Submit_Benchmark(){
var rowid = $(this).parent().parent().children().eq(12).children().eq(0).text();
additional = document.getElementById("additional_option_dropdown_"+rowid).value;

var data ={};
var data ={};
data.benchmark_driver = benchmark_driver;
data.worker = worker;
data.container_size = container_size;
Expand All @@ -824,7 +833,7 @@ function Submit_Benchmark(){
post_json.value = JSON.stringify(table_data);
post_json.key="testcase";
var address_Configuration_Set="../configuration/set_config";
var result = GetDataByAjax_POST(address_Configuration_Set,post_json);
var result = GetDataByAjax_POST(address_Configuration_Set,post_json);
//--------------------------------------------------------------------
// check benchmark_driver type and load more benchmark configurations
/*engine_type_list = [];
Expand Down
Loading