Expose the created, last login and note fields for User managment
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2.033000 - 2015-08
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* Expose the created, last login and note fields for User managment
|
||||
|
||||
2.032007 - 2015-07-30
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
@@ -36,12 +36,10 @@ __PACKAGE__->add_columns(
|
||||
);
|
||||
__PACKAGE__->set_primary_key("username");
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2awpSJkzXP7+8eyT4vGjfw
|
||||
|
||||
__PACKAGE__->has_many( roles => 'App::Netdisco::DB::Result::Virtual::UserRole',
|
||||
'username', { cascade_copy => 0, cascade_update => 0, cascade_delete => 0 } );
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
sub created { return (shift)->get_column('created') }
|
||||
sub last_seen { return (shift)->get_column('last_seen') }
|
||||
|
||||
1;
|
||||
|
||||
@@ -50,6 +50,10 @@ post '/login' => sub {
|
||||
details => param('return_url'),
|
||||
});
|
||||
|
||||
schema('netdisco')->resultset('User')
|
||||
->find( session('logged_in_user') )
|
||||
->update({ last_on => \'now()' });
|
||||
|
||||
return if request->is_ajax;
|
||||
redirect param('return_url');
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ use Digest::MD5 ();
|
||||
register_admin_task({
|
||||
tag => 'users',
|
||||
label => 'User Management',
|
||||
provides_csv => 1,
|
||||
});
|
||||
|
||||
sub _sanity_ok {
|
||||
@@ -42,6 +43,7 @@ ajax '/ajax/control/admin/users/add' => require_role admin => sub {
|
||||
ldap => (param('ldap') ? \'true' : \'false'),
|
||||
port_control => (param('port_control') ? \'true' : \'false'),
|
||||
admin => (param('admin') ? \'true' : \'false'),
|
||||
note => param('note'),
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -71,18 +73,34 @@ ajax '/ajax/control/admin/users/update' => require_role admin => sub {
|
||||
ldap => (param('ldap') ? \'true' : \'false'),
|
||||
port_control => (param('port_control') ? \'true' : \'false'),
|
||||
admin => (param('admin') ? \'true' : \'false'),
|
||||
note => param('note'),
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ajax '/ajax/content/admin/users' => require_role admin => sub {
|
||||
my $set = schema('netdisco')->resultset('User')
|
||||
->search(undef, { order_by => [qw/fullname username/]});
|
||||
get '/ajax/content/admin/users' => require_role admin => sub {
|
||||
my @results = schema('netdisco')->resultset('User')
|
||||
->search(undef, {
|
||||
'+columns' => {
|
||||
created => \"to_char(creation, 'YYYY-MM-DD HH24:MI')",
|
||||
last_seen => \"to_char(last_on, 'YYYY-MM-DD HH24:MI')",
|
||||
},
|
||||
order_by => [qw/fullname username/]
|
||||
})->hri->all;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/admintask/users.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
return unless scalar @results;
|
||||
|
||||
if ( request->is_ajax ) {
|
||||
template 'ajax/admintask/users.tt',
|
||||
{ results => \@results, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/admintask/users_csv.tt',
|
||||
{ results => \@results, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
<th class="nd_center-cell">LDAP Auth</th>
|
||||
<th class="nd_center-cell">Port Control</th>
|
||||
<th class="nd_center-cell">Administrator</th>
|
||||
<th class="nd_center-cell">Created</th>
|
||||
<th class="nd_center-cell">Last Login</th>
|
||||
<th class="nd_center-cell">Note</th>
|
||||
<th class="nd_center-cell">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -18,13 +21,16 @@
|
||||
<td class="nd_center-cell"><input data-form="add" type="checkbox" name="ldap"></td>
|
||||
<td class="nd_center-cell"><input data-form="add" type="checkbox" name="port_control"></td>
|
||||
<td class="nd_center-cell"><input data-form="add" type="checkbox" name="admin"></td>
|
||||
<td class="nd_center-cell"></td>
|
||||
<td class="nd_center-cell"></td>
|
||||
<td class="nd_center-cell"><input data-form="add" name="note" type="text"></td>
|
||||
<td class="nd_center-cell">
|
||||
<button class="btn btn-small nd_adminbutton" name="add" type="submit"><i class="icon-plus-sign"></i> Add</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
[% SET count = 0 %]
|
||||
[% WHILE (row = results.next) %]
|
||||
[% FOREACH row IN results %]
|
||||
[% SET count = count + 1 %]
|
||||
<tr>
|
||||
<td class="nd_center-cell">
|
||||
@@ -45,6 +51,11 @@
|
||||
<td class="nd_center-cell">
|
||||
<input data-form="update" name="admin" type="checkbox" [% 'checked="checked"' IF row.admin %]>
|
||||
</td>
|
||||
<td class="nd_center-cell">[% row.created | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.last_seen | html_entity %]</td>
|
||||
<td class="nd_center-cell">
|
||||
<input data-form="update" name="note" type="text" value="[% row.note | html_entity %]">
|
||||
</td>
|
||||
|
||||
<td class="nd_center-cell">
|
||||
<button class="btn nd_adminbutton" name="update" type="submit"><i class="icon-save text-warning"></i></button>
|
||||
@@ -80,11 +91,11 @@ $(document).ready(function() {
|
||||
$('#data-table').dataTable({
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [ 2, 3, 4, 5, 6 ],
|
||||
"targets": [ 2, 3, 4, 5, 6, 7, 8, 9 ],
|
||||
"searchable": false
|
||||
},
|
||||
{
|
||||
"targets": [ 0, 1, 2, 3, 4, 5, 6 ],
|
||||
"targets": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ],
|
||||
"orderable": false
|
||||
}
|
||||
],
|
||||
|
||||
18
Netdisco/share/views/ajax/admintask/users_csv.tt
Normal file
18
Netdisco/share/views/ajax/admintask/users_csv.tt
Normal file
@@ -0,0 +1,18 @@
|
||||
[% USE CSV -%]
|
||||
[% CSV.dump([ 'Full Name' 'Username'
|
||||
'LDAP Auth' 'Port Control' 'Administrator' 'Created'
|
||||
'Last Login' 'Note']) %]
|
||||
|
||||
[% FOREACH row IN results %]
|
||||
[% mylist = [] %]
|
||||
[% mylist.push(row.fullname) %]
|
||||
[% mylist.push(row.username) %]
|
||||
[% mylist.push(row.ldap) %]
|
||||
[% mylist.push(row.port_control) %]
|
||||
[% mylist.push(row.admin) %]
|
||||
[% mylist.push(row.created) %]
|
||||
[% mylist.push(row.last_seen) %]
|
||||
[% mylist.push(row.note) %]
|
||||
[% CSV.dump(mylist) %]
|
||||
|
||||
[% END %]
|
||||
Reference in New Issue
Block a user