Commit eb62a56f authored by Medicean's avatar Medicean

php mysql i18n

parent 2f3f60ac
...@@ -362,7 +362,16 @@ module.exports = { ...@@ -362,7 +362,16 @@ module.exports = {
menu: { menu: {
add: 'Add conf', add: 'Add conf',
del: 'Del conf', del: 'Del conf',
edit: 'Edit conf' edit: 'Edit conf',
adddb: 'New Database',
editdb: 'Edit Database',
deldb: 'Del Database',
addtable: 'New Table',
edittable: 'Edit TableName',
deltable: 'Del Table',
addcolumn: 'New Column',
editcolumn: 'Edit Column',
delcolumn: 'Del Column',
} }
}, },
query: { query: {
...@@ -382,6 +391,7 @@ module.exports = { ...@@ -382,6 +391,7 @@ module.exports = {
noresult: 'No query results!' noresult: 'No query results!'
} }
}, },
notsupport: 'Not support the current database type',
form: { form: {
title: 'Add conf', title: 'Add conf',
toolbar: { toolbar: {
...@@ -402,6 +412,70 @@ module.exports = { ...@@ -402,6 +412,70 @@ module.exports = {
confirm: 'Determine delete this configuration?', confirm: 'Determine delete this configuration?',
success: 'Delete configuration success!', success: 'Delete configuration success!',
error: (err) => antSword.noxss(`Delete configuration failed!\n${err}`) error: (err) => antSword.noxss(`Delete configuration failed!\n${err}`)
},
adddb: {
title: 'New Database',
dbname: 'Name',
characterset: 'Character Set',
charactercollation: 'Collation',
createbtn: 'OK',
cancelbtn: 'Cancel',
success: 'Create database successfully',
error: 'Failed to create database',
},
editdb: {
title: 'Database Properties',
dbname: 'Name(readonly)',
characterset: 'Character Set',
charactercollation: 'Collation',
updatebtn: 'OK',
cancelbtn: 'Cancel',
success: 'Edit database successfully',
error: 'Failed to edit database',
},
deldb: {
title: 'Delete Database',
confirm: (name) => antSword.noxss(`Are you sure you want to delete database ${name} ?`),
success: 'Delete database successfully',
error: 'Failed to delete database',
},
addtable: {
title: 'New Table',
add: 'New Column',
delete: 'Delete Column',
save: 'Save',
gridheader: "Name,Type,Length,Not Null,Key,Auto Increment",
delete_not_select: "Please select the row you want to delete first",
save_row_is_null: "The number of rows is empty",
cell_valid_error: (i,j)=>`Data format validation failed(row ${i+1}, col ${j+1})`,
confirmtitle: "New table name",
invalid_tablename: "Table names should not contain special symbols",
success: 'Create table successfully',
error: 'Failed to create table',
},
edittable: {
title: "New table name",
invalid_tablename: "Table names should not contain special symbols",
success: 'Update table name successfully',
error: 'Failed to update table',
},
deltable: {
title:'Delete Table',
confirm: (name) => antSword.noxss(`Are you sure you want to delete table ${name}?`),
success: 'Delete table successfully',
error: 'Failed to delete table',
},
addcolumn: {
},
editcolumn: {
},
delcolumn: {
title:'Delete Column',
confirm: (name) => antSword.noxss(`Are you sure you want to delete column ${name}?`),
success: 'Delete column successfully',
error: 'Failed to delete column',
} }
} }
}, },
......
...@@ -363,7 +363,16 @@ module.exports = { ...@@ -363,7 +363,16 @@ module.exports = {
menu: { menu: {
add: '添加配置', add: '添加配置',
del: '删除配置', del: '删除配置',
edit: '编辑配置' edit: '编辑配置',
adddb: '新建数据库',
editdb: '编辑数据库',
deldb: '删除数据库',
addtable: '新建表',
edittable: '编辑表名',
deltable: '删除表',
addcolumn: '添加列',
editcolumn: '编辑列',
delcolumn: '删除列',
} }
}, },
query: { query: {
...@@ -383,6 +392,7 @@ module.exports = { ...@@ -383,6 +392,7 @@ module.exports = {
noresult: '没有查询结果!' noresult: '没有查询结果!'
} }
}, },
notsupport: '该功能暂不支持当前类型数据库',
form: { form: {
title: '添加配置', title: '添加配置',
toolbar: { toolbar: {
...@@ -403,6 +413,70 @@ module.exports = { ...@@ -403,6 +413,70 @@ module.exports = {
confirm: '确定删除此配置吗?', confirm: '确定删除此配置吗?',
success: '删除配置成功!', success: '删除配置成功!',
error: (err) => antSword.noxss(`删除配置失败!\n${err}`) error: (err) => antSword.noxss(`删除配置失败!\n${err}`)
},
adddb: {
title: '新建数据库',
dbname: '名称',
characterset: '字符集',
charactercollation: '字符集排序',
createbtn: '创建',
cancelbtn: '取消',
success: '创建数据库成功',
error: '创建数据库失败',
},
editdb: {
title: '修改数据库',
dbname: '名称(只读)',
characterset: '字符集',
charactercollation: '字符集排序',
updatebtn: '修改',
cancelbtn: '取消',
success: '修改数据库成功',
error: '修改数据库失败',
},
deldb: {
title: '删除数据库',
confirm: (name) => antSword.noxss(`确定要删除数据库 ${name} 吗?`),
success: '删除数据库成功',
error: '删除数据库失败',
},
addtable: {
title: '新建表',
add: '新增字段',
delete: '删除字段',
save: '保存',
gridheader: "名称,类型,长度,不为空,主键,自增长",
delete_not_select: "请先选中要删除的行",
save_row_is_null: "行数为空",
cell_valid_error: (i,j)=>`数据格式校验失败(${i+1}行,${j+1}列)`,
confirmtitle: "输入新表名",
invalid_tablename: "表名不能带有特殊符号",
success: '新建表成功',
error: '新建表失败',
},
edittable: {
title: "输入新表名",
invalid_tablename: "表名不能带有特殊符号",
success: '修改表名成功',
error: '修改表名失败',
},
deltable: {
title:'删除表',
confirm: (name) => antSword.noxss(`确定要删除表 ${name} 吗?`),
success: '删除表成功',
error: '删除表失败',
},
addcolumn: {
},
editcolumn: {
},
delcolumn: {
title:'删除列',
confirm: (name) => antSword.noxss(`确定要删除列 ${name} 吗?`),
success: '删除列成功',
error: '删除列失败',
} }
} }
}, },
......
...@@ -85,7 +85,7 @@ class PHP { ...@@ -85,7 +85,7 @@ class PHP {
this.tree.callEvent('onClick', [id]); this.tree.callEvent('onClick', [id]);
bmenu([ bmenu([
{ {
text: "新建数据库", text: LANG['list']['menu']['adddb'],
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this.addDatabase.bind(this) action: this.addDatabase.bind(this)
}, },
...@@ -112,24 +112,24 @@ class PHP { ...@@ -112,24 +112,24 @@ class PHP {
this.tree.callEvent('onClick', [id]); this.tree.callEvent('onClick', [id]);
bmenu([ bmenu([
{ {
text: "新建表", text: LANG['list']['menu']['addtable'],
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this.addTable.bind(this) action: this.addTable.bind(this)
}, },
{ {
text: "新建数据库", text: LANG['list']['menu']['adddb'],
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this.addDatabase.bind(this) action: this.addDatabase.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: "编辑数据库", text: LANG['list']['menu']['editdb'],
icon: 'fa fa-edit', icon: 'fa fa-edit',
action: this.editDatabase.bind(this) action: this.editDatabase.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: "删除数据库", text: LANG['list']['menu']['deldb'],
icon: 'fa fa-remove', icon: 'fa fa-remove',
action: this.delDatabase.bind(this) action: this.delDatabase.bind(this)
} }
...@@ -139,19 +139,19 @@ class PHP { ...@@ -139,19 +139,19 @@ class PHP {
this.tree.callEvent('onClick', [id]); this.tree.callEvent('onClick', [id]);
bmenu([ bmenu([
{ {
text: "新建表", text: LANG['list']['menu']['addtable'],
icon: 'fa fa-plus-circle', icon: 'fa fa-plus-circle',
action: this.addTable.bind(this) action: this.addTable.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: "编辑表名", text: LANG['list']['menu']['edittable'],
icon: 'fa fa-edit', icon: 'fa fa-edit',
action: this.editTable.bind(this) action: this.editTable.bind(this)
}, { }, {
divider: true divider: true
}, { }, {
text: "删除表", text: LANG['list']['menu']['deltable'],
icon: 'fa fa-remove', icon: 'fa fa-remove',
action: this.delTable.bind(this) action: this.delTable.bind(this)
} }
...@@ -161,11 +161,11 @@ class PHP { ...@@ -161,11 +161,11 @@ class PHP {
this.tree.callEvent('onClick', [id]); this.tree.callEvent('onClick', [id]);
bmenu([ bmenu([
{ {
text: "编辑列", text: LANG['list']['menu']['editcolumn'],
icon: 'fa fa-edit', icon: 'fa fa-edit',
action: this.editColumn.bind(this) action: this.editColumn.bind(this)
}, { }, {
text: "删除列", text: LANG['list']['menu']['delcolumn'],
icon: 'fa fa-remove', icon: 'fa fa-remove',
action: this.delColumn.bind(this) action: this.delColumn.bind(this)
}, },
...@@ -556,7 +556,7 @@ class PHP { ...@@ -556,7 +556,7 @@ class PHP {
case "mysql": case "mysql":
// 创建窗口 // 创建窗口
const win = this.manager.win.createWindow(hash, 0, 0, 450, 200); const win = this.manager.win.createWindow(hash, 0, 0, 450, 200);
win.setText("新建数据库"); win.setText(LANG['form']['adddb']['title']);
win.centerOnScreen(); win.centerOnScreen();
win.button('minmax').hide(); win.button('minmax').hide();
win.setModal(true); win.setModal(true);
...@@ -565,8 +565,8 @@ class PHP { ...@@ -565,8 +565,8 @@ class PHP {
const form = win.attachForm([ const form = win.attachForm([
{ type: 'settings', position: 'label-left', labelWidth: 90, inputWidth: 250 }, { type: 'settings', position: 'label-left', labelWidth: 90, inputWidth: 250 },
{ type: 'block', inputWidth: 'auto', offsetTop: 12, list: [ { type: 'block', inputWidth: 'auto', offsetTop: 12, list: [
{ type: 'input', label: "名称", name: 'dbname', value: "", required: true, validate:"ValidAplhaNumeric",}, { type: 'input', label: LANG['form']['adddb']['dbname'], name: 'dbname', value: "", required: true, validate:"ValidAplhaNumeric",},
{ type: 'combo', label: '字符集', readonly:true, name: 'characterset', options: (() => { { type: 'combo', label: LANG['form']['adddb']['characterset'], readonly:true, name: 'characterset', options: (() => {
let ret = []; let ret = [];
Object.keys(this.mysqlcsMapping).map((_) => { Object.keys(this.mysqlcsMapping).map((_) => {
ret.push({ ret.push({
...@@ -576,7 +576,7 @@ class PHP { ...@@ -576,7 +576,7 @@ class PHP {
}) })
return ret; return ret;
})() }, })() },
{ type: 'combo', label: '字符集排序', readonly:true, name: 'charactercollation', options: ((c)=>{ { type: 'combo', label: LANG['form']['adddb']['charactercollation'], readonly:true, name: 'charactercollation', options: ((c)=>{
let ret = []; let ret = [];
this.mysqlcsMapping[c].map((_)=>{ this.mysqlcsMapping[c].map((_)=>{
ret.push({ ret.push({
...@@ -587,9 +587,9 @@ class PHP { ...@@ -587,9 +587,9 @@ class PHP {
return ret; return ret;
})("default")}, })("default")},
{ type: "block", name:"btnblock", className:"display: flex;flex-direction: row;align-items: right;",offsetLeft:150, list:[ { type: "block", name:"btnblock", className:"display: flex;flex-direction: row;align-items: right;",offsetLeft:150, list:[
{ type:"button" , name:"createbtn", value: `<i class="fa fa-plus"></i> 创建`}, { type:"button" , name:"createbtn", value: `<i class="fa fa-plus"></i> ${LANG['form']['adddb']['createbtn']}`},
{type: 'newcolumn', offset:20}, {type: 'newcolumn', offset:20},
{ type:"button" , name:"canclebtn", value: `<i class="fa fa-ban"></i> 取消`}, { type:"button" , name:"cancelbtn", value: `<i class="fa fa-ban"></i> ${LANG['form']['adddb']['cancelbtn']}`},
]} ]}
]} ]}
], true); ], true);
...@@ -631,25 +631,25 @@ class PHP { ...@@ -631,25 +631,25 @@ class PHP {
}; };
if(arr[1].indexOf("VHJ1ZQ==")!= -1){ if(arr[1].indexOf("VHJ1ZQ==")!= -1){
// 操作成功 // 操作成功
toastr.success("创建数据库成功" ,LANG_T['success']); toastr.success(LANG['form']['adddb']['success'] ,LANG_T['success']);
win.close(); win.close();
// refresh // refresh
this.getDatabases(id); this.getDatabases(id);
return return
} }
toastr.error("创建数据库失败", LANG_T['error']); toastr.error(LANG['form']['adddb']['error'], LANG_T['error']);
return return
}); });
// 创建 // 创建
break break
case "canclebtn": case "cancelbtn":
win.close(); win.close();
break; break;
} }
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; break;
} }
} }
...@@ -674,7 +674,7 @@ class PHP { ...@@ -674,7 +674,7 @@ class PHP {
let collation = result.datas[0][2] || "default" let collation = result.datas[0][2] || "default"
// 创建窗口 // 创建窗口
const win = this.manager.win.createWindow(hash, 0, 0, 450, 200); const win = this.manager.win.createWindow(hash, 0, 0, 450, 200);
win.setText("修改数据库"); win.setText(LANG['form']['editdb']['title']);
win.centerOnScreen(); win.centerOnScreen();
win.button('minmax').hide(); win.button('minmax').hide();
win.setModal(true); win.setModal(true);
...@@ -683,8 +683,8 @@ class PHP { ...@@ -683,8 +683,8 @@ class PHP {
const form = win.attachForm([ const form = win.attachForm([
{ type: 'settings', position: 'label-left', labelWidth: 90, inputWidth: 250 }, { type: 'settings', position: 'label-left', labelWidth: 90, inputWidth: 250 },
{ type: 'block', inputWidth: 'auto', offsetTop: 12, list: [ { type: 'block', inputWidth: 'auto', offsetTop: 12, list: [
{ type: 'input', label: "名称", name: 'dbname', readonly: true, value: dbname, required: true, validate:"ValidAplhaNumeric",}, { type: 'input', label: LANG['form']['editdb']['dbname'], name: 'dbname', readonly: true, value: dbname, required: true, validate:"ValidAplhaNumeric",},
{ type: 'combo', label: '字符集', readonly:true, name: 'characterset', options: (() => { { type: 'combo', label: LANG['form']['editdb']['characterset'], readonly:true, name: 'characterset', options: (() => {
let ret = []; let ret = [];
Object.keys(this.mysqlcsMapping).map((_) => { Object.keys(this.mysqlcsMapping).map((_) => {
ret.push({ ret.push({
...@@ -694,7 +694,7 @@ class PHP { ...@@ -694,7 +694,7 @@ class PHP {
}) })
return ret; return ret;
})() }, })() },
{ type: 'combo', label: '字符集排序', readonly:true, name: 'charactercollation', options: ((c)=>{ { type: 'combo', label: LANG['form']['editdb']['charactercollation'], readonly:true, name: 'charactercollation', options: ((c)=>{
let ret = []; let ret = [];
this.mysqlcsMapping[c].map((_)=>{ this.mysqlcsMapping[c].map((_)=>{
ret.push({ ret.push({
...@@ -705,9 +705,9 @@ class PHP { ...@@ -705,9 +705,9 @@ class PHP {
return ret; return ret;
})("default")}, })("default")},
{ type: "block", name:"btnblock", className:"display: flex;flex-direction: row;align-items: right;",offsetLeft:150, list:[ { type: "block", name:"btnblock", className:"display: flex;flex-direction: row;align-items: right;",offsetLeft:150, list:[
{ type:"button" , name:"updatebtn", value: `<i class="fa fa-pen"></i> 修改`}, { type:"button" , name:"updatebtn", value: `<i class="fa fa-pen"></i> ${LANG['form']['editdb']['updatebtn']}`},
{type: 'newcolumn', offset:20}, {type: 'newcolumn', offset:20},
{ type:"button" , name:"canclebtn", value: `<i class="fa fa-ban"></i> 取消`}, { type:"button" , name:"cancelbtn", value: `<i class="fa fa-ban"></i> ${LANG['form']['editdb']['cancelbtn']}`},
]} ]}
]} ]}
], true); ], true);
...@@ -754,18 +754,18 @@ class PHP { ...@@ -754,18 +754,18 @@ class PHP {
}; };
if(arr[1].indexOf("VHJ1ZQ==")!= -1){ if(arr[1].indexOf("VHJ1ZQ==")!= -1){
// 操作成功 // 操作成功
toastr.success("修改数据库成功" ,LANG_T['success']); toastr.success(LANG['form']['editdb']['success'] ,LANG_T['success']);
win.close(); win.close();
// refresh // refresh
this.getDatabases(id); this.getDatabases(id);
return return
} }
toastr.error("修改数据库失败", LANG_T['error']); toastr.error(LANG['form']['editdb']['error'], LANG_T['error']);
return return
}); });
// 修改 // 修改
break break
case "canclebtn": case "cancelbtn":
win.close(); win.close();
break; break;
} }
...@@ -773,7 +773,7 @@ class PHP { ...@@ -773,7 +773,7 @@ class PHP {
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; break;
} }
} }
...@@ -782,9 +782,9 @@ class PHP { ...@@ -782,9 +782,9 @@ class PHP {
// 获取配置 // 获取配置
const id = this.tree.getSelected().split('::')[1].split(":")[0]; const id = this.tree.getSelected().split('::')[1].split(":")[0];
let dbname = new Buffer(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString(); let dbname = new Buffer(this.tree.getSelected().split('::')[1].split(":")[1],"base64").toString();
layer.confirm(`确定要删除数据库 ${dbname} 吗?`, { layer.confirm(LANG['form']['deldb']['confirm'](dbname), {
icon: 2, shift: 6, icon: 2, shift: 6,
title: "警告" title: LANG['form']['deldb']['title']
}, (_) => { }, (_) => {
layer.close(_); layer.close(_);
switch(this.dbconf['type']){ switch(this.dbconf['type']){
...@@ -798,15 +798,15 @@ class PHP { ...@@ -798,15 +798,15 @@ class PHP {
} }
let result = this.parseResult(res['text']); let result = this.parseResult(res['text']);
if(result.datas[0][0]=='True'){ if(result.datas[0][0]=='True'){
toastr.success("删除数据库成功",LANG_T['success']); toastr.success(LANG['form']['deldb']['success'], LANG_T['success']);
this.getDatabases(id); this.getDatabases(id);
}else{ }else{
toastr.error("删除数据库失败",LANG_T['error']); toastr.error(LANG['form']['deldb']['error'], LANG_T['error']);
} }
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; break;
} }
}); });
...@@ -828,7 +828,7 @@ class PHP { ...@@ -828,7 +828,7 @@ class PHP {
// );`; // );`;
// this.manager.query.editor.session.setValue(sql); // this.manager.query.editor.session.setValue(sql);
const win = this.manager.win.createWindow(hash, 0, 0, 600, 400); const win = this.manager.win.createWindow(hash, 0, 0, 600, 400);
win.setText("新建表"); win.setText(LANG['form']['addtable']['title']);
win.centerOnScreen(); win.centerOnScreen();
win.button('minmax').hide(); win.button('minmax').hide();
win.setModal(true); win.setModal(true);
...@@ -838,25 +838,26 @@ class PHP { ...@@ -838,25 +838,26 @@ class PHP {
id: 'add', id: 'add',
type: 'button', type: 'button',
icon: 'plus-circle', icon: 'plus-circle',
text: '新增字段' text: LANG['form']['addtable']['add'],
}, { }, {
type: 'separator' type: 'separator'
}, { }, {
id: 'delete', id: 'delete',
type: 'button', type: 'button',
icon: 'remove', icon: 'remove',
text: "删除字段" text: LANG['form']['addtable']['delete']
},{ },{
id: 'save', id: 'save',
type: 'button', type: 'button',
icon: 'save', icon: 'save',
text: "保存" text: LANG['form']['addtable']['save']
}]); }]);
dhtmlxValidation.hasOwnProperty("isValidPositiveInteger") ? "" : dhtmlxValidation.isValidPositiveInteger = (a) => { return !!a.toString().match(/(^\d+$)/);} dhtmlxValidation.hasOwnProperty("isValidPositiveInteger") ? "" : dhtmlxValidation.isValidPositiveInteger = (a) => { return !!a.toString().match(/(^\d+$)/);}
const grid=win.attachGrid(); const grid=win.attachGrid();
grid.clearAll(); grid.clearAll();
grid.setHeader("Name,Type,Length,Not Null,Key,Auto Increment"); // Name,Type,Length,Not Null,Key,Auto Increment
grid.setHeader(LANG['form']['addtable']['gridheader']);
grid.setInitWidths('*,100,80,80,50,130'); grid.setInitWidths('*,100,80,80,50,130');
grid.setColTypes("ed,coro,edn,acheck,acheck,acheck"); grid.setColTypes("ed,coro,edn,acheck,acheck,acheck");
grid.setColValidators(["ValidAplhaNumeric","NotEmpty","ValidPositiveInteger","ValidBoolean","ValidBoolean","ValidBoolean"]); grid.setColValidators(["ValidAplhaNumeric","NotEmpty","ValidPositiveInteger","ValidBoolean","ValidBoolean","ValidBoolean"]);
...@@ -907,7 +908,7 @@ class PHP { ...@@ -907,7 +908,7 @@ class PHP {
case "delete": case "delete":
var ncids = grid.getSelectedId(); var ncids = grid.getSelectedId();
if(!ncids){ if(!ncids){
toastr.warning("请先选中要删除的行", LANG_T['warning']); toastr.warning(LANG['form']['addtable']['delete_not_select'], LANG_T['warning']);
return return
} }
let _ncids = ncids.split(","); let _ncids = ncids.split(",");
...@@ -918,7 +919,7 @@ class PHP { ...@@ -918,7 +919,7 @@ class PHP {
case "save": case "save":
let rids = grid.getAllRowIds(); let rids = grid.getAllRowIds();
if(!rids){ if(!rids){
toastr.warning("行数为空", LANG_T['warning']); toastr.warning(LANG['form']['addtable']['save_row_is_null'], LANG_T['warning']);
return return
} }
...@@ -929,7 +930,7 @@ class PHP { ...@@ -929,7 +930,7 @@ class PHP {
let cvalarr = []; let cvalarr = [];
for(var j=0; j<6;j++){ for(var j=0; j<6;j++){
if(grid.validateCell(_rids[i], j) == false){ if(grid.validateCell(_rids[i], j) == false){
toastr.error(`数据格式校验失败(${i+1}行,${j+1}列)`,LANG_T['error']); toastr.error(LANG['form']['addtable']['cell_valid_error'](i,j), LANG_T['error']);
grid.selectCell(_rids[i], j); grid.selectCell(_rids[i], j);
grid.editCell(); grid.editCell();
return return
...@@ -963,14 +964,18 @@ class PHP { ...@@ -963,14 +964,18 @@ class PHP {
} }
layer.prompt({ layer.prompt({
value: "", value: "",
title: `<i class="fa fa-file-code-o"></i> 输入新表名` title: `<i class="fa fa-file-code-o"></i> ${LANG['form']['addtable']['confirmtitle']}`
},(value, i, e) => { },(value, i, e) => {
if(!value.match(/^[a-zA-Z0-9_]+$/)){ if(!value.match(/^[a-zA-Z0-9_]+$/)){
toastr.error("表名不能带有特殊符号", LANG_T['error']); toastr.error(LANG['form']['addtable']['invalid_tablename'], LANG_T['error']);
return return
} }
layer.close(i); layer.close(i);
let pkres = pkstr.length > 0 ? `\tPRIMARY KEY ( ${pkstr.substr(0, pkstr.length-1)} )` : ""; let pkres = pkstr.length > 0 ? `\tPRIMARY KEY ( ${pkstr.substr(0, pkstr.length-1)} )` : "";
if(pkres.length == 0) {
bdstr = bdstr.slice(0, bdstr.lastIndexOf(","));
}
let rsql = `CREATE TABLE IF NOT EXISTS \`${value}\` (\n${bdstr}\n${pkres}\n);`; let rsql = `CREATE TABLE IF NOT EXISTS \`${value}\` (\n${bdstr}\n${pkres}\n);`;
this.manager.query.editor.session.setValue(rsql); this.manager.query.editor.session.setValue(rsql);
this.execSQLAsync(rsql, (res, err) => { this.execSQLAsync(rsql, (res, err) => {
...@@ -980,11 +985,11 @@ class PHP { ...@@ -980,11 +985,11 @@ class PHP {
} }
let result = this.parseResult(res['text']); let result = this.parseResult(res['text']);
if(result.datas[0][0]=='True'){ if(result.datas[0][0]=='True'){
toastr.success("新建表成功",LANG_T['success']); toastr.success(LANG['form']['addtable']['success'],LANG_T['success']);
this.getTables(id,dbname); this.getTables(id,dbname);
win.close(); win.close();
}else{ }else{
toastr.error("新建表失败", LANG_T['error']); toastr.error(LANG['form']['addtable']['error'], LANG_T['error']);
} }
}); });
}); });
...@@ -993,7 +998,7 @@ class PHP { ...@@ -993,7 +998,7 @@ class PHP {
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; break;
} }
} }
...@@ -1008,10 +1013,10 @@ class PHP { ...@@ -1008,10 +1013,10 @@ class PHP {
// const hash = (+new Date * Math.random()).toString(16).substr(2, 8); // const hash = (+new Date * Math.random()).toString(16).substr(2, 8);
layer.prompt({ layer.prompt({
value: tablename, value: tablename,
title: `<i class="fa fa-file-code-o"></i> 输入新表名` title: `<i class="fa fa-file-code-o"></i> ${LANG['form']['edittable']['title']}`
},(value, i, e) => { },(value, i, e) => {
if(!value.match(/^[a-zA-Z0-9_]+$/)){ if(!value.match(/^[a-zA-Z0-9_]+$/)){
toastr.error("表名不能带有特殊符号", LANG_T['error']); toastr.error(LANG['form']['edittable']['invalid_tablename'], LANG_T['error']);
return return
} }
layer.close(i); layer.close(i);
...@@ -1026,15 +1031,15 @@ class PHP { ...@@ -1026,15 +1031,15 @@ class PHP {
} }
let result = this.parseResult(res['text']); let result = this.parseResult(res['text']);
if(result.datas[0][0]=='True'){ if(result.datas[0][0]=='True'){
toastr.success("修改表名成功",LANG_T['success']); toastr.success(LANG['form']['edittable']['success'],LANG_T['success']);
this.getTables(id,dbname); this.getTables(id,dbname);
}else{ }else{
toastr.error("修改表名失败",LANG_T['error']); toastr.error(LANG['form']['edittable']['error'],LANG_T['error']);
} }
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; break;
} }
}); });
...@@ -1047,9 +1052,9 @@ class PHP { ...@@ -1047,9 +1052,9 @@ class PHP {
const id = treeselect.split('::')[1].split(":")[0]; const id = treeselect.split('::')[1].split(":")[0];
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString();
layer.confirm(`确定要删除表 ${tablename} 吗?`, { layer.confirm(LANG['form']['deltable']['confirm'](tablename), {
icon: 2, shift: 6, icon: 2, shift: 6,
title: "警告" title: LANG['form']['deltable']['title']
}, (_) => { }, (_) => {
layer.close(_); layer.close(_);
switch(this.dbconf['type']){ switch(this.dbconf['type']){
...@@ -1063,15 +1068,15 @@ class PHP { ...@@ -1063,15 +1068,15 @@ class PHP {
} }
let result = this.parseResult(res['text']); let result = this.parseResult(res['text']);
if(result.datas[0][0]=='True'){ if(result.datas[0][0]=='True'){
toastr.success("删除表成功",LANG_T['success']); toastr.success(LANG['form']['deltable']['success'],LANG_T['success']);
this.getTables(id,dbname); this.getTables(id,dbname);
}else{ }else{
toastr.error("删除表失败",LANG_T['error']); toastr.error(LANG['form']['deltable']['error'],LANG_T['error']);
} }
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; break;
} }
}); });
...@@ -1105,9 +1110,9 @@ class PHP { ...@@ -1105,9 +1110,9 @@ class PHP {
let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString(); let dbname = new Buffer(treeselect.split('::')[1].split(":")[1],"base64").toString();
let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString(); let tablename = new Buffer(treeselect.split('::')[1].split(":")[2],"base64").toString();
let columnname = new Buffer(treeselect.split('::')[1].split(":")[3],"base64").toString(); let columnname = new Buffer(treeselect.split('::')[1].split(":")[3],"base64").toString();
layer.confirm(`确定要删除列 ${columnname} 吗?`, { layer.confirm(LANG['form']['delcolumn']['confirm'](columnname), {
icon: 2, shift: 6, icon: 2, shift: 6,
title: "警告" title: LANG['form']['delcolumn']['title']
}, (_) => { }, (_) => {
layer.close(_); layer.close(_);
switch(this.dbconf['type']){ switch(this.dbconf['type']){
...@@ -1121,15 +1126,15 @@ class PHP { ...@@ -1121,15 +1126,15 @@ class PHP {
} }
let result = this.parseResult(res['text']); let result = this.parseResult(res['text']);
if(result.datas[0][0]=='True'){ if(result.datas[0][0]=='True'){
toastr.success("删除列成功",LANG_T['success']); toastr.success(LANG['form']['delcolumn']['success'],LANG_T['success']);
this.getColumns(id,dbname, tablename); this.getColumns(id,dbname, tablename);
}else{ }else{
toastr.error("删除列失败",LANG_T['error']); toastr.error(LANG['form']['delcolumn']['error'],LANG_T['error']);
} }
}); });
break; break;
default: default:
toastr.warning("该功能暂不支持该类型数据库", LANG_T['warning']); toastr.warning(LANG['notsupport'], LANG_T['warning']);
break; 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