##// END OF EJS Templates
admin-users: cleanup JS code.
marcink -
r1648:56bc1e18 default
parent child Browse files
Show More
@@ -1,119 +1,120 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.mako"/>
3 3
4 4 <%def name="title()">
5 5 ${_('Users administration')}
6 6 %if c.rhodecode_name:
7 7 &middot; ${h.branding(c.rhodecode_name)}
8 8 %endif
9 9 </%def>
10 10
11 11 <%def name="breadcrumbs_links()">
12 12 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
13 13 ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; <span id="user_count">0</span>
14 14 </%def>
15 15
16 16 <%def name="menu_bar_nav()">
17 17 ${self.menu_items(active='admin')}
18 18 </%def>
19 19
20 20 <%def name="main()">
21 21
22 22 <div class="box">
23 23
24 24 <div class="title">
25 25 ${self.breadcrumbs()}
26 26 <ul class="links">
27 27 <li>
28 28 <a href="${h.url('new_user')}" class="btn btn-small btn-success">${_(u'Add User')}</a>
29 29 </li>
30 30 </ul>
31 31 </div>
32 32
33 33 <div id="repos_list_wrap">
34 34 <table id="user_list_table" class="display"></table>
35 35 </div>
36 36 </div>
37 37
38 38 <script type="text/javascript">
39 39
40 40 $(document).ready(function() {
41 var $userListTable = $('#user_list_table');
41 42
42 43 var getDatatableCount = function(){
43 var table = $('#user_list_table').dataTable();
44 var table = $userListTable.dataTable();
44 45 var page = table.api().page.info();
45 46 var active = page.recordsDisplay;
46 47 var total = page.recordsTotal;
47 48
48 49 var _text = _gettext("{0} out of {1} users").format(active, total);
49 50 $('#user_count').text(_text);
50 51 };
51 52
52 53 // user list
53 $('#user_list_table').DataTable({
54 $userListTable.DataTable({
54 55 processing: true,
55 56 serverSide: true,
56 57 ajax: "${h.route_path('users_data')}",
57 58 dom: 'rtp',
58 59 pageLength: ${c.visual.admin_grid_items},
59 60 order: [[ 0, "asc" ]],
60 61 columns: [
61 62 { data: {"_": "username",
62 63 "sort": "username"}, title: "${_('Username')}", className: "td-user" },
63 64 { data: {"_": "email",
64 65 "sort": "email"}, title: "${_('Email')}", className: "td-email" },
65 66 { data: {"_": "first_name",
66 67 "sort": "first_name"}, title: "${_('First Name')}", className: "td-user" },
67 68 { data: {"_": "last_name",
68 69 "sort": "last_name"}, title: "${_('Last Name')}", className: "td-user" },
69 70 { data: {"_": "last_activity",
70 71 "sort": "last_activity",
71 72 "type": Number}, title: "${_('Last activity')}", className: "td-time" },
72 73 { data: {"_": "active",
73 74 "sort": "active"}, title: "${_('Active')}", className: "td-active" },
74 75 { data: {"_": "admin",
75 76 "sort": "admin"}, title: "${_('Admin')}", className: "td-admin" },
76 77 { data: {"_": "extern_type",
77 78 "sort": "extern_type"}, title: "${_('Auth type')}", className: "td-type" },
78 79 { data: {"_": "action",
79 "sort": "action"}, title: "${_('Action')}", className: "td-action" }
80 "sort": "action"}, title: "${_('Action')}", className: "td-action", orderable: false }
80 81 ],
81 82 language: {
82 83 paginate: DEFAULT_GRID_PAGINATION,
83 84 sProcessing: _gettext('loading...'),
84 85 emptyTable: _gettext("No users available yet.")
85 86 },
86 87
87 88 "createdRow": function ( row, data, index ) {
88 89 if (!data['active_raw']){
89 90 $(row).addClass('closed')
90 91 }
91 92 }
92 93 });
93 94
94 $('#user_list_table').on('xhr.dt', function(e, settings, json, xhr){
95 $('#user_list_table').css('opacity', 1);
95 $userListTable.on('xhr.dt', function(e, settings, json, xhr){
96 $userListTable.css('opacity', 1);
96 97 });
97 98
98 $('#user_list_table').on('preXhr.dt', function(e, settings, data){
99 $('#user_list_table').css('opacity', 0.3);
99 $userListTable.on('preXhr.dt', function(e, settings, data){
100 $userListTable.css('opacity', 0.3);
100 101 });
101 102
102 103 // refresh counters on draw
103 $('#user_list_table').on('draw.dt', function(){
104 $userListTable.on('draw.dt', function(){
104 105 getDatatableCount();
105 106 });
106 107
107 108 // filter
108 109 $('#q_filter').on('keyup',
109 110 $.debounce(250, function() {
110 $('#user_list_table').DataTable().search(
111 $userListTable.DataTable().search(
111 112 $('#q_filter').val()
112 113 ).draw();
113 114 })
114 115 );
115 116
116 117 });
117 118 </script>
118 119
119 120 </%def>
General Comments 0
You need to be logged in to leave comments. Login now