-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
197 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* JavaScript Templates | ||
* https://github.com/blueimp/JavaScript-Templates | ||
* | ||
* Copyright 2011, Sebastian Tschan | ||
* https://blueimp.net | ||
* | ||
* Licensed under the MIT license: | ||
* https://opensource.org/licenses/MIT | ||
* | ||
* Inspired by John Resig's JavaScript Micro-Templating: | ||
* http://ejohn.org/blog/javascript-micro-templating/ | ||
*/ | ||
|
||
/* global define */ | ||
|
||
;(function ($) { | ||
'use strict' | ||
var tmpl = function (str, data) { | ||
var f = !/[^\w\-.:]/.test(str) | ||
? (tmpl.cache[str] = tmpl.cache[str] || tmpl(tmpl.load(str))) | ||
: new Function( // eslint-disable-line no-new-func | ||
tmpl.arg + ',tmpl', | ||
'var _e=tmpl.encode' + | ||
tmpl.helper + | ||
",_s='" + | ||
str.replace(tmpl.regexp, tmpl.func) + | ||
"';return _s;" | ||
) | ||
return data | ||
? f(data, tmpl) | ||
: function (data) { | ||
return f(data, tmpl) | ||
} | ||
} | ||
tmpl.cache = {} | ||
tmpl.load = function (id) { | ||
return document.getElementById(id).innerHTML | ||
} | ||
tmpl.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g | ||
tmpl.func = function (s, p1, p2, p3, p4, p5) { | ||
if (p1) { | ||
// whitespace, quote and backspace in HTML context | ||
return ( | ||
{ | ||
'\n': '\\n', | ||
'\r': '\\r', | ||
'\t': '\\t', | ||
' ': ' ' | ||
}[p1] || '\\' + p1 | ||
) | ||
} | ||
if (p2) { | ||
// interpolation: {%=prop%}, or unescaped: {%#prop%} | ||
if (p2 === '=') { | ||
return "'+_e(" + p3 + ")+'" | ||
} | ||
return "'+(" + p3 + "==null?'':" + p3 + ")+'" | ||
} | ||
if (p4) { | ||
// evaluation start tag: {% | ||
return "';" | ||
} | ||
if (p5) { | ||
// evaluation end tag: %} | ||
return "_s+='" | ||
} | ||
} | ||
tmpl.encReg = /[<>&"'\x00]/g // eslint-disable-line no-control-regex | ||
tmpl.encMap = { | ||
'<': '<', | ||
'>': '>', | ||
'&': '&', | ||
'"': '"', | ||
"'": ''' | ||
} | ||
tmpl.encode = function (s) { | ||
return (s == null ? '' : '' + s).replace(tmpl.encReg, function (c) { | ||
return tmpl.encMap[c] || '' | ||
}) | ||
} | ||
tmpl.arg = 'o' | ||
tmpl.helper = | ||
",print=function(s,e){_s+=e?(s==null?'':s):_e(s);}" + | ||
',include=function(s,d){_s+=tmpl(s,d);}' | ||
if (typeof define === 'function' && define.amd) { | ||
define(function () { | ||
return tmpl | ||
}) | ||
} else if (typeof module === 'object' && module.exports) { | ||
module.exports = tmpl | ||
} else { | ||
$.tmpl = tmpl | ||
} | ||
})(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<script> | ||
$(document).ready(function() { | ||
jQuery.ajax({ | ||
type: "GET", | ||
dataType: "json", | ||
url: "<%=job_runs_path(format: :json)%>", | ||
success: function(data) { | ||
document.getElementById("job-history-table").innerHTML = tmpl("tmpl-job-history-table", data); | ||
} | ||
}); | ||
}); | ||
|
||
</script> | ||
<div class="container mt-3"> | ||
<div class="row"> | ||
<section class="col-7"> | ||
<%= render "bundle_contexts/yaml_form" %> | ||
</section> | ||
<section class="col-5"> | ||
<ul class="nav nav-pills nav-fill"> | ||
<li class="nav-item"> | ||
<a id="project-queue-tab" | ||
data-toggle="tab" | ||
class="nav-link active" href="#project-queue"> | ||
Queue of projects | ||
</a> | ||
</li> | ||
<%= render "history/tab_list_item" %> | ||
<%= render "job_runs/recent_history" %> | ||
</ul> | ||
<div class="tab-content" id="jobs-queue-history-content"> | ||
<div class="tab-pane fade" id="project-queue" role="tabpanel" | ||
aria-labelledby="project-queue-tab"> | ||
</div> | ||
</div> | ||
<%= render "history/tab_pane" %> | ||
</section> | ||
</div> | ||
</div> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script type="text/x-tmpl" id="tmpl-job-history-table"> | ||
{% for (var i=0; i<o.length; i++) { %} | ||
<tr> | ||
<td><a href="/job_runs/{%= o[i].id %}">{%= o[i].id %}</a></td> | ||
<td>{%= o[i].job_type %}</td> | ||
<td>{%= o[i].sunet_id %}</td> | ||
<td>{%= o[i].output_location ? "done" : "not done" %}</td> | ||
<td>{%= o[i].created_at.split('T')[0] %}</td> | ||
</tr> | ||
{% } %} | ||
</script> | ||
|
||
<h4>Recent jobs</h4> | ||
<div class="container"> | ||
<%= link_to '[view full history]', job_runs_path %> | ||
</div> | ||
<div class="container"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Job Type</th> | ||
<th>Created by</th> | ||
<th>Status</th> | ||
<th>Created on</th> | ||
</th> | ||
</thead> | ||
<tbody id="job-history-table"> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
<h2>Job Run History</h2> | ||
<div class="container"> | ||
<%= link_to '[start new job]', root_path %> | ||
</div> | ||
<div class="container"> | ||
<h2>Job Run History</h2> | ||
|
||
<%= paginate @job_runs %> | ||
<%= paginate @job_runs %> | ||
|
||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col">ID</th> | ||
<th scope="col">Type</th> | ||
<th scope="col">Creator</th> | ||
<th scope="col">Status</th> | ||
<th scope="col">Created At</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @job_runs.each do |job_run| %> | ||
<tr> | ||
<td><%=link_to "Job ##{job_run.id}",job_run%></td> | ||
<td><%=job_run.job_type%></td> | ||
<td><%=job_run.bundle_context.user.sunet_id%></td> | ||
<td><%=job_run.output_location ? "complete" : "not complete"%></td> | ||
<td><%=job_run.created_at.to_formatted_s(:long)%></td> | ||
</tr> | ||
</tbody> | ||
<% end %> | ||
</table> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th scope="col">ID</th> | ||
<th scope="col">Type</th> | ||
<th scope="col">Creator</th> | ||
<th scope="col">Status</th> | ||
<th scope="col">Created At</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @job_runs.each do |job_run| %> | ||
<tr> | ||
<td><%=link_to "Job ##{job_run.id}",job_run%></td> | ||
<td><%=job_run.job_type%></td> | ||
<td><%=job_run.bundle_context.user.sunet_id%></td> | ||
<td><%=job_run.output_location ? "complete" : "not complete"%></td> | ||
<td><%=job_run.created_at.to_formatted_s(:long)%></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<%= paginate @job_runs %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
RSpec.describe 'bundle_contexts/new.html.erb', type: :view do | ||
let!(:job_runs) { create_list(:job_run, 2) } | ||
|
||
it 'displays a list of job_runs in side panel' do | ||
assign(:bundle_context, BundleContext.new) | ||
assign(:job_runs, JobRun.all.page(1)) | ||
render | ||
expect(rendered).to include('<tbody id="job-history-table">') # the element we will render into | ||
expect(rendered).to include('<script type="text/x-tmpl" id="tmpl-job-history-table">') # the JS template that will be used | ||
end | ||
end |