From 2c451df55167e3447ebedbfe3384f3eadcc5b552 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 4 Feb 2013 22:35:08 -0500 Subject: [PATCH] add Collections#show page --- app/assets/stylesheets/application.css | 10 ++ app/controllers/collections_controller.rb | 37 +++++++ app/views/collections/_nav.html.erb | 6 +- app/views/collections/index.html.erb | 17 +--- app/views/collections/show.html.erb | 114 ++++++++++++++++++++++ 5 files changed, 166 insertions(+), 18 deletions(-) create mode 100644 app/views/collections/show.html.erb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 0e11d7b09e..ca1f1ea6ef 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -17,3 +17,13 @@ .contain-align-left { text-align: left; } +table.topalign>tbody>tr>td { + vertical-align: top; +} +table.topalign>thead>tr>td { + vertical-align: bottom; +} +.deemphasize { + font-size: .8em; + color: #888; +} diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index a61875cdad..f282a1bb81 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -1,5 +1,6 @@ class CollectionsController < ApplicationController before_filter :ensure_current_user_is_admin + skip_before_filter :find_object_by_uuid, :only => [:graph] def graph index @@ -37,4 +38,40 @@ class CollectionsController < ApplicationController end end end + + def show + return super if !@object + @provenance = [] + @sourcedata = {params[:uuid] => {uuid: params[:uuid]}} + whence = `whence #{params[:uuid]}` + whence.split("\n").each do |line| + if line.match /^(\#\d+@\S+)$/ + job = Job.where(submit_id: line).first + @provenance << {job: job, target: line} + elsif (re = line.match /^ +output *= *(\S+)/) + if !@provenance.empty? + @provenance[-1][:output] = re[1] + @sourcedata.delete re[1] + end + elsif (re = line.match /^([0-9a-f]{32}\b)/) + @sourcedata[re[1]] ||= {uuid: re[1]} + end + end + Link.where(head_uuid: @sourcedata.keys).each do |link| + if link.link_class == 'resources' and link.name == 'wants' + @sourcedata[link.head_uuid][:protected] = true + end + end + Link.where(tail_uuid: @sourcedata.keys).each do |link| + if link.link_class == 'data_origin' + @sourcedata[link.tail_uuid][:data_origins] ||= [] + @sourcedata[link.tail_uuid][:data_origins] << [link.name, link.head_kind, link.head_uuid] + end + end + Collection.where(uuid: @sourcedata.keys).each do |collection| + if @sourcedata[collection.uuid] + @sourcedata[collection.uuid][:collection] = collection + end + end + end end diff --git a/app/views/collections/_nav.html.erb b/app/views/collections/_nav.html.erb index 5d570830bf..678d8eb219 100644 --- a/app/views/collections/_nav.html.erb +++ b/app/views/collections/_nav.html.erb @@ -1,6 +1,8 @@ diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index 8dc4570ddf..358b216904 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -1,18 +1,3 @@ -<% content_for :head do %> - -<% end %> - <%= render :partial => 'nav' %> @@ -37,7 +22,7 @@
- <%= c[:uuid] %> + <%= link_to c[:uuid], collection_path(c[:uuid]) %> <%= raw(distance_of_time_in_words(c[:created_at], Time.now).sub('about ','~').sub(' ',' ')) if c[:created_at] %> diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb new file mode 100644 index 0000000000..e101f0ce21 --- /dev/null +++ b/app/views/collections/show.html.erb @@ -0,0 +1,114 @@ +<%= render :partial => 'nav' %> + + + + + + + + + + + + <% @provenance.each do |p| %> + <% j = p[:job] %> + + <% if j %> + + + + + + <% else %> + + + + <% end %> + + <% end %> + + +
+ job + + output ↑ command/version + parameters + + start + + clock time +
+ <%= j.uuid %> +
+ <%= j.submit_id %> +
+ <%= p[:output] %>
+ ↑ + <%= j.command %> <%= link_to j.command_version, "https://redmine.clinicalfuture.com/projects/freefactories/repository/warehouse-apps/revisions/#{j.command_version}" if j.command_version %>
+ <% j.command_parameters.each do |k,v| %> + <%= k.to_s %> +
+ <%= v %> +
+ <% end %> +
+ <%= j.started_at %> + + <% if j.started_at and j.finished_at %> + <%= raw(distance_of_time_in_words(j.started_at, j.finished_at).sub('about ','~').sub(' ',' ')) %> + <% elsif j.started_at and j.running %> + <%= raw(distance_of_time_in_words(j.started_at, Time.now).sub('about ','~').sub(' ',' ')) %> (running) + <% end %> +
+ lookup fail +
+ <%= p[:target] %> +
+
+ + + + + + + + + + <% @sourcedata.values.each do |sourcedata| %> + + + + + + <% end %> + + +
+ collection + + data size + + protected? + + origin +
+ <%= sourcedata[:uuid] %> + + <%= sourcedata[:collection].data_size if sourcedata[:collection] and sourcedata[:collection].data_size %> + + <% if sourcedata[:protected] %> + yes + <% else %> + no + <% end %> + + <% if sourcedata[:data_origins] %> + <% sourcedata[:data_origins].each do |data_origin| %> + <%= data_origin[0] %> + <%= data_origin[2] %> +
+ <% end %> + <% end %> +
-- 2.30.2