reports now a list not a hash

This commit is contained in:
Oliver Gorwits
2014-06-30 13:05:43 +01:00
parent e5e0c0c8d1
commit 755fc92c59
4 changed files with 32 additions and 8 deletions

View File

@@ -224,13 +224,13 @@ C<web_plugins> setting.
=head3 C<reports> =head3 C<reports>
Value: Dictionary of Reports Hashes. Default: None. Value: List of Reports Hashes. Default: None.
Use this configuration to add reports to Netdisco without writing any Perl Use this configuration to add reports to Netdisco without writing any Perl
code or HTML templates. For example: code or HTML templates. For example:
reports: reports:
power_inventory: - tag: power_inventory
category: Device category: Device
label: 'Power Supply Inventory' label: 'Power Supply Inventory'
columns: columns:
@@ -242,8 +242,8 @@ code or HTML templates. For example:
FROM device d FROM device d
ORDER BY name ORDER BY name
Each key of the C<reports> configuration is an alias for the report, and The C<key> of each item in the C<reports> configuration is an alias for the
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 of

View File

@@ -36,6 +36,30 @@ but they are backwards compatible.
=back =back
=head1 2.029000
=head2 Incompatible Changes
The configuration item C<reports> is now a list (used to be a dictionary).
Each item in the list must have a C<tag> entry which was previously the
dictionary key. For example:
reports:
- tag: power_inventory
category: Device
label: 'Power Supply Inventory'
columns:
- {name: 'Name'}
- {ps1_type: 'PS1 Type'}
- {ps1_status: 'PS1 Status'}
query: |
SELECT d.name, d.ps1_type, d.ps1_status
FROM device d
WHERE d.ps1_type IS NOT NULL
ORDER BY name
You I<must> reconfigure. Old configuration will not be migrated.
=head1 2.028000 =head1 2.028000
=head2 General Changes =head2 General Changes

View File

@@ -11,8 +11,8 @@ use Safe;
use vars qw/$config @data/; use vars qw/$config @data/;
foreach my $r (keys %{setting('reports')}) { foreach my $report (@{setting('reports')}) {
my $report = setting('reports')->{$r}; my $r = $report->{tag};
register_report({ register_report({
tag => $r, tag => $r,
@@ -41,7 +41,7 @@ foreach my $r (keys %{setting('reports')}) {
# Data Munging support... # Data Munging support...
my $compartment = Safe->new; my $compartment = Safe->new;
$config = setting('reports')->{$r}; $config = $report;
$compartment->share(qw/$config @data/); $compartment->share(qw/$config @data/);
$compartment->permit_only(qw/:default sort/); $compartment->permit_only(qw/:default sort/);

View File

@@ -78,7 +78,7 @@ web_plugins:
extra_web_plugins: [] extra_web_plugins: []
jobqueue_refresh: 10 jobqueue_refresh: 10
safe_password_store: true safe_password_store: true
reports: {} reports: []
# ------------- # -------------
# NETDISCO CORE # NETDISCO CORE