PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/dozer/templates/list_profiles.mako

https://bitbucket.org/bbangert/dozer/
Mako | 70 lines | 69 code | 1 blank | 0 comment | 5 complexity | 18d821b8dd00b16fcdc7e87464936d41 MD5 | raw file
 1<%inherit file="layout.mako"/>
 2<h1>All Profiles</h1>
 3<p><a href="/_profiler/delete">Delete all</a></p>
 4<table id="profile-list">
 5    <tr>
 6        <th class="url">URL</th>
 7        <th class="cost">Cost</th>
 8        <th class="time">Time</th>
 9        <th class="pid">Profile ID</th>
10        <th class="delete"></th>
11    </tr>
12    % for created_time, environ, total_cost, profile_id in profiles:
13    <%
14        width = round(400.0 * total_cost / max_cost)
15        w = 1 - (now-created_time) / (now-earliest)  # 0 .. 1
16        w = round(w * 255)
17        bg = '#%02x%02x%02x' % (w, w, w)
18        if w > 128:
19            fg = 'black'
20        else:
21            fg = 'white'
22    %>
23    <tr pid="${profile_id}">
24        <td class="url">${environ['SCRIPT_NAME'] + environ['PATH_INFO'] + environ['QUERY_STRING']|h}</td>
25        <td class="cost">\
26<div class="box">\
27${total_cost}&nbsp;ms\
28<span class="bar" style="width: ${width}px">&nbsp;</span>\
29</div>\
30</td>
31        <td class="time" style="background: ${bg}; color: ${fg};">${'%i' % int(now-created_time)}&nbsp;seconds&nbsp;ago</td>
32        <td class="pid"><a href="/_profiler/show/${profile_id}">${profile_id}</a></td>
33        <td class="delete"><a href="/_profiler/delete/${profile_id}" class="delete">delete</a></td>
34    </tr>
35    % endfor
36    % if errors:
37    <tr id="error-header">
38        <th class="error" colspan="2">Error</th>
39        <th class="time">Time</th>
40        <th class="pid">Profile ID</th>
41        <th class="delete"></th>
42    </tr>
43    % for created_time, error, profile_id in errors:
44    <tr pid="${profile_id}" class="error">
45        <td class="error" colspan="2">${error|h}</td>
46        <td class="time">${'%i' % int(now-created_time)} seconds ago</td>
47        <td class="pid">${profile_id}</td>
48        <td class="delete"><a href="/_profiler/delete/${profile_id}" class="delete">delete</a></td>
49    </tr>
50    % endfor
51    % endif
52</table>
53
54<%def name="javascript()">
55${parent.javascript()}
56<script>
57$(".delete").click(function() {
58    tr = $(this).parent().parent();
59    $.ajax({
60      type: "POST",
61      url: "/_profiler/delete/"+tr.attr("pid"),
62      success: function(msg){
63        tr.remove();
64        if ($("tr.error").length == 0) $("#error-header").remove();
65      }
66    });
67    return false;
68});
69</script>
70</%def>