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
c5442207
Commit
c5442207
authored
Jun 28, 2016
by
antoor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the edit-shell features
更新编辑数据功能
parent
a2c15de9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
34 deletions
+96
-34
database.js
modules/database.js
+13
-8
contextmenu.js
source/modules/shellmanager/list/contextmenu.js
+24
-6
form.js
source/modules/shellmanager/list/form.js
+59
-20
No files found.
modules/database.js
View file @
c5442207
...
...
@@ -141,25 +141,30 @@ class Database {
/**
* 编辑shell数据
* @param {Object} event ipcMain对象
* @param {Object} opts 数据(
url,_id,pwd,type,encode,encoder
* @param {Object} opts 数据(
old,new
* @return {[type]} [description]
*/
editShell
(
event
,
opts
)
{
logger
.
warn
(
'editShell'
,
opts
);
this
.
_url2ip
(
opts
[
'url'
])
const
_new
=
opts
.
new
;
const
_old
=
opts
.
old
;
this
.
_url2ip
(
_new
.
base
[
'url'
])
.
then
((
ret
)
=>
{
this
.
cursor
.
update
({
_id
:
opts
[
'_id'
]
_id
:
_old
[
'_id'
]
},
{
$set
:
{
ip
:
ret
[
'ip'
],
addr
:
ret
[
'addr'
],
url
:
opts
[
'url'
],
pwd
:
opts
[
'pwd'
],
type
:
opts
[
'type'
],
encode
:
opts
[
'encode'
],
encoder
:
opts
[
'encoder'
],
url
:
_new
.
base
[
'url'
],
pwd
:
_new
.
base
[
'pwd'
],
type
:
_new
.
base
[
'type'
],
encode
:
_new
.
base
[
'encode'
],
encoder
:
_new
.
base
[
'encoder'
],
httpConf
:
_new
.
http
,
otherConf
:
_new
.
other
,
utime
:
+
new
Date
}
},
(
_err
,
_ret
)
=>
{
...
...
source/modules/shellmanager/list/contextmenu.js
View file @
c5442207
...
...
@@ -18,6 +18,7 @@ class ContextMenu {
* @return {[type]} [description]
*/
constructor
(
data
,
event
,
id
,
ids
)
{
console
.
log
(
'data='
,
data
);
let
selectedData
=
!
id
||
ids
.
length
!==
1
;
let
selectedMultiData
=
!
id
;
...
...
@@ -42,7 +43,7 @@ class ContextMenu {
],
false
,
[
'add'
,
'plus-circle'
,
false
,
this
.
addData
.
bind
(
this
)],
[
'edit'
,
'edit'
,
selectedData
,
this
.
editData
.
bind
(
this
,
id
)],
[
'edit'
,
'edit'
,
selectedData
,
this
.
editData
.
bind
(
this
,
data
[
0
]
)],
[
'delete'
,
'remove'
,
selectedMultiData
,
this
.
delData
.
bind
(
this
,
ids
)],
false
,
[
'move'
,
'share-square'
,
selectedMultiData
,
null
,
this
.
parseMoveCategoryMenu
(
ids
)],
...
...
@@ -198,9 +199,9 @@ class ContextMenu {
antSword
.
modules
.
shellmanager
.
reloadData
({
category
:
data
[
'base'
][
'category'
]
});
return
res
();
return
res
(
LANG
[
'list'
][
'add'
][
'success'
]
);
}
else
{
return
rej
(
ret
.
totring
(
));
return
rej
(
LANG
[
'list'
][
'add'
][
'error'
](
ret
.
toString
()
));
}
});
})
...
...
@@ -208,14 +209,31 @@ class ContextMenu {
/**
* 编辑数据
* @param {
number} id [description]
* @param {
Object} info 当前选中的数据
* @return {[type]} [description]
*/
editData
(
i
d
)
{
editData
(
i
nfo
)
{
new
Form
({
title
:
LANG
[
'list'
][
'edit'
][
'title'
](
i
d
),
title
:
LANG
[
'list'
][
'edit'
][
'title'
](
i
nfo
.
url
),
icon
:
'save'
,
text
:
LANG
[
'list'
][
'edit'
][
'toolbar'
][
'save'
]
},
info
,
(
data
)
=>
{
return
new
Promise
((
res
,
rej
)
=>
{
// 通知后台更新数据
const
ret
=
antSword
.
ipcRenderer
.
sendSync
(
'shell-edit'
,
{
old
:
info
,
new
:
data
});
if
(
ret
===
1
)
{
// 重新加载数据
antSword
.
modules
.
shellmanager
.
reloadData
({
category
:
info
[
'category'
]
});
return
res
(
LANG
[
'list'
][
'edit'
][
'success'
]);
}
else
{
return
rej
(
LANG
[
'list'
][
'edit'
][
'error'
](
ret
.
toString
()));
}
})
})
}
...
...
source/modules/shellmanager/list/form.js
View file @
c5442207
...
...
@@ -45,14 +45,14 @@ class Form {
this
.
baseForm
.
getValues
(),
this
.
httpForm
.
getValues
(),
this
.
otherForm
.
getValues
()
)).
then
(()
=>
{
)).
then
((
msg
)
=>
{
// 添加/保存完毕后回调
win
.
close
();
toastr
.
success
(
LANG
[
'list'
][
'add'
][
'success'
]
,
LANG_T
[
'success'
]);
}).
catch
((
e
)
=>
{
toastr
.
success
(
msg
,
LANG_T
[
'success'
]);
}).
catch
((
msg
)
=>
{
// 添加/保存错误
win
.
progressOff
();
toastr
.
error
(
LANG
[
'list'
][
'add'
][
'error'
](
e
.
toString
())
,
LANG_T
[
'error'
]);
toastr
.
error
(
msg
,
LANG_T
[
'error'
]);
});
};
});
...
...
@@ -137,30 +137,45 @@ class Form {
* @return {[type]} [description]
*/
_createBaseForm
(
arg
)
{
const
opt
=
Object
.
assign
({},
{
url
:
''
,
pwd
:
''
,
type
:
'php'
,
encode
:
'utf8'
,
encoder
:
'default'
},
arg
);
const
form
=
this
.
accordion
.
cells
(
'base'
).
attachForm
([
{
type
:
'settings'
,
position
:
'label-left'
,
labelWidth
:
80
,
inputWidth
:
400
},
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[
{
type
:
'input'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'url'
],
name
:
'url'
,
required
:
true
},
{
type
:
'input'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'pwd'
],
name
:
'pwd'
,
required
:
true
},
{
type
:
'combo'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'encode'
],
readonly
:
true
,
name
:
'encode'
,
options
:
this
.
_parseEncoders
()
},
{
type
:
'combo'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'type'
],
name
:
'type'
,
readonly
:
true
,
options
:
this
.
_parseTypes
()
}
{
type
:
'input'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'url'
],
name
:
'url'
,
required
:
true
,
value
:
opt
.
url
},
{
type
:
'input'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'pwd'
],
name
:
'pwd'
,
required
:
true
,
value
:
opt
.
pwd
},
{
type
:
'combo'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'encode'
],
readonly
:
true
,
name
:
'encode'
,
options
:
this
.
_parseEncodes
(
opt
.
encode
)
},
{
type
:
'combo'
,
label
:
LANG
[
'list'
][
'add'
][
'form'
][
'type'
],
name
:
'type'
,
readonly
:
true
,
options
:
this
.
_parseTypes
(
opt
.
type
,
opt
.
encoder
)
}
]
}
],
true
);
return
form
;
}
/**
* 解析编码器列表
* 解析编码列表
* @param {String} _default 默认编码器
* @return {array} [description]
*/
_parseEncode
rs
(
)
{
_parseEncode
s
(
_default
=
'utf8'
)
{
let
ret
=
[];
ENCODES
.
map
((
_
)
=>
{
ret
.
push
({
text
:
_
,
value
:
_
,
selected
:
_
===
'UTF8'
selected
:
_
===
_default
.
toUpperCase
()
});
});
return
ret
;
...
...
@@ -168,15 +183,17 @@ class Form {
/**
* 解析脚本支持列表
* @param {String} _default 默认类型
* @param {String} _encoder 默认编码器
* @return {array} [description]
*/
_parseTypes
()
{
_parseTypes
(
_default
=
'php'
,
_encoder
=
'default'
)
{
let
ret
=
[];
for
(
let
c
in
antSword
[
'core'
])
{
let
encoders
=
antSword
[
'core'
][
c
].
prototype
.
encoders
;
ret
.
push
({
text
:
c
.
toUpperCase
(),
value
:
c
,
selected
:
c
===
'php'
,
selected
:
c
===
_default
,
list
:
((
c
)
=>
{
let
_
=
[
{
type
:
'settings'
,
position
:
'label-right'
,
offsetLeft
:
60
,
labelWidth
:
100
},
...
...
@@ -186,7 +203,7 @@ class Form {
encoders
.
map
((
e
)
=>
{
_
.
push
({
type
:
'radio'
,
name
:
`encoder_
${
c
}
`
,
value
:
e
,
label
:
e
value
:
e
,
label
:
e
,
checked
:
e
===
_encoder
})
});
return
_
;
...
...
@@ -243,14 +260,20 @@ class Form {
* @return {[type]} [description]
*/
_createOtherForm
(
arg
)
{
const
opt
=
Object
.
assign
({},
{
'ignore-https'
:
0
,
'terminal-cache'
:
1
},
arg
.
otherConf
);
const
form
=
this
.
accordion
.
cells
(
'other'
).
attachForm
([{
type
:
'settings'
,
position
:
'label-right'
,
inputWidth
:
400
},
{
type
:
'block'
,
inputWidth
:
'auto'
,
offsetTop
:
12
,
list
:
[
{
type
:
"checkbox"
,
name
:
'ignore-https'
,
label
:
"忽略HTTPS证书"
,
checked
:
false
type
:
"checkbox"
,
name
:
'ignore-https'
,
label
:
"忽略HTTPS证书"
,
checked
:
opt
[
'ignore-https'
]
===
1
},
{
type
:
"checkbox"
,
name
:
'terminal-cache'
,
label
:
"虚拟终端不使用缓存"
,
checked
:
true
type
:
"checkbox"
,
name
:
'terminal-cache'
,
label
:
"虚拟终端不使用缓存"
,
checked
:
opt
[
'terminal-cache'
]
===
1
}
]}],
true
);
return
form
;
...
...
@@ -262,6 +285,10 @@ class Form {
* @return {[type]} [description]
*/
_createHttpForm
(
arg
)
{
const
opt
=
Object
.
assign
({},
{
headers
:
{},
body
:
{}
},
arg
.
httpConf
);
const
cell
=
this
.
accordion
.
cells
(
'http'
);
// 创建toolbar,用于添加数据
const
toolbar
=
cell
.
attachToolbar
();
...
...
@@ -327,8 +354,20 @@ class Form {
break
;
}
});
_addHeader
();
_addBody
();
// 添加存储的配置
for
(
let
_
in
opt
.
headers
)
{
_addHeader
(
_
,
opt
.
headers
[
_
]);
}
for
(
let
_
in
opt
.
body
)
{
_addBody
(
_
,
opt
.
body
[
_
]);
}
// 如果没有配置,则添加空白的输入框
if
(
_headerCount
===
0
)
{
_addHeader
();
}
if
(
_bodyCount
===
0
)
{
_addBody
();
}
return
form
;
}
}
...
...
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