This commit is contained in:
fanfuxiaoran 2014-07-16 18:03:37 +08:00
parent e5e0d86cab
commit 88dd9ae130
33 changed files with 30981 additions and 49 deletions

53
Bench4Q-Web/script.xml Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testResult>
<results>
<result>
<children>
<name>累计成功数目</name>
<value>totalSuccessCountFromBegin</value>
</children>
<children>
<name>累计失败数目</name>
<value>totalFailCountFromBegin</value>
</children>
<children>
<name>平均响应时间</name>
<value>averageResponseTime</value>
</children>
<children>
<name>最大响应时间</name>
<value>maxResponseTime</value>
</children>
<children>
<name>最小响应时间</name>
<value>minResponseTime</value>
</children>
<children>
<name>最大吞吐率</name>
<value>successThroughputThisTime</value>
</children>
<children>
<name>失败吞吐率</name>
<value>failThroughputThisTime</value>
</children>
<children>
<name>响应时间</name>
<value>responseTimeDeviationThisTime</value>
</children>
<children>
<name>平均延迟时间</name>
<value>averageElapsedTime</value>
</children>
<children>
<name>计划运行时间</name>
<value>planedRunningTime</value>
</children>
<children>
<name>虚拟用户</name>
<value>vUserCount</value>
</children>
<name>脚本运行结果</name>
<value>scriptBriefResult</value>
</result>
</results>
</testResult>

View File

@ -0,0 +1,153 @@
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta charset="utf-8">
<title>Bench4Q</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
content="Bench4Q, a new method for QOS benchmarking.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link rel="shortcut icon" href="image/bench4q.png">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href='lib/chrisma/css/opa-icons.css' rel='stylesheet'>
<!-- <link href="http://cdn.alloyui.com/2.5.0/aui-css/css/bootstrap.min.css"
rel="stylesheet"></link> -->
<link href='css/editor.css' rel='stylesheet'>
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- The fav icon -->
</head>
<body>
<fmt:bundle basename="i18n">
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<div class="tab span10">
<ul style="cursor: pointer" class="nav nav-tabs">
<li id="tow1" class="on" onclick='refresh();setTab("tow",1,3);'><a
href="#">View</a></li>
<li id="tow2" onclick='setTab("tow",2,3);'><a href="#">EditBehaviors</a></li>
<li id="tow3" onclick='setTab("tow",3,3);'><a href="#">EditPlugins</a></li>
</ul>
</div>
<div class="span10">
<div id="cont_tow_1" class="one block">
<div id="contents" class="span12">
<div id="codeEditor" class="view"></div>
</div>
<%-- <jsp:include page="publiccontrol/scriptEditRightMenuBar.jsp"></jsp:include> --%>
</div>
<div id="cont_tow_2" class="one" style="display: none">
<div class="all-plugins btn-group span12">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
<span class="hidden-phone"> All plug-ins </span> <span
class="caret"></span>
</a>
<ul class="dropdown-menu" id="allPlugins">
<li><a onclick="choosePlugin(this);">All</a></li>
<li class="divider"></li>
</ul>
</div>
<div class="row-fluid">
<div id="behaviors" class="all-behaviors span4">
<ul id="behaviorUl">
</ul>
</div>
<div class="span8">
<div id="showPluginMethodForm"></div>
<div id="action" style="display: none">
<button type="button" class="btn btn-primary" id="submit"
title="save edit">
<fmt:message key="script_edit_jsp_save"></fmt:message>
</button>
<button type="button" class="btn btn-primary" id="cancel"
title="cancel edit">
<fmt:message key="script_edit_jsp_cancel" />
</button>
<button type="button" class="btn btn-primary" id="validate"
title="validate edit">
<fmt:message key="script_edit_jsp_validate"></fmt:message>
</button>
</div>
</div>
</div>
</div>
<div id="cont_tow_3" class="one" style="display: none">
<div class="all-plugins btn-group span12">
<a class="btn dropdown-toggle" href="#" data-toggle="dropdown">
<span class="hidden-phone"> All plug-ins </span> <span
class="caret"></span>
</a>
<ul class="dropdown-menu" id="allPlugins">
<li><a onclick="choosePlugin(this);">All</a></li>
<li class="divider"></li>
</ul>
</div>
<div class="row-fluid">
<div id="usePlugins" class="all-behaviors span4">
<ul id="usePlugin">
</ul>
</div>
<div class="span8">
<div id="pluginParamArea"></div>
</div>
</div>
<div id="usePluginAction" style="float: right">
<button type="button" class="btn btn-primary" id="submitPlugin"
title="save edit">
<fmt:message key="script_edit_jsp_save"></fmt:message>
</button>
<button type="button" class="btn btn-primary" id="cancel"
title="cancel edit">
<fmt:message key="script_edit_jsp_cancel" />
</button>
<button type="button" class="btn btn-primary" id="validate"
title="validate edit">
<fmt:message key="script_edit_jsp_validate"></fmt:message>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- </div> -->
<hr>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
<script
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
<script src="lib/jquery/jqueryui.js"></script>
<script
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js'></script>
<script
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="script/base.js"></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="http://cdn.alloyui.com/2.5.0/aui/aui-min.js"></script>
<script src="lib/bootstrap/js/bootstrap-collapse.js"></script>
<script src="script/ScriptEditor/pluginCommon.js"></script>
<script src="script/ScriptEditor/paramInfosForm.js"></script>
<script src="script/ScriptEditor/pluginModel.js"></script>
<script src="script/ScriptEditor/xmlEditor.js"></script>
<script src="script/ScriptEditor/editScript.js"></script>
</fmt:bundle>
</body>
</html>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
var modelData;
function setTab(name, m, n) {
for (var i = 1; i <= n; i++) {
var menu = document.getElementById(name + i);
var showDiv = document.getElementById("cont_" + name + "_" + i);
menu.className = i == m ? "on" : "";
showDiv.style.display = i == m ? "block" : "none";
}
}
function getScript(scriptId) {
$.post("getScript", {
scriptId : scriptId
}, function(data) {
if (!data.success) {
alert("failed to get script:" + data.failedMessage);
return;
} else {
data = eval("(" + data.script + ")");
}
modelData=data;
loadUsePluigns(data);
}, "json")
$.post("getScriptXml", {
scriptId : scriptId
}, function(data) {
if (!data.success) {
alert("failed to get script:" + data.failedMessage);
return;
} else {
YUI().use('aui-ace-editor', function(Y) {
new Y.AceEditor({
boundingBox : '#codeEditor',
mode : 'xml',
value : data.script,
height: '500',
width:'800px'
}).render();
});
}
}, "json")
}
$(function() {
$(function() {
var scriptId = getvars()['scriptId'];
getScript(scriptId);
});
})

