Port Log now viewable via an icon by device port name
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
* [#31] get_community now supported
|
* [#31] get_community now supported
|
||||||
* [#19] Ask for Reason when changing Port up/down Status, or VLAN
|
* [#19] Ask for Reason when changing Port up/down Status, or VLAN
|
||||||
* [#30] Support for expire_devices, expire_nodes, and expire_nodes_archive
|
* [#30] Support for expire_devices, expire_nodes, and expire_nodes_archive
|
||||||
|
* Port Log viewable via an icon by device port name (Port Control rights req'd)
|
||||||
|
|
||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
|
|||||||
@@ -218,6 +218,16 @@ Note that this won't work for any target link - the path must be an
|
|||||||
App::Netdisco Dancer route handler. Please bug the App::Netdisco devs if you
|
App::Netdisco Dancer route handler. Please bug the App::Netdisco devs if you
|
||||||
want arbitrary links supported.
|
want arbitrary links supported.
|
||||||
|
|
||||||
|
An additional feature allows you to create Admin Tasks which do not appear in
|
||||||
|
the Navbar menu. This is useful if the page is only linked directly from
|
||||||
|
another (for example Port Log). To enable this feature add the C<hidden> key:
|
||||||
|
|
||||||
|
register_admin_task({
|
||||||
|
tag => 'newfeature',
|
||||||
|
label => 'My New Feature',
|
||||||
|
hidden => true,
|
||||||
|
});
|
||||||
|
|
||||||
=head1 Device Port Columns
|
=head1 Device Port Columns
|
||||||
|
|
||||||
You can also add columns to the Device Ports page. The canonical example of
|
You can also add columns to the Device Ports page. The canonical example of
|
||||||
|
|||||||
39
Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm
Normal file
39
Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package App::Netdisco::Web::Plugin::AdminTask::PortLog;
|
||||||
|
|
||||||
|
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 => 'portlog',
|
||||||
|
label => 'Port Control Log',
|
||||||
|
hidden => true,
|
||||||
|
});
|
||||||
|
|
||||||
|
ajax '/ajax/content/admin/portlog' => require_role admin => sub {
|
||||||
|
my $device = param('q');
|
||||||
|
my $port = param('f');
|
||||||
|
send_error('Bad Request', 400) unless $device and $port;
|
||||||
|
|
||||||
|
$device = schema('netdisco')->resultset('Device')
|
||||||
|
->search_for_device($device);
|
||||||
|
return unless $device;
|
||||||
|
|
||||||
|
my $set = schema('netdisco')->resultset('DevicePortLog')->search({
|
||||||
|
ip => $device->ip,
|
||||||
|
port => $port,
|
||||||
|
}, {
|
||||||
|
order_by => { -desc => [qw/creation/] },
|
||||||
|
rows => 200,
|
||||||
|
});
|
||||||
|
|
||||||
|
content_type('text/html');
|
||||||
|
template 'ajax/admintask/portlog.tt', {
|
||||||
|
results => $set,
|
||||||
|
}, { layout => undef };
|
||||||
|
};
|
||||||
|
|
||||||
|
true;
|
||||||
@@ -251,10 +251,23 @@ td > form.nd_inline-form {
|
|||||||
/* port admin up/down control */
|
/* port admin up/down control */
|
||||||
.nd_edit-icon, .nd_hand-icon {
|
.nd_edit-icon, .nd_hand-icon {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
float: right;
|
||||||
|
display: none;
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* port admin log view */
|
||||||
|
.nd_log-icon {
|
||||||
|
cursor: pointer;
|
||||||
|
color: black;
|
||||||
float: left;
|
float: left;
|
||||||
display: none;
|
display: none;
|
||||||
margin-top: 3px;
|
margin-top: 3px;
|
||||||
}
|
}
|
||||||
|
.nd_log-icon:hover, .nd_log-icon:focus {
|
||||||
|
text-decoration: none;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
/* port power control */
|
/* port power control */
|
||||||
.nd_power-icon {
|
.nd_power-icon {
|
||||||
|
|||||||
@@ -92,14 +92,14 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
// toggle visibility of port up/down and edit controls
|
// toggle visibility of port up/down and edit controls
|
||||||
$('.tab-content').on('mouseenter', '.nd_editable-cell', function() {
|
$('.tab-content').on('mouseenter', '.nd_editable-cell', function() {
|
||||||
$(this).children('.nd_hand-icon').show();
|
$(this).children('.nd_hand-icon,.nd_log-icon').show();
|
||||||
if (! $(this).is(':focus')) {
|
if (! $(this).is(':focus')) {
|
||||||
$(this).children('.nd_edit-icon').show(); // ports
|
$(this).children('.nd_edit-icon').show(); // ports
|
||||||
$(this).siblings('td').find('.nd_device-details-edit').show(); // details
|
$(this).siblings('td').find('.nd_device-details-edit').show(); // details
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('.tab-content').on('mouseleave', '.nd_editable-cell', function() {
|
$('.tab-content').on('mouseleave', '.nd_editable-cell', function() {
|
||||||
$(this).children('.nd_hand-icon').hide();
|
$(this).children('.nd_hand-icon,.nd_log-icon').hide();
|
||||||
if (! $(this).is(':focus')) {
|
if (! $(this).is(':focus')) {
|
||||||
$(this).children('.nd_edit-icon').hide(); // ports
|
$(this).children('.nd_edit-icon').hide(); // ports
|
||||||
$(this).siblings('td').find('.nd_device-details-edit').hide(); // details
|
$(this).siblings('td').find('.nd_device-details-edit').hide(); // details
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
<form id="[% task.tag %]_form" class="nd_sidebar-form form-stacked"
|
<form id="[% task.tag %]_form" class="nd_sidebar-form form-stacked"
|
||||||
method="get" action="[% uri_for('/admin') %]">
|
method="get" action="[% uri_for('/admin') %]">
|
||||||
[% TRY %]
|
[% TRY %]
|
||||||
[% INCLUDE "sidebar/admintask/${task.tag}.tt" %]
|
|
||||||
<script type="text/javascript">has_sidebar["[% task.tag %]"] = 1;</script>
|
<script type="text/javascript">has_sidebar["[% task.tag %]"] = 1;</script>
|
||||||
|
[% INCLUDE "sidebar/admintask/${task.tag}.tt" %]
|
||||||
[% CATCH %]
|
[% CATCH %]
|
||||||
<script type="text/javascript">has_sidebar["[% task.tag %]"] = 0;</script>
|
<script type="text/javascript">has_sidebar["[% task.tag %]"] = 0;</script>
|
||||||
[% END %]
|
[% END %]
|
||||||
@@ -40,6 +40,12 @@
|
|||||||
<span id="nd_device-name">
|
<span id="nd_device-name">
|
||||||
<a class="nd_adminbutton" name="delall" href="#"><i class="icon-trash text-error"></i></a>
|
<a class="nd_adminbutton" name="delall" href="#"><i class="icon-trash text-error"></i></a>
|
||||||
</span>
|
</span>
|
||||||
|
[% ELSIF task.tag == 'portlog' %]
|
||||||
|
<span id="nd_device-name">
|
||||||
|
<a href="[% device_ports %]&q=[% params.q | uri %]&c_admin=on">[% params.q %]</a>
|
||||||
|
-
|
||||||
|
<a href="[% device_ports %]&q=[% params.q | uri %]&f=[% params.f | uri %]&c_admin=on">[% params.f %]</a>
|
||||||
|
</span>
|
||||||
[% ELSIF task.provides_csv %]
|
[% ELSIF task.provides_csv %]
|
||||||
<span id="nd_device-name">
|
<span id="nd_device-name">
|
||||||
<a id="nd_csv-download" href="#" download="netdisco.csv">
|
<a id="nd_csv-download" href="#" download="netdisco.csv">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[% IF results.count == 0 %]
|
[% IF results.count == 0 %]
|
||||||
<div class="span2 alert alert-info">The aren't enough jobs to report.</div>
|
<div class="span3 alert alert-info">The aren't enough jobs to report.</div>
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
<table class="table table-bordered table-condensed table-hover nd_floatinghead">
|
<table class="table table-bordered table-condensed table-hover nd_floatinghead">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
29
Netdisco/share/views/ajax/admintask/portlog.tt
Normal file
29
Netdisco/share/views/ajax/admintask/portlog.tt
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
[% IF results.count == 0 %]
|
||||||
|
<div class="span2 alert alert-info">This port's 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">Action</th>
|
||||||
|
<th class="nd_center-cell">Reason</th>
|
||||||
|
<th class="nd_center-cell">Log</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
[% WHILE (row = results.next) %]
|
||||||
|
<tr>
|
||||||
|
<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.action | html_entity %]</td>
|
||||||
|
<td class="nd_center-cell">[% settings.port_control_reasons.item(row.reason) || row.reason | html_entity %]</td>
|
||||||
|
<td class="nd_center-cell">[% row.log || '-' | html_entity %]</td>
|
||||||
|
</tr>
|
||||||
|
[% END %]
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
[% END %]
|
||||||
|
|
||||||
@@ -57,6 +57,12 @@
|
|||||||
rel="tooltip" data-placement="top" data-offset="3"
|
rel="tooltip" data-placement="top" data-offset="3"
|
||||||
data-animation="" data-title="Click to Enable"></i>
|
data-animation="" data-title="Click to Enable"></i>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
<a class="nd_log-icon"
|
||||||
|
href="[% uri_for('/admin/portlog') %]?q=[% device.dns || device.ip | uri %]&f=[% row.port | uri %]">
|
||||||
|
<i class="icon-file-text-alt"
|
||||||
|
rel="tooltip" data-placement="top" data-offset="3"
|
||||||
|
data-animation="" data-title="View Port Log"></i>
|
||||||
|
</a>
|
||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
<td nowrap>
|
<td nowrap>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|||||||
@@ -105,6 +105,7 @@
|
|||||||
[% IF settings._admin_tasks.size %]
|
[% IF settings._admin_tasks.size %]
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
[% FOREACH ai IN settings._admin_tasks.keys.sort %]
|
[% FOREACH ai IN settings._admin_tasks.keys.sort %]
|
||||||
|
[% NEXT IF settings._admin_tasks.$ai.hidden %]
|
||||||
<li><a href="[% uri_for('/admin/' _ ai) %]">[% settings._admin_tasks.$ai.label | html_entity %]</a></li>
|
<li><a href="[% uri_for('/admin/' _ ai) %]">[% settings._admin_tasks.$ai.label | html_entity %]</a></li>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|||||||
5
Netdisco/share/views/sidebar/admintask/portlog.tt
Normal file
5
Netdisco/share/views/sidebar/admintask/portlog.tt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<input name="q" value="[% params.q | html_entity %]" type="hidden"/>
|
||||||
|
<input name="f" value="[% params.f | html_entity %]" type="hidden"/>
|
||||||
|
<script type="text/javascript">has_sidebar["portlog"] = 0;</script>
|
||||||
Reference in New Issue
Block a user