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
=== modified file 'lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html'
--- lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html 2013-07-30 10:15:36 +0000
+++ lava_scheduler_app/templates/lava_scheduler_app/job_log_file.html 2013-08-26 13:17:24 +0000
@@ -42,11 +42,9 @@
42 var atBottom = w.attr('innerHeight') + w.scrollTop() >= s.attr('scrollHeight')42 var atBottom = w.attr('innerHeight') + w.scrollTop() >= s.attr('scrollHeight')
43 && w.attr('innerHeight') > progressNode.attr('offsetHeight');43 && w.attr('innerHeight') > progressNode.attr('offsetHeight');
44 if (last_pre.attr('class') == cls) {44 if (last_pre.attr('class') == cls) {
45 last_pre.append(document.createTextNode(d[2]));45 append_to_section(last_pre, d);
46 } else {46 } else {
47 var newNode = $("<pre></pre>");47 var newNode = create_new_section_node(d);
48 newNode.addClass('log_' + d[0]);
49 newNode.text(d[2]);
50 newNode.insertBefore(progressNode);48 newNode.insertBefore(progressNode);
51 }49 }
52 if (atBottom) {50 if (atBottom) {
@@ -62,6 +60,114 @@
62 }60 }
63 });61 });
64}62}
63
64append_to_section = function (element, data) {
65
66 current_table = $("#logfile_content table:last");
67 data_arr = data[2].replace(/\r\n/, "\n").split("\n");
68 line_number = get_current_section_number()[1];
69
70 if (data_arr[data_arr.length-1] == "") {
71 data_arr.pop();
72 }
73
74 for (var i in data_arr) {
75 line_number++;
76 name = "L_" + section_number + "_" + line_number;
77 display = section_number + "." + line_number;
78
79 link_node = $("<a>", {
80 href: "#" + name,
81 html: display
82 });
83
84 section_line = $("<div>", {
85 class: "line",
86 }).append($("<a>", {
87 name: name,
88 })).append(link_node);
89
90 $(current_table).find("td:first").append(section_line);
91
92 line_node = $("<div>", {
93 id: name,
94 class: "line"
95 }).html("&nbsp;" + data_arr[i]);
96 element.append(line_node);
97 }
98}
99
100create_new_section_node = function(data) {
101
102 section_number++;
103 data_arr = data[2].split("\n");
104 if (data_arr[data_arr.length-1] == "") {
105 data_arr.pop();
106 }
107
108 section_node = $("<td>");
109 for (var i in data_arr) {
110 name = "L_" + section_number + "_" + i;
111 if (i == 0) {
112 display = "Section " + section_number;
113 } else {
114 display = section_number + "." + i;
115 }
116
117 link_node = $("<a>", {
118 href: "#" + name,
119 html: display
120 });
121
122 section_node.append($("<div>", {
123 class: "line",
124 }).append($("<a>", {
125 name: name,
126 })).append(link_node));
127 }
128
129 text_element = $("<pre>", {
130 class: "log_" + data[0],
131 });
132 for (var i in data_arr) {
133 var id = "L_" + section_number + "_" + i;
134 text_element.append($("<div>", {
135 id: id,
136 class: "line"
137
138 }).html("&nbsp;" + data_arr[i]));
139 }
140
141 var text_node = $("<td>", {
142 class: "code",
143 }).append($("<div>",{
144 class: "container",
145 }).append(text_element));
146
147 var node = $("<table>")
148 .append($("<tr>")
149 .append(section_node)
150 .append(text_node)
151 );
152
153 return node;
154}
155
156get_current_section_number = function() {
157
158 last_div = $("#logfile_content div:last");
159
160 if ($(last_div).attr("id")) {
161 div_id_arr = $(last_div).attr("id").split('_');
162 return [div_id_arr[1], div_id_arr[2]];
163 }
164
165 return [-1, -1];
166}
167
168var section_line_number = get_current_section_number();
169var section_number = section_line_number[0];
170
65$(document).ready(function () {171$(document).ready(function () {
66 pollTimer = setTimeout(poll, 1000);172 pollTimer = setTimeout(poll, 1000);
67});173});
68174
=== modified file 'lava_scheduler_app/templatetags/linenumbers.py'
--- lava_scheduler_app/templatetags/linenumbers.py 2013-07-30 10:15:36 +0000
+++ lava_scheduler_app/templatetags/linenumbers.py 2013-08-26 13:17:24 +0000
@@ -18,7 +18,10 @@
18 ret = "<table><tr><td>"18 ret = "<table><tr><td>"
19 for i in range(0, len(text.splitlines())):19 for i in range(0, len(text.splitlines())):
20 name = "L_%s_%s" % (prefix, i)20 name = "L_%s_%s" % (prefix, i)
21 display = "Section %s.%s" % (prefix, i)21 if (i == 0):
22 display = "Section %s" % (prefix)
23 else:
24 display = "%s.%s" % (prefix, i)
22 ret += "<div class=\"line\"><a name=\"%s\"></a> \25 ret += "<div class=\"line\"><a name=\"%s\"></a> \
23 <a href=\"#%s\">%s</a></div>" % (name, name, display)26 <a href=\"#%s\">%s</a></div>" % (name, name, display)
2427

Subscribers

People subscribed via source and target branches