From 1f031c4cadb9daff3e7f8485843aba88bc6a5307 Mon Sep 17 00:00:00 2001 From: daisyonly <1241945585@qq.com> Date: Thu, 4 Sep 2014 15:06:30 +0800 Subject: [PATCH] Revert "edit CsvProvider Plugin" This reverts commit ed466e085ab3187da7df8e4f9c2ce0e933d77ed3. --- .../agent/plugin/basic/csvprovider/ui.xml | 2 +- .../script/scriptManager/containerFactory.js | 3 +- .../scriptManager/contentVerification.js | 15 +++------ .../script/scriptManager/createScript.js | 8 ++--- .../script/scriptManager/dataCollect.js | 32 ++----------------- .../script/scriptManager/editorFactory.js | 9 ++---- .../script/scriptManager/scriptEditor.js | 7 ++-- .../script/scriptManager/submitScript.js | 25 ++++++--------- .../webapp/script/scriptManager/usePlugin.js | 6 ++-- 9 files changed, 33 insertions(+), 74 deletions(-) diff --git a/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/csvprovider/ui.xml b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/csvprovider/ui.xml index 125210aa..15fe9f90 100644 --- a/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/csvprovider/ui.xml +++ b/Bench4Q-Agent/src/main/java/org/bench4q/agent/plugin/basic/csvprovider/ui.xml @@ -1,5 +1,5 @@ - + diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/containerFactory.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/containerFactory.js index ae084a89..e59e02f1 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/containerFactory.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/containerFactory.js @@ -22,6 +22,7 @@ ContainerFactory.prototype.createEditorContainer = function(header, id, containerInfo[i].name == ""; } if (containerInfo[i].children == null) { + console.log(containerInfo[i]); this.appendEdtiors(container, containerInfo[i].label, containerInfo[i].nameCN, containerInfo[i].required, containerInfo[i].name, containerInfo[i].paramTypeModel,containerInfo[i].value == null ?"":containerInfo[i].value); @@ -58,7 +59,7 @@ ContainerFactory.prototype.appendEdtiors = function(container, label, name, requ } else if (editorInfo.type.toLowerCase() == "file") { $(container).append( - editorFactory.createFile(label, name, required, editorInfo.size, id,value)); + editorFactory.createFile(label, name, required, editorInfo.size, id,value)); } else if (editorInfo.type.toLowerCase() == "date") { $(container).append( editorFactory.createDate(label, name, required, editorInfo.size, id,value)); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js index 0f8eab00..c5afa008 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js @@ -1,19 +1,13 @@ $(function() { + $(document).ready(function(){ $("#behaviorEditor").on("focusout",".editor input",function(){ var input = $(this); if(input.attr("required") == "required" && input.val() == ""){ information("Please fill in the parameter"); input.focus(); } - }); - $("#pluginEditor").on("focusout",".editor input",function(){ - var input = $(this); - if(input.attr("required") == "required" && input.val() == ""){ - if (input.attr("type") != "file") - information("Please fill in the parameter"); - input.focus(); - } - }); + }) + }); }); function checkPluginsInput(plugins) { @@ -34,7 +28,8 @@ function checkPagesInput(pages) { if (pages[i].batches[j].behaviors[k].parameters[q].check == "false"){ return false; } - } + } + } } } diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js index 21316174..ba5deccd 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js @@ -4,13 +4,11 @@ $(function() { // usePlugin.getPluginList(); $("#submitScript").click(function() { - var formData = new FormData(); - var plugins = usePlugin.getPlugins( formData ); + var plugins = usePlugin.getPlugins(); var pages = usePlugin.getPages(); if(checkPluginsInput(plugins) && checkPagesInput(pages)) - submitScript(pages, plugins, formData); + submitScript(pages,plugins); else - information("Please complete the required parameters."); - + information("必填的参数没有填写完整,请补充完整后提交"); }); }); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/dataCollect.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/dataCollect.js index 5ace2030..0712eb84 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/dataCollect.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/dataCollect.js @@ -36,36 +36,13 @@ DataCollector.prototype.fieldData = function(editor) { // if (!this.validate(value)) { // return false; // } + var required = editor.children("input").attr("required"); var check = "true"; if (required == "required" && value == "") check = "false"; return new Parameter(name, value, check); }; - -DataCollector.prototype.fileData = function(editor, formData) { - - var check = "true"; - var value = null; - var inputs = editor.find("input"); - if ($(inputs[0]).attr("checkFile") != undefined){ - value = $(inputs[0]).attr("checkFile"); - } - else{ - if (inputs[0].files.length == 0){ - check = "false"; - } - else{ - var file = inputs[0].files[0]; - formData.append("paramFiles", file); - value = file.name; - } - } - var name = editor.attr("id"); - - return new Parameter(name, value, check); -} - DataCollector.prototype.dateData = function(editor) { var name = editor.attr("id"); var value = editor.children("input").val(); @@ -149,7 +126,7 @@ DataCollector.prototype.selectData = function(editor) { return new Parameter(name, value); }; -DataCollector.prototype.getUnitParams = function(paramEditors, fromData) { +DataCollector.prototype.getUnitParams = function(paramEditors) { var params = new Array(); for ( var i = 0; i < paramEditors.length; i++) { var editor = $(paramEditors[i]); @@ -194,10 +171,7 @@ DataCollector.prototype.getUnitParams = function(paramEditors, fromData) { return; } params.push(data); - }else if (editorType == "file"){ - data = this.fileData(editor, fromData); - params.push(data); - }else { + } else { information($.i18n.prop('dataCollect-errorType')); } diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js index 0387b936..6d660d65 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/editorFactory.js @@ -115,6 +115,7 @@ EditorFactory.prototype.createFile = function(label, name, required, size, id, v if (size == null || size <= 0) { size = 150; } + var div = this.createBaseEditor(label, id, required); $(div).children(".editor").attr("editorType", "file"); var fileEditor = document.createElement("div"); @@ -123,18 +124,12 @@ EditorFactory.prototype.createFile = function(label, name, required, size, id, v $(fieldName).html(name); var file = document.createElement("input"); $(file).attr("type", "file"); - if(value != ""){ - $(file).attr("checkFile", value); - } - if(required == "true"){ $(file).attr("required", "required"); } +// $(field).attr("maxlength", size); $(fileEditor).append(fieldName.outerHTML + file.outerHTML); $(div).children(".editor").append(fileEditor); - var label = document.createElement("label"); - $(label).html(value); - $(div).append(label); return div; } diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js index bf37750f..8b59c4a8 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js @@ -29,14 +29,15 @@ $(function() { var usePlugin = new UsePlugin("useBehaviorList"); getScriptObject(scriptId,usePlugin); $("#scriptName").val(getvars()['name']); + $("#tabs").tabs(); + $("#submitScript").click(function() { - var formData = new FormData(); - var plugins = usePlugin.getPlugins(formData); + var plugins = usePlugin.getPlugins(); var pages = usePlugin.getPages(); if(checkPluginsInput(plugins) && checkPagesInput(pages)) - updateScript(scriptId,pages,plugins,formData); + updateScript(scriptId,pages,plugins); else information("必填的参数没有填写完整,请补充完整后提交"); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/submitScript.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/submitScript.js index e60deab9..cbfc95cb 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/submitScript.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/submitScript.js @@ -28,7 +28,7 @@ function CollectScriptData(behavior) { // this.behaviors = behaviors; //} -function submitScript(pages,usePlugins, formData) { +function submitScript(pages,usePlugins) { var scriptName = $("#scriptName").val(); @@ -37,47 +37,42 @@ function submitScript(pages,usePlugins, formData) { return; } var runScenarioModel = new RunScenarioModel(0,usePlugins,new Array(),pages); - formData.append("runScenarioModelStr", JSON.stringify(runScenarioModel)); + $.ajax({ type : "POST", url : "submitScriptCreated" + "/" + scriptName, - data :formData, - processData: false, - contentType: false, + data :{runScenarioModelStr: JSON.stringify(runScenarioModel)},//JSON.stringify(runScenarioModel), +// dataType : "json", +// contentType : "application/json", success : function(data) { if (!data.success) { return; } else { information("success"); - formData = new FormData(); } } }); } -function updateScript(scriptId, pages, usePlugins ,formData){ +function updateScript(scriptId, pages, usePlugins){ var scriptName = $("#scriptName").val(); if (scriptName == undefined || scriptName == "") { information("need a script name!"); return; } var runScenarioModel = new RunScenarioModel(0,usePlugins,new Array(),pages); - formData.append("runScenarioModelStr", JSON.stringify(runScenarioModel)); - formData.append("scriptId",scriptId); - formData.append("scriptName",scriptName); - console.log(formData); + $.ajax({ type : "POST", url : "updateScript", - data :formData, - processData: false, - contentType: false, + data :{scriptId:scriptId,scriptName:scriptName, runScenarioModelStr: JSON.stringify(runScenarioModel)},//JSON.stringify(runScenarioModel), +// dataType : "json", +// contentType : "application/json", success : function(data) { if (!data.success) { return; } else { information("success"); - formData = new FormData(); } } }); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js index df22c6c3..69909033 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js @@ -125,7 +125,7 @@ function UsePlugin(behaviorListContainerId) { return; } usePluginEditorMap.put($("#pluginEditor").attr("usePlugin"), $( - "#pluginEditor div:first").clone(true)); + "#pluginEditor div:first").clone()); $("#pluginEditor").attr("usePlugin", ""); $("#pluginEditor").html(""); @@ -175,7 +175,7 @@ function UsePlugin(behaviorListContainerId) { return containerId; } //this is for submit - this.getPlugins = function(formData) { + this.getPlugins = function() { updateUsePlugin(); var keys = map.getKeys(); var usePlugins = new Array(); @@ -184,7 +184,7 @@ function UsePlugin(behaviorListContainerId) { var usePluginViewModel = map.get(id); var usePluginContainer = usePluginEditorMap.get(id); var params = paramDataCollector.getUnitParams($( - usePluginContainer).find(".editor"), formData); + usePluginContainer).find(".editor")); usePlugins.push(new UsePluginModel(usePluginViewModel.id, usePluginViewModel.name,usePluginViewModel.nickName, params)); } return usePlugins;