Show More
@@ -1,140 +1,142 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 | ||
54 |
var |
|
54 | var username = data[0]; | |
55 |
var |
|
55 | var email = data[1]; | |
56 |
var |
|
56 | var first_name = data[2]; | |
|
57 | var last_name = data[3]; | |||
57 |
|
58 | |||
58 | var query_str = username + " " + |
|
59 | var query_str = username + " " + | |
59 | email + " " + |
|
60 | email + " " + | |
60 | first_name + " " + |
|
61 | first_name + " " + | |
61 | last_name; |
|
62 | last_name; | |
62 | if((query_str).indexOf(query) !== -1){ |
|
63 | ||
|
64 | if ((query_str).indexOf(query) !== -1) { | |||
63 | return true; |
|
65 | return true; | |
64 | } |
|
66 | } | |
65 | return false; |
|
67 | return false; | |
66 | } |
|
68 | } | |
67 | ); |
|
69 | ); | |
68 | // filtered data plugin |
|
70 | // filtered data plugin | |
69 | $.fn.dataTableExt.oApi.fnGetFilteredData = function ( oSettings ) { |
|
71 | $.fn.dataTableExt.oApi.fnGetFilteredData = function ( oSettings ) { | |
70 | var res = []; |
|
72 | var res = []; | |
71 | for ( var i=0, iLen=oSettings.fnRecordsDisplay() ; i<iLen ; i++ ) { |
|
73 | for ( var i=0, iLen=oSettings.fnRecordsDisplay() ; i<iLen ; i++ ) { | |
72 | var record = oSettings.aoData[i]._aData; |
|
74 | var record = oSettings.aoData[i]._aData; | |
73 | if(record['active_raw']){ |
|
75 | if(record['active_raw']){ | |
74 | res.push(record); |
|
76 | res.push(record); | |
75 | } |
|
77 | } | |
76 | } |
|
78 | } | |
77 | return res.length; |
|
79 | return res.length; | |
78 | }; |
|
80 | }; | |
79 |
|
81 | |||
80 | // user list |
|
82 | // user list | |
81 | $('#user_list_table').DataTable({ |
|
83 | $('#user_list_table').DataTable({ | |
82 | data: ${c.data|n}, |
|
84 | data: ${c.data|n}, | |
83 | dom: 'rtp', |
|
85 | dom: 'rtp', | |
84 | pageLength: ${c.visual.admin_grid_items}, |
|
86 | pageLength: ${c.visual.admin_grid_items}, | |
85 | order: [[ 1, "asc" ]], |
|
87 | order: [[ 1, "asc" ]], | |
86 | columns: [ |
|
88 | columns: [ | |
87 | { data: {"_": "username", |
|
89 | { data: {"_": "username", | |
88 | "sort": "username_raw"}, title: "${_('Username')}", className: "td-user" }, |
|
90 | "sort": "username_raw"}, title: "${_('Username')}", className: "td-user" }, | |
89 | { data: {"_": "email", |
|
91 | { data: {"_": "email", | |
90 | "sort": "email"}, title: "${_('Email')}", className: "td-email" }, |
|
92 | "sort": "email"}, title: "${_('Email')}", className: "td-email" }, | |
91 | { data: {"_": "first_name", |
|
93 | { data: {"_": "first_name", | |
92 | "sort": "first_name"}, title: "${_('First Name')}", className: "td-user" }, |
|
94 | "sort": "first_name"}, title: "${_('First Name')}", className: "td-user" }, | |
93 | { data: {"_": "last_name", |
|
95 | { data: {"_": "last_name", | |
94 | "sort": "last_name"}, title: "${_('Last Name')}", className: "td-user" }, |
|
96 | "sort": "last_name"}, title: "${_('Last Name')}", className: "td-user" }, | |
95 | { data: {"_": "last_login", |
|
97 | { data: {"_": "last_login", | |
96 | "sort": "last_login_raw", |
|
98 | "sort": "last_login_raw", | |
97 | "type": Number}, title: "${_('Last login')}", className: "td-time" }, |
|
99 | "type": Number}, title: "${_('Last login')}", className: "td-time" }, | |
98 | { data: {"_": "active", |
|
100 | { data: {"_": "active", | |
99 | "sort": "active_raw"}, title: "${_('Active')}", className: "td-active" }, |
|
101 | "sort": "active_raw"}, title: "${_('Active')}", className: "td-active" }, | |
100 | { data: {"_": "admin", |
|
102 | { data: {"_": "admin", | |
101 | "sort": "admin_raw"}, title: "${_('Admin')}", className: "td-admin" }, |
|
103 | "sort": "admin_raw"}, title: "${_('Admin')}", className: "td-admin" }, | |
102 | { data: {"_": "extern_type", |
|
104 | { data: {"_": "extern_type", | |
103 | "sort": "extern_type"}, title: "${_('Authentication type')}", className: "td-type" }, |
|
105 | "sort": "extern_type"}, title: "${_('Authentication type')}", className: "td-type" }, | |
104 | { data: {"_": "action", |
|
106 | { data: {"_": "action", | |
105 | "sort": "action"}, title: "${_('Action')}", className: "td-action" } |
|
107 | "sort": "action"}, title: "${_('Action')}", className: "td-action" } | |
106 | ], |
|
108 | ], | |
107 | language: { |
|
109 | language: { | |
108 | paginate: DEFAULT_GRID_PAGINATION, |
|
110 | paginate: DEFAULT_GRID_PAGINATION, | |
109 | emptyTable: _gettext("No users available yet.") |
|
111 | emptyTable: _gettext("No users available yet.") | |
110 | }, |
|
112 | }, | |
111 | "initComplete": function( settings, json ) { |
|
113 | "initComplete": function( settings, json ) { | |
112 | get_datatable_count(); |
|
114 | get_datatable_count(); | |
113 | }, |
|
115 | }, | |
114 | "createdRow": function ( row, data, index ) { |
|
116 | "createdRow": function ( row, data, index ) { | |
115 | if (!data['active_raw']){ |
|
117 | if (!data['active_raw']){ | |
116 | $(row).addClass('closed') |
|
118 | $(row).addClass('closed') | |
117 | } |
|
119 | } | |
118 | } |
|
120 | } | |
119 | }); |
|
121 | }); | |
120 |
|
122 | |||
121 | // update the counter when doing search |
|
123 | // update the counter when doing search | |
122 | $('#user_list_table').on( 'search.dt', function (e,settings) { |
|
124 | $('#user_list_table').on( 'search.dt', function (e,settings) { | |
123 | get_datatable_count(); |
|
125 | get_datatable_count(); | |
124 | }); |
|
126 | }); | |
125 |
|
127 | |||
126 | // filter, filter both grids |
|
128 | // filter, filter both grids | |
127 | $('#q_filter').on( 'keyup', function () { |
|
129 | $('#q_filter').on( 'keyup', function () { | |
128 | var user_api = $('#user_list_table').dataTable().api(); |
|
130 | var user_api = $('#user_list_table').dataTable().api(); | |
129 | user_api |
|
131 | user_api | |
130 | .draw(); |
|
132 | .draw(); | |
131 | }); |
|
133 | }); | |
132 |
|
134 | |||
133 | // refilter table if page load via back button |
|
135 | // refilter table if page load via back button | |
134 | $("#q_filter").trigger('keyup'); |
|
136 | $("#q_filter").trigger('keyup'); | |
135 |
|
137 | |||
136 | }); |
|
138 | }); | |
137 |
|
139 | |||
138 | </script> |
|
140 | </script> | |
139 |
|
141 | |||
140 | </%def> |
|
142 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now