View File

@ -35,7 +35,8 @@ function loadAgents(table) {
}
var tbody = table.table().body();
$(tbody).on('click', 'td a.delete', function() {
$(tbody).on('click', 'td a.delete', function(e) {
e.preventDefault();
var row = $(this).closest("tr");
var hostName = $(tr).children("td").eq(0).text();
var id = $(row).attr("id");

View File

@ -0,0 +1,4 @@
$(function() {
$( "#tabs" ).tabs();
});

View File

@ -0,0 +1,78 @@
var ContainerFactory = function() {
};
ContainerFactory.prototype.createEditorContainer = function(header, id,
containerInfo) {
var container = document.createElement("div");
$(container).addClass("containerBox");
if (id != null) {
$(container).attr("id", id);
}
var containerHeader = document.createElement("p");
$(containerHeader).addClass("header");
var img = document.createElement("img");
$(containerHeader).append(img);
$(containerHeader).append(document.createTextNode(header));
$(container).append(containerHeader);
for ( var i = 0; i < containerInfo.length; i++) {
if (containerInfo[i].label == null) {
containerInfo[i].label = "";
}
if (containerInfo[i].name == null) {
containerInfo[i].name == "";
}
if (containerInfo[i].children == null) {
this.appendEdtiors(container, containerInfo[i].label,
containerInfo[i].nameCN, containerInfo[i].name,
containerInfo[i].paramTypeModel);
} else {
$(container).append(
this.createEditorContainer(containerInfo[i].nameCN, null,
containerInfo[i].children));
}
}
return container;
};
ContainerFactory.prototype.appendEdtiors = function(container, label, name, id,
editorInfo) {
var editorFactory = new EditorFactory();
if (editorInfo.type.toLowerCase() == "field") {
$(container).append(
editorFactory.createField(label, name, editorInfo.size, id));
} else if (editorInfo.type.toLowerCase() == "nfield") {
$(container).append(
editorFactory.createMultiField(label, name, editorInfo.size,
id));
} else if (editorInfo.type.toLowerCase() == "table") {
$(container).append(
editorFactory.createTable(label, name, editorInfo.cols, id));
} else if (editorInfo.type.toLowerCase() == "file") {
$(container).append(
editorFactory.createFile(lable, name, editorInfo.size, id));
} else if (editorInfo.type.toLowerCase() == "date") {
$(container).append(
editorFactory.createDate(label, name, editorInfo.size, id));
} else if (editorInfo.type.toLowerCase() == "select") {
$(container).append(
editorFactory.createSelect(label, name, editorInfo.size,
editorInfo.options, id));
} else if (editorInfo.type.toLowerCase() == "checkbox") {
$(container).append(
editorFactory.createCheckBox(label, name,
editorInfo.choiceModels, id));
} else {
alert("no such editor type:" + editorInfo.type);
}
};

View File

@ -0,0 +1,157 @@
var Parameter = function(key, value) {
this.key = key;
this.value = value;
}
var DataCollector = function() {
};
DataCollector.prototype.validate = function(value) {
if (value == null || value == "") {
alert($.i18n.prop('dataCollect-input'));
return false;
}
return true;
}
DataCollector.prototype.checkBoxData = function(editor) {
var name = editor.attr("id");
var choice = editor.find("input[type='checkbox']");
var value = choice.is(':checked');
return new Parameter(name, value);
}
DataCollector.prototype.fieldData = function(editor) {
var name=$(editor).attr("id");
editor = $(editor.children('.field'));
var value = editor.children("input").val();
if (!this.validate(value)) {
return false;
}
return new Parameter(name, value);
};
DataCollector.prototype.dateData = function(editor) {
var name = editor.attr("id");
var value = editor.children("input").val();
if (!this.validate(value)) {
return false;
}
return new Parameter(name, value);
};
DataCollector.prototype.multiFieldData = function(editor) {
var editorArray = editor.children(".field");
if (editorArray.size == 0) {
alert($.i18n.prop('dataCollect-input'));
return;
}
var name = editor.attr("id")
var value = "";
for ( var i = 0; i < editorArray.length; i++) {
var fieldVlaue = $(editorArray[i]).children("input").val();
value += fieldVlaue + ";";
}
value = value.substring(0, value.length - 1);
if (!this.validate(value)) {
return false;
}
return new Parameter(name, value);
};
DataCollector.prototype.tableData = function(editor) {
var editorArray = editor.find("tbody").children("tr");
var name = editor.attr("id");
var value = "";
for ( var i = 0; i < editorArray.length; i++) {
var tdArray = $(editorArray[i]).children("td");
var trValue = "";
for ( var j = 1; j < tdArray.length; j++) {
trValue += $(tdArray[j]).children("input").val() + "|";
}
trValue = trValue.substring(0, trValue.length - 1);
value += trValue + ";";
}
value = value.substring(0, value.length - 1);
if (!this.validate(value)) {
return false;
}
return new Parameter(name, value);
};
DataCollector.prototype.selectData = function(editor) {
var name = editor.attr("id");
var value = editor.children("select").val();
if (!this.validate(value)) {
return false;
}
return new Parameter(name, value);
};
DataCollector.prototype.getUnitParams = function(paramEditors) {
var params = new Array();
for ( var i = 0; i < paramEditors.length; i++) {
var editor = $(paramEditors[i]);
var editorType = editor.attr("editorType");
var data;
if (editorType == "field") {
data = this.fieldData(editor);
if (!data) {
return;
}
params.push(data);
} else if (editorType == "date") {
data = this.dateData(editor);
if (!data) {
return;
}
params.push(data);
} else if (editorType == "multiField") {
data = this.multiFieldData(editor)
if (!data) {
return;
}
params.push(data);
} else if (editorType == "table") {
data = this.tableData(editor);
if (!data) {
return;
}
params.push(data);
} else if (editorType == "select") {
data = this.selectData(editor);
if (!data) {
return;
}
params.push(data);
} else if (editorType == "checkBox") {
data = this.checkBoxData(editor);
if (!data) {
return;
}
params.push(data);
} else {
alert($.i18n.prop('dataCollect-errorType'));
}
}
return params;
};
var UsePluginModel = function(id, name, parameters) {
this.id = id;
this.name = name;
this.parameters = parameters;
}
function getPluginData(id, container, pluginName) {
var dataCollector = new DataCollector();
var params = dataCollector.getUnitParams($(container).find(".editor"));
return new UsePluginModel(id, pluginName, params)
}

View File

@ -0,0 +1,254 @@
var EditorFactory = function() {
};
EditorFactory.prototype.createBaseEditor = function(label, id) {
if (label == null) {
label = "";
}
var containerBox = document.createElement("div");
$(containerBox).addClass("containerBox");
var boxHeader = document.createElement("div");
var p = document.createElement("p")
$(p).html(label)
$(boxHeader).append(p);
$(boxHeader).addClass("header")
$(containerBox).append(boxHeader);
var boxBody = document.createElement("div");
$(boxBody).addClass("editor");
$(boxBody).attr("id", id);
$(containerBox).append(boxBody);
return containerBox;
}
EditorFactory.prototype.createCheckBox = function(label, name, choices, id) {
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "checkBox");
for ( var i = 0; i < choices.length; i++) {
var choice = this.createChoice(choices[i].value,
choices[i].defaultValue, name);
$(div).children(".editor").append(choice);
}
return div;
}
EditorFactory.prototype.createChoice = function(value, defaultValue, name) {
var div = document.createElement("div");
var input = document.createElement("input");
$(input).attr("type", "checkbox");
$(input).attr("name", name);
if (defaultValue) {
$(input).attr("checked", "checked");
}
$(div).append(input);
var label = document.createElement("label");
$(label).html(value);
$(div).append(label);
return div;
}
EditorFactory.prototype.createField = function(label, name, size, id) {
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "field");
$(div).children(".editor").append(this.createFieldLine(size, name));
return div;
}
EditorFactory.prototype.createMultiField = function(label, name, size, id) {
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "multiField");
$(div).children(".editor").append(this.createFieldLine(size, name));
var editorFactory = this;
var addFieldButton = document.createElement("button");
$(addFieldButton).html("add")
$(addFieldButton).attr("type", "submit");
$(addFieldButton).click(
{
editorFactory : editorFactory
},
function(event) {
event.preventDefault()
$(event.data.editorFactory.createFieldLine(size, name))
.insertBefore($(this));
});
var removeFieldButton = document.createElement("button");
$(removeFieldButton).html("remove")
$(removeFieldButton).attr("type", "submit");
$(removeFieldButton).click(function(event) {
event.preventDefault();
$(this).parent().children(".field").last().remove();
});
$(div).children(".editor").append(addFieldButton).append(removeFieldButton);
return div;
}
EditorFactory.prototype.createFieldLine = function(size, name) {
size = 150;
var fieldDiv = document.createElement("div");
$(fieldDiv).addClass("field");
var fieldName = document.createElement("label");
$(fieldName).html(name);
var field = document.createElement("input");
$(field).attr("type", "text");
$(fieldDiv).append(fieldName.outerHTML + field.outerHTML);
return fieldDiv;
}
EditorFactory.prototype.createFile = function(label, name, size, id) {
if (size == null || size <= 0) {
size = 150;
}
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "file");
var fileEditor = document.createElement("div");
var fieldName = document.createElement("label");
$(fieldName).html(name);
var file = document.createElement("input");
$(file).attr("type", "file");
$(fileEditor).append(fieldName.outerHTML + file.outerHTML);
$(div).children(".editor").append(fileEditor);
return div;
}
EditorFactory.prototype.createTable = function(label, name, cols, id) {
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "table");
var headers = getHeaders(cols);
$(div).children(".editor").append(createTable(cols, name, headers));
var addButton = document.createElement("button");
$(addButton).html("add");
$(addButton).click(
{
headers : headers,
fieldName : name
},
function(event) {
event.preventDefault();
$(this).parent().children("table").children("tbody").append(
createTr(event.data.headers, event.data.fieldName));
});
var deleteButton = document.createElement("button");
$(deleteButton).html("remove");
$(deleteButton).click(
function(event) {
event.preventDefault();
$(this).parent().children("table").children("tbody").children(
"tr").last().remove();
});
$(div).children(".editor").append(addButton);
$(div).children(".editor").append(deleteButton);
return div;
function getHeaders(col) {
var headers = new Array();
headers.push("name:");
var cols = col.split(";");
for ( var i = 0; i < cols.length; i++) {
headers.push(cols[i]);
}
return headers;
}
function createTable(cols, name, headers) {
var table = document.createElement("table");
var thead = document.createElement("thead");
var tbody = document.createElement("tbody");
$(thead).append(createHeader(headers));
$(tbody).append(createTr(headers, name));
$(table).append(thead);
$(table).append(tbody);
return table;
}
function createHeader(headers) {
var tr = document.createElement("tr");
for ( var i = 0; i < headers.length; i++) {
var th = document.createElement("th");
$(th).append(document.createTextNode(headers[i]));
$(th).attr("style", "width:" + 100 / headers.length + "%")
$(tr).append(th);
}
return tr;
}
function createTr(headers, name) {
var tr = document.createElement("tr");
var td = document.createElement("td");
$(td).attr("style", "width:" + 100 / headers.length + "%")
$(td).html(name);
$(tr).append(td);
for ( var i = 1; i < headers.length; i++) {
var input = document.createElement("input");
$(input).attr("type", "text");
var td = document.createElement("td");
$(td).attr("style", "width:" + 100 / headers.length + "%")
$(td).append(input);
$(tr).append(td);
}
return tr;
}
}
EditorFactory.prototype.createSelect = function(label, name, size, options, id) {
if (size == null || size <= 0) {
size = 150;
}
if (options == null || options.length <= 0) {
alert("no options in:" + name);
}
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "select");
var nameLabel = document.createElement("label");
$(nameLabel).html(name);
$(div).children(".editor").append(nameLabel);
var select = document.createElement("select");
$(select).attr("style", "width:" + size + "px");
for ( var i = 0; i < options.length; i++) {
var option = document.createElement("option");
$(option).attr("value", options[i]);
$(option).html(options[i]);
$(select).append(option);
}
$(div).children(".editor").append(select);
return div;
}
EditorFactory.prototype.createDate = function(label, name, size, id) {
if (size == null || size < 0) {
size = 150
}
var div = this.createBaseEditor(label, id);
$(div).children(".editor").attr("editorType", "date");
var dateLabel = document.createElement("label");
$(dateLabel).html(name);
var date = document.createElement("input");
$(date).attr("type", "date");
$(div).children(".editor").append(dateLabel);
$(div).children(".editor").append(date);
return div;
}
function createContainer(id, name) {
var edtiorFactory = new EditorFactory();
var div = document.createElement("div");
$(div).attr("id", id);
$(div).append(edtiorFactory.createMultiField("test", "name", 150, "test"));
$(div).append(edtiorFactory.createFile("file", "file name", 150, "file"));
$(div).append(
edtiorFactory.createField("field", "field name", 150, "field"));
$(div).append(
edtiorFactory.createTable("table", "input", "td1;td1;td3", "id"));
$(div).append(
edtiorFactory.createSelect("select", "select", 150, [ 1, 2, 3 ],
"oo"));
$(div).append(edtiorFactory.createDate("date", "date", 150, "dateid"));
return div;
}

