remove the bug when click buton .event occur many times

This commit is contained in:
fanfuxiaoran 2014-07-17 10:11:14 +08:00
parent 0be40aa486
commit ed8ee5f016
11 changed files with 161 additions and 158 deletions

View File

@ -6,6 +6,7 @@ import java.util.Map;
import javax.xml.bind.JAXBException;
import org.apache.log4j.Logger;
import org.bench4q.share.helper.ExceptionLog;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.agent.RunScenarioModel;
@ -135,7 +136,7 @@ public class ScriptController extends BaseController {
try {
MarshalHelper.unmarshal(ScenarioModel.class, script);
} catch (JAXBException e) {
ExceptionLog.getStackTrace(e);
Logger.getLogger(this.getClass()).info(ExceptionLog.getStackTrace(e));
return fail(map, "error script file");
}

View File

@ -4,10 +4,7 @@
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<title>Agent manage</title>
<link
href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css"
rel="stylesheet">
<title>Bench4Q</title>
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
@ -15,9 +12,10 @@
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href="lib/dataTable/css/jquery.dataTables.css" rel="stylesheet">
<link rel="shortcut icon" href="images/bench4q.png">
<style type="text/css">
<link href="lib/dataTable/css/jquery.dataTables.css" rel="stylesheet">
</head>
<style>
body {
min-height: 600px;
padding-bottom: 40px;
@ -144,7 +142,7 @@ body {
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script src="lib/dataTable/js/jquery.dataTables.js"></script>
<script src="lib/dataTable/js/jquery.dataTables.js"></script>>
<script src="lib/bootstrap/js/bootstrap-modal.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.1/bootstrap.min.js"></script>
@ -152,6 +150,7 @@ body {
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script src="script/base.js"></script>
<script src="script/bench4q.table.js"></script>
<script src="script/admin/agentManage.js"></script>

View File

@ -4,11 +4,14 @@
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<title>PortManage Page</title>
<title>Bench4Q</title>
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link rel="shortcut icon" href="images/bench4q.png">
<link href="lib/dataTable/css/jquery.dataTables.css" rel="stylesheet">
</head>
@ -103,7 +106,6 @@
<script src="lib/chrisma/js/theme.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="script/base.js"></script>
<script src="script/bench4q.table.js"></script>
<script src="script/admin/portManage.js"></script>
</fmt:bundle>
</body>

View File

@ -16,9 +16,6 @@
class="icon-file"></i><span class="hidden-tablet"><fmt:message
key="pluginmanage"></fmt:message></span></a>
</ul>
<label id="for-is-ajax" class="hidden-tablet" for="is-ajax">
<input id="is-ajax" type="checkbox"> Ajax on menu
</label>
</div>
</fmt:bundle>
</div>

View File

@ -12,6 +12,16 @@ var agentTableModel = new Array("hostName", "port", "currentStatus", "maxLoad",
$(document).ready(function() {
var table = $('#agents').DataTable();
var tbody = table.table().body();
$(tbody).on('click', 'td a.delete', function(e) {
e.preventDefault();
var row = $(this).closest("tr");
var id = $(row).attr("id");
row = table.row(row);
var hostName =row.data()[0]
deleteAgent(id, hostName, row);
});
loadAgents(table);
});
@ -33,15 +43,6 @@ function loadAgents(table) {
}
}
var tbody = table.table().body();
$(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");
deleteAgent(id, hostName, row);
});
} else {
$("#dialog").html($.i18n.prop('fail'));
@ -74,7 +75,7 @@ function deleteAgent(id, hostName, row) {
hostName : hostName
}, function(data) {
if (data.success)
row.remove();
row.remove().draw();
else {
alert(data.failedMessage);
}

View File

@ -1,21 +1,23 @@
var portTableModel = new Array("id", "port", "inUse");
var portColumnIndex = {
"id" : 0,
"port" : 1,
"inUse" : 2
};
var deleteButton = "<a class='btn btn-info delete' ><i class='icon-trash icon-white'></i>Delete</a>";
$(document).ready(function() {
var table = $('#table').DataTable();
var tbody = table.table().body();
$(tbody).on('click', ' td a.delete', function() {
var row = $(this).closest('tr');
var portId = $(row).attr("id");
row = table.row(row);
deletePort(row, portId);
});
loadPorts(table);
});
function deletePort(row,portId) {
function deletePort(row, portId) {
$.post("removePort", {
port : portId
}, function(data) {
if (data.success) {
row.remove();
row.remove().draw();
} else
alert(data.failedMessage);
});
@ -34,26 +36,22 @@ function addPort(params) {
});
}
function loadPorts(table) {
var deleteButton = "<a class='btn btn-info delete' ><i class='icon-trash icon-white'></i>"+$.i18n.prop('delete')+"</a>";
table.clear();
$.post("loadPorts", function(data) {
if (data.success) {
if (data.ports != null)
for ( var i = 0; i < data.ports.length; i++) {
table.row.add(
extractRowData(data.ports[i], portTableModel,
deleteButton)).draw();
var tr = table.row.add(
[i,data.ports[i].port,data.ports[i].inUse,
deleteButton]).draw().node();
$(tr).attr("id", data.ports[i].id);
}
} else {
alert(data.failedMessage);
}
var tbody = table.table().body();
$(tbody).on('click', ' td a.delete', function() {
var row = $(this).closest('tr');
row=table.row(row);
var portId=row.data()[0];
deletePort(row,portId);
});
});
}
$("#plus").click(function(e) {

View File

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

View File

@ -1,78 +1,78 @@
var server=null;
var table=$("#scriptTab").DataTable(
);
var server = null;
var table = $("#scriptTab").DataTable();
$('.btn-setting').click(function(e) {
e.preventDefault();
$('#myModal').modal('show');
});
function startServer() {
$.post(
"startRecordServer",
{},
function(data) {
if(data.success){
server = data.server;
$('#scriptInfo').text( "Please use the proxy with the IP:133.133.133.87"
+ " and the port: "
+ server.port
+ " to record the script.");
$('#startServer').attr('disabled', true);
$('#stopServer').attr('disabled', false);
}
else{
$('#scriptInfo').html("Fail to start record server:"+data.failedMessage);
}
}, "json");
}
$('#uploadScript').click(function(){
var myModalContent=$('#myModal').html();
$(".modal-footer").html("");
var uploadForm='<form method="post" enctype="multipart/form-data" action="uploadScriptFile">'+
'<p>script name:<input class="input-mini" type="text" name="scriptName" ></p>'+
'<p>script to upload: <input type="file" name="scriptFile"/></p>'+
'<p><input type="submit"/></p></form>';
var status="<div id='status'><h3></h3><div>";
$('#scriptInfo').html("");
$('#scriptInfo').html(uploadForm+status);
$('form').ajaxForm({
success: function(data){
if(data.success)
$("#status").text(data.message);
else
$("#status").text(data.failedMessage);
}
});
$('#myModal-close').click(function(){
$('#myModal').html(myModalContent);
$('#myModal').modal('hide');
});
});
function stopServer() {
if(server!=null){
$.post("stopRecordServer", {
port : server.port,
scriptRecordUUID : server.fileName
}, function(data) {
if (!data.success){
$('#scriptInfo').text("stop record server error:"+data.failedMessage);
$('#stopServer').attr('disabled', true);
$('#startServer').attr('disabled', false);
}
else {
$('#fileName').show();
$.post("startRecordServer", {}, function(data) {
if (data.success) {
server = data.server;
$('#scriptInfo').text(
"The script recording has been stopped,"
+ " please input the script name and save it");
"Please use the proxy with the IP:133.133.133.87"
+ " and the port: " + server.port
+ " to record the script.");
$('#startServer').attr('disabled', true);
$('#stopServer').attr('disabled', false);
} else {
$('#scriptInfo').html(
"Fail to start record server:" + data.failedMessage);
}
}, "json");
}
else{
}
$('#uploadScript')
.click(
function() {
var myModalContent = $('#myModal').html();
$(".modal-footer").html("");
var uploadForm = '<form method="post" enctype="multipart/form-data" action="uploadScriptFile">'
+ '<p>script name:<input class="input-mini" type="text" name="scriptName" ></p>'
+ '<p>script to upload: <input type="file" name="scriptFile"/></p>'
+ '<p><input type="submit"/></p></form>';
var status = "<div id='status'><h3></h3><div>";
$('#scriptInfo').html("");
$('#scriptInfo').html(uploadForm + status);
$('form').ajaxForm({
success : function(data) {
if (data.success) {
$("#status").text(data.message);
loadScript(table, 2);
}
else
$("#status").text(data.failedMessage);
}
});
$('#myModal-close').click(function() {
$('#myModal').html(myModalContent);
$('#myModal').modal('hide');
});
});
function stopServer() {
if (server != null) {
$.post("stopRecordServer", {
port : server.port,
scriptRecordUUID : server.fileName
}, function(data) {
if (!data.success) {
$('#scriptInfo').text(
"stop record server error:" + data.failedMessage);
$('#stopServer').attr('disabled', true);
$('#startServer').attr('disabled', false);
}
else {
$('#fileName').show();
$('#scriptInfo').text(
"The script recording has been stopped,"
+ " please input the script name and save it");
}
}, "json");
} else {
$('#scriptInfo').text("record script server has not started");
}
@ -88,21 +88,21 @@ function saveScript() {
if (data.success) {
$("#scriptInfo").text("Saving success!");
$('#fileName').hide();
server=null;
server = null;
} else {
$("#scriptInfo").text("Saving failure:"+data.failedMessage);
$("#scriptInfo").text("Saving failure:" + data.failedMessage);
$('#fileName').hide();
}
loadScript(table,2);
loadScript(table, 2);
});
}
$(document).ready(function() {
addEvent(table);
loadScript(table);
$('#stopServer').attr('disabled', true);
});
function refresh(){
location.replace(location) ;
function refresh() {
location.replace(location);
}

View File

@ -22,26 +22,29 @@ function loadScript(table) {
} else {
alert(data.failedMessage);
}
var tbody = table.table().body();
$(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(e) {
e.preventDefault();
var row = $(this).closest("tr");
var scriptId = $(row).attr("id");
var scriptId = $(row).attr("id");
var scriptName = table.row(row).data()[1];
editScript(scriptId, scriptName);
});
}, "json");
}
function addEvent(table) {
var tbody = table.table().body();
$(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(e) {
e.preventDefault();
var row = $(this).closest("tr");
var scriptId = $(row).attr("id");
var scriptId = $(row).attr("id");
var scriptName = table.row(row).data()[1];
editScript(scriptId, scriptName);
});
}
function deleteScript(scriptId, row) {
$.post("deleteScript", {
scriptId : scriptId
@ -49,7 +52,7 @@ function deleteScript(scriptId, row) {
if (data.success) {
alert($.i18n.prop("script-deleteSuc"));
row.remove();
row.remove().draw();
} else {
alert(data.failedMessage);
// error message

View File

@ -26,30 +26,34 @@ function loadTestPlans(table) {
}
var tbody = table.table().body();
$(tbody).on("click", "td a.download", function(e) {
e.preventDefault();
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("testPlanRunId");
downloadResult(testPlanId);
});
$(tbody).on("click", "td a.delete", function(e) {
e.preventDefault();
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("id");
var row = table.row(tr);
deleteTest(testPlanId, row);
});
$(tbody).on("click", "td a.result", function(e) {
e.preventDefault();
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("testPlanRunId");
window.open("result.jsp?testPlanId=" + testPlanId);
});
}, "json");
}
function addEvent(table){
var tbody = table.table().body();
$(tbody).on("click", "td a.download", function(e) {
e.preventDefault();
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("testPlanRunId");
downloadResult(testPlanId);
});
$(tbody).on("click", "td a.delete", function(e) {
e.preventDefault();
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("id");
var row = table.row(tr);
deleteTest(testPlanId, row);
});
$(tbody).on("click", "td a.result", function(e) {
e.preventDefault();
var tr = $(this).closest("tr");
var testPlanId = $(tr).attr("testPlanRunId");
window.open("result.jsp?testPlanId=" + testPlanId);
});
}
function downloadResult(testPlanId) {
var form = $("<form>");// 定义一个form表单
form.attr("style", "display:none");

View File

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