[tools] testbot/web: Only show the patches day and time to limit line wrapping.

Francois Gouget fgouget at codeweavers.com
Tue Apr 26 12:33:30 CDT 2022


This adds ValueFormatter::GenerateDayTimeTipDate().
As usual the full date is shown as a tooltip.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/lib/ObjectModel/CGI/ValueFormatter.pm | 55 ++++++++++++++++++-
 testbot/web/PatchesList.pl                    |  3 +-
 testbot/web/WineTestBot.css                   |  1 +
 testbot/web/js/datetime.js                    | 13 +++++
 4 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/testbot/lib/ObjectModel/CGI/ValueFormatter.pm b/testbot/lib/ObjectModel/CGI/ValueFormatter.pm
index d987cee55..41d1e14aa 100644
--- a/testbot/lib/ObjectModel/CGI/ValueFormatter.pm
+++ b/testbot/lib/ObjectModel/CGI/ValueFormatter.pm
@@ -23,7 +23,7 @@ package ObjectModel::CGI::ValueFormatter;
 
 use Exporter 'import';
 our @EXPORT = qw(GetDateTimeJSFile GenerateDateTime GenerateTipDateTime
-                 GenerateTimeTipDate GenerateValueHTML);
+                 GenerateDayTimeTipDate GenerateTimeTipDate GenerateValueHTML);
 
 use POSIX qw(strftime);
 
@@ -151,6 +151,51 @@ sub GenerateTipDateTime($$;$$)
 =pod
 =over 12
 
+=item C<GenerateDayTimeTipDate()>
+
+Show the timestamp's day and time with the date as a tooltip.
+
+The timestamp is shown in the user's timezone if JavaScript is available and
+in the server's timezone otherwise.
+
+The default for TagAttrs is 'a' and it should always be a tag that shows the
+content of the title attribute as a tooltip.
+
+See GenerateDateTime() for more details.
+
+=back
+=cut
+
+sub GenerateDayTimeTipDate($;$$)
+{
+  my ($Sec1970, $Class, $TagAttrs) = @_;
+
+  if (defined $Sec1970)
+  {
+    my $Tag;
+    if ($TagAttrs)
+    {
+      $Tag = $TagAttrs;
+      $Tag =~ s/ .*$//;
+    }
+    else
+    {
+      $TagAttrs = $Tag = "a";
+    }
+    $Class = "$Class " if ($Class);
+    print "<$TagAttrs class='${Class}daytimetipdate' timestamp='$Sec1970' ",
+          strftime("title='%Y-%m-%d'>%d %H:%M:%S", localtime($Sec1970)),
+          "</$Tag>";
+  }
+  else
+  {
+    print " ";
+  }
+}
+
+=pod
+=over 12
+
 =item C<GenerateTimeTipDate()>
 
 Show the timestamp's time with the date as a tooltip.
@@ -221,6 +266,9 @@ for timestamp properties.
 =item "timetipdate"
 Same as above but put the date part in a tooltip.
 
+=item "daytimetipdate"
+Show the day and time and put the full date as a tooltip.
+
 =back
 
 =back
@@ -250,6 +298,11 @@ sub GenerateValueHTML($$$;$)
       GenerateTimeTipDate($Value);
       return;
     }
+    if ($Format eq "daytimetipdate")
+    {
+      GenerateDayTimeTipDate($Value);
+      return;
+    }
   }
   elsif ($PropertyDescriptor->GetClass() eq "Itemref" and defined $Value)
   {
diff --git a/testbot/web/PatchesList.pl b/testbot/web/PatchesList.pl
index 30cfc7547..fc074ada1 100644
--- a/testbot/web/PatchesList.pl
+++ b/testbot/web/PatchesList.pl
@@ -40,7 +40,8 @@ sub DisplayProperty($$)
   my ($self, $PropertyDescriptor) = @_;
 
   my $PropertyName = $PropertyDescriptor->GetName();
-  return $PropertyName =~ /^(?:Received|Disposition|FromName|Subject)$/ ? "ro" :
+  return $PropertyName eq "Received" ? ("ro", "daytimetipdate") :
+         $PropertyName =~ /^(?:Disposition|FromName|Subject)$/ ? "ro" :
          "";
 }
 
diff --git a/testbot/web/WineTestBot.css b/testbot/web/WineTestBot.css
index 350ab64a4..a8756dfce 100644
--- a/testbot/web/WineTestBot.css
+++ b/testbot/web/WineTestBot.css
@@ -410,6 +410,7 @@ pre
 a.title { color:inherit; text-decoration: none; }
 a.tipdatetime { color:inherit; text-decoration: none; }
 a.timetipdate { color:inherit; text-decoration: none; }
+a.daytimetipdate { color:inherit; text-decoration: none; }
 
 th.Record { text-align: center; }
 td.Record { text-align: center; }
diff --git a/testbot/web/js/datetime.js b/testbot/web/js/datetime.js
index 23b7b2718..d21bf5c6e 100644
--- a/testbot/web/js/datetime.js
+++ b/testbot/web/js/datetime.js
@@ -40,6 +40,16 @@ function ShowDateTime(dom, attr)
     }
 }
 
+function ShowDayTimeTipDate(dom)
+{
+    const sec1970 = dom.getAttribute("timestamp");
+    const dt = new Date(sec1970 * 1000);
+    dom.setAttribute('title', dt.getFullYear() +'-'+ Pad2(dt.getMonth() + 1)
+                              +'-'+ Pad2(dt.getDate()));
+    dom.innerHTML = Pad2(dt.getDate()) +' '+ Pad2(dt.getHours()) +':'+
+                    Pad2(dt.getMinutes()) +':'+ Pad2(dt.getSeconds());
+}
+
 function ShowTimeTipDate(dom)
 {
     const sec1970 = dom.getAttribute("timestamp");
@@ -58,6 +68,9 @@ function init()
     document.querySelectorAll(".tipdatetime").forEach(dom => {
         ShowDateTime(dom, 'title');
     });
+    document.querySelectorAll(".daytimetipdate").forEach(dom => {
+        ShowDayTimeTipDate(dom);
+    });
     document.querySelectorAll(".timetipdate").forEach(dom => {
         ShowTimeTipDate(dom);
     });
-- 
2.30.2




More information about the wine-devel mailing list