[LNT] r263925 - [ui] Use Bootstrap CSS styling for run report tables where possible

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 03:46:10 PDT 2016


Author: jamesm
Date: Mon Mar 21 05:46:10 2016
New Revision: 263925

URL: http://llvm.org/viewvc/llvm-project?rev=263925&view=rev
Log:
[ui] Use Bootstrap CSS styling for run report tables where possible

The run reports are rendered in two ways: for email and for web. Email doesn't do CSS very well, so we were styling the tables ourselves.

However, on web we have a real theme and the manually styled table doesn't fit it.

Not only does this make the table fit the rest of the page better, it makes it more suitable as a container for profile view links, which will be added in a followup commit.

Modified:
    lnt/trunk/lnt/server/reporting/runs.py
    lnt/trunk/lnt/server/ui/templates/reporting/runs.html
    lnt/trunk/lnt/server/ui/views.py

Modified: lnt/trunk/lnt/server/reporting/runs.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/reporting/runs.py?rev=263925&r1=263924&r2=263925&view=diff
==============================================================================
--- lnt/trunk/lnt/server/reporting/runs.py (original)
+++ lnt/trunk/lnt/server/reporting/runs.py Mon Mar 21 05:46:10 2016
@@ -11,7 +11,8 @@ import lnt.util.stats
 def generate_run_report(run, baseurl, only_html_body=False,
                         num_comparison_runs=0, result=None,
                         compare_to=None, baseline=None,
-                        aggregation_fn=lnt.util.stats.safe_min, confidence_lv=.05):
+                        aggregation_fn=lnt.util.stats.safe_min, confidence_lv=.05,
+                        styles=dict(), classes=dict()):
     """
     generate_run_report(...) -> (str: subject, str: text_report,
                                  str: html_report)
@@ -164,7 +165,10 @@ def generate_run_report(run, baseurl, on
     # Gmail) which can't deal with embedded style sheets.
     #
     # These are derived from the static style.css file we use elsewhere.
-    styles = {
+    #
+    # These are just defaults however, and the caller can override them with the
+    # 'styles' and 'classes' kwargs.
+    styles_ = {
         "body" : ("color:#000000; background-color:#ffffff; "
                   "font-family: Helvetica, sans-serif; font-size:9pt"),
         "h1" : ("font-size: 14pt"),
@@ -174,7 +178,12 @@ def generate_run_report(run, baseurl, on
             "cursor: default; text-align:center; font-weight: bold; "
             "font-family: Verdana; padding:5px; padding-left:8px"),
         "td" : "padding:5px; padding-left:8px",
-        }
+    }
+    classes_ = {
+    }
+
+    styles_.update(styles)
+    classes_.update(classes)
 
     # Create an environment for rendering the reports.
     env = lnt.server.ui.app.create_jinja_environment()
@@ -219,7 +228,7 @@ def generate_run_report(run, baseurl, on
         prioritized_buckets_run_over_run=prioritized_buckets_run_over_run,
         run_to_baseline_info=run_to_baseline_info,
         prioritized_buckets_run_over_baseline=prioritized_buckets_run_over_baseline,
-        styles=styles,
+        styles=styles_, classes=classes_,
         start_time=start_time)
 
     return subject, text_report, html_report, sri

Modified: lnt/trunk/lnt/server/ui/templates/reporting/runs.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/reporting/runs.html?rev=263925&r1=263924&r2=263925&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/reporting/runs.html (original)
+++ lnt/trunk/lnt/server/ui/templates/reporting/runs.html Mon Mar 21 05:46:10 2016
@@ -7,16 +7,19 @@
 {%
   macro add_report_changes_detail_for_field_and_bucket(
     field, show_perf, run_url, field_index, field_display_name, bucket_name, bucket, test_names,
-    metric_name, metric_field_suffix, secondary_field_suffix, secondary_info, styles
+    metric_name, metric_field_suffix, secondary_field_suffix, secondary_info, styles, classes
   )
 %}
 
 {% if bucket and bucket_name != 'Unchanged Tests' %}
    <p>
-     <table style="{{ styles['table'] }}">
+     <table style="{{ styles['table'] }}" class="{{ classes['table'] }}">
+       <thead>
        <tr>
          <th style="{{ styles['th'] }}; width:500px">{{ bucket_name }} - {{ field_display_name }}</th>
        {% if not show_perf %}
+         </tr>
+         </thead>
          <tbody class="searchable">
          {% for name in test_names %}
            <tr><td class="benchmark-name" style="{{ styles['td'] }}">
@@ -33,6 +36,7 @@
          <th style="{{ styles['th'] }}">σ {{ secondary_field_suffix }}</th>
          {% endif %}
          </tr>
+         </thead>
          <tbody class="searchable">
          
          {% for name, cr, test_id in bucket %}
@@ -70,7 +74,7 @@
 </h1>
 
 <p>
-<table style="{{ styles['table'] }}">
+<table style="{{ styles['table'] }}" class="{{ classes['table'] }}">
   <thead>
     <tr>
       <th style="{{ styles['th'] }}">Run</th>
@@ -108,7 +112,7 @@
 
 <hr>
 <h3>Tests Summary</h3>
-<table style="{{ styles['table'] }}">
+<table style="{{ styles['table'] }}" class="{{ classes['table'] }}">
   <thead>
     <tr>
       <th style="{{ styles['th'] }}">Status Group</th>
@@ -151,7 +155,7 @@
   {{
     add_report_changes_detail_for_field_and_bucket(field, show_perf, run_url, field_index, field_display_name,
                                                    bucket_name, sorted_bucket, test_names,
-                                                   'Previous', '', ' (B)', run_to_baseline_info, styles)
+                                                   'Previous', '', ' (B)', run_to_baseline_info, styles, classes)
   }}
 {% endfor %}
 <p>
@@ -164,7 +168,7 @@
   {{
     add_report_changes_detail_for_field_and_bucket(field, show_perf, run_url, field_index, field_display_name,
                                                    bucket_name, sorted_bucket, test_names,
-                                                   'Baseline', '(B)', '', run_to_run_info, styles)
+                                                   'Baseline', '(B)', '', run_to_run_info, styles, classes)
   }}
 {% endfor %}
 {% endif %}

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=263925&r1=263924&r2=263925&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Mon Mar 21 05:46:10 2016
@@ -282,12 +282,26 @@ class V4RequestInfo(object):
         # Gather the runs to use for statistical data.
         comparison_start_run = self.compare_to or self.run
 
+        # We're going to render this on a real webpage with CSS support, so
+        # override the default styles and provide bootstrap class names for
+        # the tables.
+        styles = {
+            'body': '', 'td': '',
+            'h1': 'font-size: 14pt',
+            'table': 'width: initial; font-size: 9pt;',
+            'th': 'text-align: center;'
+        }
+        classes = {
+            'table': 'table table-striped table-condensed table-hover'
+        }
+        
         reports = lnt.server.reporting.runs.generate_run_report(
             self.run, baseurl=db_url_for('index', _external=True),
             only_html_body=only_html_body, result=None,
             compare_to=self.compare_to, baseline=self.baseline,
             num_comparison_runs=self.num_comparison_runs,
-            aggregation_fn=self.aggregation_fn, confidence_lv=confidence_lv)
+            aggregation_fn=self.aggregation_fn, confidence_lv=confidence_lv,
+            styles=styles, classes=classes)
         _, self.text_report, self.html_report, self.sri = reports
 
 @v4_route("/<int:id>/report")




More information about the llvm-commits mailing list