diff --git a/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js b/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js index 00fa1d45451ba3626a4f0ca44e19f4181abfcb31..c56ba6f9bf1cae8cee17d5119db8aa9b7aa01a86 100644 --- a/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js +++ b/o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js @@ -1,29 +1,29 @@ MWF.xDesktop.Actions = MWF.xDesktop.Actions || {}; MWF.xDesktop.Actions.RestActions = new Class({ Implements: [Events], - initialize: function(actionPath, serviceName, root){ - this.actionPath = actionPath; - this.serviceName = serviceName; + initialize: function(actionPath, serviceName, root){ + this.actionPath = actionPath; + this.serviceName = serviceName; this.root = root; - }, - - listApplicationAddress: function(success, failure){ - var url = this.actions.listAddress; - url = this.actions.slotHost+url; - var callback = new MWF.xApplication.Common.Actions.RestActions.Callback(success, failure); - MWF.getJSON(url, callback); - }, - getAddress: function(success, failure){ + }, + + listApplicationAddress: function(success, failure){ + var url = this.actions.listAddress; + url = this.actions.slotHost+url; + var callback = new MWF.xApplication.Common.Actions.RestActions.Callback(success, failure); + MWF.getJSON(url, callback); + }, + getAddress: function(success, failure){ // var name = "x_processplatform_core_designer"; // var url = this.actions.getAddress.replace(/{id}/g, name); // url = this.actions.slotHost+url; // var callback = new MWF.process.RestActions.Callback(success, failure, function(data){ // this.designAddress = data.data.url; // }.bind(this)); - + // MWF.getJSON(url, callback); - - //this.address = "http://xa02.zoneland.net:8080/"+this.serviceName; + + //this.address = "http://xa02.zoneland.net:8080/"+this.serviceName; var addressObj = layout.serviceAddressList[this.serviceName]; if (addressObj){ @@ -38,11 +38,11 @@ MWF.xDesktop.Actions.RestActions = new Class({ } //this.address = "http://hbxa01.bf.ctc.com/"+this.serviceName; - //this.designAddress = "http://localhost:9080/x_processplatform_front_designer"; - if (success) success.apply(); + //this.designAddress = "http://localhost:9080/x_processplatform_front_designer"; + if (success) success.apply(); return this.address; - }, - getActions: function(callback){ + }, + getActions: function(callback){ if (!this.actions){ var url = (this.root) ? "/"+this.root+this.actionPath : MWF.defaultPath+this.actionPath; @@ -68,7 +68,7 @@ MWF.xDesktop.Actions.RestActions = new Class({ } MWF.restful(method, uri, data, callback, async, credentials); }, - invoke: function(option){ + invoke: function(option){ if (window.importScripts && window.isCompletionEnvironment) return null; if (!this.address) this.getAddress(); var res = null; @@ -142,10 +142,10 @@ MWF.xDesktop.Actions.RestActions = new Class({ } }.bind(this)); return res; - }, - formDataUpdateProgress: function(){ - - }, + }, + formDataUpdateProgress: function(){ + + }, invokeFormDataWithProgress: function(xhr, method, uri, data, file, callback, async, progress){ var messageItem = null; @@ -445,13 +445,13 @@ MWF.xDesktop.Actions.RestActions = new Class({ var submitNode = new Element("input", { "type": "submit" }).inject(formNode); - // formNode.submit(); + // formNode.submit(); }, - invokeFormData: function(method, uri, data, file, callback, async, progress){ + invokeFormData: function(method, uri, data, file, callback, async, progress){ uri = o2.filterUrl(uri); - var xhr = new COMMON.Browser.Request(); - if(file){ + var xhr = new COMMON.Browser.Request(); + if(file){ data.append('fileName', file.name); } @@ -465,8 +465,8 @@ MWF.xDesktop.Actions.RestActions = new Class({ } } return xhr; - }, - addFormDataMessage: function(file, noProgress, xhr, showMsg){ + }, + addFormDataMessage: function(file, noProgress, xhr, showMsg){ if (layout.desktop.message){ var contentHTML = ""; @@ -541,94 +541,98 @@ MWF.xDesktop.Actions.RestActions = new Class({ //}; //var tooltipItem = layout.desktop.message.addTooltip(msg); return messageItem; - }, - getAuthentication: function(success, failure){ - this.invoke({ - "name": "authentication", - "async": true, - "success": function(json, responseText){ - if (json.data.tokenType!="anonymous"){ - if (success) success(json); - }else{ - if (failure) failure(null, responseText, json.message); - } - }, - "failure": failure - }); - }, - login: function(data, success, failure){ + }, + getAuthentication: function(success, failure){ + this.invoke({ + "name": "authentication", + "async": true, + "success": function(json, responseText){ + if (json.data.tokenType!="anonymous"){ + if (success) success(json); + }else{ + if (failure) failure(null, responseText, json.message); + } + }, + "failure": failure + }); + }, + login: function(data, success, failure){ var name = "login"; - // if (data.credential.toLowerCase()=="xadmin") name = "loginAdmin"; - this.invoke({ - "name": name, - "async": true, - "data": data, - "success": function(json, responseText){ - //if (json.data.authentication){ + // if (data.credential.toLowerCase()=="xadmin") name = "loginAdmin"; + this.invoke({ + "name": name, + "async": true, + "data": data, + "success": function(json, responseText){ + //if (json.data.authentication){ if (json.data.tokenType!="anonymous"){ - if (success) success(json); - }else{ - if (failure) failure(null, responseText, json.message); - } - }, - "failure": failure - }); - }, - logout: function(success, failure){ - this.invoke({ - "name": "logout", - "async": false, - "success": success, - "failure": failure - }); - } - + if (success) success(json); + }else{ + if (failure) failure(null, responseText, json.message); + } + }, + "failure": failure + }); + }, + logout: function(success, failure){ + this.invoke({ + "name": "logout", + "async": false, + "success": success, + "failure": failure + }); + } + }); MWF.xDesktop.Actions.RestActions.Callback = new Class({ - initialize: function(success, failure, appendSuccess, appendFailure){ - this.success = success; - this.failure = failure; - this.appendSuccess = appendSuccess; - this.appendFailure = appendFailure; - }, - - onSuccess: function(responseJSON, responseText){ - if (responseJSON){ - switch(responseJSON.type) { - case "success": - if (this.appendSuccess) this.appendSuccess(responseJSON); - if (this.success) return this.success(responseJSON, responseText); - return responseJSON; - break; - case "warn": - MWF.xDesktop.notice("info", {x: "right", y:"top"}, responseJSON.errorMessage.join("\n")); - - if (this.appendSuccess) this.appendSuccess(responseJSON); - if (this.success) return this.success(responseJSON); - return responseJSON; - break; - case "error": - return this.doError(null, responseText, responseJSON.message); - return responseJSON; - break; - } - }else{ + initialize: function(success, failure, appendSuccess, appendFailure){ + this.success = success; + this.failure = failure; + this.appendSuccess = appendSuccess; + this.appendFailure = appendFailure; + }, + + onSuccess: function(responseJSON, responseText){ + if (responseJSON){ + switch(responseJSON.type) { + // case "success": + // if (this.appendSuccess) this.appendSuccess(responseJSON); + // if (this.success) return this.success(responseJSON, responseText); + // return responseJSON; + // break; + case "warn": + MWF.xDesktop.notice("info", {x: "right", y:"top"}, responseJSON.errorMessage.join("\n")); + if (this.appendSuccess) this.appendSuccess(responseJSON); + if (this.success) return this.success(responseJSON); + return responseJSON; + break; + case "error": + return this.doError(null, responseText, responseJSON.message); + return responseJSON; + break; + default: + if (this.appendSuccess) this.appendSuccess(responseJSON); + if (this.success) return this.success(responseJSON, responseText); + return responseJSON; + break; + } + }else{ return this.doError(null, responseText, ""); - } - }, - onRequestFailure: function(xhr){ - return this.doError(xhr, "", ""); - }, - onFailure: function(xhr, text, error){ + } + }, + onRequestFailure: function(xhr){ + return this.doError(xhr, "", ""); + }, + onFailure: function(xhr, text, error){ return this.doError(xhr, text, error); - }, - onError: function(text, error){ + }, + onError: function(text, error){ return this.doError(null, text, error); - }, - doError: function(xhr, text, error){ - if (this.appendFailure) this.appendFailure(xhr, text, error); - if (this.failure && this.failure.owner){ + }, + doError: function(xhr, text, error){ + if (this.appendFailure) this.appendFailure(xhr, text, error); + if (this.failure && this.failure.owner){ if (this.failure.reject || (this.failure.rejectList && this.failure.rejectList.length)){ return this.failure(xhr, text, error); } @@ -636,7 +640,7 @@ MWF.xDesktop.Actions.RestActions.Callback = new Class({ }else{ if (this.failure) return this.failure(xhr, text, error); } - if (!this.failure && !this.appendFailure){ + if (!this.failure && !this.appendFailure){ if (xhr.status!=0){ var errorText = error; if (xhr){ @@ -651,8 +655,8 @@ MWF.xDesktop.Actions.RestActions.Callback = new Class({ errorText = errorText.replace(/\ - * this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。 + * this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。同时不建议在queryLoad里使用本方法。 * @method save * @static * @param {Function} [callback] - 保存后的回调 diff --git a/o2web/source/x_component_service_AgentDesigner/Agent.js b/o2web/source/x_component_service_AgentDesigner/Agent.js index 3e37c1dd84c25396a16fd9c6b9154d1dfc876199..e6759319d65507bf1cf8796c3614e26e83c7ca01 100644 --- a/o2web/source/x_component_service_AgentDesigner/Agent.js +++ b/o2web/source/x_component_service_AgentDesigner/Agent.js @@ -228,6 +228,7 @@ MWF.xApplication.service.AgentDesigner.Agent = new Class({ setButton : function(){ this.designer.propertyEnableButton.store("id", this.data.id); this.designer.propertyDisableButton.store("id", this.data.id); + this.designer.propertyExecuteButton.store("id", this.data.id); if( this.data.enable ){ this.designer.propertyEnableButton.setStyle("display","none"); this.designer.propertyDisableButton.setStyle("display", this.data.isNewAgent ? "none" : "" ); diff --git a/o2web/source/x_component_service_AgentDesigner/Main.js b/o2web/source/x_component_service_AgentDesigner/Main.js index 45705984b5a969b9d2e51e7c20fb4d7657ea7c07..c727fb07376c3d8f807f180904ab141ba34b53db 100644 --- a/o2web/source/x_component_service_AgentDesigner/Main.js +++ b/o2web/source/x_component_service_AgentDesigner/Main.js @@ -602,6 +602,26 @@ MWF.xApplication.service.AgentDesigner.Main = new Class({ this.refresh(); }.bind(this)); }.bind(this)); + + node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.debugger+":"}).inject(this.propertyContentArea); + var div = new Element("div", {"styles": this.css.propertyTextNode, "text": ""}).inject(this.propertyContentArea); + + this.propertyExecuteButton = new Element("input", { type : "button", styles : this.css.propertyButton, "value": this.lp.run }).inject(div); + this.propertyExecuteButton.addEvent("click", function(){ + var id = this.propertyExecuteButton.retrieve("id"); + if( id )o2.Actions.load("x_program_center").AgentAction.execute(id, function () { + this.notice( this.lp.runSuccess, "success"); + }.bind(this), function () { + this.notice("request processToolbars error: "+xhr.responseText, "error"); + }.bind(this)); + }.bind(this)); + this.propertyExecuteButton.setStyle("margin","0px"); + + this.propertyOpenLogViewer = new Element("input", { type : "button", styles : this.css.propertyButton, "value": this.lp.openLogViewer }).inject(div); + this.propertyOpenLogViewer.addEvent("click", function(){ + layout.openApplication(null, "LogViewer"); + }.bind(this)); + }, loadCronTooltip : function(){ MWF.xDesktop.requireApp("Template", "widget.CronPicker", null, false); diff --git a/o2web/source/x_component_service_AgentDesigner/lp/en.js b/o2web/source/x_component_service_AgentDesigner/lp/en.js index 89c119f3474ecc86d40734f5f44939d372c71353..797a94ba03ce1af4a3fa5c8c108ec578f969d82a 100644 --- a/o2web/source/x_component_service_AgentDesigner/lp/en.js +++ b/o2web/source/x_component_service_AgentDesigner/lp/en.js @@ -22,6 +22,11 @@ MWF.xApplication.service.AgentDesigner.LP = { "enable" : "Click to enable", "disable" : "Click to disable", + "openLogViewer": "Open LogViewer", + "debugger": "Debug", + "run": "Simulation Run", + "runSuccess": "Run successfully", + "notice": { "save_success": "Agent saved successfully!", diff --git a/o2web/source/x_component_service_AgentDesigner/lp/zh-cn.js b/o2web/source/x_component_service_AgentDesigner/lp/zh-cn.js index f026c3c318abfaeb9b1d37581d0b304ac6e40560..3b535cdbceb93a7e5ad02ab7b5b8522ff15a48c2 100644 --- a/o2web/source/x_component_service_AgentDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_service_AgentDesigner/lp/zh-cn.js @@ -16,6 +16,11 @@ MWF.xApplication.service.AgentDesigner.LP = { "lastEndTime" : "最近结束时间", "appointmentTime" : "预计下次执行时间", + "openLogViewer": "打开日志查看器", + "debugger": "调试", + "run": "模拟运行", + "runSuccess": "运行成功", + "true" : "是", "false" : "否", "enable" : "点击启用", diff --git a/o2web/source/x_component_service_InvokeDesigner/Invoke.js b/o2web/source/x_component_service_InvokeDesigner/Invoke.js index f368363cfd98f102b567594b1d0306da2a30628c..fd6194eb09a09c8701fb1c3d77d49826f5110d40 100644 --- a/o2web/source/x_component_service_InvokeDesigner/Invoke.js +++ b/o2web/source/x_component_service_InvokeDesigner/Invoke.js @@ -64,6 +64,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ this.page = this.tab.addTab(this.areaNode, this.data.name || this.designer.lp.newInvoke, (!this.data.isNewInvoke && this.data.id!=this.designer.options.id)); this.page.invoke = this; this.page.addEvent("show", function(){ + this.designer.currentPage = this.page; this.designer.invokeListAreaNode.getChildren().each(function(node){ var scrtip = node.retrieve("invoke"); if (scrtip.id==this.data.id){ @@ -230,6 +231,18 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ this.setInvokeUrlText(); this.designer.propertyEnableTokenNode.addEvent("change", this.setInvokeUrlText.bind(this)); + + if(this.page){ + this.designer.propertyRequireBodyNode.set("value", this.page.requireBody || ""); + this.designer.propertyRunResultNode.set("html", this.page.executeResult || ""); + } + + this.setButton() + }, + setButton : function(){ + this.designer.propertyExecuteButton.store("id", this.data.id); + this.designer.propertyExecuteButton.store("alias", this.data.alias); + this.designer.propertyExecuteButton.store("name", this.data.name); }, setInvokeUrlText: function(){ debugger @@ -265,7 +278,6 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ addInclude: function(){ }, - saveInvoke: function (data, success, failure) { if (data.isNewInvoke) { this.designer.actions.createInvoke(data, success, failure); @@ -327,7 +339,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ this.isSave = false; if( this.data.isNewInvoke ){ this.data.isNewInvoke = false; - //this.setButton(); + this.setButton(); } this.isChanged = false; this.page.textNode.set("text", this.data.name); @@ -405,7 +417,7 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ this.isSave = false; if( this.data.isNewInvoke ){ this.data.isNewInvoke = false; - //this.setButton(); + this.setButton(); } this.data.isNewInvoke = false; this.isChanged = false; diff --git a/o2web/source/x_component_service_InvokeDesigner/Main.js b/o2web/source/x_component_service_InvokeDesigner/Main.js index 6786662d6d6d571e67f83f6786da17c6515c938f..9b3ca8cf2378fea70eed22d85a45dcdc64a7a619 100644 --- a/o2web/source/x_component_service_InvokeDesigner/Main.js +++ b/o2web/source/x_component_service_InvokeDesigner/Main.js @@ -611,7 +611,95 @@ MWF.xApplication.service.InvokeDesigner.Main = new Class({ node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.invokeHead+":"}).inject(this.propertyContentArea); this.propertyInvokeHeadTextNode = new Element("div", {"styles": this.css.propertyTextNode, "text": "Content-Type:application/json; charset=utf-8"}).inject(this.propertyContentArea); + this.propertyInvokeHeadTextNode.setStyles({ + "height": "auto" + }) + node = new Element("div", {"styles": this.css.propertyItemTitleNode, "text": this.lp.debugger+":"}).inject(this.propertyContentArea); + + new Element("div", {"styles": this.css.propertyTextNode, "text": this.lp.requireArguments}).setStyles({ + "word-break":"break-all", + "height" : "auto", + "line-height": "18px", + "margin-top": "10px", + "color": "#999999" + }).inject(this.propertyContentArea); + this.propertyRequireBodyNode = new Element("textarea", { + "styles": this.css.propertyInputAreaNode, + "value": "", + "events": { + change : function () { + debugger; + if(this.currentPage){ + this.currentPage.requireBody = this.propertyRequireBodyNode.get("value"); + } + }.bind(this) + } + }).inject(this.propertyContentArea); + + new Element("div", {"styles": this.css.propertyTextNode, "text": this.lp.runResult}).setStyles({ + "word-break":"break-all", + "height" : "auto", + "line-height": "18px", + "margin-top": "10px", + "color": "#999999" + }).inject(this.propertyContentArea); + this.propertyRunResultNode = new Element("div", {"styles": this.css.propertyTextNode}).inject(this.propertyContentArea); + this.propertyRunResultNode.set("style", "white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; height: auto; overflow:auto; margin-left:10px;"); + + var div = new Element("div", {"styles": this.css.propertyTextNode, "text": ""}).setStyles({ + "margin-top": "10px" + }).inject(this.propertyContentArea); + + this.propertyExecuteButton = new Element("input", { type : "button", styles : this.css.propertyButton, "value": this.lp.run }).inject(div); + this.propertyExecuteButton.addEvent("click", function(){ + + debugger; + var alias = this.propertyExecuteButton.retrieve("alias"); + var name = this.propertyExecuteButton.retrieve("name"); + var id = this.propertyExecuteButton.retrieve("id"); + + var body = this.propertyRequireBodyNode.get("value"); + var bodyJson; + try{ + bodyJson = JSON.parse(body); + }catch(e) { + } + + if( id )o2.Actions.load("x_program_center").InvokeAction.execute( alias || name || id, bodyJson || body, function (json) { + var result; + try{ + result = JSON.stringify(json, null, 4); + }catch (e) { + result = json; + } + if(this.currentPage){ + this.currentPage.executeResult = result; + } + this.propertyRunResultNode.set("html",result); + + this.notice( this.lp.runSuccess, "success"); + }.bind(this), function (xhr) { + var result; + try{ + result = JSON.stringify(xhr.responseText, null, 4); + }catch (e) { + result = xhr.responseText; + } + if(this.currentPage){ + this.currentPage.executeResult = result; + } + this.propertyRunResultNode.set("html",result); + + // this.notice("request processToolbars error: "+xhr.responseText, "error"); + }.bind(this)); + }.bind(this)); + this.propertyExecuteButton.setStyle("margin","0px"); + + this.propertyOpenLogViewer = new Element("input", { type : "button", styles : this.css.propertyButton, "value": this.lp.openLogViewer }).inject(div); + this.propertyOpenLogViewer.addEvent("click", function(){ + layout.openApplication(null, "LogViewer"); + }.bind(this)); }, loadPropertyResize: function(){ // var size = this.propertyNode.getSize(); diff --git a/o2web/source/x_component_service_InvokeDesigner/lp/en.js b/o2web/source/x_component_service_InvokeDesigner/lp/en.js index 6a52fae8129369466a1493fb324a1797c28440d1..6754c9dbe340ec15a62083a8786c12e99c906a58 100644 --- a/o2web/source/x_component_service_InvokeDesigner/lp/en.js +++ b/o2web/source/x_component_service_InvokeDesigner/lp/en.js @@ -25,8 +25,15 @@ MWF.xApplication.service.InvokeDesigner.LP = { "invokeUri": "Invoke address", "invokeMethod": "Invoke Method", "enableToken": "Enable authentication", - "enableTokenInfo": "After enabling authentication, you must use the authentication client name and encrypted token to call the service", + "invokeHead": "head", + + "openLogViewer": "Open LogViewer", + "debugger": "Debug", + "run": "Simulation Run", + "runSuccess": "Run successfully", + "requireArguments": "Request Arguments", + "runResult": "Execution Result", "notice": { "save_success": "The interface was saved successfully!", diff --git a/o2web/source/x_component_service_InvokeDesigner/lp/zh-cn.js b/o2web/source/x_component_service_InvokeDesigner/lp/zh-cn.js index 4c8001a816384759d4c06c49952d2c3881675aa0..f20b90fc77709495ee9da058215b672da5251ab4 100644 --- a/o2web/source/x_component_service_InvokeDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_service_InvokeDesigner/lp/zh-cn.js @@ -22,6 +22,14 @@ MWF.xApplication.service.InvokeDesigner.LP = { "invokeMethod" : "调用方法", "enableToken": "启用鉴权", "enableTokenInfo": "启用鉴权后,您必须使用鉴权客户端名称和加密后的token来调用服务", + "invokeHead": "head", + + "openLogViewer": "打开日志查看器", + "debugger": "调试", + "run": "模拟运行", + "runSuccess": "运行成功", + "requireArguments": "请求参数", + "runResult": "执行结果", "notice": { "save_success": "接口保存成功!",