Commit 7f467af4 authored by Medicean's avatar Medicean

(Enhance:Module::ShellManager) 新增测试连接功能

parent 9713e7ec
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
### Shell 管理 ### Shell 管理
* 新增「测试连接」功能
* 其它设置增加「开启分块传输」开关,设置「最小分块」和「最大分块」。每次分块大小为[n, m]区间。 * 其它设置增加「开启分块传输」开关,设置「最小分块」和「最大分块」。每次分块大小为[n, m]区间。
![chunk-1.png](https://i.loli.net/2019/01/28/5c4e8868f178a.png) ![chunk-1.png](https://i.loli.net/2019/01/28/5c4e8868f178a.png)
......
...@@ -106,6 +106,7 @@ module.exports = { ...@@ -106,6 +106,7 @@ module.exports = {
add: { add: {
title: 'Add shell', title: 'Add shell',
toolbar: { toolbar: {
test: 'Test Connection',
add: 'Add', add: 'Add',
clear: 'Clear' clear: 'Clear'
}, },
...@@ -117,6 +118,8 @@ module.exports = { ...@@ -117,6 +118,8 @@ module.exports = {
type: 'Shell type', type: 'Shell type',
encoder: 'Encoder' encoder: 'Encoder'
}, },
test_success: 'Connection Successful!',
test_warning: 'Response is null!',
warning: 'Please enter the full!', warning: 'Please enter the full!',
success: 'Add shell success!', success: 'Add shell success!',
error: (err) => antSword.noxss(`Add shell failed!\n${err}`) error: (err) => antSword.noxss(`Add shell failed!\n${err}`)
......
...@@ -107,6 +107,7 @@ module.exports = { ...@@ -107,6 +107,7 @@ module.exports = {
add: { add: {
title: '添加数据', title: '添加数据',
toolbar: { toolbar: {
test: '测试连接',
add: '添加', add: '添加',
clear: '清空' clear: '清空'
}, },
...@@ -118,6 +119,8 @@ module.exports = { ...@@ -118,6 +119,8 @@ module.exports = {
type: '连接类型', type: '连接类型',
encoder: '编码器' encoder: '编码器'
}, },
test_success: '连接成功!',
test_warning: '返回数据为空',
warning: '请输入完整!', warning: '请输入完整!',
success: '添加数据成功!', success: '添加数据成功!',
error: (err) => antSword.noxss(`添加数据失败!\n${err}`) error: (err) => antSword.noxss(`添加数据失败!\n${err}`)
......
...@@ -27,9 +27,51 @@ class Form { ...@@ -27,9 +27,51 @@ class Form {
// toolbar点击事件 // toolbar点击事件
this.toolbar.attachEvent('onClick', (id) => { this.toolbar.attachEvent('onClick', (id) => {
if (id === 'clear') { switch(id){
return this.baseForm.clear(); case 'clear':
this.baseForm.clear();
break;
case 'test':
if (
!this.baseForm.validate() ||
!this.httpForm.validate() ||
!this.otherForm.validate()
) {
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
};
let opts = this._parseFormData(
this.baseForm.getValues(),
this.httpForm.getValues(),
this.otherForm.getValues()
);
let opt = {
"url": opts.base['url'],
"pwd": opts.base['pwd'],
"type": opts.base['type'],
"encode": opts.base['encode'],
"encoder": opts.base['encoder'],
"httpConf": opts.http,
"otherConf": opts.other,
} }
win.progressOn();
let core = new antSword["core"][opt['type']](opt);
core.request(
core.base.info()
)
.then((ret) => {
if(ret['text'].length > 0){
toastr.success(LANG['list']['add']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['list']['add']['test_warning'], LANG_T['warning']);
}
win.progressOff();
})
.catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
case 'act':
// 检测表单数据 // 检测表单数据
if ( if (
!this.baseForm.validate() || !this.baseForm.validate() ||
...@@ -57,6 +99,10 @@ class Form { ...@@ -57,6 +99,10 @@ class Form {
}); });
}, 100); }, 100);
}; };
break;
default:
break;
}
}); });
} }
...@@ -109,7 +155,10 @@ class Form { ...@@ -109,7 +155,10 @@ class Form {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['list']['add']['toolbar']['clear'] text: LANG['list']['add']['toolbar']['clear']
}]); },
{ type: 'separator' },
{ id: 'test', type: 'button', 'icon': 'spinner', text: LANG['list']['add']['toolbar']['test'] },
]);
return toolbar; return toolbar;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment