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
c940a4c0
Commit
c940a4c0
authored
Mar 22, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Fixture] 增加 task list 删除按钮
parent
3f72ce4b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
47 additions
and
125 deletions
+47
-125
tasks.py
apps/assets/tasks.py
+1
-2
asset_list.html
apps/assets/templates/assets/asset_list.html
+1
-37
api.py
apps/ops/api.py
+15
-0
__init__.py
apps/ops/api/__init__.py
+0
-2
exc.py
apps/ops/api/exc.py
+0
-16
permissions.py
apps/ops/api/permissions.py
+0
-19
views.py
apps/ops/api/views.py
+0
-7
hands.py
apps/ops/hands.py
+1
-1
serializers.py
apps/ops/serializers.py
+13
-0
task_list.html
apps/ops/templates/ops/task_list.html
+9
-39
api_urls.py
apps/ops/urls/api_urls.py
+7
-2
No files found.
apps/assets/tasks.py
View file @
c940a4c0
...
...
@@ -12,8 +12,7 @@ def update_assets_hardware_info(assets):
task_tuple
=
(
(
'setup'
,
''
),
)
task_name
=
','
.
join
([
asset
.
hostname
for
asset
in
assets
])
summary
,
result
=
run_AdHoc
(
task_tuple
,
assets
,
record
=
True
,
task_name
=
task_name
)
summary
,
result
=
run_AdHoc
(
task_tuple
,
assets
,
record
=
False
)
for
hostname
,
info
in
result
[
'contacted'
]
.
items
():
if
info
:
info
=
info
[
0
][
'ansible_facts'
]
...
...
apps/assets/templates/assets/asset_list.html
View file @
c940a4c0
...
...
@@ -104,37 +104,6 @@ function tagShow() {
}
}
//onload;
function
objDelete
(
obj
,
name
,
url
)
{
function
doDelete
()
{
var
body
=
{};
var
success
=
function
()
{
swal
(
'Deleted!'
,
"[ "
+
name
+
"]"
+
" has been deleted "
,
"success"
);
$
(
obj
).
parent
().
parent
().
remove
();
};
var
fail
=
function
()
{
swal
(
"Failed"
,
"Delete"
+
"[ "
+
name
+
" ]"
+
"failed"
,
"error"
);
};
APIUpdateAttr
({
url
:
url
,
body
:
JSON
.
stringify
(
body
),
method
:
'DELETE'
,
success
:
success
,
error
:
fail
});
}
swal
({
title
:
'Are you sure delete ?'
,
text
:
" ["
+
name
+
"] "
,
type
:
"warning"
,
showCancelButton
:
true
,
cancelButtonText
:
'Cancel'
,
confirmButtonColor
:
"#DD6B55"
,
confirmButtonText
:
'Confirm'
,
closeOnConfirm
:
false
},
function
()
{
doDelete
()
});
}
$
(
document
).
ready
(
function
(){
var
options
=
{
...
...
@@ -214,15 +183,10 @@ $(document).ready(function(){
.
on
(
'click'
,
'.btn_asset_delete'
,
function
()
{
var
$this
=
$
(
this
);
var
$data_table
=
$
(
"#asset_list_table"
).
DataTable
();
var
name
=
$
(
this
).
closest
(
"tr"
).
find
(
":nth-child(2)"
).
children
(
'a'
).
html
();
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-assets:asset-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
console
.
log
(
the_url
);
objDelete
(
$this
,
name
,
the_url
);
setTimeout
(
function
()
{
$data_table
.
ajax
.
reload
();
},
3000
);
objectDelete
(
$this
,
name
,
the_url
);
})
.
on
(
'click'
,
'#btn_bulk_update'
,
function
()
{
...
...
apps/ops/api.py
0 → 100644
View file @
c940a4c0
# ~*~ coding: utf-8 ~*~
from
rest_framework
import
viewsets
from
.hands
import
IsSuperUser
from
.models
import
Task
from
.serializers
import
TaskSerializer
class
TaskViewSet
(
viewsets
.
ModelViewSet
):
queryset
=
Task
.
objects
.
all
()
serializer_class
=
TaskSerializer
permission_classes
=
(
IsSuperUser
,)
apps/ops/api/__init__.py
deleted
100644 → 0
View file @
3f72ce4b
from
views
import
*
\ No newline at end of file
apps/ops/api/exc.py
deleted
100644 → 0
View file @
3f72ce4b
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
,
print_function
from
rest_framework.exceptions
import
APIException
from
django.utils.translation
import
ugettext
as
_
class
ServiceUnavailable
(
APIException
):
status_code
=
default_code
=
503
default_detail
=
_
(
'Service temporarily unavailable, try again later.'
)
class
ServiceNotImplemented
(
APIException
):
status_code
=
default_code
=
501
default_detail
=
_
(
'This service maybe implemented in the future, but now not implemented!'
)
apps/ops/api/permissions.py
deleted
100644 → 0
View file @
3f72ce4b
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
rest_framework
import
permissions
class
AdminUserRequired
(
permissions
.
BasePermission
):
"""
Custom permission to only allow admin user to access the resource.
"""
def
has_object_permission
(
self
,
request
,
view
,
obj
):
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
if
request
.
method
in
permissions
.
SAFE_METHODS
:
return
True
# Write permissions are only allowed to the admin role.
return
request
.
user
.
is_staff
apps/ops/api/views.py
deleted
100644 → 0
View file @
3f72ce4b
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
rest_framework
import
viewsets
from
serializers
import
*
from
permissions
import
*
apps/ops/
api/serializer
s.py
→
apps/ops/
hand
s.py
View file @
c940a4c0
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
users.permissions
import
IsSuperUser
apps/ops/serializers.py
0 → 100644
View file @
c940a4c0
# ~*~ coding: utf-8 ~*~
from
__future__
import
unicode_literals
from
rest_framework
import
serializers
from
.models
import
Task
class
TaskSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
Task
fields
=
'__all__'
apps/ops/templates/ops/task_list.html
View file @
c940a4c0
...
...
@@ -35,7 +35,7 @@
{% endblock %}
{% block table_head %}
<th></th>
<th
class=
"text-center"
></th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset' %}
</th>
<th
class=
"text-center"
>
{% trans 'Success' %}
</th>
...
...
@@ -69,6 +69,7 @@
<td
class=
"text-center"
>
{{ object.timedelta }} s
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'ops:task-run' pk=object.uuid %}"
class=
"btn btn-xs btn-info"
>
{% trans "Run again" %}
</a>
<a
data-uid=
"{{ object.uuid }}"
class=
"btn btn-xs btn-danger btn-del"
>
{% trans "Delete" %}
</a>
</td>
</tr>
{% endfor %}
...
...
@@ -92,45 +93,14 @@
forceParse
:
false
,
autoclose
:
true
});
}).
on
(
'click'
,
'.btn-del'
,
function
()
{
var
$this
=
$
(
this
);
var
name
=
$
(
this
).
closest
(
"tr"
).
find
(
":nth-child(2)"
).
children
(
'a'
).
html
();
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-ops:task-detail" pk=99991937 %}'
.
replace
(
'99991937'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
})
</script>
{# function terminateConnection(data) {#}
{# function success() {#}
{# window.setTimeout(function () {#}
{# window.location.reload()#}
{# }, 300)#}
{# }#}
{# var the_url = "{% url 'api-applications:terminate-connection' %}";#}
{# APIUpdateAttr({url: the_url, method: 'POST', body: JSON.stringify(data), success: success, success_message: 'Terminate success'});#}
{# }#}
{# $(document).ready(function() {#}
{# $('table').DataTable({#}
{# "searching": false,#}
{# "paging": false,#}
{# "bInfo" : false,#}
{# "order": []#}
{# });#}
{# $('.select2').select2();#}
{# $('#date .input-daterange').datepicker({#}
{# dateFormat: 'mm/dd/yy',#}
{# keyboardNavigation: false,#}
{# forceParse: false,#}
{# autoclose: true#}
{# });#}
{# }).on('click', '.btn-term', function () {#}
{# var $this = $(this);#}
{# var proxy_log_id = $this.attr('value');#}
{# var data = {#}
{# proxy_log_id: proxy_log_id#}
{# };#}
{# terminateConnection(data)#}
{# }).on('click', '#btn_bulk_update', function () {#}
{# var data = [];#}
{# $('.cbx-term:checked').each(function () {#}
{# data.push({proxy_log_id: $(this).attr('value')})#}
{# });#}
{# terminateConnection(data)#}
{# })#}
{#
</script>
#}
{% endblock %}
apps/ops/urls/api_urls.py
View file @
c940a4c0
...
...
@@ -2,6 +2,12 @@
from
__future__
import
unicode_literals
from
rest_framework.routers
import
DefaultRouter
from
..
import
api
urlpatterns
=
[]
\ No newline at end of file
router
=
DefaultRouter
()
router
.
register
(
r'v1/tasks'
,
api
.
TaskViewSet
,
'task'
)
urlpatterns
=
[]
urlpatterns
+=
router
.
urls
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