mirror of https://github.com/jumpserver/jumpserver
[Fixture] 增加 task list 删除按钮
parent
3f72ce4b1f
commit
c940a4c0fb
|
@ -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']
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# ~*~ 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,)
|
||||
|
|
@ -1 +0,0 @@
|
|||
from views import *
|
|
@ -1,16 +0,0 @@
|
|||
# ~*~ 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!')
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# ~*~ 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
|
|
@ -1,4 +0,0 @@
|
|||
# ~*~ coding: utf-8 ~*~
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# ~*~ coding: utf-8 ~*~
|
||||
from __future__ import unicode_literals
|
||||
from rest_framework import viewsets
|
||||
|
||||
from serializers import *
|
||||
from permissions import *
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# ~*~ coding: utf-8 ~*~
|
||||
|
||||
from users.permissions import IsSuperUser
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
# ~*~ 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__'
|
||||
|
||||
|
|
@ -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 %}
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from .. import api
|
||||
|
||||
|
||||
urlpatterns = []
|
||||
router = DefaultRouter()
|
||||
router.register(r'v1/tasks', api.TaskViewSet, 'task')
|
||||
|
||||
urlpatterns = []
|
||||
|
||||
urlpatterns += router.urls
|
||||
|
|
Loading…
Reference in New Issue