From 13af853582381f7a8b03960f56f0db416dcf5ffc Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 10 Mar 2013 23:40:53 +0000 Subject: [PATCH] fixes to main app to support reports --- Netdisco/lib/App/Netdisco/Web/Report.pm | 3 +++ Netdisco/share/public/javascripts/netdisco.js | 3 ++- Netdisco/share/views/ajax/report/duplexmismatch.tt | 0 Netdisco/share/views/js/common.js | 5 +++++ Netdisco/share/views/js/report.js | 11 +++++++++++ Netdisco/share/views/report.tt | 5 ++++- 6 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 Netdisco/share/views/ajax/report/duplexmismatch.tt create mode 100644 Netdisco/share/views/js/report.js diff --git a/Netdisco/lib/App/Netdisco/Web/Report.pm b/Netdisco/lib/App/Netdisco/Web/Report.pm index 6d494978..fba23e90 100644 --- a/Netdisco/lib/App/Netdisco/Web/Report.pm +++ b/Netdisco/lib/App/Netdisco/Web/Report.pm @@ -5,6 +5,9 @@ use Dancer ':syntax'; get '/report/*' => sub { my ($tag) = splat; + # trick the ajax into working as if this were a tabbed page + params->{tab} = $tag; + var(nav => 'reports'); template 'report', { report => setting('reports')->{ $tag }, diff --git a/Netdisco/share/public/javascripts/netdisco.js b/Netdisco/share/public/javascripts/netdisco.js index 343b7c8a..137996fd 100644 --- a/Netdisco/share/public/javascripts/netdisco.js +++ b/Netdisco/share/public/javascripts/netdisco.js @@ -44,7 +44,8 @@ function do_search (event, tab) { // update browser search history with the new query. // however if it's the same tab, this is a *replace* of the query url. - if (window.History && window.History.enabled) { + // and just skip this bit if it's the reports display. + if (path != 'report' && window.History && window.History.enabled) { is_from_history_plugin = 1; window.History.replaceState( {name: tab, fields: $(form).serializeArray()}, diff --git a/Netdisco/share/views/ajax/report/duplexmismatch.tt b/Netdisco/share/views/ajax/report/duplexmismatch.tt new file mode 100644 index 00000000..e69de29b diff --git a/Netdisco/share/views/js/common.js b/Netdisco/share/views/js/common.js index b2080087..7b23897b 100644 --- a/Netdisco/share/views/js/common.js +++ b/Netdisco/share/views/js/common.js @@ -7,6 +7,11 @@ $('[% "#${tab.tag}_form" %]').submit(function(event){ do_search(event, '[% tab.tag %]'); }); [% END %] + // and for the reports page + [% IF report %] + $('[% "#${report.tag}_form" %]').submit(function(event){ do_search(event, '[% report.tag %]'); }); + [% END %] + // on page load, load the content for the active tab [% IF params.tab %] $('#[% params.tab %]_form').trigger("submit"); diff --git a/Netdisco/share/views/js/report.js b/Netdisco/share/views/js/report.js new file mode 100644 index 00000000..d3126253 --- /dev/null +++ b/Netdisco/share/views/js/report.js @@ -0,0 +1,11 @@ + // used by the tabbing interface to make sure the correct + // ajax content is loaded + var path = 'report'; + + // this is called by do_search to support local code + // here, when tab changes need to strike/unstrike the navbar search + function inner_view_processing(tab) { } + + // on load, check initial Device Search Options form state, + // and on each change to the form fields + $(document).ready(function() { }); diff --git a/Netdisco/share/views/report.tt b/Netdisco/share/views/report.tt index 879b73fe..2e81c373 100644 --- a/Netdisco/share/views/report.tt +++ b/Netdisco/share/views/report.tt @@ -12,7 +12,6 @@ + +