public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: Leo Hofmann <hofmann@leo-andres.de>
To: development@lists.ipfire.org
Subject: Re: [PATCH] pakfire.cgi: Bring back old logic for log displaying
Date: Thu, 18 Nov 2021 13:03:40 +0100	[thread overview]
Message-ID: <ced7a230-831d-09b8-98cf-ac4b1d0169f8@leo-andres.de> (raw)
In-Reply-To: <0417b6a1637eff70598dccdc7dbbf9380a683f56.camel@ipfire.org>

[-- Attachment #1: Type: text/plain, Size: 9174 bytes --]

Hi,

It is possible to refresh the log output frequently without reloading the entire page, by using Javascript/Ajax:
https://www.w3schools.com/js/js_ajax_intro.asp

I'm pretty sure we could create a nice log output with Javascript. If you like, I can try to implement this :)

Best regards,
Leo

Am 16.11.2021 um 19:36 schrieb Stefan Schantl:
> Hello Bernhard,
>
> thanks for pointing this out.
>
> The "page refresh" is defined and performed by the following line:
>
>>> &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh'
> content='10;'>" ); <<
>
> This kind of refresh logic is untouched and worked well since many
> years. The "http-equiv" tells the browser to do a refresh of the page
> and the content contains the amount in seconds to wait. (See more
> here: https://www.w3schools.com/tags/att_meta_http_equiv.asp)
>
> I didn't noticed any problems with Firefox as browser on various
> linux distros.
>
> A very easy test would be to decrease the time interval (minimum is
> "1") to force more periodic page reloads and check if the log output go
> further.
>
> If everything works well we may need to think about a new interval
> value because 10 seconds nowadays may be to long for the high speed
> hardware out there.
>
> Best regards,
>
> -Stefan
>> Hello Stefan,
>>
>> the logs are only displayed once ( the last 20 lines ).
>> The aim of the change was a refreshing of this log to show the
>> progress
>> of the pakfire function, if I remember right.
>> I tried to implement this, but with no success. :(
>>
>> - Bernhard
>>
>> Am 16.11.2021 um 05:47 schrieb Stefan Schantl:
>>> Hello Bernhard,
>>>
>>> thanks for testing and your feedback.
>>>> Reviewed-by: Bernhard Bitsch <bbitsch(a)ipfire.org>
>>>> Tested-by: Bernhard Bitsch <bbitsch(a)ipfire.org>
>>>>
>>>> Okay, the old behaviour is reinstalled. Remains the problem with
>>>> the
>>>> page reload.
>>> I'm sorry I do not exactly understand which problem do you mean
>>> here -
>>> please provide some more details.
>>>
>>> A big thanks in advance,
>>>
>>> -Stefan
>>>
>>>> Am 15.11.2021 um 21:23 schrieb Stefan Schantl:
>>>>> Trying to get rid of the system backpipe check if a pakfire is
>>>>> running
>>>>> does not work very well. It simply makes the code more complex
>>>>> and
>>>>> only introduced some new problems.
>>>>>
>>>>> This commit switches back to the old logic which worked well in
>>>>> the
>>>>> past.
>>>>>
>>>>> Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
>>>>> ---
>>>>>     html/cgi-bin/pakfire.cgi | 57 +++++++-----------------------
>>>>> -----
>>>>> -----
>>>>>     1 file changed, 10 insertions(+), 47 deletions(-)
>>>>>
>>>>> diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-
>>>>> bin/pakfire.cgi
>>>>> index f2381f031..4d6eee284 100644
>>>>> --- a/html/cgi-bin/pakfire.cgi
>>>>> +++ b/html/cgi-bin/pakfire.cgi
>>>>> @@ -44,8 +44,6 @@ $cgiparams{'VALID'} = '';
>>>>>     $cgiparams{'INSPAKS'} = '';
>>>>>     $cgiparams{'DELPAKS'} = '';
>>>>>     
>>>>> -my $page_lock;
>>>>> -
>>>>>     sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-
>>>>> equiv='refresh' content='1;'>" );print "<center><img
>>>>> src='/images/clock.gif' alt='' /><br/><font
>>>>> color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::
>>>>> clos
>>>>> ebox();}
>>>>>     
>>>>>     &Header::getcgihash(\%cgiparams);
>>>>> @@ -59,9 +57,8 @@ sub refreshpage{&Header::openbox( 'Waiting',
>>>>> 1,
>>>>> "<meta http-equiv='refresh' cont
>>>>>     if (($cgiparams{'ACTION'} eq 'install') && (! -e
>>>>> $Pakfire::lockfile)) {
>>>>>           my @pkgs = split(/\|/, $cgiparams{'INSPAKS'});
>>>>>           if ("$cgiparams{'FORCE'}" eq "on") {
>>>>> -               # Lock the page.
>>>>> -               $page_lock = "1";
>>>>>                   &General::system_background("/usr/local/bin/pa
>>>>> kfire
>>>>> ", "install", "--non-interactive", "--no-colors", @pkgs);
>>>>> +               sleep(1);
>>>>>           } else {
>>>>>                   &Header::openbox("100%", "center",
>>>>> $Lang::tr{'request'});
>>>>>                   my @output =
>>>>> &General::system_output("/usr/local/bin/pakfire",
>>>>> "resolvedeps", "-
>>>>> -no-colors", @pkgs);
>>>>> @@ -98,9 +95,8 @@ END
>>>>>     } elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e
>>>>> $Pakfire::lockfile)) {
>>>>>           my @pkgs = split(/\|/, $cgiparams{'DELPAKS'});
>>>>>           if ("$cgiparams{'FORCE'}" eq "on") {
>>>>> -               # Lock the page.
>>>>> -               $page_lock = "1";
>>>>>                   &General::system_background("/usr/local/bin/pa
>>>>> kfire
>>>>> ", "remove", "--non-interactive", "--no-colors", @pkgs);
>>>>> +               sleep(1);
>>>>>           } else {
>>>>>                   &Header::openbox("100%", "center",
>>>>> $Lang::tr{'request'});
>>>>>                   my @output =
>>>>> &General::system_output("/usr/local/bin/pakfire",
>>>>> "resolvedeps", "-
>>>>> -no-colors", @pkgs);
>>>>> @@ -136,13 +132,11 @@ END
>>>>>           }
>>>>>     
>>>>>     } elsif (($cgiparams{'ACTION'} eq 'update') && (! -e
>>>>> $Pakfire::lockfile)) {
>>>>> -       # Set variable to lock the page.
>>>>> -       $page_lock = "1";
>>>>>           &General::system_background("/usr/local/bin/pakfire",
>>>>> "update", "--force", "--no-colors");
>>>>> +       sleep(1);
>>>>>     } elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e
>>>>> $Pakfire::lockfile)) {
>>>>> -       # Lock the page.
>>>>> -       $page_lock = "1";
>>>>>           &General::system_background("/usr/local/bin/pakfire",
>>>>> "upgrade", "-y", "--no-colors");
>>>>> +       sleep(1);
>>>>>     } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
>>>>>           $pakfiresettings{"TREE"} = $cgiparams{"TREE"};
>>>>>     
>>>>> @@ -156,6 +150,7 @@ END
>>>>>     
>>>>>                   # Update lists
>>>>>                   &General::system_background("/usr/local/bin/pa
>>>>> kfire
>>>>> ", "update", "--force", "--no-colors");
>>>>> +               sleep(1);
>>>>>           }
>>>>>     }
>>>>>     
>>>>> @@ -177,44 +172,12 @@ if ($errormessage) {
>>>>>           &Header::closebox();
>>>>>     }
>>>>>     
>>>>> -# Check if a page lock is required.
>>>>> -if ($page_lock) {
>>>>> -       &Header::openbox('Waiting', 1, ,);
>>>>> -               print <<END;
>>>>> -               <table>
>>>>> -                       <tr>
>>>>> -                               <td>
>>>>> -                                       <img
>>>>> src='/images/indicator.gif' alt='$Lang::tr{'active'}'
>>>>> title='$Lang::tr{'active'}'>
>>>>> -                               </td>
>>>>> -
>>>>> -                               <td>
>>>>> -                                       $Lang::tr{'pakfire
>>>>> working'}
>>>>> -                               </td>
>>>>> -                       </tr>
>>>>> -               </table>
>>>>> -END
>>>>> -       &Header::closebox();
>>>>> -
>>>>> -       # Infinite loop to lock the page until pakfire lockfile
>>>>> is
>>>>> present.
>>>>> -       while($page_lock) {
>>>>> -               unless (-e $Pakfire::lockfile) {
>>>>> -                       sleep(1);
>>>>> -               } else {
>>>>> -                       # Release page lock.
>>>>> -                       undef($page_lock);
>>>>> -
>>>>> -                       # Break loop.
>>>>> -                       last;
>>>>> -               }
>>>>> -       }
>>>>> -
>>>>> -       # Perform page reload.
>>>>> -       print "<meta http-equiv='refresh' content='1;'>\n";
>>>>> -       exit;
>>>>> -}
>>>>> +# Check if pakfire is already running.
>>>>> +#
>>>>> +# The system backpipe command is safe, because no user input
>>>>> is
>>>>> computed.
>>>>> +my $pid = `pidof pakfire`;
>>>>>     
>>>>> -# Check if pakfire is already running. In this case a lockfile
>>>>> is
>>>>> present.
>>>>> -if (-e $Pakfire::lockfile) {
>>>>> +if ($pid) {
>>>>>           &Header::openbox( 'Waiting', 1, "<meta http-
>>>>> equiv='refresh'
>>>>> content='10;'>" );
>>>>>           print <<END;
>>>>>           <table>
>>>>>

  parent reply	other threads:[~2021-11-18 12:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 20:23 Stefan Schantl
2021-11-15 20:46 ` Bernhard Bitsch
2021-11-16  4:47   ` Stefan Schantl
2021-11-16 15:51     ` Bernhard Bitsch
2021-11-16 18:36       ` Stefan Schantl
2021-11-16 20:01         ` Bernhard Bitsch
2021-11-18 12:03         ` Leo Hofmann [this message]
2021-11-18 21:15           ` Jon Murphy
2021-11-19 11:03           ` Michael Tremer
2021-11-20  8:03             ` hofmann
2021-11-20 10:13               ` Michael Tremer
2021-11-17 19:39 ` Michael Tremer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ced7a230-831d-09b8-98cf-ac4b1d0169f8@leo-andres.de \
    --to=hofmann@leo-andres.de \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox