Commit 5fb08ba3 authored by Medicean's avatar Medicean

(Enhance:Database) 新增「测试连接」功能

parent ca4510a0
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
### 数据管理 ### 数据管理
* 新增「测试连接」功能
* 新增「检测」功能, 检测支持的数据库函数(目前仅 PHP 有效) * 新增「检测」功能, 检测支持的数据库函数(目前仅 PHP 有效)
* 新增 php sqlsrv 连接方式, php5.3之后 mssql 默认不存在,可使用该类型连接 sqlserver >= 2008 * 新增 php sqlsrv 连接方式, php5.3之后 mssql 默认不存在,可使用该类型连接 sqlserver >= 2008
......
...@@ -438,7 +438,8 @@ module.exports = { ...@@ -438,7 +438,8 @@ module.exports = {
toolbar: { toolbar: {
add: 'Add', add: 'Add',
clear: 'Clear', clear: 'Clear',
edit: 'Edit' edit: 'Edit',
test: 'Test connect'
}, },
conn: 'Connection String', conn: 'Connection String',
type: 'Database type', type: 'Database type',
...@@ -448,6 +449,8 @@ module.exports = { ...@@ -448,6 +449,8 @@ module.exports = {
passwd: 'Password', passwd: 'Password',
warning: 'Please fill in the complete!', warning: 'Please fill in the complete!',
success: 'Successful add configuration!', success: 'Successful add configuration!',
test_success: 'Connection Successful!',
test_warning: 'Response is null!',
del: { del: {
title: 'Delete configuration', title: 'Delete configuration',
confirm: 'Determine delete this configuration?', confirm: 'Determine delete this configuration?',
......
...@@ -439,7 +439,8 @@ module.exports = { ...@@ -439,7 +439,8 @@ module.exports = {
toolbar: { toolbar: {
add: '添加', add: '添加',
clear: '清空', clear: '清空',
edit: '编辑' edit: '编辑',
test: '测试连接'
}, },
conn: '连接字符串', conn: '连接字符串',
type: '数据库类型', type: '数据库类型',
...@@ -449,6 +450,8 @@ module.exports = { ...@@ -449,6 +450,8 @@ module.exports = {
passwd: '连接密码', passwd: '连接密码',
warning: '请填写完整!', warning: '请填写完整!',
success: '成功添加配置!', success: '成功添加配置!',
test_success: '连接成功!',
test_warning: '返回数据为空',
del: { del: {
title: '删除配置', title: '删除配置',
confirm: '确定删除此配置吗?', confirm: '确定删除此配置吗?',
......
...@@ -168,6 +168,13 @@ class ASP { ...@@ -168,6 +168,13 @@ class ASP {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['form']['toolbar']['clear'] text: LANG['form']['toolbar']['clear']
}, {
type: 'separator'
}, {
id: 'test',
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}]); }]);
// form // form
...@@ -225,6 +232,29 @@ class ASP { ...@@ -225,6 +232,29 @@ class ASP {
this.manager.list.imgs[0] this.manager.list.imgs[0]
); );
break; break;
case 'test':
if (!form.validate()) {
return toastr.warning(LANG['form']['warning'], LANG_T['warning']);
};
// 解析数据
let _data = form.getValues();
win.progressOn();
this.core.request(
this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
})
).then((res) => {
if(res['text'].length > 0){
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
}
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
} }
}); });
} }
...@@ -259,6 +289,13 @@ class ASP { ...@@ -259,6 +289,13 @@ class ASP {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['form']['toolbar']['clear'] text: LANG['form']['toolbar']['clear']
}, {
type: 'separator'
}, {
id: 'test',
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}]); }]);
// form // form
...@@ -310,6 +347,29 @@ class ASP { ...@@ -310,6 +347,29 @@ class ASP {
// 刷新 UI // 刷新 UI
this.parse(); this.parse();
break; break;
case 'test':
if (!form.validate()) {
return toastr.warning(LANG['form']['warning'], LANG_T['warning']);
};
// 解析数据
let _data = form.getValues();
win.progressOn();
this.core.request(
this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
})
).then((res) => {
if(res['text'].length > 0){
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
}
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
} }
}); });
} }
......
...@@ -164,6 +164,13 @@ class CUSTOM { ...@@ -164,6 +164,13 @@ class CUSTOM {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['form']['toolbar']['clear'] text: LANG['form']['toolbar']['clear']
}, {
type: 'separator'
}, {
id: 'test',
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}]); }]);
// form // form
...@@ -221,6 +228,29 @@ class CUSTOM { ...@@ -221,6 +228,29 @@ class CUSTOM {
this.manager.list.imgs[0] this.manager.list.imgs[0]
); );
break; break;
case 'test':
if (!form.validate()) {
return toastr.warning(LANG['form']['warning'], LANG_T['warning']);
};
// 解析数据
let _data = form.getValues();
win.progressOn();
this.core.request(
this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
})
).then((res) => {
if(res['text'].length > 0){
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
}
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
} }
}); });
} }
...@@ -255,6 +285,13 @@ class CUSTOM { ...@@ -255,6 +285,13 @@ class CUSTOM {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['form']['toolbar']['clear'] text: LANG['form']['toolbar']['clear']
}, {
type: 'separator'
}, {
id: 'test',
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}]); }]);
// form // form
...@@ -307,6 +344,29 @@ class CUSTOM { ...@@ -307,6 +344,29 @@ class CUSTOM {
// 刷新 UI // 刷新 UI
this.parse(); this.parse();
break; break;
case 'test':
if (!form.validate()) {
return toastr.warning(LANG['form']['warning'], LANG_T['warning']);
};
// 解析数据
let _data = form.getValues();
win.progressOn();
this.core.request(
this.core[`database_${_data['type']}`].show_databases({
conn: _data['conn']
})
).then((res) => {
if(res['text'].length > 0){
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
}
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
} }
}); });
} }
......
...@@ -308,6 +308,13 @@ class PHP { ...@@ -308,6 +308,13 @@ class PHP {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['form']['toolbar']['clear'] text: LANG['form']['toolbar']['clear']
}, {
type: 'separator'
}, {
id: 'test',
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}]); }]);
// form // form
...@@ -436,6 +443,31 @@ class PHP { ...@@ -436,6 +443,31 @@ class PHP {
this.manager.list.imgs[0] this.manager.list.imgs[0]
); );
break; break;
case 'test':
if (!form.validate()) {
return toastr.warning(LANG['form']['warning'], LANG_T['warning']);
};
// 解析数据
let _data = form.getValues();
win.progressOn();
this.core.request(
this.core[`database_${_data['type']}`].show_databases({
host: _data['host'],
user: _data['user'],
passwd: _data['passwd']
})
).then((res) => {
if(res['text'].length > 0){
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
}
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
} }
}); });
} }
...@@ -470,6 +502,13 @@ class PHP { ...@@ -470,6 +502,13 @@ class PHP {
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: LANG['form']['toolbar']['clear'] text: LANG['form']['toolbar']['clear']
}, {
type: 'separator'
}, {
id: 'test',
type: 'button',
icon: 'spinner',
text: LANG['form']['toolbar']['test']
}]); }]);
// form // form
...@@ -605,6 +644,31 @@ class PHP { ...@@ -605,6 +644,31 @@ class PHP {
// 刷新 UI // 刷新 UI
this.parse(); this.parse();
break; break;
case 'test':
if (!form.validate()) {
return toastr.warning(LANG['form']['warning'], LANG_T['warning']);
};
// 解析数据
let _data = form.getValues();
win.progressOn();
this.core.request(
this.core[`database_${_data['type']}`].show_databases({
host: _data['host'],
user: _data['user'],
passwd: _data['passwd']
})
).then((res) => {
if(res['text'].length > 0){
toastr.success(LANG['form']['test_success'], LANG_T['success']);
}else{
toastr.warning(LANG['form']['test_warning'], LANG_T['warning']);
}
win.progressOff();
}).catch((err)=>{
toastr.error(JSON.stringify(err), LANG_T['error']);
win.progressOff();
});
break;
} }
}); });
} }
......
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