Allow Port Control users to see Port Config Log report

This commit is contained in:
Oliver Gorwits
2014-02-14 19:38:54 +00:00
parent e2fef8285b
commit e3ae76cea2
12 changed files with 31 additions and 18 deletions

View File

@@ -4,6 +4,7 @@
* Display clean version of creation stamp on port log * Display clean version of creation stamp on port log
* Make sure only to check for admins in deploy script * Make sure only to check for admins in deploy script
* Allow Port Control users to see Port Config Log report
[BUG FIXES] [BUG FIXES]

View File

@@ -178,6 +178,16 @@ any query parameters which might customize the report search.
See the L<App::Netdisco::Web::Plugin::Report::DuplexMismatch> module for a See the L<App::Netdisco::Web::Plugin::Report::DuplexMismatch> module for a
simple example of how to implement the handler. simple example of how to implement the handler.
An additional feature allows you to create Reports 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_report({
tag => 'newfeature',
label => 'My New Feature',
hidden => true,
});
=head1 CSV Response =head1 CSV Response
Most pages in Netdisco are a table with data. It's possible to have the Most pages in Netdisco are a table with data. It's possible to have the
@@ -224,7 +234,7 @@ want arbitrary links supported.
An additional feature allows you to create Admin Tasks which do not appear in 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 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: another. To enable this feature add the C<hidden> key:
register_admin_task({ register_admin_task({
tag => 'newfeature', tag => 'newfeature',

View File

@@ -1,4 +1,4 @@
package App::Netdisco::Web::Plugin::AdminTask::PortLog; package App::Netdisco::Web::Plugin::Report::PortLog;
use Dancer ':syntax'; use Dancer ':syntax';
use Dancer::Plugin::Ajax; use Dancer::Plugin::Ajax;
@@ -7,13 +7,14 @@ use Dancer::Plugin::Auth::Extensible;
use App::Netdisco::Web::Plugin; use App::Netdisco::Web::Plugin;
register_admin_task({ register_report({
tag => 'portlog', tag => 'portlog',
label => 'Port Control Log', label => 'Port Control Log',
category => 'Port', # not used
hidden => true, hidden => true,
}); });
ajax '/ajax/content/admin/portlog' => require_role admin => sub { ajax '/ajax/content/report/portlog' => require_role port_control => sub {
my $device = param('q'); my $device = param('q');
my $port = param('f'); my $port = param('f');
send_error('Bad Request', 400) unless $device and $port; send_error('Bad Request', 400) unless $device and $port;
@@ -31,7 +32,7 @@ ajax '/ajax/content/admin/portlog' => require_role admin => sub {
})->with_times; })->with_times;
content_type('text/html'); content_type('text/html');
template 'ajax/admintask/portlog.tt', { template 'ajax/report/portlog.tt', {
results => $set, results => $set,
}, { layout => undef }; }, { layout => undef };
}; };

View File

@@ -53,7 +53,7 @@ web_plugins:
- Report::SsidInventory - Report::SsidInventory
- Report::VlanInventory - Report::VlanInventory
- Report::SubnetUtilization - Report::SubnetUtilization
- AdminTask::PortLog - Report::PortLog
- AdminTask::JobQueue - AdminTask::JobQueue
- AdminTask::Topology - AdminTask::Topology
- AdminTask::PollerPerformance - AdminTask::PollerPerformance

View File

@@ -40,12 +40,6 @@
<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">

View File

@@ -67,7 +67,7 @@
data-animation="" data-title="Click to Enable"></i> data-animation="" data-title="Click to Enable"></i>
[% END %] [% END %]
<a class="nd_log-icon" <a class="nd_log-icon"
href="[% uri_for('/admin/portlog') %]?q=[% device.ip | uri %]&f=[% row.port | uri %]"> href="[% uri_for('/report/portlog') %]?q=[% device.ip | uri %]&f=[% row.port | uri %]">
<i class="icon-file-text-alt" <i class="icon-file-text-alt"
rel="tooltip" data-placement="top" data-offset="3" rel="tooltip" data-placement="top" data-offset="3"
data-animation="" data-title="View Port Log"></i> data-animation="" data-title="View Port Log"></i>
@@ -342,7 +342,7 @@
role="dialog" aria-hidden="true"> role="dialog" aria-hidden="true">
<div class="modal-body"> <div class="modal-body">
<blockquote> <blockquote>
<ul><li><p>Please provide a reason for chainging the Port Configuration</p></li></ul> <ul><li><p>Please provide a reason for changing the Port Configuration</p></li></ul>
</blockquote> </blockquote>
<select id="nd_portlog-reason" class="input-block-level" name="reason"> <select id="nd_portlog-reason" class="input-block-level" name="reason">
[% FOREACH pair IN settings.port_control_reasons.pairs %] [% FOREACH pair IN settings.port_control_reasons.pairs %]

View File

@@ -18,8 +18,8 @@
method="get" action="[% uri_for('/device') %]"> method="get" action="[% uri_for('/device') %]">
<input name="tab" value="[% tab.tag %]" type="hidden"/> <input name="tab" value="[% tab.tag %]" type="hidden"/>
[% TRY %] [% TRY %]
[% INCLUDE "sidebar/device/${tab.tag}.tt" %]
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script> <script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script>
[% INCLUDE "sidebar/device/${tab.tag}.tt" %]
[% CATCH %] [% CATCH %]
<!-- no "[% tab.tag %]" search options --> <!-- no "[% tab.tag %]" search options -->
<input name="q" value="[% params.q | html_entity %]" type="hidden"/> <input name="q" value="[% params.q | html_entity %]" type="hidden"/>

View File

@@ -77,6 +77,7 @@
<a href="#">[% category | html_entity %]</a> <a href="#">[% category | html_entity %]</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
[% FOREACH item IN settings._reports_menu.$category %] [% FOREACH item IN settings._reports_menu.$category %]
[% NEXT IF settings._reports.$item.hidden %]
<li><a href="[% uri_for('/report/' _ item) %]">[% settings._reports.$item.label | html_entity %]</a></li> <li><a href="[% uri_for('/report/' _ item) %]">[% settings._reports.$item.label | html_entity %]</a></li>
[% END %] [% END %]
</ul> </ul>

View File

@@ -13,8 +13,8 @@
<form id="[% report.tag %]_form" class="nd_sidebar-form form-stacked" <form id="[% report.tag %]_form" class="nd_sidebar-form form-stacked"
method="get" action="[% uri_for('/report') %]"> method="get" action="[% uri_for('/report') %]">
[% TRY %] [% TRY %]
[% INCLUDE "sidebar/report/${report.tag}.tt" %]
<script type="text/javascript">has_sidebar["[% report.tag %]"] = 1;</script> <script type="text/javascript">has_sidebar["[% report.tag %]"] = 1;</script>
[% INCLUDE "sidebar/report/${report.tag}.tt" %]
[% CATCH %] [% CATCH %]
<script type="text/javascript">has_sidebar["[% report.tag %]"] = 0;</script> <script type="text/javascript">has_sidebar["[% report.tag %]"] = 0;</script>
[% END %] [% END %]
@@ -28,7 +28,13 @@
<ul id="nd_search-results" class="nav nav-tabs"> <ul id="nd_search-results" class="nav nav-tabs">
<li class="active"><a id="[% report.tag %]_link" class="nd_single-tab" <li class="active"><a id="[% report.tag %]_link" class="nd_single-tab"
href="#[% report.tag %]_pane">[% report.label %]</a></li> href="#[% report.tag %]_pane">[% report.label %]</a></li>
[% IF report.provides_csv %] [% IF report.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 report.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">
<i id="nd_csv-download-icon" class="text-info icon-file-text-alt icon-large" <i id="nd_csv-download-icon" class="text-info icon-file-text-alt icon-large"

View File

@@ -13,8 +13,8 @@
<form id="[% tab.tag %]_form" class="nd_sidebar-form form-stacked" method="get" action="[% uri_for('/search') %]"> <form id="[% tab.tag %]_form" class="nd_sidebar-form form-stacked" method="get" action="[% uri_for('/search') %]">
<input name="tab" value="[% tab.tag %]" type="hidden"/> <input name="tab" value="[% tab.tag %]" type="hidden"/>
[% TRY %] [% TRY %]
[% INCLUDE "sidebar/search/${tab.tag}.tt" %]
<script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script> <script type="text/javascript">has_sidebar["[% tab.tag %]"] = 1;</script>
[% INCLUDE "sidebar/search/${tab.tag}.tt" %]
[% CATCH %] [% CATCH %]
<!-- no "[% tab.tag %]" search options --> <!-- no "[% tab.tag %]" search options -->
<input name="q" value="[% params.q | html_entity %]" type="hidden"/> <input name="q" value="[% params.q | html_entity %]" type="hidden"/>