Commit 7f467af4 authored by Medicean's avatar Medicean

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

parent 9713e7ec
......@@ -12,6 +12,7 @@
### Shell 管理
* 新增「测试连接」功能
* 其它设置增加「开启分块传输」开关,设置「最小分块」和「最大分块」。每次分块大小为[n, m]区间。
![chunk-1.png](https://i.loli.net/2019/01/28/5c4e8868f178a.png)
......
......@@ -106,6 +106,7 @@ module.exports = {
add: {
title: 'Add shell',
toolbar: {
test: 'Test Connection',
add: 'Add',
clear: 'Clear'
},
......@@ -117,6 +118,8 @@ module.exports = {
type: 'Shell type',
encoder: 'Encoder'
},
test_success: 'Connection Successful!',
test_warning: 'Response is null!',
warning: 'Please enter the full!',
success: 'Add shell success!',
error: (err) => antSword.noxss(`Add shell failed!\n${err}`)
......
......@@ -107,6 +107,7 @@ module.exports = {
add: {
title: '添加数据',
toolbar: {
test: '测试连接',
add: '添加',
clear: '清空'
},
......@@ -118,6 +119,8 @@ module.exports = {
type: '连接类型',
encoder: '编码器'
},
test_success: '连接成功!',
test_warning: '返回数据为空',
warning: '请输入完整!',
success: '添加数据成功!',
error: (err) => antSword.noxss(`添加数据失败!\n${err}`)
......
......@@ -27,36 +27,82 @@ class Form {
// toolbar点击事件
this.toolbar.attachEvent('onClick', (id) => {
if (id === 'clear') {
return this.baseForm.clear();
}
// 检测表单数据
if (
!this.baseForm.validate() ||
!this.httpForm.validate() ||
!this.otherForm.validate()
) {
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
};
// 回调数据
if (callback) {
win.progressOn();
setTimeout(() => {
callback(this._parseFormData(
switch(id){
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()
)).then((msg) => {
// 添加/保存完毕后回调
win.close();
toastr.success(msg, LANG_T['success']);
}).catch((msg) => {
// 添加/保存错误
);
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();
toastr.error(msg, LANG_T['error']);
});
}, 100);
};
break;
case 'act':
// 检测表单数据
if (
!this.baseForm.validate() ||
!this.httpForm.validate() ||
!this.otherForm.validate()
) {
return toastr.warning(LANG['list']['add']['warning'], LANG_T['warning']);
};
// 回调数据
if (callback) {
win.progressOn();
setTimeout(() => {
callback(this._parseFormData(
this.baseForm.getValues(),
this.httpForm.getValues(),
this.otherForm.getValues()
)).then((msg) => {
// 添加/保存完毕后回调
win.close();
toastr.success(msg, LANG_T['success']);
}).catch((msg) => {
// 添加/保存错误
win.progressOff();
toastr.error(msg, LANG_T['error']);
});
}, 100);
};
break;
default:
break;
}
});
}
......@@ -109,7 +155,10 @@ class Form {
type: 'button',
icon: 'remove',
text: LANG['list']['add']['toolbar']['clear']
}]);
},
{ type: 'separator' },
{ id: 'test', type: 'button', 'icon': 'spinner', text: LANG['list']['add']['toolbar']['test'] },
]);
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