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