提交 a683a0ed 编写于 作者: 蔡祥熠

Merge branch 'fix/Service.agent_interface_add_run' into 'wrdp'

Merge of fix/Service.agent_interface_add_run 服务管理的代理和接口增加调试功能  to wrdp

See merge request o2oa/o2oa!4703
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(/\</g, "&gt;");
if (layout.session && layout.session.user) MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
}
// throw "request error: "+errorText;
}
return Promise.reject(xhr);
}
// throw "request error: "+errorText;
}
return Promise.reject(xhr);
}
});
......@@ -148,7 +148,8 @@ MWF.xScript.Environment = function(ev){
* orders.add(0, {name: "mobile", count: 10}, true);
*/
/**保存data对象。不触发事件
/**保存data对象。不触发事件。
* 不建议在queryLoad、beforeSave和afterSave中使用本方法。
* @method save
* @static
* @memberOf module:data
......@@ -2339,7 +2340,7 @@ MWF.xScript.Environment = function(ev){
"getData": function(){return new MWF.xScript.JSONData(_form.getData());},
/**保存当前表单所绑定的业务数据。<br/>
* this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。
* this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。同时不建议在queryLoad里使用本方法。
* @method save
* @static
* @param {Function} [callback] - 保存后的回调
......
......@@ -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" : "" );
......
......@@ -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);
......
......@@ -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!",
......
......@@ -16,6 +16,11 @@ MWF.xApplication.service.AgentDesigner.LP = {
"lastEndTime" : "最近结束时间",
"appointmentTime" : "预计下次执行时间",
"openLogViewer": "打开日志查看器",
"debugger": "调试",
"run": "模拟运行",
"runSuccess": "运行成功",
"true" : "",
"false" : "",
"enable" : "点击启用",
......
......@@ -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;
......
......@@ -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();
......
......@@ -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!",
......
......@@ -22,6 +22,14 @@ MWF.xApplication.service.InvokeDesigner.LP = {
"invokeMethod" : "调用方法",
"enableToken": "启用鉴权",
"enableTokenInfo": "启用鉴权后,您必须使用鉴权客户端名称和加密后的token来调用服务",
"invokeHead": "head",
"openLogViewer": "打开日志查看器",
"debugger": "调试",
"run": "模拟运行",
"runSuccess": "运行成功",
"requireArguments": "请求参数",
"runResult": "执行结果",
"notice": {
"save_success": "接口保存成功!",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册