Skip to content

Commit

Permalink
More job details in pm (#3700)
Browse files Browse the repository at this point in the history
Add more details to the job details panel in project manger.
  • Loading branch information
ashton22305 authored Aug 20, 2024
1 parent cbcee72 commit 4b09edb
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 23 deletions.
22 changes: 1 addition & 21 deletions apps/dashboard/app/helpers/active_jobs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,7 @@ def has_grafana(host)
end

def status_label(status)
case status
when "completed"
label = "Completed"
labelclass = "bg-success"
when "running"
label = "Running"
labelclass = "bg-primary"
when "queued"
label = "Queued"
labelclass = "bg-info"
when "queued_held"
label = "Hold"
labelclass = "bg-warning"
when "suspended"
label = "Suspend"
labelclass = "bg-warning"
else
label = "Undetermined"
labelclass = "bg-secondary"
end
"<span class='badge #{labelclass}'>#{label}</span>".html_safe
"<span class='badge #{status_class(status)}'>#{status_text(status)}</span>".html_safe
end

def filters
Expand Down
36 changes: 36 additions & 0 deletions apps/dashboard/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,40 @@ def custom_javascript_paths
{ src: File.join(@user_configuration.public_url, js_file_src), type: js_file_type }
end.compact
end

# Assigns text corresponding to a job status
def status_text(status)
case status
when 'completed'
'Completed'
when 'running'
'Running'
when 'queued'
'Queued'
when 'qued_held'
'Hold'
when 'suspended'
'Suspend'
else
'Undetermined'
end
end

# Assigns a bootstrap class corresponding to the status of a job
def status_class(status)
case status
when 'completed'
'bg-success'
when 'running'
'bg-primary'
when 'queued'
'bg-info'
when 'queued_held'
'bg-warning'
when 'suspended'
'bg-warning'
else
'bg-secondary'
end
end
end
4 changes: 4 additions & 0 deletions apps/dashboard/app/models/hpc_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ def to_h
status: status.to_s,
allocated_nodes: [] }).deep_stringify_keys
end

def to_human_display
to_h.transform_keys { |k| k.humanize }.compact_blank
end
end
18 changes: 16 additions & 2 deletions apps/dashboard/app/views/projects/_job_details.turbo_stream.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,22 @@

<turbo-stream action="replace" target="<%= id %>">
<template>
<div>
<%= job.id %> is currently <%= job.status.to_s %>.
<button class="badge <%= status_class(job.status.to_s) %> rounded-pill border-0 btn" type="button" data-bs-toggle="collapse" data-bs-target="#<%= id %>_data">
<span>
<%= job.id %> <%= status_text(job.status.to_s) %>
</span>
</button>
<div class="collapse" id="<%= id %>_data">
<div class="card card-body">
<table class="table table-bordered table-sm m-0 mb-2">
<% job.to_human_display.each do |name, value| %>
<tr>
<td><strong><%= name %></strong></td>
<td><%= value %></td>
</tr>
<% end %>
</table>
</div>
</div>
</template>
</turbo-stream>

0 comments on commit 4b09edb

Please sign in to comment.