[#143] Pass parameter(s) to custom reports via bind_params config

This commit is contained in:
Oliver Gorwits
2014-10-05 13:00:03 +01:00
parent 7630b6ec7b
commit d50dba3eee
2 changed files with 24 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
[NEW FEATURES] [NEW FEATURES]
* Administration (SSH, Telnet, Web) links for devices * Administration (SSH, Telnet, Web) links for devices
* [#143] Pass parameter(s) to custom reports via bind_params config
2.029009 - 2014-09-27 2.029009 - 2014-09-27

View File

@@ -256,16 +256,21 @@ code or HTML templates. For example:
FROM device d FROM device d
ORDER BY name ORDER BY name
The C<key> of each item in the C<reports> configuration is an alias for the The C<tag> of each item in the C<reports> configuration is an alias for the
report, and becomes part of the web path. report, and becomes part of the web path.
You can munge the data retrieved from the database by placing a Perl script You can munge the data retrieved from the database by placing a Perl script
with the same name as the C<reports> key into the C<site_plugins> directory of with the same name as the C<reports> key into the "C<site_plugins>" directory
Netdisco's home area. The script can access C<$config> for its configuration of Netdisco's home area. The script can access C<$config> for its
and C<@data> for the retrieved data. It should return a list of munged data. configuration and C<@data> for the retrieved data. It should return a list of
munged data.
Within the tree you can provide each of the keys below: Within the tree you can provide each of the keys below:
=head4 C<tag>
Alias for the Report, which must be usable in a web path.
=head4 C<label> =head4 C<label>
Title for the Report. Title for the Report.
@@ -295,6 +300,20 @@ C<query> may not be the same as those in the web report. Set this to a list of
the columns in C<query>. The C<columns> setting will then be used for the web the columns in C<query>. The C<columns> setting will then be used for the web
report. report.
=head4 C<bind_params> (optional)
You can use placeholders in the SQL C<query> (that is, "C<?>") to bind
user-supplied parameters. This setting should be a list of the parameters to
pick out of the URL query string and match to the placeholders in the same
order. For example:
query: |
SELECT ... FROM ... WHERE device = ? AND port = ?
bind-params: ['device', 'port']
# then
http://localhost:5000/report/my_special_report?device=192.0.2.1&port=Vlan142
=head3 C<jobqueue_refresh> =head3 C<jobqueue_refresh>
Value: Integer Number. Default: 5. Value: Integer Number. Default: 5.