Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
antSword
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HuangJunbo
antSword
Commits
16239843
Commit
16239843
authored
May 11, 2016
by
Medicean
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shell-editDataConf
添加数据库配置编辑功能
parent
7244ab55
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
157 additions
and
0 deletions
+157
-0
database.js
modules/database.js
+30
-0
index.js
source/modules/database/php/index.js
+127
-0
No files found.
modules/database.js
View file @
16239843
...
@@ -41,6 +41,7 @@ class Database {
...
@@ -41,6 +41,7 @@ class Database {
.
on
(
'shell-clear'
,
this
.
clearShell
.
bind
(
this
))
.
on
(
'shell-clear'
,
this
.
clearShell
.
bind
(
this
))
.
on
(
'shell-findOne'
,
this
.
findOneShell
.
bind
(
this
))
.
on
(
'shell-findOne'
,
this
.
findOneShell
.
bind
(
this
))
.
on
(
'shell-addDataConf'
,
this
.
addDataConf
.
bind
(
this
))
.
on
(
'shell-addDataConf'
,
this
.
addDataConf
.
bind
(
this
))
.
on
(
'shell-editDataConf'
,
this
.
editDataConf
.
bind
(
this
))
.
on
(
'shell-delDataConf'
,
this
.
delDataConf
.
bind
(
this
))
.
on
(
'shell-delDataConf'
,
this
.
delDataConf
.
bind
(
this
))
.
on
(
'shell-getDataConf'
,
this
.
getDataConf
.
bind
(
this
))
.
on
(
'shell-getDataConf'
,
this
.
getDataConf
.
bind
(
this
))
.
on
(
'shell-renameCategory'
,
this
.
renameShellCategory
.
bind
(
this
));
.
on
(
'shell-renameCategory'
,
this
.
renameShellCategory
.
bind
(
this
));
...
@@ -261,6 +262,35 @@ class Database {
...
@@ -261,6 +262,35 @@ class Database {
});
});
}
}
/**
* 修改数据库配置
* @param {Object} event ipcMain对象
* @param {Object} opts 配置(_id,data
*/
editDataConf
(
event
,
opts
)
{
logger
.
info
(
'shell-editDataConf'
,
opts
);
// 1. 获取原配置列表
this
.
cursor
.
findOne
({
_id
:
opts
[
'_id'
]
},
(
err
,
ret
)
=>
{
let
confs
=
ret
[
'database'
]
||
{};
// 添加到配置
logger
.
info
(
'shell-editDataConf-opts["id"]'
,
opts
[
'id'
]);
confs
[
opts
[
'id'
]]
=
opts
[
'data'
];
// 更新数据库
this
.
cursor
.
update
({
_id
:
opts
[
'_id'
]
},
{
$set
:
{
database
:
confs
,
utime
:
+
new
Date
}
},
(
_err
,
_ret
)
=>
{
event
.
returnValue
=
opts
[
'id'
];
});
});
}
/**
/**
* 删除数据库配置
* 删除数据库配置
* @param {Object} event ipcMain对象
* @param {Object} event ipcMain对象
...
...
source/modules/database/php/index.js
View file @
16239843
...
@@ -262,7 +262,134 @@ class PHP {
...
@@ -262,7 +262,134 @@ class PHP {
// 编辑配置
// 编辑配置
editConf
(){
editConf
(){
const
id
=
this
.
tree
.
getSelected
().
split
(
'::'
)[
1
];
// 获取配置
const
conf
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-getDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
id
});
const
hash
=
(
+
new
Date
*
Math
.
random
()).
toString
(
16
).
substr
(
2
,
8
);
// 创建窗口
const
win
=
this
.
manager
.
win
.
createWindow
(
hash
,
0
,
0
,
450
,
300
);
win
.
setText
(
LANG
[
'form'
][
'title'
]);
win
.
centerOnScreen
();
win
.
button
(
'minmax'
).
hide
();
win
.
setModal
(
true
);
win
.
denyResize
();
// 工具栏
const
toolbar
=
win
.
attachToolbar
();
toolbar
.
loadStruct
([{
id
:
'add'
,
type
:
'button'
,
icon
:
'plus-circle'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'add'
]
},
{
type
:
'separator'
},
{
id
:
'clear'
,
type
:
'button'
,
icon
:
'remove'
,
text
:
LANG
[
'form'
][
'toolbar'
][
'clear'
]
}]);
// form
const
form
=
win
.
attachForm
([
{
type
:
'settings'
,
position
:
'label-left'
,
labelWidth
:
90
,
inputWidth
:
250
},
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[
{
type
:
'combo'
,
label
:
LANG
[
'form'
][
'type'
],
readonly
:
true
,
name
:
'type'
,
options
:
[
{
text
:
'MYSQL'
,
value
:
'mysql'
,
selected
:
conf
[
'type'
]
===
'mysql'
,
list
:
[
{
type
:
'settings'
,
position
:
'label-left'
,
offsetLeft
:
70
,
labelWidth
:
90
,
inputWidth
:
150
},
{
type
:
'label'
,
label
:
LANG
[
'form'
][
'encode'
]
},
{
type
:
'combo'
,
label
:
''
,
name
:
'encode'
,
options
:
(()
=>
{
let
ret
=
[];
[
'utf8'
,
'big5'
,
'dec8'
,
'cp850'
,
'hp8'
,
'koi8r'
,
'latin1'
,
'latin2'
,
'ascii'
,
'euckr'
,
'gb2312'
,
'gbk'
].
map
((
_
)
=>
{
ret
.
push
({
text
:
_
,
value
:
_
,
selected
:
conf
[
'encode'
]
===
_
});
})
return
ret
;
})()
}
]
},
{
text
:
'MYSQLI'
,
value
:
'mysqli'
,
selected
:
conf
[
'type'
]
===
'mysqli'
,
list
:
[
{
type
:
'settings'
,
position
:
'label-left'
,
offsetLeft
:
70
,
labelWidth
:
90
,
inputWidth
:
150
},
{
type
:
'label'
,
label
:
LANG
[
'form'
][
'encode'
]
},
{
type
:
'combo'
,
label
:
''
,
name
:
'encode'
,
options
:
(()
=>
{
let
ret
=
[];
[
'utf8'
,
'big5'
,
'dec8'
,
'cp850'
,
'hp8'
,
'koi8r'
,
'latin1'
,
'latin2'
,
'ascii'
,
'euckr'
,
'gb2312'
,
'gbk'
].
map
((
_
)
=>
{
ret
.
push
({
text
:
_
,
value
:
_
,
selected
:
conf
[
'encode'
]
===
_
});
})
return
ret
;
})()
}
]
},
{
text
:
'MSSQL'
,
value
:
'mssql'
,
selected
:
conf
[
'type'
]
===
'mssql'
},
{
text
:
'ORACLE'
,
value
:
'oracle'
,
selected
:
conf
[
'type'
]
===
'oracle'
},
{
text
:
'INFORMIX'
,
value
:
'informix'
,
selected
:
conf
[
'type'
]
===
'informix'
}
]
},
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'host'
],
name
:
'host'
,
required
:
true
,
value
:
conf
[
'host'
]
},
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'user'
],
name
:
'user'
,
required
:
true
,
value
:
conf
[
'user'
]
},
{
type
:
'input'
,
label
:
LANG
[
'form'
][
'passwd'
],
name
:
'passwd'
,
value
:
conf
[
'passwd'
]
}
]}
],
true
);
form
.
attachEvent
(
'onChange'
,
(
_
,
id
)
=>
{
if
(
_
!==
'type'
)
{
return
};
switch
(
id
)
{
case
'mysql'
:
case
'mysqli'
:
form
.
setFormData
({
user
:
conf
[
'user'
],
passwd
:
conf
[
'passwd'
]
});
break
;
case
'mssql'
:
form
.
setFormData
({
user
:
conf
[
'user'
],
passwd
:
conf
[
'passwd'
]
});
break
;
default
:
form
.
setFormData
({
user
:
conf
[
'user'
],
passwd
:
conf
[
'passwd'
]
});
}
});
// 工具栏点击事件
toolbar
.
attachEvent
(
'onClick'
,
(
id
)
=>
{
switch
(
id
)
{
case
'clear'
:
form
.
clear
();
break
;
case
'add'
:
if
(
!
form
.
validate
())
{
return
toastr
.
warning
(
LANG
[
'form'
][
'warning'
],
LANG_T
[
'warning'
]);
};
// 解析数据
let
data
=
form
.
getValues
();
// 验证是否连接成功(获取数据库列表)
const
id
=
antSword
[
'ipcRenderer'
].
sendSync
(
'shell-editDataConf'
,
{
_id
:
this
.
manager
.
opt
[
'_id'
],
id
:
this
.
tree
.
getSelected
().
split
(
'::'
)[
1
],
data
:
data
});
win
.
close
();
toastr
.
success
(
LANG
[
'form'
][
'success'
],
LANG_T
[
'success'
]);
// 刷新 UI
this
.
parse
();
break
;
}
});
}
}
// 删除配置
// 删除配置
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment