app/views/jobs/show.html.haml
- content_for(:title) { @job.to_s }
%div[@job]
.page-heading
%div(style="float:right;padding-top:6px")
- if @job.completed?
= link_to "Resubmit", url(:job_resubmit, @job.id), :class => "btn btn-mini", :method => "post"
- if !@job.running?
= link_to "Delete", url(:job_delete, @job.id), :class => "btn btn-danger btn-mini", :confirm => "Delete job?", :method => "delete"
%h2
= state_label(@job.state) << @job.to_s
%ul.nav.nav-tabs
%li.active
= link_to "Overview", "#overview", :data => {:toggle => "tab"}
%li
= link_to "Results", "#results", :data => {:toggle => "tab"}
%li
= link_to "Output", "#output", :data => {:toggle => "tab"}
.tab-content
#overview.tab-pane.active
%table.table.table-bordered.table-condensed
%tbody
- sort_options(@job).each do |option|
%tr
%th
= format_option_name(option)
%td
= format_option_value(option, @job.options[option])
%tr
%th
Priority
%td
= @job.priority.to_s.titleize
%tr
%th
Execute
%td
- if @job.execute?
= @job.execute
- else
—
%tr
%th
Created
%td
= l @job.created_at
%tr
%th
Updated
%td
= l @job.updated_at
#results.tab-pane
= render_job_result(@job)
#output.tab-pane
- if @job.output?
.actions
= link_to content_tag(:i, "", :class => "icon-resize-full") << "View", url(:job_output, @job.id, :format => :log)
= link_to content_tag(:i, "", :class => "icon-download-alt") << "Download", url(:job_output, @job.id)
%pre
= @job.output
- else
%p
No output.
:javascript
iTMS.jobState = '#{@job.state}';
iTMS.jobOffset = #{@job.output.bytesize};
function trackJob() {
var e = $('.job-state', '#job_#{@job.id}'), intId = setInterval(function() {
$.get('#{ url("/jobs/#{@job.id}/status") }', function(st) {
state = st.state;
if(state != iTMS.jobState) {
e.removeClass('label-' + iTMS.jobState);
e.addClass('label-' + state);
e.text(state.replace(/^(\w)/, function(chr) { return chr.toUpperCase(); }));
iTMS.jobState = state;
}
if(state != iTMS.QUEUED) {
$.get('#{ url("/jobs/#{@job.id}/output") }', {offset: iTMS.jobOffset}, function(data) {
if(!data) return;
if(iTMS.jobOffset == 0)
$('#output').html('<pre>');
$('#output pre').append(document.createTextNode(data))
.animate({ scrollTop: $('#output pre')[0].scrollHeight });
iTMS.jobOffset += data.length;
});
if(state != iTMS.RUNNING) {
clearInterval(intId);
$.get('#{ url("/jobs/#{@job.id}/results") }', function(data) { $('#results').html(data) });
}
}
});
}, 5000);
}
if(iTMS.jobState == iTMS.RUNNING || iTMS.jobState == iTMS.QUEUED)
trackJob();