Show More
@@ -1,140 +1,140 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="/base/base.html"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="title()"> |
|
5 | 5 | ${_('Users administration')} |
|
6 | 6 | %if c.rhodecode_name: |
|
7 | 7 | · ${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'))} » <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 | <div class="box"> |
|
22 | 22 | |
|
23 | 23 | <div class="title"> |
|
24 | 24 | ${self.breadcrumbs()} |
|
25 | 25 | <ul class="links"> |
|
26 | 26 | <li> |
|
27 | 27 | <a href="${h.url('new_user')}" class="btn btn-small btn-success">${_(u'Add User')}</a> |
|
28 | 28 | </li> |
|
29 | 29 | </ul> |
|
30 | 30 | </div> |
|
31 | 31 | |
|
32 | 32 | <div id="repos_list_wrap"> |
|
33 | 33 | <table id="user_list_table" class="display"></table> |
|
34 | 34 | </div> |
|
35 | 35 | </div> |
|
36 | 36 | |
|
37 | 37 | <script> |
|
38 | 38 | $(document).ready(function() { |
|
39 | 39 | |
|
40 | 40 | var get_datatable_count = function(){ |
|
41 | 41 | var datatable = $('#user_list_table').dataTable(); |
|
42 | 42 | var api = datatable.api(); |
|
43 | 43 | var total = api.page.info().recordsDisplay; |
|
44 | 44 | var active = datatable.fnGetFilteredData(); |
|
45 | 45 | var _text = _gettext("{0} active out of {1} users").format(active, total); |
|
46 | 46 | $('#user_count').text(_text); |
|
47 | 47 | }; |
|
48 | 48 | |
|
49 | 49 | // custom filter that filters by username OR email |
|
50 | 50 | $.fn.dataTable.ext.search.push( |
|
51 | 51 | function( settings, data, dataIndex ) { |
|
52 | 52 | var query = $('#q_filter').val(); |
|
53 | 53 | var username = data[1]; |
|
54 | 54 | var email = data[2]; |
|
55 | 55 | var first_name = data[3]; |
|
56 | 56 | var last_name = data[4]; |
|
57 | 57 | |
|
58 | 58 | var query_str = username + " " + |
|
59 | 59 | email + " " + |
|
60 | 60 | first_name + " " + |
|
61 | 61 | last_name; |
|
62 | 62 | if((query_str).indexOf(query) !== -1){ |
|
63 | 63 | return true; |
|
64 | 64 | } |
|
65 | 65 | return false; |
|
66 | 66 | } |
|
67 | 67 | ); |
|
68 | 68 | // filtered data plugin |
|
69 | 69 | $.fn.dataTableExt.oApi.fnGetFilteredData = function ( oSettings ) { |
|
70 | 70 | var res = []; |
|
71 | 71 | for ( var i=0, iLen=oSettings.fnRecordsDisplay() ; i<iLen ; i++ ) { |
|
72 | 72 | var record = oSettings.aoData[i]._aData; |
|
73 | 73 | if(record['active_raw']){ |
|
74 | 74 | res.push(record); |
|
75 | 75 | } |
|
76 | 76 | } |
|
77 | 77 | return res.length; |
|
78 | 78 | }; |
|
79 | 79 | |
|
80 | 80 | // user list |
|
81 | 81 | $('#user_list_table').DataTable({ |
|
82 | 82 | data: ${c.data|n}, |
|
83 | 83 | dom: 'rtp', |
|
84 | 84 | pageLength: ${c.visual.admin_grid_items}, |
|
85 | 85 | order: [[ 1, "asc" ]], |
|
86 | 86 | columns: [ |
|
87 | 87 | { data: {"_": "username", |
|
88 | 88 | "sort": "username_raw"}, title: "${_('Username')}", className: "td-user" }, |
|
89 | 89 | { data: {"_": "email", |
|
90 | 90 | "sort": "email"}, title: "${_('Email')}", className: "td-email" }, |
|
91 | 91 | { data: {"_": "first_name", |
|
92 | 92 | "sort": "first_name"}, title: "${_('First Name')}", className: "td-user" }, |
|
93 | 93 | { data: {"_": "last_name", |
|
94 | 94 | "sort": "last_name"}, title: "${_('Last Name')}", className: "td-user" }, |
|
95 | 95 | { data: {"_": "last_login", |
|
96 | 96 | "sort": "last_login_raw", |
|
97 | 97 | "type": Number}, title: "${_('Last login')}", className: "td-time" }, |
|
98 | 98 | { data: {"_": "active", |
|
99 | 99 | "sort": "active_raw"}, title: "${_('Active')}", className: "td-active" }, |
|
100 | 100 | { data: {"_": "admin", |
|
101 | 101 | "sort": "admin_raw"}, title: "${_('Admin')}", className: "td-admin" }, |
|
102 | 102 | { data: {"_": "extern_type", |
|
103 | 103 | "sort": "extern_type"}, title: "${_('Authentication type')}", className: "td-type" }, |
|
104 | 104 | { data: {"_": "action", |
|
105 | 105 | "sort": "action"}, title: "${_('Action')}", className: "td-action" } |
|
106 | 106 | ], |
|
107 | 107 | language: { |
|
108 | 108 | paginate: DEFAULT_GRID_PAGINATION, |
|
109 |
emptyTable: _gettext("No user |
|
|
109 | emptyTable: _gettext("No users available yet.") | |
|
110 | 110 | }, |
|
111 | 111 | "initComplete": function( settings, json ) { |
|
112 | 112 | get_datatable_count(); |
|
113 | 113 | }, |
|
114 | 114 | "createdRow": function ( row, data, index ) { |
|
115 | 115 | if (!data['active_raw']){ |
|
116 | 116 | $(row).addClass('closed') |
|
117 | 117 | } |
|
118 | 118 | } |
|
119 | 119 | }); |
|
120 | 120 | |
|
121 | 121 | // update the counter when doing search |
|
122 | 122 | $('#user_list_table').on( 'search.dt', function (e,settings) { |
|
123 | 123 | get_datatable_count(); |
|
124 | 124 | }); |
|
125 | 125 | |
|
126 | 126 | // filter, filter both grids |
|
127 | 127 | $('#q_filter').on( 'keyup', function () { |
|
128 | 128 | var user_api = $('#user_list_table').dataTable().api(); |
|
129 | 129 | user_api |
|
130 | 130 | .draw(); |
|
131 | 131 | }); |
|
132 | 132 | |
|
133 | 133 | // refilter table if page load via back button |
|
134 | 134 | $("#q_filter").trigger('keyup'); |
|
135 | 135 | |
|
136 | 136 | }); |
|
137 | 137 | |
|
138 | 138 | </script> |
|
139 | 139 | |
|
140 | 140 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now