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
9c0f00f6
Unverified
Commit
9c0f00f6
authored
Dec 11, 2018
by
老广
Committed by
GitHub
Dec 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改命令执行 (#2148)
* [Update] 修改命令执行 * Update forms.py
parent
6a239833
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
19 deletions
+49
-19
command_execution_create.html
apps/ops/templates/ops/command_execution_create.html
+29
-13
asset_permission_create_update.html
...perms/templates/perms/asset_permission_create_update.html
+9
-3
forms.py
apps/users/forms.py
+4
-0
user.py
apps/users/models/user.py
+0
-2
_user.html
apps/users/templates/users/_user.html
+5
-1
user.py
apps/users/views/user.py
+2
-0
No files found.
apps/ops/templates/ops/command_execution_create.html
View file @
9c0f00f6
...
...
@@ -11,6 +11,10 @@
<script
src=
"{% static 'js/plugins/xterm/xterm.js' %}"
></script>
<link
rel=
"stylesheet"
href=
"{% static 'js/plugins/xterm/xterm.css' %}"
/>
<script
src=
"{% static 'js/plugins/xterm/addons/fit/fit.js' %}"
></script>
<script
src=
"{% static 'js/plugins/codemirror/codemirror.js' %}"
></script>
<script
src=
"{% static 'js/plugins/codemirror/mode/shell/shell.js' %}"
></script>
<link
href=
"{% static 'css/plugins/codemirror/codemirror.css' %}"
rel=
"stylesheet"
>
<link
href=
"{% static 'css/plugins/codemirror/ambiance.css' %}"
rel=
"stylesheet"
>
<link
href=
"{% static 'css/plugins/select2/select2.min.css' %}"
rel=
"stylesheet"
>
<script
src=
"{% static 'js/plugins/select2/select2.full.min.js' %}"
></script>
<style
type=
"text/css"
>
...
...
@@ -51,24 +55,22 @@
<div
id=
"term"
style=
"height: 100%;width: 100%"
></div>
</div>
<div
class=
"row"
>
<div
class=
"col-lg-10"
>
<div
class=
"input-group"
style=
"height: 100%; width: 100%"
>
<textarea
class=
"form-control"
id=
"command-text"
></textarea>
</div>
</div>
<div
class=
"col-lg-2"
>
<select
class=
"select2 form-control"
id=
"system-users-select"
>
{% for s in system_users %}
<select
class=
"select2 form-control"
id=
"system-users-select"
>
{% for s in system_users %}
{% if s.protocol == 'ssh' and s.login_mode == 'auto' %}
<option
value=
"{{ s.id }}"
>
{{ s }}
</option>
{% endif %}
{% endfor %}
</select>
</div>
<div
class=
"col-lg-10"
>
<div
class=
"input-group"
style=
"height: 100%"
>
<input
type=
"text"
id=
"command-text"
class=
"form-control"
>
<span
class=
"input-group-btn"
>
<button
type=
"button"
class=
"btn btn-primary btn-execute"
>
{% trans 'Go' %}
</button>
</span>
{% endfor %}
</select>
<button
type=
"button"
class=
"btn btn-primary btn-execute"
style=
"margin-top: 30px; width: 100%"
>
{% trans 'Go' %}
</button>
</div>
</div>
</div>
</form>
</div>
</div>
...
...
@@ -186,7 +188,7 @@ function execute() {
}
var
url
=
'{% url "api-ops:command-execution-list" %}'
;
var
run_as
=
systemUserId
;
var
command
=
$
(
"#command-text"
).
val
();
var
command
=
editor
.
getValue
();
var
hosts
=
getSelectedAssetsNode
().
map
(
function
(
node
)
{
return
node
.
id
;
});
...
...
@@ -242,6 +244,7 @@ function execute() {
return
false
;
}
var
editor
;
$
(
document
).
ready
(
function
(){
systemUserId
=
$
(
'#system-users-select'
).
val
();
$
(
".select2"
).
select2
().
on
(
'select2:select'
,
function
(
evt
)
{
...
...
@@ -249,6 +252,19 @@ $(document).ready(function(){
systemUserId
=
data
.
id
;
initTree
();
});
editor
=
CodeMirror
.
fromTextArea
(
document
.
getElementById
(
"command-text"
),
{
lineNumbers
:
true
,
lineWrapping
:
true
,
mode
:
"shell"
});
editor
.
setSize
(
600
,
100
);
var
charWidth
=
editor
.
defaultCharWidth
(),
basePadding
=
4
;
editor
.
on
(
"renderLine"
,
function
(
cm
,
line
,
elt
)
{
var
off
=
CodeMirror
.
countColumn
(
line
.
text
,
null
,
cm
.
getOption
(
"tabSize"
))
*
charWidth
;
elt
.
style
.
textIndent
=
"-"
+
off
+
"px"
;
elt
.
style
.
paddingLeft
=
(
basePadding
+
off
)
+
"px"
;
});
editor
.
refresh
();
initTree
();
initResultTerminal
();
}).
on
(
'click'
,
'.btn-execute'
,
function
()
{
...
...
apps/perms/templates/perms/asset_permission_create_update.html
View file @
9c0f00f6
...
...
@@ -54,9 +54,15 @@
<div
class=
"col-sm-9"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
type=
"text"
class=
"input-sm form-control"
id=
"date_start"
name=
"date_start"
value=
"{{ form.date_start.value|date:'Y-m-d H:i' }}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
id=
"date_expired"
name=
"date_expired"
value=
"{{ form.date_expired.value|date:'Y-m-d H:i' }}"
>
{% if form.errors %}
<input
type=
"text"
class=
"input-sm form-control"
id=
"date_start"
name=
"date_start"
value=
"{{ form.date_start.value }}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
id=
"date_expired"
name=
"date_expired"
value=
"{{ form.date_expired.value }}"
>
{% else %}
<input
type=
"text"
class=
"input-sm form-control"
id=
"date_start"
name=
"date_start"
value=
"{{ form.date_start.value|date:'Y-m-d H:i' }}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
id=
"date_expired"
name=
"date_expired"
value=
"{{ form.date_expired.value|date:'Y-m-d H:i' }}"
>
{% endif %}
</div>
<span
class=
"help-block "
>
{{ form.date_expired.errors }}
</span>
<span
class=
"help-block "
>
{{ form.date_start.errors }}
</span>
...
...
apps/users/forms.py
View file @
9c0f00f6
...
...
@@ -131,6 +131,10 @@ class UserCreateUpdateForm(OrgModelForm):
class
UserProfileForm
(
forms
.
ModelForm
):
username
=
forms
.
CharField
(
disabled
=
True
)
name
=
forms
.
CharField
(
disabled
=
True
)
email
=
forms
.
CharField
(
disabled
=
True
)
class
Meta
:
model
=
User
fields
=
[
...
...
apps/users/models/user.py
View file @
9c0f00f6
...
...
@@ -260,8 +260,6 @@ class User(AbstractUser):
self
.
role
=
'Admin'
self
.
is_active
=
True
super
()
.
save
(
*
args
,
**
kwargs
)
if
current_org
and
current_org
.
is_real
():
self
.
orgs
.
add
(
current_org
.
id
)
@property
def
private_token
(
self
):
...
...
apps/users/templates/users/_user.html
View file @
9c0f00f6
...
...
@@ -30,7 +30,11 @@
<div
class=
"col-sm-9"
>
<div
class=
"input-group date"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
id=
"{{ form.date_expired.id_for_label }}"
name=
"{{ form.date_expired.html_name }}"
type=
"text"
class=
"form-control"
value=
"{{ form.date_expired.value|date:'Y-m-d H:i' }}"
>
{% if form.errors %}
<input
id=
"{{ form.date_expired.id_for_label }}"
name=
"{{ form.date_expired.html_name }}"
type=
"text"
class=
"form-control"
value=
"{{ form.date_expired.value }}"
>
{% else %}
<input
id=
"{{ form.date_expired.id_for_label }}"
name=
"{{ form.date_expired.html_name }}"
type=
"text"
class=
"form-control"
value=
"{{ form.date_expired.value|date:'Y-m-d H:i' }}"
>
{% endif %}
</div>
<span
class=
"help-block "
>
{{ form.date_expired.errors }}
</span>
</div>
...
...
apps/users/views/user.py
View file @
9c0f00f6
...
...
@@ -87,6 +87,8 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
user
=
form
.
save
(
commit
=
False
)
user
.
created_by
=
self
.
request
.
user
.
username
or
'System'
user
.
save
()
if
current_org
and
current_org
.
is_real
():
user
.
orgs
.
add
(
current_org
.
id
)
post_user_create
.
send
(
self
.
__class__
,
user
=
user
)
return
super
()
.
form_valid
(
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