Re: [webmin-devel] adding a "please wait" popup while executing time consuming commands

"Jamie Cameron" <[email protected]> Fri, 23 May 2014 13:48:30 -0700 (PDT)
Newsgroups gmane.comp.web.webmin.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.

--bound1400878110
Content-Type: multipart/alternative; boundary="altsbound1400878110"
Content-Transfer-Encoding: 7bit


--altsbound1400878110
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit


   You can't use the redirect function, as that can only be called if header
   isn't. You should instead output some JS like :
   <script>
   window.location = "/module./page.cgi";
   </script>

   On 23/May/2014 07:15 marty leisner <[email protected]> wrote ..

   Thanks -- its ui_print_unbuffered_header.
   But after the page is displayed, I want to force a redirect to another page
   -- how would I do it
   Something like:
   &ui_print_unbuffered_header('please wait');
   system('date');
   print "<BR>\n";
   sleep(5);
   system('date');
   print "<BR>first line\n<BR>";
   sleep(5);
   system('date');
   print "<BR>second line\n<BR>";
   footer();
   # redirect('index.cgi');
   marty

   On Wed, May 21, 2014 at 1:47 PM, Jamie Cameron <[1][email protected]>
   wrote:

     Try using un_print_unbuffered_header instead of ui_print_header

     On 20/May/2014 21:20 marty leisner <[2][email protected]> wrote ..

   I'm having a problem where my page is delivered on the network at the same
   time -- after the delay (I used wireshark to
   monitor this)
   What I want tried is:
   ui_print_header('please wait');
   footer();
   sleep(5);
   print "final\n<BR>";
   I would have expected to see the header render, a delay, and "final".
   Its all happening after the delay.
   What I really want to do is:
   display "please wait"
   run a long command
   redirect to another page (after the command runs)
   marty

   On Tue, May 20, 2014 at 4:19 PM, Jamie Cameron <[3][email protected]>
   wrote:

     On 20/May/2014 09:27 marty leisner <[4][email protected]> wrote ..

   > When having a custom module in webmin execute time consuming commands, how
   > would I add a
   > "please wait" message until the command is finished (without user
   > interaction).
   >
   > I.e.:
   >
   > start_please_wait();
   > system("long_command");
   > stop_please_wait();

     In some modules, I've had Webmin print out a series of dots (one per
     second)
     while performing some long operation. The code is like :
     print "Doing something slow ..";
     launch_slow_op_in_background();
     while(!done_slow_op()) {
       sleep(1);
       print ".";
       }
     print "<br>\n";
     print ".. done<p>\n";
      - Jamie
     --------------------------------------------------------------------------
     ----
     "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
     Instantly run your Selenium tests across 300+ browser/OS combos.
     Get unparalleled scalability from the best Selenium testing platform
     available
     Simple to use. Nothing to install. Get started now for free."
     [5]http://p.sf.net/sfu/SauceLabs
     -
     Forwarded by the Webmin development list at [6][email protected]
     To remove yourself from this list, go to
     [7]http://lists.sourceforge.net/lists/listinfo/webadmin-devel

     --------------------------------------------------------------------------
     ----
     "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
     Instantly run your Selenium tests across 300+ browser/OS combos.
     Get unparalleled scalability from the best Selenium testing platform
     available
     Simple to use. Nothing to install. Get started now for free."
     [8]http://p.sf.net/sfu/SauceLabs
     -
     Forwarded by the Webmin development list at [9][email protected]
     To remove yourself from this list, go to
     [10]http://lists.sourceforge.net/lists/listinfo/webadmin-devel


   1. file://localhost/home/webmail/homes/jcameron/.tmp/reply_mail.cgi?new=1&to=jcameron%40webmin%2Ecom
   2. file://localhost/home/webmail/homes/jcameron/.tmp/reply_mail.cgi?new=1&to=maleisner%40gmail%2Ecom
   9. file://localhost/home/webmail/homes/jcameron/.tmp/reply_mail.cgi?new=1&to=webmin%2Ddevel%40webmin%2Ecom

--altsbound1400878110
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>You can't use the redirect function, as that can only be called if header isn't. You should instead output some JS like :<br /><br />&lt;script&gt;<br />window.location = &quot;/module./page.cgi&quot;;<br />&lt;/script&gt;&nbsp;</p>
  <p>On 23/May/2014 07:15 marty leisner &lt;[email protected]&gt; wrote ..
</p>
  <blockquote type="cite"> 
    <div dir="ltr">
      <div><br /></div>
      <div>Thanks -- its ui_print_unbuffered_header.</div>
      <div><br /></div>
      <div>But after the page is displayed, I want to force a redirect to another page -- how would I do it</div>
      <div><br /></div>
      <div>

Something like:</div>
      <div style="margin-left: 40px !important;">&amp;ui_print_unbuffered_header('please wait');
        <div>system('date');</div>
        <div>print &quot;&lt;BR&gt;\n&quot;;</div>
        <div>sleep(5);</div>
        <div>system('date');</div> 
        <div> print &quot;&lt;BR&gt;first line\n&lt;BR&gt;&quot;;</div>
        <div>sleep(5);</div>
        <div>system('date');</div>
        <div>print &quot;&lt;BR&gt;second line\n&lt;BR&gt;&quot;;</div>
        <div><br /></div>
        <div>footer();</div>
        <div> <br /> </div>
        <div># redirect('index.cgi');<br /></div>
      </div>
      <div style="margin-left: 40px !important;"><br /></div>
      <div style="margin-left: 0px !important;">marty<br /></div>
    </div>
    <div class="gmail_extra"><br /><br />
      <div class="gmail_quote">

