add /jobs page. refs #1417
authorTom Clegg <tom@clinicalfuture.com>
Mon, 18 Mar 2013 03:02:03 +0000 (20:02 -0700)
committerTom Clegg <tom@clinicalfuture.com>
Mon, 18 Mar 2013 03:02:03 +0000 (20:02 -0700)
app/controllers/jobs_controller.rb
app/views/jobs/index.html.erb [new file with mode: 0644]
app/views/layouts/application.html.erb

index c890844a3d5b1d4cb977ddd71761ec32eccb135c..1cd3c3e28e894f4d188cbd52399834c5d44117ca 100644 (file)
@@ -1,2 +1,5 @@
 class JobsController < ApplicationController
+  def index
+    @jobs = Job.all
+  end
 end
diff --git a/app/views/jobs/index.html.erb b/app/views/jobs/index.html.erb
new file mode 100644 (file)
index 0000000..de34600
--- /dev/null
@@ -0,0 +1,71 @@
+<% content_for :head do %>
+<style>
+  table.topalign>tbody>tr>td {
+  vertical-align: top;
+  }
+  table.topalign>thead>tr>td {
+  vertical-align: bottom;
+  }
+</style>
+<% end %>
+
+<table class="topalign table">
+  <thead>
+    <tr class="contain-align-left">
+      <th>
+       id
+      </th><th>
+       state
+      </th><th>
+       start
+      </th><th>
+       finish
+      </th><th>
+       command, parameters, input, output
+      </th><th>
+       resource_limits
+      </th>
+    </tr>
+  </thead>
+  <tbody>
+
+    <% @jobs.sort_by { |j| j[:created_at] }.reverse.each do |j| %>
+
+    <tr>
+      <td>
+       <%= link_to_if_orvos_object j.uuid %>
+      </td><td>
+        <% if j.success == false %>
+        <span class="badge badge-warning" title="fail">&#x2716;</span>
+        <% elsif j.success %>
+        <span class="badge badge-success" title="success">&#x2714;</span>
+        <% elsif j.running %>
+        <span class="badge badge-info" title="running">&#x2708;</span>
+        <% else %>
+        <span class="badge" title="queued">&#x2709;</span>
+        <% end %>
+      </td><td>
+       <%= raw distance_of_time_in_words(j.started_at, Time.now).sub('about ','~').sub(' ','&nbsp;') if j.started_at.is_a? Time %>
+      </td><td>
+       <%= raw distance_of_time_in_words(j.finished_at, Time.now).sub('about ','~').sub(' ','&nbsp;') if j.finished_at.is_a? Time %>
+      </td><td>
+        <%= j.command %><br />
+        <table class="table">
+        <% j.command_parameters.sort.each do |k,v| %>
+        <tr><td><%= k %></td><td><%= link_to_if_orvos_object v %></td></tr>
+        <% end %>
+        <tr><td>output</td><td><%= link_to_if_orvos_object j.output %></td></tr>
+        </table>
+      </td><td>
+        <table class="table">
+        <% j.resource_limits.sort.each do |k,v| %>
+        <tr><td><%= k %></td><td><%= v %></td></tr>
+        <% end %>
+        </table>
+      </td>
+    </tr>
+
+    <% end %>
+
+  </tbody>
+</table>
index a7cea73bc4ddd3b5a299e4a2bda57d9d51b3faa2..62ad6239cf818e55c41e9289295b0b446fded50e 100644 (file)
@@ -34,7 +34,8 @@
           <ul class="nav">
            <% [
               [true, 'Data', collections_path],
-              [true, 'FactoryJobs', factory_jobs_path]
+              [true, 'FactoryJobs', factory_jobs_path],
+              [true, 'Jobs', jobs_path]
               ].each do |admin_only, name, path| %>
            <% if !admin_only or (current_user and current_user.is_admin) %>
             <li<%= raw ' class="active"' if request.fullpath.index(path) %>><a href="<%= path %>"><%= name %></a></li>