rql.dbtmako 4.26 KB
Newer Older
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
<table id="rql-table" class="table table-striped table-condensed">
    <thead>
        <tr>
            <th class="table-col-1">#</th>
            <th class="table-col-2">Time (ms)</th>
            <th class="table-col-3">RQL</th>
            <th class="table-col-5">Result</th>
            <th class="table-col-7">Description</th>
            <th class="table-col-8">Stack</th>
        </tr>
    </thead>
    <tbody>
        % for i, query in enumerate(rql_queries):
            <tr>
                <th class="table-col-1">${1 + i}</th>
                <td class="table-col-2">${'%.2f' % query["time"]}</td>
                <td class="table-col-3">${highlight(query["rql"], "RQL") | n}<br>${highlight(query["args"], "python3") | n}</td>
                % if len(str(query["result"])) > 50:
                <td id="result-${i}" class="table-col-5">
                    <span id="result-${i}-short">
                    ${highlight(str(query["result"])[:50], "python3") | n}...
                    <a title="display more" href="javascript:show_result(${i})"><span class="badge progress-bar-default">+</span></a>
                    </span>
                    <span id="result-${i}-long" style="display: none">
                    ${highlight(query["result"], "python3") | n}
                    <a title="display less" href="javascript:hide_result(${i})"><span class="badge progress-bar-warning">←</span></a>
                    </span>
                </td>
                % else:
                <td class="table-col-5">${highlight(query["result"], "python3") | n}</td>
                % endif
                <td class="table-col-7">${highlight(query["description"], "python3") | n}</td>
                <td class="table-col-8">
                    <a class="btn btn-default" id="show-stack-${i}" href="javascript:show_stack(${i})">show stack</a>
                    <a class="btn btn-default" id="hide-stack-${i}" href="javascript:hide_stack(${i})" style="display: none">hide stack</a>
                </td>
            </tr>
            <tr style="display: none" id="stack-${i}">
                <td colspan="7">
                    <pre>${highlight(query["callstack"], "py3tb", linenos="inline") | n}</pre>
                </td>
            </tr>
            <tr style="display: none"></tr> <!-- css hack because of previous hidden tr for -stripped -->
        % endfor
    </tbody>
</table>

<script type="text/javascript" charset="utf-8">
    function show_result(result_id) {
        element = document.querySelector("#result-" + result_id + "-long");
        element.style.setProperty("display", "inline");

        element = document.querySelector("#result-" + result_id + "-short");
        element.style.setProperty("display", "none");
    }

    function hide_result(result_id) {
        element = document.querySelector("#result-" + result_id + "-short");
        element.style.setProperty("display", "inline");

        element = document.querySelector("#result-" + result_id + "-long");
        element.style.setProperty("display", "none");
    }

    function show_stack(stack_id) {
        element = document.querySelector("#stack-" + stack_id);
        element.style.setProperty("display", "table-row");

        element = document.querySelector("#show-stack-" + stack_id);
        element.style.setProperty("display", "none");

        element = document.querySelector("#hide-stack-" + stack_id);
        element.style.setProperty("display", "inline");
    }

    function hide_stack(stack_id) {
        element = document.querySelector("#stack-" + stack_id);
        element.style.setProperty("display", "none");

        element = document.querySelector("#show-stack-" + stack_id);
        element.style.setProperty("display", "inline");

        element = document.querySelector("#hide-stack-" + stack_id);
        element.style.setProperty("display", "none");
    }
</script>

<style>
#rql-table {
    table-layout: fixed;
}

#rql-table .table-col-1 {
    text-align: right;
    width: 30px;
}

#rql-table .table-col-2 {
    white-space: nowrap;
    width: 73px;
    text-align: center;
}

#rql-table .table-col-8 {
    padding: 8px;
    width: 110px;
    text-align: center;
}

${generate_css() | n}

.highlight > pre {
    word-break: unset;
    border: none;
    margin: 0;
    padding: 0;
    background-color: unset;
}
</style>