[PATCH] testbot/web: Allow hiding the full log with a double-click.

Francois Gouget fgouget at codeweavers.com
Wed Aug 29 18:59:08 CDT 2018


This saves the user from having to search for the hard to find start
of the (build) log.
Special care is taken to not disable word-based selection when
double-clicking on the log text itself. To switch back to the summary
view one must therefore double-click to the right of the end-of-line.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/web/JobDetails.pl | 41 +++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index 37185eb1f..51fb2e9dd 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -252,7 +252,7 @@ sub InitMoreInfo($)
   }
 }
 
-sub GenerateMoreInfoLink($$$;$)
+sub GetMoreInfoLink($$$$;$)
 {
   my ($self, $LinkKey, $Label, $Set, $Value) = @_;
 
@@ -295,6 +295,14 @@ sub GenerateMoreInfoLink($$$;$)
     }
   }
   $Url .= "#k" . uri_escape($LinkKey);
+  return ($Action, $Url);
+}
+
+sub GenerateMoreInfoLink($$$$;$)
+{
+  my ($self, $LinkKey, $Label, $Set, $Value) = @_;
+
+  my ($Action, $Url) = $self->GetMoreInfoLink($LinkKey, $Label, $Set, $Value);
 
   my $Html = "<a href='". $self->CGI->escapeHTML($Url) ."'>$Action $Label</a>";
   if ($Action eq "Hide")
@@ -309,9 +317,9 @@ sub GetErrorCategory($)
   return "error";
 }
 
-sub GenerateFullLog($$;$)
+sub GenerateFullLog($$$;$)
 {
-  my ($self, $FileName, $Header) = @_;
+  my ($self, $FileName, $HideLog, $Header) = @_;
 
   my $GetCategory = $FileName =~ /\.err$/ ? \&GetErrorCategory :
                     $FileName =~ /\.report$/ ? \&GetReportLineCategory :
@@ -326,7 +334,7 @@ sub GenerateFullLog($$;$)
       if ($IsEmpty)
       {
         print $Header if (defined $Header);
-        print "<pre><code>";
+        print "<pre$HideLog><code>";
         $IsEmpty = 0;
       }
 
@@ -353,6 +361,23 @@ sub GenerateBody($)
 
   $self->InitMoreInfo();
 
+  print <<EOF;
+<script type='text/javascript'>
+<!--
+function HideLog(event, url)
+{
+  // Ignore double-clicks on the log text (i.e. on the <code> element) to
+  // allow word-selection
+  if (event.target.nodeName == 'PRE' && !event.altKey && !event.ctrlKey &&
+      !event.metaKey && !event.shiftKey)
+  {
+    window.open(url, "_self", "", true);
+  }
+}
+//-->
+</script>
+EOF
+
   print "<div class='Content'>\n";
   my $Keys = $self->SortKeys(undef, $self->{Collection}->GetKeys());
   foreach my $Key (@$Keys)
@@ -397,7 +422,11 @@ sub GenerateBody($)
       # Show this log in full, highlighting the important lines
       #
 
-      my $LogIsEmpty = $self->GenerateFullLog("$TaskDir/$MoreInfo->{Full}");
+      my ($Action, $Url) = $self->GetMoreInfoLink($Key, GetLogLabel($MoreInfo->{Full}), "Full", $MoreInfo->{Full});
+      $Url = $self->CGI->escapeHTML($Url);
+      my $HideLog = $Action eq "Hide" ? " ondblclick='HideLog(event, \"$Url\")'" : "";
+
+      my $LogIsEmpty = $self->GenerateFullLog("$TaskDir/$MoreInfo->{Full}", $HideLog);
       my $EmptyDiag;
       if ($LogIsEmpty)
       {
@@ -420,7 +449,7 @@ sub GenerateBody($)
       my $ErrHeader = $MoreInfo->{Full} =~ /\.report/ ? "report" : "task";
       $ErrHeader = "old $ErrHeader" if ($MoreInfo->{Full} =~ /^old_/);
       $ErrHeader = "<div class='HrTitle'>". ucfirst($ErrHeader) ." errors<div class='HrLine'></div></div>";
-      my $ErrIsEmpty = $self->GenerateFullLog("$TaskDir/$MoreInfo->{Full}.err", $ErrHeader);
+      my $ErrIsEmpty = $self->GenerateFullLog("$TaskDir/$MoreInfo->{Full}.err", $HideLog, $ErrHeader);
       print $EmptyDiag if ($ErrIsEmpty and defined $EmptyDiag);
     }
     else
-- 
2.18.0




More information about the wine-devel mailing list