progressbar fix for elements/ exclusion, RT#38752
authorIvan Kohler <ivan@freeside.biz>
Tue, 27 Oct 2015 16:40:45 +0000 (09:40 -0700)
committerIvan Kohler <ivan@freeside.biz>
Tue, 27 Oct 2015 16:40:45 +0000 (09:40 -0700)
FS/FS/CGI.pm
httemplate/elements/jsrsServer.html [deleted file]
httemplate/elements/progress-init.html
httemplate/elements/progress-popup.html [deleted file]
httemplate/misc/jsrsServer.html [new file with mode: 0644]
httemplate/misc/progress-popup.html [new file with mode: 0644]

index 5ac31db..fc0f652 100644 (file)
@@ -244,17 +244,13 @@ sub rooturl {
   $url_string =~
     s{
        /
-       (browse|config|docs|edit|graph|misc|search|view|loginout|pref|elements|rt|torrus)
+       (browse|config|docs|edit|graph|misc|search|view|loginout|pref|rt|torrus)
        (/process)?
        ([\w\-\.\/]*)
        $
      }
      {}x;
 
-  #elements because of progress-popup.html... 
-  #XXX remove anything from elements that is called directly & prevent
-  #those pages from being served up
-
   $url_string .= '/' unless $url_string =~ /\/$/;
 
   $url_string;
diff --git a/httemplate/elements/jsrsServer.html b/httemplate/elements/jsrsServer.html
deleted file mode 100644 (file)
index f37b0aa..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-%
-%  my $server = new FS::UI::Web::JSRPC '', $cgi;
-%
-<% $server->process %>
index 2728240..e38dde6 100644 (file)
@@ -161,7 +161,7 @@ if ( ref($url_or_message) ) { #its a message or something
   %dest_info = ( 'url' => $url_or_message );
 }
 
-my $progress_url = URI->new($fsurl.'elements/progress-popup.html');
+my $progress_url = URI->new($fsurl.'misc/progress-popup.html');
 $progress_url->query_form(
   'jobnum'    => '_JOBNUM_',
   'formname'  => $formname,
diff --git a/httemplate/elements/progress-popup.html b/httemplate/elements/progress-popup.html
deleted file mode 100644 (file)
index a37cf24..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-%
-%  my $jobnum = $cgi->param('jobnum');
-%  my $url = $cgi->param('url');
-%  my $message = $cgi->param('message');
-%  my $popup_url = $cgi->param('popup_url');
-%  my $formname = scalar($cgi->param('formname'));
-%  my $error_url = $cgi->param('error_url');
-%
-
-<HTML>
-  <HEAD>
-    <TITLE></TITLE>
-  </HEAD>
-  <BODY BGCOLOR="#ccccff" onLoad="refreshStatus()">
-
-<% include('/elements/xmlhttp.html',
-              'url'  => $p.'elements/jsrsServer.html',
-              'subs' => [ 'job_status' ],
-           )
-%>
-<SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/control.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/imagelist.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/progress.js"></SCRIPT>
-<SCRIPT TYPE="text/javascript">
-function refreshStatus () {
-  //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
-
-  job_status( '<% $jobnum %>', updateStatus );
-}
-function updateStatus( status_statustext ) {
-
-  //var Array = status_statustext.split("\n");
-  var statusArray = eval('(' + status_statustext + ')');
-  var status = statusArray[0];
-  var statustext = statusArray[1];
-  var actiontext = statusArray[2];
-
-  //if ( status == 'progress' ) {
-  //IE workaround, no i have no idea why
-  if ( status.indexOf('progress') > -1 ) {
-    document.getElementById("progress_message").innerHTML = actiontext + '...';
-    document.getElementById("progress_percent").innerHTML = statustext + '%';
-    bar1.set(statustext);
-    bar1.update;
-    //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
-    job_status( '<% $jobnum %>', updateStatus );
-  } else if ( status.indexOf('complete') > -1 ) {
-% if ( $message ) {
-%
-%   my $onClick = $url
-%                   ? "window.top.location.href = \\'$url\\';"
-%                   : 'parent.nd(1);';
-
-    document.getElementById("progress_message").innerHTML = "<% $message %>";
-    document.getElementById("progress_bar").innerHTML = '';
-    document.getElementById("progress_percent").innerHTML =
-      '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
-    document.getElementById("progress_jobnum").innerHTML = '';
-
-%   unless ( $url ) {
-        if ( parent.document.<%$formname%>.submit.disabled == true ) {
-          parent.document.<%$formname%>.submit.disabled=false;
-        }
-%   }
-
-% } elsif ( $url ) {
-    parent.nd(1);
-    window.top.location.href = '<% $url %>';
-% } elsif ( $popup_url ) {
-    document.location.replace('<% $popup_url %>');
-% } else { 
-
-
-    alert('job done but no url or message specified');
-% } 
-  } else if ( status.indexOf('done') > -1 ) {
-
-    document.getElementById("progress_message").innerHTML = "Loading report";
-    document.getElementById("progress_bar").innerHTML = '';
-    document.getElementById("progress_percent").innerHTML = '';
-    document.getElementById("progress_jobnum").innerHTML = '';
-    window.top.location.href = statustext.substr(8, statustext.length-18);
-
-  } else if ( status.indexOf('error') > -1 ) {
-%
-% # default behavior: just close the popup
-% my $onClick = 'parent.nd(1);';
-% if ( $error_url ) { # then on clicking to confirm, redirect somewhere
-%   $onClick = "window.top.location.href = \\'$error_url\\';";
-% }
-
-    document.getElementById("progress_message").innerHTML = '<FONT SIZE="+1" COLOR="#FF0000">Error: ' + statustext + '</FONT>';
-    document.getElementById("progress_bar").innerHTML = '';
-    document.getElementById("progress_percent").innerHTML = '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
-    document.getElementById("progress_jobnum").innerHTML = '';
-    if ( parent.document.<%$formname%>.submit.disabled == true ) {
-      parent.document.<%$formname%>.submit.disabled=false;
-    }
-  } else {
-    alert('XXX unknown status returned from server: ' + status);
-  }
-  
-}
-</SCRIPT>
-
-    <TABLE WIDTH="100%">
-      <TR>
-        <TD ALIGN="center" ID="progress_message">
-          Server processing job...
-        </TD>
-      </TR><TR>
-        <TD ALIGN="center" ID="progress_bar">
-          <SCRIPT TYPE="text/javascript">
-            // Create imagelist
-            SEGS = new QImageList(4, 23, "<%$fsurl%>images/progressbar-empty.png", "<%$fsurl%>images/progressbar-full.png");
-            // Create bars
-            bar1 = new QProgress(null, "bar1", SEGS, 100);
-            // bar1.set(0);
-            // bar1.update;
-          </SCRIPT>
-        </TD>
-      </TR><TR>
-        <TD ALIGN="center">
-          <DIV ID="progress_percent">%</DIV>
-        </TD>
-      </TR><TR>
-        <TD ALIGN="center" ID="progress_jobnum">
-          (progress of job #<% $jobnum %>)
-        </TD>
-      </TR>
-    </TABLE>
-
-  </BODY>
-</HTML>
-
diff --git a/httemplate/misc/jsrsServer.html b/httemplate/misc/jsrsServer.html
new file mode 100644 (file)
index 0000000..f37b0aa
--- /dev/null
@@ -0,0 +1,4 @@
+%
+%  my $server = new FS::UI::Web::JSRPC '', $cgi;
+%
+<% $server->process %>
diff --git a/httemplate/misc/progress-popup.html b/httemplate/misc/progress-popup.html
new file mode 100644 (file)
index 0000000..8e2d676
--- /dev/null
@@ -0,0 +1,135 @@
+%
+%  my $jobnum = $cgi->param('jobnum');
+%  my $url = $cgi->param('url');
+%  my $message = $cgi->param('message');
+%  my $popup_url = $cgi->param('popup_url');
+%  my $formname = scalar($cgi->param('formname'));
+%  my $error_url = $cgi->param('error_url');
+%
+
+<HTML>
+  <HEAD>
+    <TITLE></TITLE>
+  </HEAD>
+  <BODY BGCOLOR="#ccccff" onLoad="refreshStatus()">
+
+<% include('/elements/xmlhttp.html',
+              'url'  => $p.'misc/jsrsServer.html',
+              'subs' => [ 'job_status' ],
+           )
+%>
+<SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/control.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/imagelist.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript" src="<%$fsurl%>elements/qlib/progress.js"></SCRIPT>
+<SCRIPT TYPE="text/javascript">
+function refreshStatus () {
+  //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
+
+  job_status( '<% $jobnum %>', updateStatus );
+}
+function updateStatus( status_statustext ) {
+
+  //var Array = status_statustext.split("\n");
+  var statusArray = eval('(' + status_statustext + ')');
+  var status = statusArray[0];
+  var statustext = statusArray[1];
+  var actiontext = statusArray[2];
+
+  //if ( status == 'progress' ) {
+  //IE workaround, no i have no idea why
+  if ( status.indexOf('progress') > -1 ) {
+    document.getElementById("progress_message").innerHTML = actiontext + '...';
+    document.getElementById("progress_percent").innerHTML = statustext + '%';
+    bar1.set(statustext);
+    bar1.update;
+    //jsrsExecute( '<%$p%>elements/jsrsServer.html', updateStatus, 'job_status', '<% $jobnum %>' );
+    job_status( '<% $jobnum %>', updateStatus );
+  } else if ( status.indexOf('complete') > -1 ) {
+% if ( $message ) {
+%
+%   my $onClick = $url
+%                   ? "window.top.location.href = \\'$url\\';"
+%                   : 'parent.nd(1);';
+
+    document.getElementById("progress_message").innerHTML = "<% $message %>";
+    document.getElementById("progress_bar").innerHTML = '';
+    document.getElementById("progress_percent").innerHTML =
+      '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
+    document.getElementById("progress_jobnum").innerHTML = '';
+
+%   unless ( $url ) {
+        if ( parent.document.<%$formname%>.submit.disabled == true ) {
+          parent.document.<%$formname%>.submit.disabled=false;
+        }
+%   }
+
+% } elsif ( $url ) {
+    parent.nd(1);
+    window.top.location.href = '<% $url %>';
+% } elsif ( $popup_url ) {
+    document.location.replace('<% $popup_url %>');
+% } else { 
+
+
+    alert('job done but no url or message specified');
+% } 
+  } else if ( status.indexOf('done') > -1 ) {
+
+    document.getElementById("progress_message").innerHTML = "Loading report";
+    document.getElementById("progress_bar").innerHTML = '';
+    document.getElementById("progress_percent").innerHTML = '';
+    document.getElementById("progress_jobnum").innerHTML = '';
+    window.top.location.href = statustext.substr(8, statustext.length-18);
+
+  } else if ( status.indexOf('error') > -1 ) {
+%
+% # default behavior: just close the popup
+% my $onClick = 'parent.nd(1);';
+% if ( $error_url ) { # then on clicking to confirm, redirect somewhere
+%   $onClick = "window.top.location.href = \\'$error_url\\';";
+% }
+
+    document.getElementById("progress_message").innerHTML = '<FONT SIZE="+1" COLOR="#FF0000">Error: ' + statustext + '</FONT>';
+    document.getElementById("progress_bar").innerHTML = '';
+    document.getElementById("progress_percent").innerHTML = '<INPUT TYPE="button" VALUE="OK" onClick="<% $onClick %>">';
+    document.getElementById("progress_jobnum").innerHTML = '';
+    if ( parent.document.<%$formname%>.submit.disabled == true ) {
+      parent.document.<%$formname%>.submit.disabled=false;
+    }
+  } else {
+    alert('XXX unknown status returned from server: ' + status);
+  }
+  
+}
+</SCRIPT>
+
+    <TABLE WIDTH="100%">
+      <TR>
+        <TD ALIGN="center" ID="progress_message">
+          Server processing job...
+        </TD>
+      </TR><TR>
+        <TD ALIGN="center" ID="progress_bar">
+          <SCRIPT TYPE="text/javascript">
+            // Create imagelist
+            SEGS = new QImageList(4, 23, "<%$fsurl%>images/progressbar-empty.png", "<%$fsurl%>images/progressbar-full.png");
+            // Create bars
+            bar1 = new QProgress(null, "bar1", SEGS, 100);
+            // bar1.set(0);
+            // bar1.update;
+          </SCRIPT>
+        </TD>
+      </TR><TR>
+        <TD ALIGN="center">
+          <DIV ID="progress_percent">%</DIV>
+        </TD>
+      </TR><TR>
+        <TD ALIGN="center" ID="progress_jobnum">
+          (progress of job #<% $jobnum %>)
+        </TD>
+      </TR>
+    </TABLE>
+
+  </BODY>
+</HTML>
+