Commit bb8852d5 authored by ibuler's avatar ibuler

Modify some style

parent 037d9323
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<td class="text-center">{{ idc.address }}</td> <td class="text-center">{{ idc.address }}</td>
<td class="text-center"> <td class="text-center">
<a href="{% url 'assets:idc-update' pk=idc.id %}" class="btn btn-xs btn-info">{% trans 'Update' %}</a> <a href="{% url 'assets:idc-update' pk=idc.id %}" class="btn btn-xs btn-info">{% trans 'Update' %}</a>
<a onclick="obj_del(this,'{{ idc.name }}','{% url 'assets:idc-delete' idc.id %}')" class="btn btn-xs btn-danger del">{% trans 'Delete' %}</a> <a onclick="objectDelete(this, '{{ idc.name }}', '{% url 'assets:idc-delete' idc.id %}')" class="btn btn-xs btn-danger del">{% trans 'Delete' %}</a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
......
...@@ -173,7 +173,7 @@ class IDCListView(AdminUserRequiredMixin, ListView): ...@@ -173,7 +173,7 @@ class IDCListView(AdminUserRequiredMixin, ListView):
class IDCCreateView(AdminUserRequiredMixin, CreateView): class IDCCreateView(AdminUserRequiredMixin, CreateView):
model = IDC model = IDC
form_class = IDCForm form_class = IDCForm
template_name = 'assets/idc_create.html' template_name = 'assets/idc_create_update.html'
success_url = reverse_lazy('assets:idc-list') success_url = reverse_lazy('assets:idc-list')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
...@@ -188,24 +188,26 @@ class IDCCreateView(AdminUserRequiredMixin, CreateView): ...@@ -188,24 +188,26 @@ class IDCCreateView(AdminUserRequiredMixin, CreateView):
class IDCUpdateView(AdminUserRequiredMixin, UpdateView): class IDCUpdateView(AdminUserRequiredMixin, UpdateView):
model = IDC model = IDC
form_class = IDCForm form_class = IDCForm
template_name = 'assets/idc_create.html' template_name = 'assets/idc_create_update.html'
context_object_name = 'IDC' context_object_name = 'idc'
success_url = reverse_lazy('assets:idc-list') success_url = reverse_lazy('assets:idc-list')
def form_valid(self, form): def form_valid(self, form):
IDC = form.save(commit=False) idc = form.save(commit=False)
IDC.save() idc.save()
return super(IDCUpdateView, self).form_valid(form) return super(IDCUpdateView, self).form_valid(form)
class IDCDetailView(AdminUserRequiredMixin, DetailView): class IDCDetailView(AdminUserRequiredMixin, DetailView):
pass pass
class IDCDeleteView(AdminUserRequiredMixin, DeleteView): class IDCDeleteView(AdminUserRequiredMixin, DeleteView):
model = IDC model = IDC
template_name = 'assets/delete_confirm.html' template_name = 'assets/delete_confirm.html'
success_url = reverse_lazy('assets:idc-list') success_url = reverse_lazy('assets:idc-list')
class AdminUserListView(AdminUserRequiredMixin, ListView): class AdminUserListView(AdminUserRequiredMixin, ListView):
model = AdminUser model = AdminUser
paginate_by = settings.CONFIG.DISPLAY_PER_PAGE paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
...@@ -241,7 +243,6 @@ class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVie ...@@ -241,7 +243,6 @@ class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVie
form_class = AdminUserForm form_class = AdminUserForm
template_name = 'assets/admin_user_create_update.html' template_name = 'assets/admin_user_create_update.html'
success_url = reverse_lazy('assets:admin-user-list') success_url = reverse_lazy('assets:admin-user-list')
success_message = _('Create admin user <a href="%s">%s</a> successfully.')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = { context = {
...@@ -252,17 +253,18 @@ class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVie ...@@ -252,17 +253,18 @@ class AdminUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVie
return super(AdminUserCreateView, self).get_context_data(**kwargs) return super(AdminUserCreateView, self).get_context_data(**kwargs)
def get_success_message(self, cleaned_data): def get_success_message(self, cleaned_data):
return self.success_message % ( success_message = _('Create admin user <a href="%s">%s</a> successfully.' %
reverse_lazy('assets:admin-user-detail', kwargs={'pk': self.object.pk}), (
self.object.name, reverse_lazy('assets:admin-user-detail', kwargs={'pk': self.object.pk}),
) self.object.name,
))
return success_message
class AdminUserUpdateView(AdminUserRequiredMixin, UpdateView): class AdminUserUpdateView(AdminUserRequiredMixin, UpdateView):
model = AdminUser model = AdminUser
form_class = AdminUserForm form_class = AdminUserForm
template_name = 'assets/admin_user_create_update.html' template_name = 'assets/admin_user_create_update.html'
success_message = _('Update admin user <a href="%s">%s</a> successfully.')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = { context = {
...@@ -340,7 +342,6 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi ...@@ -340,7 +342,6 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi
form_class = SystemUserForm form_class = SystemUserForm
template_name = 'assets/system_user_create_update.html' template_name = 'assets/system_user_create_update.html'
success_url = reverse_lazy('assets:system-user-list') success_url = reverse_lazy('assets:system-user-list')
success_message = _('Create system user <a href="%s">%s</a> successfully.')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = { context = {
...@@ -351,10 +352,13 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi ...@@ -351,10 +352,13 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi
return super(SystemUserCreateView, self).get_context_data(**kwargs) return super(SystemUserCreateView, self).get_context_data(**kwargs)
def get_success_message(self, cleaned_data): def get_success_message(self, cleaned_data):
return self.success_message % ( success_message = _('Create system user <a href="%s">%s</a> successfully.' %
reverse_lazy('assets:system-user-detail', kwargs={'pk': self.object.pk}), (
self.object.name, reverse_lazy('assets:system-user-detail', kwargs={'pk': self.object.pk}),
) self.object.name,
))
return self.success_message
class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView): class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
......
This diff is collapsed.
...@@ -60,7 +60,6 @@ class AssetPermissionCreateView(AdminUserRequiredMixin, SuccessMessageMixin, Cre ...@@ -60,7 +60,6 @@ class AssetPermissionCreateView(AdminUserRequiredMixin, SuccessMessageMixin, Cre
form_class = AssetPermissionForm form_class = AssetPermissionForm
template_name = 'perms/asset_permission_create_update.html' template_name = 'perms/asset_permission_create_update.html'
success_url = reverse_lazy('perms:asset-permission-list') success_url = reverse_lazy('perms:asset-permission-list')
success_message = _('Create asset permission <a href="%s"> %s </a> successfully.')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = { context = {
...@@ -71,10 +70,12 @@ class AssetPermissionCreateView(AdminUserRequiredMixin, SuccessMessageMixin, Cre ...@@ -71,10 +70,12 @@ class AssetPermissionCreateView(AdminUserRequiredMixin, SuccessMessageMixin, Cre
return super(AssetPermissionCreateView, self).get_context_data(**kwargs) return super(AssetPermissionCreateView, self).get_context_data(**kwargs)
def get_success_message(self, cleaned_data): def get_success_message(self, cleaned_data):
return self.success_message % ( success_message = _('Create asset permission <a href="%s"> %s </a> successfully.' %
reverse_lazy('perms:asset-permission-detail', kwargs={'pk': self.object.pk}), (
self.object.name, reverse_lazy('perms:asset-permission-detail', kwargs={'pk': self.object.pk}),
) self.object.name,
))
return success_message
class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView): class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
......
...@@ -124,33 +124,66 @@ function move_left(from, to, from_o, to_o) { ...@@ -124,33 +124,66 @@ function move_left(from, to, from_o, to_o) {
function selectAll(){ function selectAll(){
// 选择该页面所有option // Select all check box
$('option').each(function(){ $('option').each(function(){
$(this).attr('selected', true); $(this).attr('selected', true);
}); });
} }
// // function getIDall() {
//function move_all(from, to){ // var check_array = [];
// $("#"+from).children().each(function(){ // $(".gradeX input:checked").each(function () {
// $("#"+to).append(this); // var id = $(this).attr("value");
// }); // check_array.push(id);
//} // });
// return check_array.join(",");
// }
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
//function commit_select(form_array){ function csrfSafeMethod(method) {
// $('#{0} option'.format(form_array)).each(function(){ // these HTTP methods do not require CSRF protection
// $(this).prop('selected', true) return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
// }) }
//}
function getIDall() { function setAjaxCSRFToken() {
var check_array = []; var csrftoken = getCookie('csrftoken');
$(".gradeX input:checked").each(function () { var sessionid = getCookie('sessionid');
var id = $(this).attr("value");
check_array.push(id); $.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
}); });
return check_array.join(","); }
function activeNav() {
var url_array = document.location.pathname.split("/");
var app = url_array[1];
var resource = url_array[2];
if (app == ''){
$('#index').addClass('active')
} else {
$("#" + app).addClass('active');
$('#' + app + ' #' + resource).addClass('active');
}
} }
function APIUpdateAttr(props) { function APIUpdateAttr(props) {
...@@ -158,6 +191,7 @@ function APIUpdateAttr(props) { ...@@ -158,6 +191,7 @@ function APIUpdateAttr(props) {
props = props || {}; props = props || {};
success_message = props.success_message || 'Update Successfully!'; success_message = props.success_message || 'Update Successfully!';
fail_message = props.fail_message || 'Error occurred while updating.'; fail_message = props.fail_message || 'Error occurred while updating.';
$.ajax({ $.ajax({
url: props.url, url: props.url,
type: props.method || "PATCH", type: props.method || "PATCH",
......
...@@ -6,62 +6,23 @@ ...@@ -6,62 +6,23 @@
<!-- Custom and plugin javascript --> <!-- Custom and plugin javascript -->
<script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script> <script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script>
<script src="{% static "js/inspinia.js" %}"></script> <script src="{% static "js/inspinia.js" %}"></script>
<script src="{% static "js/jumpserver.js" %}"></script>
<script> <script>
// active menu activeNav();
var url_array = document.location.pathname.split("/"); $(document).ready(function(){
app = url_array[1]; setAjaxCSRFToken();
resource = url_array[2];
if (app == ''){
$('#index').addClass('active')
} else {
$("#"+app).addClass('active');
$('#'+app+' #'+resource).addClass('active');
}
// ajax set cookie
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
var sessionid = getCookie('sessionid');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
// textarea rows
$('textarea').attr('rows', 5)
// Set textarea rows five
$('textarea').attr('rows', 5);
});
//Sweet Alert for Delete // Sweet Alert for Delete
function obj_del(obj,name,url){ // Todo: Change name to objectDelete(obj, name, url)
function objectDelete(obj, name, url){
swal({ swal({
title: "{% trans 'Are you sure delete ??' %}", title: "{% trans 'Are you sure delete ?' %}",
//text: "You will not be able to recover this imaginary file!", text: "【" + name + "】",
text: "【"+name+"】",
type: "warning", type: "warning",
showCancelButton: true, showCancelButton: true,
cancelButtonText: "{% trans 'Cancel' %}", cancelButtonText: "{% trans 'Cancel' %}",
...@@ -73,16 +34,14 @@ function obj_del(obj,name,url){ ...@@ -73,16 +34,14 @@ function obj_del(obj,name,url){
type : "post", type : "post",
url : url, url : url,
data : { data : {
// idc_id : idc_id
}, },
dataType : "text",
success : function(data) { success : function(data) {
swal("{% trans 'Deleted!' %}", "【"+name+"】"+"{% trans 'has been deleted.' %}", "success"); swal("{% trans 'Deleted!' %}", "【"+name+"】"+"{% trans 'has been deleted.' %}", "success");
$(obj).parent().parent().remove(); $(obj).parent().parent().remove();
}, }
dataType : "text" })
});
}); });
} }
</script> </script>
<script src="{% static "js/jumpserver.js" %}"></script>
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
{% include '_head_css_js.html' %} {% include '_head_css_js.html' %}
{% block custom_head_css_js %} {% endblock %} {% block custom_head_css_js %} {% endblock %}
<link href="{% static "css/jumpserver.css" %}" rel="stylesheet"> <link href="{% static "css/jumpserver.css" %}" rel="stylesheet">
<script src="{% static "js/jumpserver.js" %}"></script>
</head> </head>
<body> <body>
......
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