Add user activity log to frontend admin menu
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* Can now set untagged VLAN on trunking and non-trunking ports
|
||||
* Add user activity log to frontend admin menu
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
|
||||
43
Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/UserLog.pm
Normal file
43
Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/UserLog.pm
Normal file
@@ -0,0 +1,43 @@
|
||||
package App::Netdisco::Web::Plugin::AdminTask::UserLog;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_admin_task({
|
||||
tag => 'userlog',
|
||||
label => 'User Activity Log',
|
||||
});
|
||||
|
||||
ajax '/ajax/control/admin/userlog/del' => require_role admin => sub {
|
||||
send_error('Missing entry', 400) unless param('entry');
|
||||
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my $device = schema('netdisco')->resultset('UserLog')
|
||||
->search({entry => param('entry')})->delete;
|
||||
});
|
||||
};
|
||||
|
||||
ajax '/ajax/control/admin/userlog/delall' => require_role admin => sub {
|
||||
schema('netdisco')->txn_do(sub {
|
||||
my $device = schema('netdisco')->resultset('UserLog')->delete;
|
||||
});
|
||||
};
|
||||
|
||||
ajax '/ajax/content/admin/userlog' => require_role admin => sub {
|
||||
my $set = schema('netdisco')->resultset('UserLog')
|
||||
->search({}, {
|
||||
order_by => { -desc => [qw/creation event/] },
|
||||
rows => 200,
|
||||
});
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/admintask/userlog.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
};
|
||||
|
||||
true;
|
||||
@@ -45,6 +45,7 @@ web_plugins:
|
||||
- AdminTask::Topology
|
||||
- AdminTask::JobQueue
|
||||
- AdminTask::Users
|
||||
- AdminTask::UserLog
|
||||
- Search::Device
|
||||
- Search::Node
|
||||
- Search::VLAN
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
<i id="nd_countdown-control-icon" class="text-success icon-play"></i></a>
|
||||
<span id="nd_countdown"></span>
|
||||
</span>
|
||||
[% ELSIF task.tag == 'userlog' %]
|
||||
<span id="nd_device-name">
|
||||
<a class="nd_adminbutton" name="delall" href="#"><i class="icon-trash text-error"></i></a>
|
||||
</span>
|
||||
[% ELSIF task.provides_csv %]
|
||||
<span id="nd_device-name">
|
||||
<a id="nd_csv-download" href="#" download="netdisco.csv">
|
||||
|
||||
30
Netdisco/share/views/ajax/admintask/userlog.tt
Normal file
30
Netdisco/share/views/ajax/admintask/userlog.tt
Normal file
@@ -0,0 +1,30 @@
|
||||
[% IF results.count == 0 %]
|
||||
<div class="span2 alert alert-info">The user activity log is empty.</div>
|
||||
[% ELSE %]
|
||||
<table class="table table-bordered table-condensed table-hover nd_floatinghead">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="nd_center-cell">Creation</th>
|
||||
<th class="nd_center-cell">User</th>
|
||||
<th class="nd_center-cell">User IP</th>
|
||||
<th class="nd_center-cell">Event</th>
|
||||
<th class="nd_center-cell">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr data-content="<pre>[% row.details | html_entity %]</pre>">
|
||||
<td class="nd_center-cell">[% row.creation | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.username | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.userip | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.event | html_entity %]</td>
|
||||
<td class="nd_center-cell">
|
||||
<input data-form="del" name="entry" type="hidden" value="[% row.entry | html_entity %]">
|
||||
<button class="btn nd_adminbutton" name="del" type="submit"><i class="icon-trash text-error"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% END %]
|
||||
|
||||
Reference in New Issue
Block a user