Skip to content

Commit b7af96d

Browse files
Martchuscoolo
authored andcommitted
Unify code for scheduled/running table and fix sorting (#1556)
* Seems like 7eebd17 did a little bit more than just fixing indentation * See https://progress.opensuse.org/issues/29241
1 parent 409d640 commit b7af96d

File tree

4 files changed

+22
-39
lines changed

4 files changed

+22
-39
lines changed

assets/javascripts/tests.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,24 @@ function getFailedSteps(failed_module) {
303303
function setupAsyncFailedResult() {
304304
$(document).on('show.bs.tooltip', '.failedmodule', function() { getFailedSteps(this) });
305305
}
306+
307+
function setupRunningAndScheduledTables() {
308+
$('#scheduled, #running').DataTable({
309+
pagingType: 'simple',
310+
order: [],
311+
columnDefs: [{
312+
targets: 0,
313+
className: "name"
314+
},
315+
{
316+
targets: "time",
317+
render: function ( data, type, row ) {
318+
if (type === 'display') {
319+
return data !== '0Z' ? jQuery.timeago(new Date(data)) : 'not yet';
320+
} else {
321+
return data;
322+
}
323+
}
324+
}],
325+
});
326+
}

templates/test/list.html.ep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
% content_for 'ready_function' => begin
55
is_operator = <%= (is_operator) ? 'true' : 'false' %>;
66
restart_url = "<%= url_for("apiv1_restart", jobid => 'REPLACEIT') %>";
7+
setupRunningAndScheduledTables();
78
renderTestsList([ <%= join(',', map { $_->id } $jobs->all) %> ]);
89
% end
910

templates/test/running_table.html.ep

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,3 @@
1-
% content_for 'ready_function' => begin
2-
$('#running').DataTable( {
3-
"pagingType" : 'simple',
4-
"order": [],
5-
"columnDefs": [
6-
{ targets: 0,
7-
className: "name" },
8-
{ targets: 'time',
9-
"render": function ( data, type, row ) {
10-
if (type === 'display' && data != '0Z') {
11-
return jQuery.timeago(new Date(data));
12-
} else {
13-
return 'Not yet';
14-
}
15-
}
16-
},
17-
],
18-
} );
19-
% end
20-
211
<table id="running" class="display table table-striped" style="width: 100%">
222
<thead>
233
<tr>

templates/test/scheduled_table.html.ep

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
% content_for 'ready_function' => begin
2-
$('#scheduled').DataTable( {
3-
"pagingType" : 'simple',
4-
"order": [],
5-
"columnDefs": [
6-
{ targets: 0,
7-
className: "name" },
8-
{ targets: "time",
9-
"render": function ( data, type, row ) {
10-
if (type === 'display' && data != '0Z') {
11-
return jQuery.timeago(new Date(data));
12-
} else
13-
return 'Not yet';
14-
}
15-
},
16-
],
17-
} );
18-
% end
19-
201
<table id="scheduled" class="display table table-striped" style="width: 100%">
212
<thead>
223
<tr>

0 commit comments

Comments
 (0)