summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-04-06 22:01:05 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-04-06 22:01:05 -0500
commit9cfdddf49df7d5f47691ca467d9fbae51bfd71a0 (patch)
treecedc5524f5dfeeb026e51da1da6834db876d7938 /httemplate
parentfe529fcf74225297231dc3678594166720721205 (diff)
RT#18834: Cacti integration [database storage]
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/misc/cacti_graphs.html42
-rw-r--r--httemplate/misc/process/cacti_graphs.cgi3
2 files changed, 29 insertions, 16 deletions
diff --git a/httemplate/misc/cacti_graphs.html b/httemplate/misc/cacti_graphs.html
index 9cc5e2494..90a435091 100644
--- a/httemplate/misc/cacti_graphs.html
+++ b/httemplate/misc/cacti_graphs.html
@@ -21,33 +21,43 @@
process();
</SCRIPT>
-% } else {
-% if ($error) {
+% } elsif ($error) {
-<P><% $error %></P>
+<P><% emt($error) %></P>
+<FORM NAME="CactiGraphForm" ID="CactiGraphForm" style="margin-top: 0">
+<INPUT TYPE="hidden" NAME="svcnum" VALUE="<% $svcnum %>">
+<INPUT TYPE="hidden" NAME="load" VALUE="1">
+<INPUT TYPE="submit" VALUE="Reload Graphs">
+</FORM>
-% } else {
+% } else {
-<% slurp($htmlfile) %>
+<% $content %>
-% }
% }
<%init>
use File::Slurp qw( slurp );
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
+
my $svcnum = $cgi->param('svcnum') or die 'Illegal svcnum';
my $load = $cgi->param('load');
-my $graphnum = $cgi->param('graphnum');
-
-my $htmlfile = $FS::UID::cache_dir
- . '/cacti-graphs/'
- . 'svc_'
- . $svcnum;
-$htmlfile .= '_graph_' . $graphnum
- if $graphnum;
-$htmlfile .= '.html';
+my $graphnum = $cgi->param('graphnum') || '';
+
+my ($content,$error);
+unless ($load) {
+ my $page = qsearchs({
+ 'table' => 'cacti_page',
+ 'hashref' => { 'svcnum' => $svcnum, 'graphnum' => $graphnum },
+ });
+ if ($page) {
+ $content = $page->content;
+ } else {
+ $error = 'No graphs found in import cache. Click below to retry import.';
+ }
+}
-my $error = (-e $htmlfile) ? '' : 'File not found';
</%init>
diff --git a/httemplate/misc/process/cacti_graphs.cgi b/httemplate/misc/process/cacti_graphs.cgi
index 160b1ad85..f2baeb455 100644
--- a/httemplate/misc/process/cacti_graphs.cgi
+++ b/httemplate/misc/process/cacti_graphs.cgi
@@ -1,6 +1,9 @@
<% $server->process %>
<%init>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('View customer services');
+
my $server = FS::UI::Web::JSRPC->new('FS::part_export::cacti::process_graphs', $cgi);
</%init>