Browse Source

Improve output of results (yeay colors)

Baptiste Jonglez 10 years ago
parent
commit
816a8f60fe
1 changed files with 9 additions and 6 deletions
  1. 9 6
      templates/results.html

+ 9 - 6
templates/results.html

@@ -15,19 +15,22 @@
     <th>Contact</th>
     <th>Contact</th>
     <th>Date</th>
     <th>Date</th>
   </tr>
   </tr>
+  {% macro color(packetloss) -%}
+  {% if packetloss >= 50 %}
+  "red"
+  {% elif packetloss > 0 %}
+  "orange"
+  {% endif %}
+  {%- endmacro %}
   {% for r in results %}
   {% for r in results %}
   {% set packetloss = (100 * (r.probes_sent - r.probes_received) / r.probes_sent) %}
   {% set packetloss = (100 * (r.probes_sent - r.probes_received) / r.probes_sent) %}
   <tr>
   <tr>
     <td>{% if r.avgrtt is not none() %}{{ r.avgrtt }} ms{% endif %}</td>
     <td>{% if r.avgrtt is not none() %}{{ r.avgrtt }} ms{% endif %}</td>
     <td>{% if r.jitter is not none() %}{{ r.jitter }} ms{% endif %}</td>
     <td>{% if r.jitter is not none() %}{{ r.jitter }} ms{% endif %}</td>
-    <td><span {% if packetloss >= 50 %}
-        class="red"
-        {% elif packetloss > 0 %}
-        class="orange"
-        {% endif %}>
+    <td><span class={{ color(packetloss) }}>
         {{ packetloss|round(2) }}%
         {{ packetloss|round(2) }}%
       </span>
       </span>
-      ({{ r.probes_sent - r.probes_received }}/{{ r.probes_sent }})
+      (<span class={{ color(packetloss) }}>{{ r.probes_sent - r.probes_received }}</span>/{{ r.probes_sent }})
     </td>
     </td>
     <td>{{ r.participant.name }}
     <td>{{ r.participant.name }}
       {% if r.participant.country is not none() %}
       {% if r.participant.country is not none() %}