From 30c25c7dfcefc604e569241bbd368ab72cf49c9e Mon Sep 17 00:00:00 2001 From: "Qi.Yu" Date: Tue, 21 Mar 2017 10:55:12 +0800 Subject: [PATCH] User control --- webui/static/js/Common.js | 115 +++++++++-------- webui/static/js/Script.js | 254 ++++++++++++++++++++------------------ webui/webui.py | 5 + 3 files changed, 199 insertions(+), 175 deletions(-) diff --git a/webui/static/js/Common.js b/webui/static/js/Common.js index 054966b..2b48b28 100644 --- a/webui/static/js/Common.js +++ b/webui/static/js/Common.js @@ -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 @@ -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 @@ -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"); - } + } }); } @@ -45,7 +45,7 @@ function CreateTableHtml_Configuation(jsonObj){ tableHtml += ""; //table head - tableHtml += ""; + tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; @@ -114,15 +114,20 @@ function CreateTableHTML_Benchmark(jsonObj){ tableHtml="
"; - tableHtml +=""; - tableHtml +=""; + if(GetDataByAjax(address-userrole) == 2){ + tableHtml +=""; + tableHtml +=""; + }else{ + tableHtml +=""; + tableHtml +=""; + } tableHtml += "
" tableHtml += ""; tableHtml += ""; //table head - tableHtml += ""; + tableHtml += ""; tableHtml += ""; @@ -245,35 +250,35 @@ function CreateTableHTML_Benchmark(jsonObj){ tableHtml += ""; - + html += ""; - + html += ""; - + html += ""; - + html += ""; - $("#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"); @@ -775,14 +784,14 @@ function BenchMarkModel_OK(){ html += ""; - $("#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; @@ -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; @@ -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 = []; diff --git a/webui/static/js/Script.js b/webui/static/js/Script.js index c588650..1aa1ed5 100644 --- a/webui/static/js/Script.js +++ b/webui/static/js/Script.js @@ -3,7 +3,7 @@ Author: Sean,Lin E-mail: xiangx.lin@intel.com Date:2015-09-18 - Descrption: + Descrption: **********************************/ //http://192.168.5.22:8080/configuration/get_group?request_type=cluster var address_Configuration_Get="../configuration/get_group?request_type="; @@ -22,6 +22,7 @@ var address_GetRuningStatus="../monitor/cetune_status"; var address_IntoRuningMode="../configuration/execute"; var address_ExitRuningMode_cancel_all="../configuration/cancel_all"; var address_ExitRuningMode_cancel_one="../configuration/cancel_one"; +var address_userrole="../configuration/user_role"; var timer_RunStatus; var timer_Console; @@ -37,8 +38,10 @@ function showtopdiv(){ $("#result_report_top").show("slow"); } function mouse_on(){ - $("#result_report_top").show("slow"); - document.getElementById('result_report_top').style.display="block"; + if(GetDataByAjax(address_userrole) == 2{ + $("#result_report_top").show("slow"); + document.getElementById('result_report_top').style.display="block"; + } } function Cancel_delete(){ $("#result_report_top").hide("slow"); @@ -60,7 +63,7 @@ function RunStatus_Timer(){ } else { - $("#div_Configuration_right_back_id").hide(); + $("#div_Configuration_right_back_id").hide(); clearTimer(timer_RunStatus); $("#div_top_status_id h1").text(line1); $("#div_top_status_id .ceph_thr").text(line2); @@ -75,7 +78,7 @@ function Console_Timer(init){ return //(1) get the last timestamp var timestamp = GetTimestamp(); - + //(2) request ajax var data ; if(timestamp!="" & typeof(timestamp) != "undefined" & timestamp != undefined) @@ -85,17 +88,17 @@ function Console_Timer(init){ }else{ var consoleData = GetDataByAjax(address_Status); } - + if(consoleData.content == "") - return + return //create content html var consoleHTML = ""; consoleHTML += "
"; consoleHTML += consoleData.content; consoleHTML += "
"; - + //insert html - $("#div_console_id").append(consoleHTML); + $("#div_console_id").append(consoleHTML); var scroll_position = 0 $("#div_console_id").children(".div_console_timestamp").each(function(){ scroll_position += $(this).height()}); $("#div_console_id").scrollTop( scroll_position ); @@ -188,7 +191,7 @@ function Report_Timer(init){ var reportSummaryData = GetDataByAjax(address_Report); reportSummaryData = reportSummaryData.replace(/
"; tableHtml += ""; tableHtml += ""; tableHtml += ""; if(val.additional_option == "restart"){ - tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; } if(val.additional_option == "redeploy"){ - tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; } if(val.additional_option == "resetPerf"){ - tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; } if(val.additional_option == "NULL"){ - tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; } if(val.additional_option == ""){ - tableHtml += ""; tableHtml += ""; tableHtml += ""; tableHtml += ""; @@ -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 = ""; - strHtml += ""; - strHtml += ""; + var strHtml = ""; + strHtml += ""; + strHtml += ""; - otd.innerHTML =strHtml; + otd.innerHTML =strHtml; + } } //edit value apply @@ -317,7 +324,7 @@ function Ok_Apply(rowNum){ otd.innerHTML =" "; //--------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(); @@ -343,7 +350,7 @@ function Ok_Apply(rowNum){ Append_Row_to_Configuration(value) }); } - + CheckTableDataError(); ExecutvieCheckSync(); } @@ -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 = ""; - strHtml += ""; - strHtml += ""; - 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 = ""; + strHtml += ""; + strHtml += ""; + otd.innerHTML =strHtml; + } } //edit value apply @@ -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 =" "; + otd.innerHTML =" "; } /********************************************************************************************************************************************************/ @@ -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(); } }); } @@ -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(); @@ -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(); } }); } @@ -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){ @@ -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; @@ -608,21 +617,21 @@ function Append_Row_to_Configuration(params){ html +=""; html +=""; html +=""; html += ""; html += "" html +=""; html +=""; html += ""; html += "