Merge lp:~stevanr/lava-scheduler/fix-1213949 into lp:lava-scheduler

Proposed by Stevan Radaković
Status: Merged
Merged at revision: 254
Proposed branch: lp:~stevanr/lava-scheduler/fix-1213949
Merge into: lp:lava-scheduler
Diff against target: 147 lines (+114/-5)
2 files modified
lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html (+110/-4)
lava_scheduler_app/templatetags/linenumbers.py (+4/-1)
To merge this branch: bzr merge lp:~stevanr/lava-scheduler/fix-1213949
Reviewer Review Type Date Requested Status
Milosz Wasilewski Approve
Antonio Terceiro Approve
Linaro Automation & Validation Pending
Review via email: mp+182096@code.launchpad.net

Description of the change

Fixes all three aspects of bug #1213949.

To post a comment you must log in.
Revision history for this message
Antonio Terceiro (terceiro) wrote :

Hi Stevan,

This looks good, thanks!

 review approve

review: Approve
Revision history for this message
Milosz Wasilewski (mwasilew) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html'
2--- lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html 2013-07-30 10:15:36 +0000
3+++ lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html 2013-08-26 13:17:24 +0000
4@@ -42,11 +42,9 @@
5 var atBottom = w.attr('innerHeight') + w.scrollTop() >= s.attr('scrollHeight')
6 && w.attr('innerHeight') > progressNode.attr('offsetHeight');
7 if (last_pre.attr('class') == cls) {
8- last_pre.append(document.createTextNode(d[2]));
9+ append_to_section(last_pre, d);
10 } else {
11- var newNode = $("<pre></pre>");
12- newNode.addClass('log_' + d[0]);
13- newNode.text(d[2]);
14+ var newNode = create_new_section_node(d);
15 newNode.insertBefore(progressNode);
16 }
17 if (atBottom) {
18@@ -62,6 +60,114 @@
19 }
20 });
21 }
22+
23+append_to_section = function (element, data) {
24+
25+ current_table = $("#logfile_content table:last");
26+ data_arr = data[2].replace(/\r\n/, "\n").split("\n");
27+ line_number = get_current_section_number()[1];
28+
29+ if (data_arr[data_arr.length-1] == "") {
30+ data_arr.pop();
31+ }
32+
33+ for (var i in data_arr) {
34+ line_number++;
35+ name = "L_" + section_number + "_" + line_number;
36+ display = section_number + "." + line_number;
37+
38+ link_node = $("<a>", {
39+ href: "#" + name,
40+ html: display
41+ });
42+
43+ section_line = $("<div>", {
44+ class: "line",
45+ }).append($("<a>", {
46+ name: name,
47+ })).append(link_node);
48+
49+ $(current_table).find("td:first").append(section_line);
50+
51+ line_node = $("<div>", {
52+ id: name,
53+ class: "line"
54+ }).html("&nbsp;" + data_arr[i]);
55+ element.append(line_node);
56+ }
57+}
58+
59+create_new_section_node = function(data) {
60+
61+ section_number++;
62+ data_arr = data[2].split("\n");
63+ if (data_arr[data_arr.length-1] == "") {
64+ data_arr.pop();
65+ }
66+
67+ section_node = $("<td>");
68+ for (var i in data_arr) {
69+ name = "L_" + section_number + "_" + i;
70+ if (i == 0) {
71+ display = "Section " + section_number;
72+ } else {
73+ display = section_number + "." + i;
74+ }
75+
76+ link_node = $("<a>", {
77+ href: "#" + name,
78+ html: display
79+ });
80+
81+ section_node.append($("<div>", {
82+ class: "line",
83+ }).append($("<a>", {
84+ name: name,
85+ })).append(link_node));
86+ }
87+
88+ text_element = $("<pre>", {
89+ class: "log_" + data[0],
90+ });
91+ for (var i in data_arr) {
92+ var id = "L_" + section_number + "_" + i;
93+ text_element.append($("<div>", {
94+ id: id,
95+ class: "line"
96+
97+ }).html("&nbsp;" + data_arr[i]));
98+ }
99+
100+ var text_node = $("<td>", {
101+ class: "code",
102+ }).append($("<div>",{
103+ class: "container",
104+ }).append(text_element));
105+
106+ var node = $("<table>")
107+ .append($("<tr>")
108+ .append(section_node)
109+ .append(text_node)
110+ );
111+
112+ return node;
113+}
114+
115+get_current_section_number = function() {
116+
117+ last_div = $("#logfile_content div:last");
118+
119+ if ($(last_div).attr("id")) {
120+ div_id_arr = $(last_div).attr("id").split('_');
121+ return [div_id_arr[1], div_id_arr[2]];
122+ }
123+
124+ return [-1, -1];
125+}
126+
127+var section_line_number = get_current_section_number();
128+var section_number = section_line_number[0];
129+
130 $(document).ready(function () {
131 pollTimer = setTimeout(poll, 1000);
132 });
133
134=== modified file 'lava_scheduler_app/templatetags/linenumbers.py'
135--- lava_scheduler_app/templatetags/linenumbers.py 2013-07-30 10:15:36 +0000
136+++ lava_scheduler_app/templatetags/linenumbers.py 2013-08-26 13:17:24 +0000
137@@ -18,7 +18,10 @@
138 ret = "<table><tr><td>"
139 for i in range(0, len(text.splitlines())):
140 name = "L_%s_%s" % (prefix, i)
141- display = "Section %s.%s" % (prefix, i)
142+ if (i == 0):
143+ display = "Section %s" % (prefix)
144+ else:
145+ display = "%s.%s" % (prefix, i)
146 ret += "<div class=\"line\"><a name=\"%s\"></a> \
147 <a href=\"#%s\">%s</a></div>" % (name, name, display)
148

Subscribers

People subscribed via source and target branches