summaryrefslogtreecommitdiff
path: root/templates/events.mako
blob: 8ac87093b45f5999cbb5aa01925701b829518fc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
    <%! import os %>
    <%! import html %>
    <%! import base64 %>
    <%! from ezbench.report import Event, EventRenderingChange %>

    <%
         key = 0
         week_prev = -1
    %>

    <div class="css-treeview">
      <ul>

    % for c in events:
      <%
        key = key + 1
        id = "events_" + str(key)

        subentries = ""
        for t in events[c]:
          if len(subentries) > 0:
            subentries += ", "
          subentries += "{} {}(s)".format(len(events[c][t]), t)

        commit_date = c.commit_date()
        label = "{} ({}) - {}".format(str(c), subentries, commit_date)
        label = html.escape(label)
        type_checked = len(events[c]) == 1

        isocal = commit_date.isocalendar()
        week = "{}-{}".format(isocal[0], isocal[1])
      %>

      % if week != week_prev:
      <%
        week_prev = week
      %>
        <h4>Work week ${week}</h4>
      % endif

        <li>
          <input type="checkbox" id="${id}"/>
          <label class="tree_node" for="${id}">
            + ${label}
          </label>
          <ul>
      % for t in events[c]:
        <%
          key = key + 1
          id = "events_" + str(key)
        %>
            <li>
              <input type="checkbox" id="${id}" checked="${type_checked}"/>
              <label class="tree_node" for="${id}">
                + ${t} (${len(events[c][t])} test(s))
              </label>
              <ul>
        % for test in events[c][t]:
          % if not isinstance(test, Event):
            <%
              key = key + 1
              id = "events_" + str(key)
            %>
                <li>
                  <input type="checkbox" id="${id}" checked="${type_checked}"/>
                  <label class="tree_node" for="${id}">
                    + ${test} (${len(events[c][t][test])} reports(s))
                  </label>
                  <ul>
            % for r in events[c][t][test]:
              <%
                key = key + 1
                id = "events_" + str(key)
              %>
                    <li>
                      <input type="checkbox" id="${id}" checked="${type_checked}"/>
                      <label class="tree_node" for="${id}">
                        + ${r} (${len(events[c][t][test][r])} result(s))
                      </label>
                      <ul>
              % for e in events[c][t][test][r]:
                % if not isinstance(e, EventRenderingChange):
                        <li>${html.escape(e.short_desc)}</li>
                % else:
                  <%
                    # Reconstruct image path
                    new = e.result.average_image_file
                    old = new.replace(e.commit_range.new.sha1, e.commit_range.old.sha1)
                    diff = '{}_compare_{}'.format(new, os.path.basename(old))

                    old_image = ''
                    diff_image = ''
                    new_image = ''

                    if embed:
                      old_image = 'data:image/png;base64,' + base64.b64encode(open(old, 'rb').read()).decode()
                      diff_image = 'data:image/png;base64,' + base64.b64encode(open(diff, 'rb').read()).decode()
                      new_image = 'data:image/png;base64,' + base64.b64encode(open(new, 'rb').read()).decode()
                    else:
                      old_image = os.path.join(os.path.basename(old))
                      diff_image = os.path.join(os.path.basename(diff))
                      new_image = os.path.join(os.path.basename(new))
                  %>
                        <li>${html.escape(e.short_desc)}</li>
                        <img src="${old_image}" style="max-width:20%;">
                        <img src="${diff_image}" style="max-width:20%;">
                        <img src="${new_image}" style="max-width:20%;">
                % endif
              % endfor
                      </ul>
                    </li>
            % endfor
                  </ul>
                </li>
          % endif
        % endfor
              </ul>
            </li>
      % endfor
          </ul>
        </li>
    % endfor
      </ul>
    </div>