Commit a448fd02 authored by ibuler's avatar ibuler

merged

parents 96d32f2e 2ab8e92b
......@@ -39,6 +39,12 @@ class AssetGroupViewSet(viewsets.ModelViewSet):
serializer_class = serializers.AssetGroupSerializer
class AssetUpdateGroupApi(generics.RetrieveUpdateAPIView):
queryset = Asset.objects.all()
serializer_class = serializers.AssetUpdateGroupSerializer
permission_classes = (IsSuperUser,)
class IDCViewSet(viewsets.ModelViewSet):
"""API endpoint that allows IDC to be viewed or edited."""
queryset = IDC.objects.all()
......@@ -58,6 +64,12 @@ class SystemUserViewSet(viewsets.ModelViewSet):
permission_classes = (IsSuperUser,)
class SystemUserUpdateApi(generics.RetrieveUpdateAPIView):
queryset = Asset.objects.all()
serializer_class = serializers.AssetUpdateSystemUserSerializer
permission_classes = (IsSuperUser,)
# class IDCAssetsApi(generics.ListAPIView):
# model = IDC
# serializer_class = serializers.AssetSerializer
......
......@@ -17,6 +17,19 @@ class AssetGroupSerializer(serializers.ModelSerializer):
def get_assets_amount(obj):
return obj.assets.count()
class AssetUpdateGroupSerializer(serializers.ModelSerializer):
groups = serializers.PrimaryKeyRelatedField(many=True, queryset=AssetGroup.objects.all())
class Meta:
model = Asset
fields = ['id', 'groups']
class AssetUpdateSystemUserSerializer(serializers.ModelSerializer):
system_users = serializers.PrimaryKeyRelatedField(many=True, queryset=SystemUser.objects.all())
class Meta:
model = Asset
fields = ['id', 'system_users']
class AdminUserSerializer(serializers.ModelSerializer):
class Meta:
......
......@@ -6,7 +6,7 @@
<div class="uc pull-left m-l-5 m-r-5">
<a href="{% url "assets:asset-group-create" %}" class="btn btn-sm btn-primary"> {% trans "Create asset group" %} </a>
</div>
<table class="table table-striped table-bordered table-hover " id="admin_user_list_table" >
<table class="table table-striped table-bordered table-hover " id="asset_groups_list_table" >
<thead>
<tr>
<th class="text-center">
......@@ -27,7 +27,7 @@
<script>
$(document).ready(function(){
var options = {
ele: $('#admin_user_list_table'),
ele: $('#asset_groups_list_table'),
columnDefs: [
{targets: 1, createdCell: function (td, cellData, rowData) {
var detail_btn = '<a href="{% url "assets:asset-group-detail" pk=99991937 %}">' + cellData + '</a>';
......@@ -46,7 +46,14 @@ $(document).ready(function(){
columns: [{data: "id"}, {data: "name" }, {data: "assets_amount" }, {data: "comment" }, {data: "id"}]
};
jumpserver.initDataTable(options);
});
})
.on('click', '.btn_asset_group_delete', 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-assets:asset-group-detail" pk=99991937 %}'.replace('99991937', uid);
objectDelete($this, name, the_url);
});
</script>
{% endblock %}
......@@ -127,8 +127,9 @@
}},
{targets: 9, createdCell: function (td, cellData, rowData) {
var update_btn = '<a href="{% url "assets:asset-update" pk=99991937 %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('99991937', cellData);
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_user_delete" data-uid="99991937">{% trans "Delete" %}</a>'.replace('99991937', cellData);
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_asset_delete" data-uid="99991937">{% trans "Delete" %}</a>'.replace('99991937', cellData);
$(td).html(update_btn + del_btn)
}}
],
ajax_url: '{% url "api-assets:asset-list" %}',
......@@ -179,6 +180,14 @@
$form.ajaxSubmit({success: success});
})
})
.on('click', '.btn_asset_delete', 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-assets:asset-detail" pk=99991937 %}'.replace('99991937', uid);
objectDelete($this, name, the_url);
});
</script>
{% endblock %}
\ No newline at end of file
......@@ -17,6 +17,10 @@ urlpatterns = [
url(r'^v1/assets_bulk$', api.AssetListUpdateApi.as_view(), name='asset-bulk-update'),
# url(r'^v1/idc/(?P<pk>[0-9]+)/assets/$', api.IDCAssetsApi.as_view(), name='api-idc-assets'),
url(r'^v1/system-user/auth', api.SystemUserAuthApi.as_view(), name='system-user-auth'),
url(r'^v1/assets/(?P<pk>\d+)/groups$',
api.AssetUpdateGroupApi.as_view(), name='asset-update-group'),
url(r'^v1/assets/(?P<pk>\d+)/system-users$',
api.SystemUserUpdateApi.as_view(), name='asset-update-systemusers'),
]
urlpatterns += router.urls
......
......@@ -255,16 +255,19 @@ function updateUserGroups(groups) {
success: success
});
}
$(document).ready(function() {
$('.select2').select2()
.on('select2:select', function(evt) {
var data = evt.params.data;
jumpserver.groups_selected[data.id] = data.text;
}).on('select2:unselect', function(evt) {
})
.on('select2:unselect', function(evt) {
var data = evt.params.data;
delete jumpserver.groups_selected[data.id]
})
}).on('click', '#is_active', function() {
})
.on('click', '#is_active', function() {
var the_url = "{% url 'api-users:user-detail' pk=user.id %}";
var checked = $(this).prop('checked');
var body = {
......@@ -276,19 +279,21 @@ $(document).ready(function() {
body: JSON.stringify(body),
success_message: success
});
}).on('click', '#enable_otp', function() {
var the_url = "{% url 'api-users:user-detail' pk=user.id %}";
var checked = $(this).prop('checked');
var body = {
'enable_otp': checked
};
var success = '{% trans "Update Successfully!" %}';
APIUpdateAttr({
url: the_url,
body: JSON.stringify(body),
success_message: success
});
}).on('click', '#btn_join_group', function() {
})
.on('click', '#enable_otp', function() {
var the_url = "{% url 'api-users:user-detail' pk=user.id %}";
var checked = $(this).prop('checked');
var body = {
'enable_otp': checked
};
var success = '{% trans "Update Successfully!" %}';
APIUpdateAttr({
url: the_url,
body: JSON.stringify(body),
success_message: success
});
})
.on('click', '#btn_join_group', function() {
if (Object.keys(jumpserver.groups_selected).length === 0) {
return false;
}
......
......@@ -132,7 +132,8 @@ $(document).ready(function(){
$form.ajaxSubmit({success: success});
})
}).on('click', '#btn_bulk_update', function(){
})
.on('click', '#btn_bulk_update', function(){
var action = $('#slct_bulk_update').val();
var $data_table = $('#user_list_table').DataTable();
var id_list = [];
......@@ -204,13 +205,15 @@ $(document).ready(function(){
default:
break;
}
}).on('click', '.btn_user_delete', function(){
})
.on('click', '.btn_user_delete', function(){
var $this = $(this);
var name = $this.data('name');
var uid = $this.data('uid');
var the_url = '{% url "api-users:user-detail" pk=99991937 %}'.replace('99991937', uid);
objectDelete($this, name, the_url);
}).on('click', '#btn_user_bulk_update', function(){
})
.on('click', '#btn_user_bulk_update', function(){
var json_data = $('#fm_user_bulk_update').serializeObject();
var body = {};
body.enable_otp = (json_data.enable_otp === 'on')? true: false;
......
ibtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
\ No newline at end of file
libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment