upadte result jsp

This commit is contained in:
fanfuxiaoran 2014-06-26 17:15:29 +08:00
parent 5659b46cec
commit b008839121
13 changed files with 998 additions and 979 deletions

View File

@ -1,79 +0,0 @@
package org.bench4q.web.api;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.web.masterMessager.ScriptMessager;
import org.bench4q.web.model.ScenarioModel;
import org.bench4q.web.newapi.BaseController;
import org.bench4q.web.newservice.ScriptServiceNew;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;
@Controller
@SessionAttributes("accessToken")
public class DeviceController extends BaseController {
private Logger logger = Logger.getLogger(DeviceController.class);
private ScriptServiceNew scriptService;
private ScriptMessager scriptMessager;
public ScriptServiceNew getScriptService() {
return scriptService;
}
@Autowired
public void setScriptService(ScriptServiceNew scriptService) {
this.scriptService = scriptService;
}
public ScriptMessager getScriptMessager() {
return scriptMessager;
}
@Autowired
public void setScriptMessager(ScriptMessager scriptMessager) {
this.scriptMessager = scriptMessager;
}
@RequestMapping(value = "deviceScript", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> uploadPluginEditedScript(
@ModelAttribute("accessToken") String accessToken,
@RequestBody ScenarioModel script) {
Map<String, Object> map = new HashMap<String, Object>();
if (script.getUsePlugins() == null
|| script.getUsePlugins().size() == 0) {
fail(map, "empty use plugin");
}
if (script.getBehaviors() == null || script.getBehaviors().size() == 0) {
fail(map, "empty behaviors");
}
RunScenarioModel runScenarioModel = this.getScriptService()
.createRunScenarioModel(script.getUsePlugins(),
script.getBehaviors());
String scenarioModel = MarshalHelper.tryMarshal(runScenarioModel);
logger.info(scenarioModel);
OperateScriptServerResponseModel operateScriptServerResponseModel = this
.getScriptMessager().uploadScript(accessToken,
script.getName(), scenarioModel, null);
if (operateScriptServerResponseModel.isSuccess()) {
return success(map);
} else {
logger.info("fail:"
+ operateScriptServerResponseModel.getFailCauseString());
return fail(map,
operateScriptServerResponseModel.getFailCauseString());
}
}
}

View File

@ -164,3 +164,17 @@ script_edit_jsp_validate=Validate
register_jsp_username=Username
register_jsp_password=Password
register_jsp_retype=Retype Password
register_title=please commit your information
success-register=Congratulations! You have registered successfully!
register-count=seconds later, you will enter the login page!
test-warmUp=WarmUp
test-load=Load
test-coldDown=ColdDown
test-excuteRange=ExcuteRange
test-createTopology=Create Topology
result-addGraph=Add Graph
result-deleteGraph=Delete Graph
result-testStatus=Test Status
result-vuser=VUs Active
result-request=Requests
result-loadingInfo=Please wait,loading result data...

View File

@ -165,3 +165,17 @@ register_jsp_retype=\u91CD \u8F93
register_jsp_admin=\u7BA1\u7406\u5458
register_jsp_register=\u6CE8\u518C
register_jsp_clear=\u6E05\u695A
register_title=\u8BF7\u586B\u5199\u6CE8\u518C\u4FE1\u606F
success-register=\u6CE8\u518C\u6210\u529F
register-count=\u6B63\u5728\u8DF3\u8F6C\u5230\u767B\u9646\u9875\u9762
test-warmUp=\u9884\u70ED\u65F6\u95F4
test-load=\u8D1F\u8F7D\u91CF
test-coldDown=\u51B7\u5374\u65F6\u95F4
test-excuteRange=\u6267\u884C\u65F6\u95F4
test-createTopology=\u65B0\u5EFA\u62D3\u6251
result-addGraph=\u6DFB\u52A0\u56FE
result-deleteGraph=\u5220\u9664\u56FE
result-testStatus=\u6D4B\u8BD5\u72B6\u6001
result-vuser=\u5E76\u53D1\u7528\u6237
result-request=\u53D1\u9001\u8BF7\u6C42
result-loadingInfo=\u8BF7\u7A0D\u7B49\uFF0C\u6B63\u5728\u52A0\u8F7D\u6570\u636E

View File

@ -4,3 +4,25 @@ addCol=addCol
removeCol=removeCol
save=Save
cancel=Cancel
agent-InIdle=InIdle
agent-InRunning=InRunning
agent-BackUp=BackUp
agent-BreakDown=BreakDown
delete=Delete
report=Report
test-loadSchedule=Load Schedule
result-testResult=Test Result
result-script=Script
result-scriptResult=Script Result
result-SUT=SUT
result-sutResult=SUT Result
test-NotStart=NotStart
test-ApplyForLoad=ApplyForLoad
test-DistributeScriptAndParams=DistributeScriptAndParams
test-InRunning=InRunning
test-PendingNoEnoughMaxLoad=PendingNoEnoughMaxLoad
test-PendingNoEnoughCurrentLoad=PendingNoEnoughCurrentLoad
test-Error=Error
test-ErrorInSubmitTask=ErrorInSubmitTask
test-ErrorInDistributeLoadForScript=ErrorInDistributeLoadForScript
test-Complete=Complete

View File

@ -4,3 +4,20 @@ addCol=\u6DFB\u52A0\u884C
removeCol=\u79FB\u9664\u884C
cancel=\u53D6\u6D88
save=\u4FDD\u5B58
agent-InIdle=\u7A7A\u95F2
agent-InRunning=\u6B63\u5728\u8FD0\u884C
agent-BackUp=\u5907\u4EFD
agent-BreakDown=\u5B95\u673A
delete=\u5220\u9664
report=\u62A5\u544A
test-loadSchedule=\u8D1F\u8F7D\u573A\u666F
test-NotStart=\u7B49\u5F85
test-ApplyForLoad=\u5206\u914D\u8D44\u6E90
test-DistributeScriptAndParams=\u51C6\u5907\u73AF\u5883
test-InRunning=\u8FD0\u884C
test-PendingNoEnoughMaxLoad=\u8D44\u6E90\u4E0D\u8DB3
test-PendingNoEnoughCurrentLoad=\u7B49\u5F85\u8D44\u6E90
test-Error=\u9519\u8BEF
test-ErrorInSubmitTask=\u63D0\u4EA4\u9519\u8BEF
test-ErrorInDistributeLoadForScript=\u5206\u53D1\u6587\u4EF6\u9519\u8BEF
test-Complete=\u5B8C\u6210

View File

@ -45,29 +45,33 @@ body {
</div>
<div class="row-fluid" id="test">
<div class="span4 span-brief" id="status">
Test Status<br /> <br>
<fmt:message key="result-testStatus" />
<br /> <br>
</div>
<div class="span4 span-brief" id="vu">
VUs active<br /> <br>
<fmt:message key="result-vuser" />
<br /> <br>
</div>
<div class="span4 span-brief-last" id="request">
Requests<br /> <br>
<fmt:message key="result-request" />
<br /> <br>
</div>
</div>
<div class="row-fluid">
<h4 class="pull-left">Charts</h4>
<div class="field-inline">
<button type="button" class="btn btn-primary " id="del-graph">Delete
Graph</button>
<button type="button" class="btn btn-primary " id="del-graph">
<fmt:message key="result-deleteGraph" />
</button>
</div>
<div class="field-inline">
<button type="button" class="btn btn-primary " id="add-graph">Add
Graph</button>
<button type="button" class="btn btn-primary " id="add-graph">
<fmt:message key="result-addGraph" />
</button>
</div>
</div>
<div class="app-container " id="chart"></div>
<div class="row-fluid">
<h4 class="pull-left">Pages</h4>
@ -115,35 +119,47 @@ body {
</div>
</div>
<div class="modal hide fade" id="add-graph-modal">
< <div class="modal hide fade" id="add-graph-modal">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">x</button>
<h3>Add Graph</h3>
<h3>
<fmt:message key="result-addGraph" />
</h3>
</div>
<div class="modal-body" id="add-graph-list"></div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="add-graph-add"
data-dismiss="modal">add</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">cancel</button>
data-dismiss="modal">
<fmt:message key="add" />
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">
<fmt:message key="cancel" />
</button>
</div>
</div>
<div class="modal hide fade" id="del-graph-modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
<h3>Delete Graph</h3>
<h3>
<fmt:message key="result-deleteGraph" />
</h3>
</div>
<div class="modal-body" id="del-graph-list"></div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="del-graph-del"
data-dismiss="modal">delete</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">cancel</button>
data-dismiss="modal">
<fmt:message key="delete" />
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">
<fmt:message key="cancel" />
</button>
</div>
</div>
<div class="modal hide fade" id="load">
<div class="modal-header">
<h3>Please wait,loading result data...</h3>
<h3> <fmt:message key="result-loadingInfo" /></h3>
</div>
<div class="modal-body">
<div id="loading">
@ -152,7 +168,7 @@ body {
</div>
<div class="modal-footer">
<button type="button" id="cancelLoading" class="btn btn-primary ">cancel</button>
<button type="button" id="cancelLoading" class="btn btn-primary "> <fmt:message key="cancel" /></button>
</div>
</div>
<hr>
@ -177,10 +193,12 @@ body {
<script src="script/bench4q.table.js"></script>
<script src="script/testResult/behaviorAndPage.js"></script>
<script src="script/testResult/highChartTheme.js"></script>
<script src="script/testResult/result-tree.js"></script>
<script src="script/testResult/resultInfo.js"></script>
<script src="script/testResult/chartSelector.js"></script>
<script src="script/testResult/tree.js"></script>
<script src="script/testResult/Model.js"></script>
<script src="script/share/TestStatusMap.js"></script>
<script src="script/testResult/graphSelectorTree.js"></script>
<script src="script/testResult/pieChart.js"></script>
<script src="script/testResult/graphSelector.js"></script>
<script src="script/testResult/result-load.js"></script>
<script src="script/testResult/result.js"></script>
</fmt:bundle>

View File

@ -0,0 +1,33 @@
function testStatusMap(status) {
if (status == "NotStart") {
return $.i18n.prop('test-NotStart');
}
if(status=="Complete"){
return $.i18n.prop('test-Complete');
}
if (status == "ApplyForLoad") {
return $.i18n.prop('test-ApplyForLoad')
}
if (status == "DistributeScriptAndParams") {
return $.i18n.prop('test-DistributeScriptAndParams');
}
if (status == "InRunning") {
return $.i18n.prop('test-InRunning');
}
if (status == "PendingNoEnoughMaxLoad") {
return $.i18n.prop('test-PendingNoEnoughMaxLoad');
}
if (status == "PendingNoEnoughCurrentLoad") {
return $.i18n.prop('test-PendingNoEnoughCurrentLoad');
}
if (status == "Error") {
return $.i18n.prop('test-Error');
}
if (status == "ErrorInSubmitTask") {
return $.i18n.prop('test-ErrorInSubmitTask');
}
if (status == "ErrorInDistributeLoadForScript") {
return $.i18n.prop('test-ErrorInDistributeLoadForScript');
}
}

View File

@ -0,0 +1,36 @@
var Model = function() {
this.url = "";
this.series = "";
this.data = null;
this.intervalId = null;
this.axis = "";
this.time = 0;
};
Model.prototype.setUrl = function(pathValue, chartSelector) {
this.url = chartSelector.allTree.root.value;
if (pathValue == null)
return null;
if (pathValue.length <= 0)
return null;
replace(pathValue, chartSelector.replaceArray);
for ( var i = 0; i < pathValue.length; i++) {
this.url += "/" + pathValue[i];
}
};
Model.prototype.setSeries = function(pathValue) {
this.series = "";
if (pathValue == null)
return null;
if (pathValue.length <= 0)
return null;
this.series += pathValue[0];
for ( var i = 1; i < pathValue.length; i++) {
this.series += "_" + pathValue[i];
}
};
Model.prototype.setIntervalId = function(intervalId) {
this.intervalId = intervalId;
};

View File

@ -1,233 +0,0 @@
var ChartSelector = function(allTree, showTree, chart, addSelectorId,
deleteSelectorId, addButton, deleteButton,replaceArray,showTreePathValues) {
this.allTree = allTree;
this.showTree = showTree;
this.addSelectorId = addSelectorId;
this.deleteSelectorId = deleteSelectorId;
this.excessTree =this.getExcessTree(allTree, showTreePathValues);
this.addButton = addButton;
this.deleteButton = deleteButton;
this.createSelector($("#"+addSelectorId), this.excessTree.root);
this.chart = chart;
this.replaceArray=replaceArray;
this.addEventListener(this);
};
ChartSelector.prototype.getExcessTree=function(allTree,pathValues){
var excessTree=allTree.getClonedTree(allTree);
excessTree.deleteFromTree(pathValues);
return excessTree;
};
ChartSelector.prototype.addEventListener = function(chartSelector) {
this.addButton.click(function(e) {
e.preventDefault();
chartSelector.addGraph();
});
this.deleteButton.click(function(e) {
e.preventDefault();
chartSelector.deleteGraph();
});
};
ChartSelector.prototype.updateSelector = function(selectorId, updatedData, tree) {
var parentDomNode = $("#" + selectorId);
this.deleteChildSelector(parentDomNode,updatedData);
/*var pathValues = getSubDataArray(updatedData, this
.getSlectedVluesArray(selectorId));*/
/*var newShowTree = tree.getCloneTreeFromVlaue(valuePath);*/
var newShowTree=tree.getClondSubTreeByValue(updatedData);
if(newShowTree==null)
return;
this.createSelector(parentDomNode, newShowTree.root);
this.addSelectlistEvent();
};
ChartSelector.prototype.deleteChildSelector=function(parentDomNode,updatedData){
var selectArray=$("#"+parentDomNode.attr("id")+" select");
var divArray=$("#"+parentDomNode.attr("id")+" div");
parentDomNode.html("");
for(var i=0;i<selectArray.length;i++){
parentDomNode.append(divArray[i]);
if($(selectArray[i]).find("option:selected").text()==updatedData){
break;
}
}
};;
ChartSelector.prototype.createSelectorByValues = function(parentDomNode, treeNode,pathValues) {
var currentNode = treeNode;
if (currentNode == null)
return ;
var selectedNode;
if (currentNode.children != null && currentNode.children.length > 0) {
selectedNode=this.getSelectNodeByValue(currentNode,pathValues);
if(selectedNode==null)
selectedNode = currentNode.children[0];
var selectOptions = new Array();
for (var i = 0; i < currentNode.children.length; i++) {
selectOptions.push(currentNode.children[i].value);
}
parentDomNode.append(this.createSingleListDom(currentNode.childClassName,selectOptions));
this.createSelectorByValues(parentDomNode, selectedNode,pathValues);
}
};
ChartSelector.prototype.addSelectlistEvent=function(){
var chartSelector=this;
$("#" + this.deleteSelectorId+" select").change(function(event) {
var updatedData=$(this).find("option:selected").text();
chartSelector.updateSelector( chartSelector.deleteSelectorId, updatedData, chartSelector.showTree);
event.stopImmediatePropagation();
});
$("#" + this.addSelectorId+" select").change(function(event) {
var updatedData=$(this).find("option:selected").text();
chartSelector.updateSelector( chartSelector.addSelectorId, updatedData, chartSelector.excessTree);
event.stopImmediatePropagation();
});
};
ChartSelector.prototype.createSelector = function(parentDomNode, treeNode) {
var currentNode = treeNode;
if (currentNode == null)
return ;
var selectedNode;
if (currentNode.children != null && currentNode.children.length > 0) {
selectedNode = currentNode.children[0];
var selectOptions = new Array();
for (var i = 0; i < currentNode.children.length; i++) {
selectOptions.push(currentNode.children[i].value);
}
parentDomNode.append(this.createSingleListDom(currentNode.childClassName,selectOptions));
this.createSelector(parentDomNode, selectedNode);
}
};
ChartSelector.prototype.getSelectNodeByValue=function(parentNode,values){
for(var i=0;i<values.length;i++){
for(var j=0;j<parentNode.children.length;j++){
if(parentNode.children[j].value==values[i])
return parentNode.children[j];
}
}
return null;
};
ChartSelector.prototype.createSingleListDom = function(lableText, options) {
var div = $("<div></div>");
div.addClass("control-group");
var lable = $("<lable></lable>");
lable.addClass("control-label");
lable.text(lableText);
div.append(lable);
div.append("</br>");
var select = $("<select ></select>");
select.addClass("form-control");
for (var i = 0; i < options.length; i++) {
var option = $("<option></option>");
option.text(options[i]);
select.append(option);
}
div.append(select);
return div;
};
ChartSelector.prototype.getSlectedVluesArray = function(selectorId) {
var dataArray = new Array();
var selectArray = $("#" + selectorId + " select");
for (var i = 0; i < selectArray.length; i++) {
dataArray.push($(selectArray[i]).find("option:selected").text());
}
return dataArray;
};
ChartSelector.prototype.addGraphToTree = function( tree,selectorId) {
var pathValues = this.getSlectedVluesArray(selectorId);
var singlePathTree = this.allTree.getCloneTreeFromVlaue(pathValues);
if(tree==null)
tree=singlePathTree;
else
tree.insertToTree(tree.root, singlePathTree.root);
return tree;
};
ChartSelector.prototype.deleteGraphFromTree = function(tree, selectorId) {
if(tree==null)
return null;
var pathValues = this.getSlectedVluesArray(selectorId);
tree.deleteFromTree(pathValues);
return tree;
};
ChartSelector.prototype.addGraph = function() {
this.showTree=this.addGraphToTree(this.showTree, this.addSelectorId);
this.excessTree=this.deleteGraphFromTree(this.excessTree, this.addSelectorId);
var model = new Model();
model.setSeries(this.getSlectedVluesArray(this.addSelectorId));
model.setUrl(this.getSlectedVluesArray(this.addSelectorId),this);
model.axis=(model.series+"_Axis");
this.chart.addGraph(model);
};
ChartSelector.prototype.initChart=function(pathValues){
var model = new Model();
model.setSeries(pathValues);
model.setUrl(this.getSlectedVluesArray(this.addSelectorId),this);
model.axis=(model.series+"_Axis");
this.chart.addGraph(model);
};
ChartSelector.prototype.deleteGraph = function() {
this.showTree=this.deleteGraphFromTree(this.showTree, this.deleteSelectorId);
this.excessTree=this.addGraphToTree(this.excessTree, this.deleteSelectorId);
var model = new Model();
model.setSeries(this.getSlectedVluesArray(this.deleteSelectorId));
model.axis=(model.series+"_Axis");
this.chart.deleteGraph(model);
};
var Model = function() {
this.url = "";
this.series = "";
this.data = null;
this.intervalId = null;
this.axis="";
this.time=0;
};
Model.prototype.setUrl = function(pathValue,chartSelector) {
/* this.url = "/"+chartSelector.allTree.root.value;*/
this.url = chartSelector.allTree.root.value;
if (pathValue == null)
return null;
if (pathValue.length <= 0)
return null;
replace(pathValue,chartSelector.replaceArray);
for(var i=0;i<pathValue.length;i++){
this.url += "/" + pathValue[i];
}
};
Model.prototype.setSeries = function(pathValue) {
this.series = "";
if (pathValue == null)
return null;
if (pathValue.length <= 0)
return null;
this.series += pathValue[0];
for (var i = 1; i < pathValue.length; i++) {
this.series += "_" + pathValue[i];
}
};
Model.prototype.setIntervalId = function(intervalId) {
this.intervalId = intervalId;
};
function getSubDataArray(indexData, dataArray) {
var subDataArray = new Array();
for (var i = 0; i < dataArray.length; i++) {
subDataArray.push(dataArray[i]);
if (dataArray[i] == indexData) {
break;
}
}
return subDataArray;
}

View File

@ -0,0 +1,205 @@
var ChartSelector = function(allTree, showTree, chart, addSelectorId,
deleteSelectorId, addButton, deleteButton, replaceArray,
showTreePathValues) {
this.allTree = allTree;
this.showTree = showTree;
this.addSelectorId = addSelectorId;
this.deleteSelectorId = deleteSelectorId;
this.excessTree = this.getExcessTree(allTree, showTreePathValues);
this.addButton = addButton;
this.deleteButton = deleteButton;
this.createSelector($("#" + addSelectorId), this.excessTree.root);
this.chart = chart;
this.replaceArray = replaceArray;
this.addEventListener(this);
};
ChartSelector.prototype.getExcessTree = function(allTree, pathValues) {
var excessTree = allTree.getClonedTree(allTree);
excessTree.deleteFromTree(pathValues);
return excessTree;
};
ChartSelector.prototype.addEventListener = function(chartSelector) {
this.addButton.click(function(e) {
e.preventDefault();
chartSelector.addGraph();
});
this.deleteButton.click(function(e) {
e.preventDefault();
chartSelector.deleteGraph();
});
};
ChartSelector.prototype.updateSelector = function(selectorId, updatedData, tree) {
var parentDomNode = $("#" + selectorId);
this.deleteChildSelector(parentDomNode, updatedData);
var newShowTree = tree.getClondSubTreeByValue(updatedData);
if (newShowTree == null)
return;
this.createSelector(parentDomNode, newShowTree.root);
this.addSelectlistEvent();
};
ChartSelector.prototype.deleteChildSelector = function(parentDomNode,
updatedData) {
var selectArray = $("#" + parentDomNode.attr("id")).find("select");
var divArray = $("#" + parentDomNode.attr("id") + " div");
parentDomNode.html("");
for ( var i = 0; i < selectArray.length; i++) {
parentDomNode.append(divArray[i]);
if ($(selectArray[i]).find("option:selected").text() == updatedData) {
break;
}
}
};
//
// ChartSelector.prototype.createSelectorByValues = function(parentDomNode,
// treeNode, pathValues) {
// var currentNode = treeNode;
// if (currentNode == null)
// return;
// var selectedNode;
// if (currentNode.children != null && currentNode.children.length > 0) {
// selectedNode = this.getSelectNodeByValue(currentNode, pathValues);
// if (selectedNode == null)
// selectedNode = currentNode.children[0];
// var selectOptions = new Array();
// for ( var i = 0; i < currentNode.children.length; i++) {
// selectOptions.push(currentNode.children[i].value);
// }
// parentDomNode.append(this.createSingleListDom(
// currentNode.childClassName, selectOptions));
// this.createSelectorByValues(parentDomNode, selectedNode, pathValues);
// }
//
// };
ChartSelector.prototype.addSelectlistEvent = function() {
var chartSelector = this;
$("#" + this.deleteSelectorId).find("select").change(
function(event) {
var updatedData = $(this).find("option:selected").text();
chartSelector.updateSelector(chartSelector.deleteSelectorId,
updatedData, chartSelector.showTree);
event.stopImmediatePropagation();
});
$("#" + this.addSelectorId).find("select").change(
function(event) {
var updatedData = $(this).find("option:selected").text();
chartSelector.updateSelector(chartSelector.addSelectorId,
updatedData, chartSelector.excessTree);
event.stopImmediatePropagation();
});
};
ChartSelector.prototype.createSelector = function(parentDomNode, treeNode) {
var currentNode = treeNode;
if (currentNode == null)
return;
var selectedNode;
if (currentNode.children != null && currentNode.children.length > 0) {
selectedNode = currentNode.children[0];
var selectOptions = new Array();
for ( var i = 0; i < currentNode.children.length; i++) {
selectOptions.push(currentNode.children[i].value);
}
parentDomNode.append(this.createSingleListDom(
currentNode.childClassName, selectOptions));
this.createSelector(parentDomNode, selectedNode);
}
};
ChartSelector.prototype.getSelectNodeByValue = function(parentNode, values) {
for ( var i = 0; i < values.length; i++) {
for ( var j = 0; j < parentNode.children.length; j++) {
if (parentNode.children[j].value == values[i])
return parentNode.children[j];
}
}
return null;
};
ChartSelector.prototype.createSingleListDom = function(lableText, options) {
var div = $("<div></div>");
div.addClass("control-group");
var lable = $("<lable></lable>");
lable.addClass("control-label");
lable.text(lableText);
div.append(lable);
div.append("</br>");
var select = $("<select ></select>");
select.addClass("form-control");
for ( var i = 0; i < options.length; i++) {
var option = $("<option></option>");
$(option).val(options[i]);
option.text(options[i]);
select.append(option);
}
div.append(select);
return div;
};
ChartSelector.prototype.getSlectedVluesArray = function(selectorId) {
var dataArray = new Array();
var selectArray = $("#" + selectorId).find("select");
for ( var i = 0; i < selectArray.length; i++) {
dataArray.push($(selectArray[i]).find("option:selected").text());
}
return dataArray;
};
ChartSelector.prototype.addGraphToTree = function(tree, selectorId) {
var pathValues = this.getSlectedVluesArray(selectorId);
var singlePathTree = this.allTree.getCloneTreeFromVlaue(pathValues);
if (tree == null)
tree = singlePathTree;
else
tree.insertToTree(tree.root, singlePathTree.root);
return tree;
};
ChartSelector.prototype.deleteGraphFromTree = function(tree, selectorId) {
if (tree == null)
return null;
var pathValues = this.getSlectedVluesArray(selectorId);
tree.deleteFromTree(pathValues);
return tree;
};
ChartSelector.prototype.addGraph = function() {
this.showTree = this.addGraphToTree(this.showTree, this.addSelectorId);
this.excessTree = this.deleteGraphFromTree(this.excessTree,
this.addSelectorId);
var model = new Model();
model.setSeries(this.getSlectedVluesArray(this.addSelectorId));
model.setUrl(this.getSlectedVluesArray(this.addSelectorId), this);
model.axis = (model.series + "_Axis");
this.chart.addGraph(model);
};
ChartSelector.prototype.initChart = function(pathValues) {
var model = new Model();
model.setSeries(pathValues);
model.setUrl(this.getSlectedVluesArray(this.addSelectorId), this);
model.axis = (model.series + "_Axis");
this.chart.addGraph(model);
};
ChartSelector.prototype.deleteGraph = function() {
this.showTree = this.deleteGraphFromTree(this.showTree,
this.deleteSelectorId);
this.excessTree = this.addGraphToTree(this.excessTree,
this.deleteSelectorId);
var model = new Model();
model.setSeries(this.getSlectedVluesArray(this.deleteSelectorId));
model.axis = (model.series + "_Axis");
this.chart.deleteGraph(model);
};
function getSubDataArray(indexData, dataArray) {
var subDataArray = new Array();
for ( var i = 0; i < dataArray.length; i++) {
subDataArray.push(dataArray[i]);
if (dataArray[i] == indexData) {
break;
}
}
return subDataArray;
}

View File

@ -0,0 +1,107 @@
function getResultInfoTree(testPlanId) {
var tree = new Tree();
tree.createRoot("Test Result", testPlanId);
createScriptResultInfoTree(testPlanId, tree);
var sutResultInfo = new SutResult(testPlanId);
if (sutResultInfo.root != null)
tree.root.insertSingleNode(sutResultInfo.root);
return tree;
}
function createScriptResultInfoTree(testPlanId, tree) {
var scriptResultTree = new Tree();
scriptResultTree.createRoot("Script", "script");
$.ajax({
type : "POST",
url : testPlanId + "/runningScriptInfo",
dataType : "json",
async : false,
success : function(data) {
if (!data.success) {
return;
} else
data = data.scriptInfo;
createScriptTree(data, scriptResultTree);
tree.root.insertSingleNode(scriptResultTree.root);
}
});
}
function createScriptTree(scriptResultInfoList, tree) {
if (scriptResultInfoList == null)
return;
for ( var i = 0; i < scriptResultInfoList.length; i++) {
var node = new TreeNode("Script Result",
scriptResultInfoList[i].scriptName, null);
tree.root.insertSingleNode(node);
var nodeArray = insertResultList(scriptResultInfoList[i].childResults);
for ( var j = 0; j < nodeArray.length; j++) {
node.insertSingleNode(nodeArray[j]);
}
}
};
var SutResult = function(testPlanId) {
var sutResultInfo = this;
var scriptResultTree = new Tree();
$.ajax({
type : "POST",
url : testPlanId + "/sutInfo",
dataType : "json",
async : false,
success : function(data) {
if (!data.success) {
sutResultInfo.root = null;
return;
} else
data = data.sutInfo;
scriptResultTree.createRoot("SUT", "SUT");
sutResultInfo.root = scriptResultTree.root;
sutResultInfo.data = data;
sutResultInfo.createTree(data);
}
});
};
SutResult.prototype.createTree = function(sutResultInfoList) {
for ( var i = 0; i < sutResultInfoList.length; i++) {
var ipNode = new TreeNode("port", sutResultInfoList[i].ip, null);
this.root.insertSingleNode(ipNode);
var portNode = new TreeNode("sut result", sutResultInfoList[i].port,
null);
ipNode.insertSingleNode(portNode);
var nodeArray = insertResultList(sutResultInfoList[i].childResults);
for ( var j = 0; j < nodeArray.length; j++) {
portNode.insertSingleNode(nodeArray[j]);
}
}
}
function insertResultList(childResults) {
if (childResults == null)
return null;
else {
var nodeArray = new Array();
for ( var i = 0; i < childResults.length; i++) {
var node = new TreeNode(childResults[i].result,
childResults[i].result, null);
var childNode = insertResultList(childResults[i].childResults);
if (childNode !== null) {
for ( var j = 0; j < childNode.length; j++) {
node.insertSingleNode(childNode[j]);
}
}
nodeArray.push(node);
}
}
return nodeArray;
};

View File

@ -1,110 +0,0 @@
function getResultInfoTree(testPlanId){
var tree=new Tree();
tree.createRoot("Test Result",testPlanId);
createScriptResultInfoTree(testPlanId,tree);
/*this.SutResult=new SutResult(testPlanId);*/
var sutResultInfo=new SutResult(testPlanId);
if(sutResultInfo.root!=null)
tree.root.insertSingleNode(sutResultInfo.root);
return tree;
}
function createScriptResultInfoTree(testPlanId,tree){
var scriptResultTree=new Tree();
scriptResultTree.createRoot("Script","script");
$.ajax({
type:"POST",
url:testPlanId+"/runningScriptInfo",
dataType:"json",
async: false,
success: function(data){
if(!data.success){
return;
}
else data=data.data;
createScriptTree(data,scriptResultTree);
tree.root.insertSingleNode(scriptResultTree.root);
}
});
}
function createScriptTree(scriptResultInfoList,tree){
if(scriptResultInfoList==null)
return;
for(var i=0;i<scriptResultInfoList.length;i++){
var node=new TreeNode("Script Result",scriptResultInfoList[i].scriptName,null);
tree.root.insertSingleNode(node);
var nodeArray=insertResultList(scriptResultInfoList[i].childResults);
for(var j=0;j<nodeArray.length;j++){
node.insertSingleNode(nodeArray[j]);
}
}
};
var SutResult=function(testPlanId){
var sutResultInfo=this;
var scriptResultTree=new Tree();
$.ajax({
type:"POST",
url:testPlanId+"/sutInfo",
dataType:"json",
async: false,
success: function(data){
if(!data.success)
{
sutResultInfo.root=null;
return;
}
else data=data.data;
scriptResultTree.createRoot("SUT","SUT");
sutResultInfo.root=scriptResultTree.root;
sutResultInfo.data=data;
sutResultInfo.createTree(data);
}
});
};
SutResult.prototype.createTree=function(sutResultInfoList){
for(var i=0;i<sutResultInfoList.length;i++){
var ipNode=new TreeNode("port",sutResultInfoList[i].ip,null);
this.root.insertSingleNode(ipNode);
var portNode=new TreeNode("sut result",sutResultInfoList[i].port,null);
ipNode.insertSingleNode(portNode);
var nodeArray=insertResultList(sutResultInfoList[i].childResults);
for(var j=0;j<nodeArray.length;j++){
portNode.insertSingleNode(nodeArray[j]);
}
}
}
function insertResultList(childResults){
if(childResults==null)
return null;
else{
var nodeArray=new Array();
for(var i=0;i<childResults.length;i++){
var node=new TreeNode(childResults[i].result,childResults[i].result,null);
var childNode=insertResultList(childResults[i].childResults);
if(childNode!==null){
for(var j=0;j<childNode.length;j++){
node.insertSingleNode(childNode[j]);
}
}
nodeArray.push(node);
}
}
return nodeArray;
};

View File

@ -209,31 +209,6 @@ Tree.prototype.getClonedNode = function(node) {
}
return clonedNode;
};
/*
* Tree.prototype.getExcessTreeNodes = function(allTreeNode, showTreeNode) { var
* tree=this; if (allTreeNode == null) return null;
* if(allTreeNode.children==null) return null; var excessTreeNode = new
* TreeNode(allTreeNode.childClassName, allTreeNode.value, null); if
* (showTreeNode == null) { getClonedSubTree(allTreeNode, excessTreeNode);
* return excessTreeNode.children; } for ( var i = 0; i <
* allTreeNode.children.length; i++) { var flag = false; for ( var j = 0; j <
* showTreeNode.children.length; j++) { if (allTreeNode.children[i].value ==
* showTreeNode.children[j].value) { flag = true; var childrenExcessTree=tree.
* getExcessTreeNodes(allTreeNode.children[i], showTreeNode.children[j]); if
* (childrenExcessTree.children != null && childrenExcessTree.children.length >
* 0)
*
* excessTreeNode.insertNodes(childrenExcessTree); } } if (!flag) {
* excessTreeNode.insertSingleNode(allTree.children[i]); } } if
* (excessTree.children.length == 0) excessTree.children = null; return
* excessTree.children; }; Tree.prototype.getExcessTree = function(allTree,
* showTree) { if (showTree == null) { showTree = new Tree(); showTree.root =
* null; } var excessTree = new Tree();
* excessTree.createRoot(allTree.root.childClassName, allTree.root.value);
* excessTree.root.insertNodes(excessTree.getExcessTreeNodes(allTree.root,
* showTree.root)); return excessTree;
* }
*/
function getClonedSubTree(startNode, parentNode) {
if (startNode == null)
return null;