On Wed, May 21, 2014 at 1:47 PM, Jamie Cameron <span dir="ltr">&lt;<a href="reply_mail.cgi?new=1&amp;to=jcameron%40webmin%2Ecom" target="_blank">[email protected]</a>&gt;</span> wrote:<br />
        <blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: #cccccc; border-left-style: solid; padding-left: 1ex;"> 
          <p>Try using un_print_unbuffered_header instead of ui_print_header&nbsp;</p> 
          <p>On 20/May/2014 21:20 marty leisner &lt;<a href="reply_mail.cgi?new=1&amp;to=maleisner%40gmail%2Ecom" target="_blank">[email protected]</a>&gt; wrote ..
</p>
          <div class="HOEnZb">
            <div class="h5"> 
              <blockquote type="cite"> 
                <div dir="ltr"> 
                  <div> 
                    <div> 
                      <div> 
                        <div>I'm having a problem where my page is delivered on the network at the same time -- after the delay (I used wireshark to <br /></div> 
                        <div>monitor this)<br /></div> 
                        <div><br /></div>What I want tried is:<br /> <br />ui_print_header('please wait');<br /> 
                      </div> 
                      <div>footer();<br />sleep(5);<br />print &quot;final\n&lt;BR&gt;&quot;;<br /><br /></div> 
                      <div>I would have expected to see the header render, a delay, and &quot;final&quot;.<br /> </div> 
                      <div><br /></div> 
                      <div>Its all happening after the delay.<br /><br /></div> 
                      <div>What I really want to do is:<br /><br /></div> 
                      <div>display &quot;please wait&quot;<br /></div> 
                      <div>run a long command<br /></div> 
                      <div>redirect to another page (after the command runs)<br /> <br /></div> 
                      <div>marty<br /></div> 
                    </div> 
                  </div> 
                </div> 
                <div class="gmail_extra"><br /><br /> 
                  <div class="gmail_quote">On Tue, May 20, 2014 at 4:19 PM, Jamie Cameron <span dir="ltr">&lt;<a href="http://reply_mail.cgi?new=1&amp;to=jcameron%40webmin%2Ecom" target="_blank">[email protected]</a>&gt;</span> wrote:<br /> 
                    <blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: #cccccc; border-left-style: solid; padding-left: 1ex;">On 20/May/2014 09:27 marty leisner &lt;<a href="http://reply_mail.cgi?new=1&amp;to=maleisner%40gmail%2Ecom" target="_blank">[email protected]</a>&gt; wrote ..<br /> 
                      <div> 
                        <div>&gt; When having a custom module in webmin execute time consuming commands, how<br />
&gt; would I add a<br />
&gt; &quot;please wait&quot; message until the command is finished (without user<br />
&gt; interaction).<br />
&gt;<br />
&gt; I.e.:<br />
&gt;<br />
&gt; start_please_wait();<br />
&gt; system(&quot;long_command&quot;);<br />
&gt; stop_please_wait();<br /> <br /> </div> 
                      </div>In some modules, I've had Webmin print out a series of dots (one per second)<br />
while performing some long operation. The code is like :<br /> <br />
print &quot;Doing something slow ..&quot;;<br />
launch_slow_op_in_background();<br />
while(!done_slow_op()) {<br />
&nbsp; sleep(1);<br />
&nbsp; print &quot;.&quot;;<br />
&nbsp; }<br />
print &quot;&lt;br&gt;\n&quot;;<br />
print &quot;.. done&lt;p&gt;\n&quot;;<br /> <br />
&nbsp;- Jamie<br /> <br />
------------------------------------------------------------------------------<br />
&quot;Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE<br />
Instantly run your Selenium tests across 300+ browser/OS combos.<br />
Get unparalleled scalability from the best Selenium testing platform available<br />
Simple to use. Nothing to install. Get started now for free.&quot;<br /> <a href="http://p.sf.net/sfu/SauceLabs" target="_blank">http://p.sf.net/sfu/SauceLabs</a><br />
-<br />
Forwarded by the Webmin development list at <a href="http://reply_mail.cgi?new=1&amp;to=webmin%2Ddevel%40webmin%2Ecom" target="_blank">[email protected]</a><br />
To remove yourself from this list, go to<br /> <a href="http://lists.sourceforge.net/lists/listinfo/webadmin-devel" target="_blank">http://lists.sourceforge.net/lists/listinfo/webadmin-devel</a><br /> 
                    </blockquote> 
                  </div><br /> 
                </div> 
              </blockquote><br /> 
            </div>
          </div><br />------------------------------------------------------------------------------<br />
&quot;Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE<br />
Instantly run your Selenium tests across 300+ browser/OS combos.<br />
Get unparalleled scalability from the best Selenium testing platform available<br />
Simple to use. Nothing to install. Get started now for free.&quot;<br /> <a href="http://p.sf.net/sfu/SauceLabs" target="_blank">http://p.sf.net/sfu/SauceLabs</a><br />-<br />
Forwarded by the Webmin development list at <a href="reply_mail.cgi?new=1&amp;to=webmin%2Ddevel%40webmin%2Ecom">[email protected]</a><br />
To remove yourself from this list, go to<br /> <a href="http://lists.sourceforge.net/lists/listinfo/webadmin-devel" target="_blank">http://lists.sourceforge.net/lists/listinfo/webadmin-devel</a><br /> <br />
        </blockquote>
      </div><br />
    </div> 
  </blockquote><br />

--altsbound1400878110--


--bound1400878110
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
--bound1400878110
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-
Forwarded by the Webmin development list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-devel

--bound1400878110--