From 9f558482e06cc4f554e05df7209b33e7019fcd24 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 27 Feb 2014 16:51:08 +0000 Subject: [PATCH] User Reports via config, without requiring HTML or Perl --- Netdisco/Changes | 8 ++- .../DB/Result/Virtual/GenericReport.pm | 13 +++++ .../lib/App/Netdisco/Manual/Configuration.pod | 44 ++++++++++++++++ .../App/Netdisco/Manual/WritingPlugins.pod | 6 ++- Netdisco/lib/App/Netdisco/Web.pm | 1 + .../lib/App/Netdisco/Web/GenericReport.pm | 50 +++++++++++++++++++ Netdisco/share/environments/deployment.yml | 2 +- .../share/views/ajax/report/generic_report.tt | 18 +++++++ .../views/ajax/report/generic_report_csv.tt | 11 ++++ 9 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 Netdisco/lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm create mode 100644 Netdisco/lib/App/Netdisco/Web/GenericReport.pm create mode 100644 Netdisco/share/views/ajax/report/generic_report.tt create mode 100644 Netdisco/share/views/ajax/report/generic_report_csv.tt diff --git a/Netdisco/Changes b/Netdisco/Changes index 809b93fc..ab23a445 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,4 +1,10 @@ -2.024001 - +2.024002 - 2014-02-27 + + [NEW FEATURES] + + * User Reports via config, without requiring HTML or Perl + +2.024001 - 2014-02-25 [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm b/Netdisco/lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm new file mode 100644 index 00000000..bbab1286 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/DB/Result/Virtual/GenericReport.pm @@ -0,0 +1,13 @@ +package App::Netdisco::DB::Result::Virtual::GenericReport; + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->table_class('DBIx::Class::ResultSource::View'); +__PACKAGE__->table("generic_report"); +__PACKAGE__->result_source_instance->is_virtual(1); +__PACKAGE__->result_source_instance->view_definition(q{}); + +1; diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index 1bda3475..9512c8c7 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -222,6 +222,50 @@ Value: List of Modules. Default: Empty List. List of additional L names to load. See also the C setting. +=head3 C + +Value: Dictionary of Reports Hashes. Default: None. + +Use this configuration to add reports to Netdisco without writing any Perl +code or HTML templates. For example: + + reports: + 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 + ORDER BY name + +Each key of the C configuration is an alias for the report, and +becomes part of the web path. Within the tree you must provide each of the +keys shown: + +=head4 C + +Section of the Reports menu where this report will appear. See +L for the full list. + +=head4 C