diff --git a/Makefile.PL b/Makefile.PL index 5c2be17da1..109249d088 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,6 +16,7 @@ requires 'Catalyst::Action::RenderView'; requires 'Moose'; requires 'namespace::autoclean'; requires 'Config::General'; # This should reflect the config file format you've chosen +requires 'Catalyst::Helper::View::JSON' # See Catalyst::Plugin::ConfigLoader for supported formats requires 'Log::Log4perl::Catalyst'; test_requires 'Test::More' => '0.88'; diff --git a/lib/NGCP/Panel.pm b/lib/NGCP/Panel.pm index 01b9ecbb5e..44f22cb5de 100644 --- a/lib/NGCP/Panel.pm +++ b/lib/NGCP/Panel.pm @@ -53,6 +53,11 @@ __PACKAGE__->config( ], ABSOLUTE => 1, }, + 'View::JSON' => { + #Set the stash keys to be exposed to a JSON response + #(sEcho iTotalRecords iTotalDisplayRecords aaData) for datatables + expose_stash => [ qw(sEcho iTotalRecords iTotalDisplayRecords aaData) ], + }, 'Plugin::Static::Simple' => { include_path => [ @@ -135,6 +140,7 @@ __PACKAGE__->config( } } ); +__PACKAGE__->config( default_view => 'HTML' ); __PACKAGE__->log(Log::Log4perl::Catalyst->new('ngcp_panel.conf')); diff --git a/lib/NGCP/Panel/View/JSON.pm b/lib/NGCP/Panel/View/JSON.pm new file mode 100644 index 0000000000..a70ed4d189 --- /dev/null +++ b/lib/NGCP/Panel/View/JSON.pm @@ -0,0 +1,29 @@ +package NGCP::Panel::View::JSON; + +use strict; +use base 'Catalyst::View::JSON'; + +=head1 NAME + +NGCP::Panel::View::JSON - Catalyst JSON View + +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +Catalyst JSON View. + +=head1 AUTHOR + +Gerhard,,, + +=head1 LICENSE + +This library is free software, you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +1; diff --git a/t/view_JSON.t b/t/view_JSON.t new file mode 100644 index 0000000000..54627e3093 --- /dev/null +++ b/t/view_JSON.t @@ -0,0 +1,8 @@ +use strict; +use warnings; +use Test::More; + + +BEGIN { use_ok 'NGCP::Panel::View::JSON' } + +done_testing();