Commit ca4fcef5 by Kálmán Viktor

dashboard: user list features

- add org id to the dashboard list (and make it searchable)
- shorten "superuser status" text
- fix copypaste typos
parent 3ce61935
......@@ -182,7 +182,9 @@ $(function () {
var search_result = [];
for(var i in my_vms) {
if(my_vms[i].name.toLowerCase().indexOf(input) != -1 ||
my_vms[i].host && my_vms[i].host.indexOf(input) != -1) {
(my_vms[i].host && my_vms[i].host.indexOf(input) != -1) ||
(my_vms[i].org_id && my_vms[i].org_id.toLowerCase().indexOf(input) != -1)
) {
search_result.push(my_vms[i]);
}
}
......@@ -237,7 +239,7 @@ $(function () {
favicon.reset();
});
/* on the client confirmation button fire the clientInstalledAction */
$(document).on("click", "#client-check-button", function(event) {
var connectUri = $('#connect-uri').val();
......@@ -299,8 +301,10 @@ function generateGroupHTML(data, is_last) {
function generateUserHTML(data, is_last) {
return '<a href="' + data.url + '" class="list-group-item real-link' + (is_last ? " list-group-item-last" : "") +'">'+
'<i class="fa fa-user"></i> '+ safe_tags_replace(data.name) +
'</a>';
'<span class="index-user-list-name"><i class="fa fa-user"></i> '+ safe_tags_replace(data.name) + '</span>' +
'<span class="index-user-list-org">' +
'<small class="text-muted"> ' + (data.org_id ? safe_tags_replace(data.org_id) : "") + '</small>' +
'</span></a>';
}
function generateTemplateHTML(data, is_last) {
......
......@@ -1168,6 +1168,28 @@ textarea[name="new_members"] {
}
}
#dashboard-user-list {
.list-group-item {
display: flex;
}
.index-user-list-name, .index-user-list-org {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.index-user-list-name {
max-width: 80%;
}
.index-user-list-org {
padding-left: 5px;
flex: 1;
}
}
.fa-fw-12 {
/* fa-fw is too wide */
width: 12px;
......
......@@ -18,13 +18,16 @@
from __future__ import absolute_import
from django.contrib.auth.models import Group, User
from django.utils.translation import ugettext_lazy as _
from django.utils.html import mark_safe
from django_tables2 import Table, A
from django_tables2.columns import (TemplateColumn, Column, LinkColumn,
BooleanColumn)
from django_tables2.columns import (
TemplateColumn, Column, LinkColumn, BooleanColumn
)
from django_sshkey.models import UserKey
from vm.models import Node, InstanceTemplate, Lease
from django.utils.translation import ugettext_lazy as _
from django_sshkey.models import UserKey
from dashboard.models import ConnectCommand
......@@ -133,11 +136,17 @@ class UserListTable(Table):
args=[A('username')],
verbose_name=_('Organization ID')
)
is_superuser = BooleanColumn()
is_superuser = BooleanColumn(
verbose_name=mark_safe(
_('<abbr data-placement="left" title="Superuser status">SU</abbr>')
)
)
is_active = BooleanColumn()
class Meta:
model = User
template = "django_tables2/table_no_page.html"
attrs = {'class': ('table table-bordered table-striped table-hover')}
fields = ('username', 'last_name', 'first_name', 'profile__org_id',
'email', 'is_active', 'is_superuser')
......
......@@ -11,7 +11,12 @@
{% for i in users %}
<a href="{% url "dashboard.views.profile" username=i.username %}" class="list-group-item real-link
{% if forloop.last and users|length < 5 %} list-group-item-last{% endif %}">
<i class="fa fa-user"></i> {% firstof i.get_full_name|safe i.username|safe %}
<span class="index-user-list-name">
<i class="fa fa-user"></i> {% firstof i.get_full_name|safe i.username|safe %}
</span>
<span class="index-user-list-org">
<small class="text-muted"> {{ i.profile.org_id|default:"" }}</small>
</span>
</a>
{% endfor %}
</div>
......
......@@ -18,7 +18,7 @@
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-offset-8 col-md-4" id="template-list-search">
<div class="col-md-offset-8 col-md-4" id="user-list-search">
<form action="" method="GET">
<div class="input-group">
{{ search_form.s }}
......@@ -30,7 +30,7 @@
</div>
</div><!-- .input-group -->
</form>
</div><!-- .col-md-4 #template-list-search -->
</div><!-- .col-md-4 #user-list-search -->
</div>
</div>
<div class="panel-body">
......
......@@ -526,7 +526,9 @@ class UserList(LoginRequiredMixin, PermissionRequiredMixin, SingleTableView):
if self.request.is_ajax():
users = [
{'url': reverse("dashboard.views.profile", args=[i.username]),
'name': i.get_full_name() or i.username}
'name': i.get_full_name() or i.username,
'org_id': i.profile.org_id,
}
for i in self.get_queryset()]
return HttpResponse(
json.dumps(users), content_type="application/json")
......@@ -536,7 +538,7 @@ class UserList(LoginRequiredMixin, PermissionRequiredMixin, SingleTableView):
def get_queryset(self):
logger.debug('UserList.get_queryset() called. User: %s',
unicode(self.request.user))
qs = User.objects.all()
qs = User.objects.all().order_by("-pk")
q = self.search_form.cleaned_data.get('s')
if q:
......
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 sign in to comment