View File

@ -0,0 +1,29 @@
function dataTransfer(serverData) {
var Container = function(name, children) {
this.name = name;
this.children = children;
};
var editorInfos = new Array();
var paramInfos = serverData.paramInfoModels;
var groupInfos = serverData.groupModels;
if (paramInfos!= null) {
for ( var i = 0; i < paramInfos.length; i++) {
editorInfos.push(paramInfos[i]);
}
}
if (serverData.groupModels != null) {
for ( var i = 0; i < groupInfos.length; i++) {
var container = new Container(groupInfos[i].name,
dataTransfer(groupInfos[i]));
editorInfos.push(container);
}
}
var editorInfos = editorInfos.sort(function(a, b) {
return a.name.localeCompare( b.name);
});

View File

@ -0,0 +1,16 @@
function usePlugin(){
this.map=new
this.getPluginList=function(){
$.post("loadPluginName",{},function(){
}
);
}
}

View File

@ -1,7 +1,7 @@
var table = $('#scriptTab');
$(document).ready(function() {
setTable();
loadTestPlans($("#testPlanTab"));
loadTestPlans($("#testPlanTab").DataTable());
loadScript(table, 1);
});

View File

@ -1,7 +1,8 @@
function loadScript(table) {
var editButton = "<a class='btn btn-success edit' ><i class='icon-edit icon-white'></i>"+$.i18n.prop('script-edit')+"</a>";
var deleteButton = "<a class='btn btn-info delete'><i class='icon-trash icon-white'></i>"+$.i18n.prop('delete')+"</a>";
var editButton = "<a class='btn btn-success edit' ><i class='icon-edit icon-white'></i>"
+ $.i18n.prop('script-edit') + "</a>";
var deleteButton = "<a class='btn btn-info delete'><i class='icon-trash icon-white'></i>"
+ $.i18n.prop('delete') + "</a>";
table.clear();
$.post("loadScripts", {}, function(data) {
if (data.success) {
@ -10,8 +11,9 @@ function loadScript(table) {
return;
}
for ( var i = 0; i < scripts.length; i++) {
var tr=
table.row.add([i+1,scripts[i].name,new Date(scripts[i].createDateTime),
var tr = table.row.add(
[ i + 1, scripts[i].name,
new Date(scripts[i].createDateTime),
editButton + deleteButton ]).draw().node();
$(tr).attr("id", scripts[i].id);
@ -21,13 +23,15 @@ function loadScript(table) {
alert(data.failedMessage);
}
var tbody = table.table().body();
$(tbody).on("click","td a.delete",function(){
$(tbody).on("click", "td a.delete", function(e) {
e.preventDefault();
var row = $(this).closest("tr");
var scriptId = $(row).attr("id");
deleteScript(scriptId, table.row(row));
});
$(tbody).on("click","td a.edit",function(){
$(tbody).on("click", "td a.edit", function(e) {
e.preventDefault();
var row = $(this).closest("tr");
var scriptId = $(row).attr("id");
var scriptId = $(row).attr("id");
@ -35,7 +39,6 @@ function loadScript(table) {
editScript(scriptId, scriptName);
});
}, "json");
}

View File

@ -1,18 +1,22 @@
function loadTestPlans(table) {
var downLoadButton = "<a class='btn btn-success download' >"+$.i18n.prop('report')+"</a>";
var deleteButton = "<a class='btn btn-info delete'>"+$.i18n.prop('delete')+"</a>";
var downLoadButton = "<a class='btn btn-success download' >"
+ $.i18n.prop('report') + "</a>";
var deleteButton = "<a class='btn btn-info delete'>"
+ $.i18n.prop('delete') + "</a>";
var viewResult = "<a class='btn btn-info result'><i class='icon-zoom-in icon-white'></i>"
+ $.i18n.prop('view') + " " + "</a>";
table.dataTable().fnClearTable();
table.clear();
$.get("loadTestPlans", {}, function(data) {
if (data.success) {
var testPlans = data.testPlans;
for ( var i = 0; i < testPlans.length; i++) {
var addRow = table.dataTable().fnAddData(
[ i, testPlans[i].name,testStatusMap( testPlans[i].currentStatus),
var tr = table.row.add(
[ i, testPlans[i].name,
testStatusMap(testPlans[i].currentStatus),
new Date(testPlans[i].createDateTime),
viewResult, deleteButton + downLoadButton ]);
var tr = table.dataTable().fnSettings().aoData[addRow[0]].nTr;
viewResult, deleteButton + downLoadButton ])
.draw().node();
$(tr).attr("testPlanRunId", testPlans[i].testPlanRunId);
$(tr).attr("id", testPlans[i].id);
}
@ -22,22 +26,28 @@ function loadTestPlans(table) {
}
$('.download').click(function(e) {
var tbody = table.table().body();
$(tbody).on("click", "td a.download", function(e) {
e.preventDefault();
var testPlanId = $(this).closest("tr").attr("id");
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("testPlanRunId");
downloadResult(testPlanId);
});
$('.delete').click(function(e) {
$(tbody).on("click", "td a.delete", function(e) {
e.preventDefault();
var testPlanId = $(this).closest("tr").attr("id");
var row= $(this).closest("tr");
deleteTest(testPlanId,table,row);
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("id");
var row = table.row(tr);
deleteTest(testPlanId, row);
});
$('.result').click(function(e) {
$(tbody).on("click", "td a.result", function(e) {
e.preventDefault();
var testPlanId = $(this).closest("tr").attr("testPlanRunId");
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("testPlanRunId");
window.open("result.jsp?testPlanId=" + testPlanId);
});
}, "json");
}
function downloadResult(testPlanId) {
@ -53,12 +63,12 @@ function downloadResult(testPlanId) {
form.append(input1);
form.submit();
}
function deleteTest(testPlanId,table,row) {
function deleteTest(testPlanId, row) {
$.post("deleteTest", {
testPlanId : testPlanId
}, function(data) {
if (data.success) {
$(table).dataTable().fnDeleteRow(row.index());
row.remove().draw();
} else {
alert($.i18n.prop('fail'));
}

View File

@ -1,5 +1,5 @@
$(document).ready(function() {
var table = $("#table");
var table = $("#table").DataTable();
loadTestPlans(table);
});

101
Bench4Q-Web/sut.xml Normal file
View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<testResult>
<results>
<result>
<children>
<name>使用率</name>
<value>processorTimePercent</value>
</children>
<children>
<name>系统使用率</name>
<value>privilegedTimePercent</value>
</children>
<children>
<name>用户使用率</name>
<value>userTimePercent</value>
</children>
<name>cpu</name>
<value>cpu</value>
</result>
<result>
<children>
<name>页速率</name>
<value>pagesPerSecond</value>
</children>
<children>
<name>读页速率</name>
<value>pagesInputPerSecond</value>
</children>
<children>
<name>写页速率</name>
<value>pagesOutputPerSecond</value>
</children>
<children>
<name>可用内存(KB)</name>
<value>availableKiloBytes</value>
</children>
<children>
<name>总容量(KB)</name>
<value>totalKiloBytes</value>
</children>
<children>
<name>使用率</name>
<value>memoryUsedPercent</value>
</children>
<children>
<name>交换内存(KB)</name>
<value>swapKiloBytes</value>
</children>
<name>内存</name>
<value>memory</value>
</result>
<result>
<children>
<name>读速率(KB/S)</name>
<value>diskReadKBytesRate</value>
</children>
<children>
<name>写速率(KB/S)</name>
<value>diskWriteKBytesRate</value>
</children>
<children>
<name>总速率(KB)</name>
<value>diskTotalKBytesRate</value>
</children>
<children>
<name>等待队列</name>
<value>curDiskQueLength</value>
</children>
<children>
<name>总容量(GB)</name>
<value>totalGB</value>
</children>
<children>
<name>占用量(GB)</name>
<value>usedGB</value>
</children>
<children>
<name>使用率</name>
<value>usedPercent</value>
</children>
<name>磁盘</name>
<value>physicalDisk</value>
</result>
<result>
<children>
<name>总速率(KB/S)</name>
<value>kiloBytesTotalPerSecond</value>
</children>
<children>
<name>接收速率(KB/S)</name>
<value>kiloBytesReceivedPerSecond</value>
</children>
<children>
<name>发送率(KB/S)</name>
<value>kiloBytesSentPerSecond</value>
</children>
<name>网络</name>
<value>network</value>
</result>
</results>
</testResult>