mirror of https://github.com/jumpserver/jumpserver
[Update] 修改database 表现
parent
13b610c140
commit
0b299344a7
|
@ -216,6 +216,7 @@ class ClusterSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
||||||
assets_amount = serializers.SerializerMethodField()
|
assets_amount = serializers.SerializerMethodField()
|
||||||
admin_user_name = serializers.SerializerMethodField()
|
admin_user_name = serializers.SerializerMethodField()
|
||||||
assets = serializers.PrimaryKeyRelatedField(many=True, queryset=Asset.objects.all())
|
assets = serializers.PrimaryKeyRelatedField(many=True, queryset=Asset.objects.all())
|
||||||
|
system_users = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Cluster
|
model = Cluster
|
||||||
|
@ -232,6 +233,10 @@ class ClusterSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_system_users(obj):
|
||||||
|
return ', '.join(obj.name for obj in obj.systemuser_set.all())
|
||||||
|
|
||||||
|
|
||||||
class AssetGroupGrantedSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
class AssetGroupGrantedSerializer(BulkSerializerMixin, serializers.ModelSerializer):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -373,7 +373,7 @@ $(document).ready(function () {
|
||||||
url: the_url,
|
url: the_url,
|
||||||
error: error,
|
error: error,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
success_message: "{% trans "Pong" %}"
|
success_message: "{% trans "Reachable" %}"
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,7 @@
|
||||||
<th class="text-center"><a href="{% url 'assets:cluster-list' %}?sort=name">{% trans 'Name' %}</a></th>
|
<th class="text-center"><a href="{% url 'assets:cluster-list' %}?sort=name">{% trans 'Name' %}</a></th>
|
||||||
<th class="text-center">{% trans 'Admin user' %}</th>
|
<th class="text-center">{% trans 'Admin user' %}</th>
|
||||||
<th class="text-center">{% trans 'Asset num' %}</th>
|
<th class="text-center">{% trans 'Asset num' %}</th>
|
||||||
<th class="text-center">{% trans 'Contact' %}</th>
|
<th class="text-center">{% trans 'System users' %}</th>
|
||||||
<th class="text-center">{% trans 'Phone' %}</th>
|
|
||||||
<th class="text-center">{% trans 'Operator' %}</th>
|
|
||||||
<th class="text-center">{% trans 'Action' %}</th>
|
<th class="text-center">{% trans 'Action' %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -41,14 +39,16 @@ $(document).ready(function(){
|
||||||
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
|
$(td).html(detail_btn.replace('{{ DEFAULT_PK }}', rowData.id));
|
||||||
}},
|
}},
|
||||||
|
|
||||||
{targets: 7, createdCell: function (td, cellData, rowData) {
|
{targets: 5, createdCell: function (td, cellData, rowData) {
|
||||||
var update_btn = '<a href="{% url "assets:cluster-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
|
var update_btn = '<a href="{% url "assets:cluster-update" pk=DEFAULT_PK %}" class="btn btn-xs btn-info">{% trans "Update" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
|
||||||
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_cluster_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
|
var del_btn = '<a class="btn btn-xs btn-danger m-l-xs btn_cluster_delete" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'.replace('{{ DEFAULT_PK }}', cellData);
|
||||||
$(td).html(update_btn + del_btn)
|
$(td).html(update_btn + del_btn)
|
||||||
}}],
|
}}],
|
||||||
ajax_url: '{% url "api-assets:cluster-list" %}',
|
ajax_url: '{% url "api-assets:cluster-list" %}',
|
||||||
columns: [{data: function(){return ""}}, {data: "name" }, {data: "admin_user_name"}, {data: "assets_amount" }, {data: "contact" }, {data: "phone" },
|
columns: [
|
||||||
{data: "operator" }, {data: "id" }],
|
{data: "id"}, {data: "name" }, {data: "admin_user_name"}, {data: "assets_amount" },
|
||||||
|
{data: "system_users" }, {data: "id" }
|
||||||
|
],
|
||||||
op_html: $('#actions').html()
|
op_html: $('#actions').html()
|
||||||
};
|
};
|
||||||
jumpserver.initDataTable(options);
|
jumpserver.initDataTable(options);
|
||||||
|
|
|
@ -257,10 +257,13 @@ jumpserver.initDataTable = function (options) {
|
||||||
$(td).html('<input type="checkbox" class="text-center ipt_check" id=99991937>'.replace('99991937', cellData));
|
$(td).html('<input type="checkbox" class="text-center ipt_check" id=99991937>'.replace('99991937', cellData));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// className: 'select-checkbox'
|
|
||||||
{className: 'text-center', targets: '_all'}
|
{className: 'text-center', targets: '_all'}
|
||||||
];
|
];
|
||||||
columnDefs = options.columnDefs ? options.columnDefs.concat(columnDefs) : columnDefs;
|
columnDefs = options.columnDefs ? options.columnDefs.concat(columnDefs) : columnDefs;
|
||||||
|
var select = {
|
||||||
|
style: 'multi',
|
||||||
|
selector: 'td:first-child'
|
||||||
|
};
|
||||||
var table = ele.DataTable({
|
var table = ele.DataTable({
|
||||||
pageLength: options.pageLength || 15,
|
pageLength: options.pageLength || 15,
|
||||||
dom: options.dom || '<"#uc.pull-left">flt<"row m-t"<"col-md-8"<"#op.col-md-6"><"col-md-6 text-center"i>><"col-md-4"p>>',
|
dom: options.dom || '<"#uc.pull-left">flt<"row m-t"<"col-md-8"<"#op.col-md-6"><"col-md-6 text-center"i>><"col-md-4"p>>',
|
||||||
|
@ -273,9 +276,16 @@ jumpserver.initDataTable = function (options) {
|
||||||
dataSrc: ""
|
dataSrc: ""
|
||||||
},
|
},
|
||||||
columns: options.columns || [],
|
columns: options.columns || [],
|
||||||
select: {
|
select: options.select || select,
|
||||||
style: 'multi',
|
language: {
|
||||||
selector: 'td:first-child'
|
search: "搜索",
|
||||||
|
lengthMenu: "每页 _MENU_",
|
||||||
|
paginate: {
|
||||||
|
first: "第一页",
|
||||||
|
previous: "上一页",
|
||||||
|
next: "下一页",
|
||||||
|
last: "最后"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
lengthMenu: [[15, 25, 50, -1], [15, 25, 50, "All"]]
|
lengthMenu: [[15, 25, 50, -1], [15, 25, 50, "All"]]
|
||||||
});
|
});
|
||||||
|
@ -292,17 +302,17 @@ jumpserver.initDataTable = function (options) {
|
||||||
$('#op').html(options.op_html || '');
|
$('#op').html(options.op_html || '');
|
||||||
$('#uc').html(options.uc_html || '');
|
$('#uc').html(options.uc_html || '');
|
||||||
});
|
});
|
||||||
// $('.ipt_check_all').on('click', function() {
|
$('.ipt_check_all').on('click', function() {
|
||||||
// if (!jumpserver.checked) {
|
if (!jumpserver.checked) {
|
||||||
// $(this).closest('table').find('.ipt_check').prop('checked', true);
|
$(this).closest('table').find('.ipt_check').prop('checked', true);
|
||||||
// jumpserver.checked = true;
|
jumpserver.checked = true;
|
||||||
// table.rows().select();
|
table.rows().select();
|
||||||
// } else {
|
} else {
|
||||||
// $(this).closest('table').find('.ipt_check').prop('checked', false);
|
$(this).closest('table').find('.ipt_check').prop('checked', false);
|
||||||
// jumpserver.checked = false;
|
jumpserver.checked = false;
|
||||||
// table.rows().deselect();
|
table.rows().deselect();
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
};
|
};
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<td class="text-center">{{ session.id | get_session_command_amount }}</td>
|
<td class="text-center">{{ session.id | get_session_command_amount }}</td>
|
||||||
|
|
||||||
<td class="text-center">{{ session.date_start }}</td>
|
<td class="text-center">{{ session.date_start }}</td>
|
||||||
<td class="text-center">{{ session.date_end|default_if_none:now|timeuntil:session.date_start }}</td>
|
<td class="text-center">{{ session.date_end|timeuntil:session.date_start }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if session.is_finished %}
|
{% if session.is_finished %}
|
||||||
<a onclick="window.open('/luna/replay/{{ session.id }}','luna', 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=no, status=no')" class="btn btn-xs btn-warning btn-replay" >{% trans "Replay" %}</a>
|
<a onclick="window.open('/luna/replay/{{ session.id }}','luna', 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=no, status=no')" class="btn btn-xs btn-warning btn-replay" >{% trans "Replay" %}</a>
|
||||||
|
|
|
@ -24,10 +24,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select class="select2 form-control" name="username">
|
<select class="select2 form-control" name="user">
|
||||||
<option value="">{% trans 'Select user' %}</option>
|
<option value="">{% trans 'Select user' %}</option>
|
||||||
{% for u in user_list %}
|
{% for u in user_list %}
|
||||||
<option value="{{ u }}" {% if u == username %} selected {% endif %}>{{ u }}</option>
|
<option value="{{ u }}" {% if u == user %} selected {% endif %}>{{ u }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -88,8 +88,10 @@ function initTable() {
|
||||||
$(td).html(update_btn + del_btn)
|
$(td).html(update_btn + del_btn)
|
||||||
}}],
|
}}],
|
||||||
ajax_url: '{% url "api-users:user-list" %}',
|
ajax_url: '{% url "api-users:user-list" %}',
|
||||||
columns: [{data: "id"}, {data: "name" }, {data: "username" }, {data: "get_role_display" },
|
columns: [
|
||||||
{data: "groups_display" }, {data: "is_valid" }, {data: "id" }],
|
{data: "id"}, {data: "name" }, {data: "username" }, {data: "get_role_display" },
|
||||||
|
{data: "groups_display" }, {data: "is_valid" }, {data: "id" }
|
||||||
|
],
|
||||||
op_html: $('#actions').html()
|
op_html: $('#actions').html()
|
||||||
};
|
};
|
||||||
table = jumpserver.initDataTable(options);
|
table = jumpserver.initDataTable(options);
|
||||||
|
|
|
@ -215,20 +215,20 @@ class LoginLogListView(DatetimeSearchMixin, ListView):
|
||||||
template_name = 'users/login_log_list.html'
|
template_name = 'users/login_log_list.html'
|
||||||
model = LoginLog
|
model = LoginLog
|
||||||
paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
|
paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
|
||||||
username = keyword = ""
|
user = keyword = ""
|
||||||
date_to = date_from = None
|
date_to = date_from = None
|
||||||
date_format = '%m/%d/%Y'
|
date_format = '%m/%d/%Y'
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
self.username = self.request.GET.get('user', '')
|
self.user = self.request.GET.get('user', '')
|
||||||
self.keyword = self.request.GET.get("keyword", '')
|
self.keyword = self.request.GET.get("keyword", '')
|
||||||
|
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
queryset = queryset.filter(
|
queryset = queryset.filter(
|
||||||
datetime__gt=self.date_from, datetime__lt=self.date_to
|
datetime__gt=self.date_from, datetime__lt=self.date_to
|
||||||
)
|
)
|
||||||
if self.username:
|
if self.user:
|
||||||
queryset = queryset.filter(username=self.username)
|
queryset = queryset.filter(username=self.user)
|
||||||
if self.keyword:
|
if self.keyword:
|
||||||
queryset = self.queryset.filter(
|
queryset = self.queryset.filter(
|
||||||
Q(ip__contains=self.keyword) |
|
Q(ip__contains=self.keyword) |
|
||||||
|
@ -243,7 +243,7 @@ class LoginLogListView(DatetimeSearchMixin, ListView):
|
||||||
'action': _('Login log list'),
|
'action': _('Login log list'),
|
||||||
'date_from': self.date_from,
|
'date_from': self.date_from,
|
||||||
'date_to': self.date_to,
|
'date_to': self.date_to,
|
||||||
'username': self.username,
|
'user': self.user,
|
||||||
'keyword': self.keyword,
|
'keyword': self.keyword,
|
||||||
'user_list': set(LoginLog.objects.all().values_list('username', flat=True))
|
'user_list': set(LoginLog.objects.all().values_list('username', flat=True))
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,8 +305,8 @@ class UserGrantedAssetView(AdminUserRequiredMixin, DetailView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = {
|
context = {
|
||||||
'app': 'User',
|
'app': _('Users'),
|
||||||
'action': 'User granted asset',
|
'action': _('User granted assets'),
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
@ -319,8 +319,8 @@ class UserProfileView(LoginRequiredMixin, TemplateView):
|
||||||
from perms.utils import get_user_granted_assets
|
from perms.utils import get_user_granted_assets
|
||||||
assets = get_user_granted_assets(self.request.user)
|
assets = get_user_granted_assets(self.request.user)
|
||||||
context = {
|
context = {
|
||||||
'app': 'User',
|
'app': _('Users'),
|
||||||
'action': 'User Profile',
|
'action': _('Profile'),
|
||||||
'assets': assets,
|
'assets': assets,
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
|
@ -345,8 +345,8 @@ class UserProfileUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = {
|
context = {
|
||||||
'app': 'User',
|
'app': _('User'),
|
||||||
'action': 'Profile update',
|
'action': _('Profile setting'),
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
@ -363,8 +363,8 @@ class UserPasswordUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = {
|
context = {
|
||||||
'app': 'User',
|
'app': _('Users'),
|
||||||
'action': 'Password update',
|
'action': _('Password update'),
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
@ -385,8 +385,8 @@ class UserPublicKeyUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = {
|
context = {
|
||||||
'app': 'User',
|
'app': _('Users'),
|
||||||
'action': 'Public key update',
|
'action': _('Public key update'),
|
||||||
}
|
}
|
||||||
kwargs.update(context)
|
kwargs.update(context)
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
|
@ -61,7 +61,7 @@ def start_gunicorn():
|
||||||
cmd += log
|
cmd += log
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
cmd += " --reload"
|
cmd += " --reload"
|
||||||
p = subprocess.call(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
|
p = subprocess.Popen(cmd, shell=True, stdout=sys.stdout, stderr=sys.stderr)
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue