Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
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
ops
jumpserver
Commits
4cd3dd36
Commit
4cd3dd36
authored
May 22, 2019
by
BaiJiangJie
Committed by
老广
May 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 更新RemoteApp (#2720)
* [Update] RemoteAppForm添加RemoteApp各类型参数保存逻辑 * [Update] RemoteApp添加默认应用路径
parent
b18ca8c9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
7 deletions
+61
-7
remote_app.py
apps/applications/forms/remote_app.py
+21
-0
remote_app_create_update.html
...ions/templates/applications/remote_app_create_update.html
+40
-7
No files found.
apps/applications/forms/remote_app.py
View file @
4cd3dd36
...
@@ -8,6 +8,7 @@ from orgs.mixins import OrgModelForm
...
@@ -8,6 +8,7 @@ from orgs.mixins import OrgModelForm
from
assets.models
import
Asset
,
SystemUser
from
assets.models
import
Asset
,
SystemUser
from
..models
import
RemoteApp
from
..models
import
RemoteApp
from
..
import
const
__all__
=
[
__all__
=
[
...
@@ -109,3 +110,23 @@ class RemoteAppCreateUpdateForm(RemoteAppTypeForms, OrgModelForm):
...
@@ -109,3 +110,23 @@ class RemoteAppCreateUpdateForm(RemoteAppTypeForms, OrgModelForm):
})
})
}
}
def
_clean_params
(
self
):
app_type
=
self
.
data
.
get
(
'type'
)
fields
=
const
.
REMOTE_APP_TYPE_MAP_FIELDS
.
get
(
app_type
,
[])
params
=
{}
for
field
in
fields
:
name
=
field
[
'name'
]
value
=
self
.
cleaned_data
[
name
]
params
.
update
({
name
:
value
})
return
params
def
_save_params
(
self
,
instance
):
params
=
self
.
_clean_params
()
instance
.
params
=
params
instance
.
save
()
return
instance
def
save
(
self
,
commit
=
True
):
instance
=
super
()
.
save
(
commit
=
commit
)
instance
=
self
.
_save_params
(
instance
)
return
instance
apps/applications/templates/applications/remote_app_create_update.html
View file @
4cd3dd36
...
@@ -64,28 +64,60 @@
...
@@ -64,28 +64,60 @@
{% block custom_foot_js %}
{% block custom_foot_js %}
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var
type_id
=
'#'
+
'{{ form.type.id_for_label }}'
;
var
app_type_id
=
'#'
+
'{{ form.type.id_for_label }}'
;
var
app_path_id
=
'#'
+
'{{ form.path.id_for_label }}'
;
var
all_type_fields
=
[
var
all_type_fields
=
[
'.chrome-fields'
,
'.chrome-fields'
,
'.mysql_workbench-fields'
,
'.mysql_workbench-fields'
,
'.vmware_client-fields'
,
'.vmware_client-fields'
,
'.custom-fields'
'.custom-fields'
];
];
function
appTypeChange
(){
var
app_type_map_default_fields_value
=
{
'chrome'
:
{
'app_path'
:
'C:
\\
Program Files (x86)
\\
Google
\\
Chrome
\\
Application
\\
chrome.exe'
},
'mysql_workbench'
:
{
'app_path'
:
'C:
\\
Program Files
\\
MySQL
\\
MySQL Workbench 8.0 CE
\\
MySQLWorkbench.exe'
},
'vmware_client'
:
{
'app_path'
:
''
},
'custom'
:
{
'app_path'
:
''
}
};
function
getAppType
(){
return
$
(
app_type_id
+
" option:selected"
).
val
();
}
function
initialDefaultValue
(){
var
app_type
=
getAppType
();
var
app_path
=
$
(
app_path_id
).
val
();
if
(
app_path
){
app_type_map_default_fields_value
[
app_type
][
'app_path'
]
=
app_path
}
}
function
setDefaultValue
(){
// 设置类型相关字段的默认值
var
app_type
=
getAppType
();
var
app_path
=
app_type_map_default_fields_value
[
app_type
][
'app_path'
];
$
(
app_path_id
).
val
(
app_path
)
}
function
hiddenFields
(){
var
app_type
=
getAppType
();
$
.
each
(
all_type_fields
,
function
(
index
,
value
){
$
.
each
(
all_type_fields
,
function
(
index
,
value
){
$
(
value
).
addClass
(
'hidden'
)
$
(
value
).
addClass
(
'hidden'
)
});
});
var
type
=
$
(
type_id
+
" option:selected"
).
val
();
$
(
'.'
+
app_type
+
'-fields'
).
removeClass
(
'hidden'
);
$
(
'.'
+
type
+
'-fields'
).
removeClass
(
'hidden'
);
}
}
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
({
$
(
'.select2'
).
select2
({
closeOnSelect
:
true
closeOnSelect
:
true
});
});
appTypeChange
()
initialDefaultValue
();
hiddenFields
();
setDefaultValue
();
})
})
.
on
(
'change'
,
type_id
,
function
(){
.
on
(
'change'
,
app_type_id
,
function
(){
appTypeChange
();
hiddenFields
();
setDefaultValue
();
});
});
</script>
</script>
{% endblock %}
{% endblock %}
\ No newline at end of file
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