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