From c16a97576716f81c721bcd0c889309cb75e3eb9a Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Wed, 5 Feb 2014 23:04:40 -0500 Subject: [PATCH] * Left nav correctly highlights current section * Refactored pipeline instances and job pages to use tabs * Uses javascript to adjust height of tab pane so that scrollbars show up in the right place * Fixed some glyphicons broken by bootstrap 3 --- .../app/assets/javascripts/application.js | 2 + .../app/assets/javascripts/provenance.js | 13 ++- .../assets/stylesheets/application.css.scss | 4 + .../app/controllers/application_controller.rb | 33 +----- .../app/controllers/collections_controller.rb | 2 +- .../app/controllers/jobs_controller.rb | 4 + .../pipeline_instances_controller.rb | 4 + .../application/_arvados_object.html.erb | 88 --------------- .../app/views/application/_show_api.html.erb | 27 +++++ .../application/_show_attributes.html.erb | 14 ++- .../app/views/application/_show_json.html.erb | 3 + .../views/application/_show_links.html.erb | 40 +++++++ .../app/views/application/_svg_div.html.erb | 4 +- .../app/views/application/index.html.erb | 22 ++-- .../app/views/application/show.html.erb | 7 +- .../views/collections/_show_files.html.erb | 4 +- ...how.html.erb => _show_provenance.html.erb} | 2 - .../app/views/layouts/application.html.erb | 105 ++++++++++++------ ...how.html.erb => _show_components.html.erb} | 17 --- .../pipeline_instances/_show_graph.html.erb | 19 ++++ .../{show.js.erb => _show_graph.js.erb} | 0 21 files changed, 217 insertions(+), 197 deletions(-) create mode 100644 apps/workbench/app/views/application/_show_api.html.erb create mode 100644 apps/workbench/app/views/application/_show_json.html.erb create mode 100644 apps/workbench/app/views/application/_show_links.html.erb rename apps/workbench/app/views/jobs/{show.html.erb => _show_provenance.html.erb} (77%) rename apps/workbench/app/views/pipeline_instances/{show.html.erb => _show_components.html.erb} (74%) create mode 100644 apps/workbench/app/views/pipeline_instances/_show_graph.html.erb rename apps/workbench/app/views/pipeline_instances/{show.js.erb => _show_graph.js.erb} (100%) diff --git a/apps/workbench/app/assets/javascripts/application.js b/apps/workbench/app/assets/javascripts/application.js index 863776bfff..fbbf8f330b 100644 --- a/apps/workbench/app/assets/javascripts/application.js +++ b/apps/workbench/app/assets/javascripts/application.js @@ -14,6 +14,7 @@ //= require jquery_ujs //= require bootstrap //= require bootstrap/dropdown +//= require bootstrap/tab //= require bootstrap-editable //= require bootstrap-editable-rails //= require_tree . @@ -46,3 +47,4 @@ jQuery(function($){ $('.loading').hide(); }); })(jQuery); + diff --git a/apps/workbench/app/assets/javascripts/provenance.js b/apps/workbench/app/assets/javascripts/provenance.js index bacbfd1307..53e2d19920 100644 --- a/apps/workbench/app/assets/javascripts/provenance.js +++ b/apps/workbench/app/assets/javascripts/provenance.js @@ -29,6 +29,7 @@ function provenance_sizing_fixup(divId, svgId) { b.style.paddingTop = String(max) + "px"; } + /* w = window.innerWidth - 25; a.style.width = String(w) + "px"; gw = parseFloat(g.getAttribute("width")); @@ -37,7 +38,7 @@ function provenance_sizing_fixup(divId, svgId) { } else { c.style.paddingLeft = "0px"; - } + }*/ } function graph_zoom(divId, svgId, scale) { @@ -51,3 +52,13 @@ function graph_zoom(divId, svgId, scale) { pg.scrollLeft = (hcenter * pg.scrollWidth) - (pg.scrollWidth - pg.scrollLeftMax)/2.0; provenance_sizing_fixup(divId, svgId); } + +$(window).on('load resize', function () { + var s = document.getElementsByClassName("smart-scroll"); + for (var i = 0; i < s.length; i++) { + a = s[i]; + var h = window.innerHeight - a.getBoundingClientRect().top - 20; + height = String(h) + "px"; + a.style.height = height; + } +}); diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss index 6fc4522828..d94dc4efa4 100644 --- a/apps/workbench/app/assets/stylesheets/application.css.scss +++ b/apps/workbench/app/assets/stylesheets/application.css.scss @@ -117,3 +117,7 @@ ul.arvados-nav li ul li { margin-right: 1em; float: left } + +.smart-scroll { + overflow: auto; +} \ No newline at end of file diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index aa87a60384..4c2d6ddf62 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -142,6 +142,10 @@ class ApplicationController < ActionController::Base (@object.friendly_link_name if @object.respond_to? :friendly_link_name)) end + def show_pane_list + %w(attributes links json api) + end + protected def find_object_by_uuid @@ -343,34 +347,5 @@ class ApplicationController < ActionController::Base if @notification_count == 0 @notification_count = '' end - - # @my_ssh_keys = AuthorizedKey.where(authorized_user_uuid: current_user.uuid) - # @my_vm_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#virtual_machine', link_class: 'permission', name: 'can_login') - # @my_repo_perms = Link.where(tail_uuid: current_user.uuid, head_kind: 'arvados#repository', link_class: 'permission', name: 'can_write') - - # @my_tag_links = {} - - # @my_jobs = Job. - # limit(10). - # order('created_at desc'). - # where(created_by: current_user.uuid) - - # @my_collections = Collection. - # limit(10). - # order('created_at desc'). - # where(created_by: current_user.uuid) - - # Link.limit(1000).where(head_uuid: @my_collections.collect(&:uuid), - # link_class: 'tag').each do |link| - # (@my_tag_links[link.head_uuid] ||= []) << link - # end - - # @my_pipelines = PipelineInstance. - # limit(10). - # order('created_at desc'). - # where(created_by: current_user.uuid) - - - end end diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb index c6a7eafafd..c38ca9a98c 100644 --- a/apps/workbench/app/controllers/collections_controller.rb +++ b/apps/workbench/app/controllers/collections_controller.rb @@ -3,7 +3,7 @@ class CollectionsController < ApplicationController skip_before_filter :check_user_agreements, :only => [:show_file] def show_pane_list - %w(files attributes provenance provenance_graph used_by) + %w(files attributes provenance_graph used_by) end def index if params[:search].andand.length.andand > 0 diff --git a/apps/workbench/app/controllers/jobs_controller.rb b/apps/workbench/app/controllers/jobs_controller.rb index e6179ffdd9..9b52977b6e 100644 --- a/apps/workbench/app/controllers/jobs_controller.rb +++ b/apps/workbench/app/controllers/jobs_controller.rb @@ -30,4 +30,8 @@ class JobsController < ApplicationController def show generate_provenance([@object]) end + + def show_pane_list + %w(attributes provenance links json api) + end end diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb index 4798271109..b7339c07de 100644 --- a/apps/workbench/app/controllers/pipeline_instances_controller.rb +++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb @@ -128,6 +128,10 @@ class PipelineInstancesController < ApplicationController :pips => pips } end + def show_pane_list + %w(components graph attributes links json api) + end + protected def for_comparison v if v.is_a? Hash or v.is_a? Array diff --git a/apps/workbench/app/views/application/_arvados_object.html.erb b/apps/workbench/app/views/application/_arvados_object.html.erb index d04ca84439..b4bf70dd23 100644 --- a/apps/workbench/app/views/application/_arvados_object.html.erb +++ b/apps/workbench/app/views/application/_arvados_object.html.erb @@ -1,57 +1,5 @@ <% content_for :arvados_object_table do %> -<%= form_for @object do |f| %> - - - - - <% @object.attributes_for_display.each do |attr, attrvalue| %> - <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %> - <% end %> - -
- -<% incoming = Link.where(tail_uuid: @object.uuid) %> -<% if incoming.items_available > 0 %> -

Incoming Links

- - - - - <% incoming.each do |link| %> - - - - - - - - <% end %> - -
<%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "uuid", attrvalue: link.uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "link_class", attrvalue: link.link_class } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "name", attrvalue: link.name } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "head_uuid", attrvalue: link.head_uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "properties", attrvalue: link.properties } %>
-<% end %> - -<% outgoing = Link.where(head_uuid: @object.uuid) %> -<% if outgoing.items_available > 0 %> -

Outgoing Links

- - - - - <% outgoing.each do |link| %> - - - - - - - - <% end %> - -
<%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "uuid", attrvalue: link.uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "link_class", attrvalue: link.link_class } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "name", attrvalue: link.name } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "tail_uuid", attrvalue: link.tail_uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "properties", attrvalue: link.properties } %>
-<% end %> - -<% end %> <% end %> <% if content_for? :page_content %> @@ -80,45 +28,9 @@ <% end %>
-
-<%= JSON.pretty_generate(@object.attributes.reject { |k,v| k == 'id' }) rescue nil %>
-      
-
- <% if @object.andand.uuid %> - -
-
-curl -X PUT \
- -H "Authorization: OAuth2 $ARVADOS_API_TOKEN" \
- --data-urlencode <%= @object.class.to_s.underscore %>@/dev/stdin \
- https://$ARVADOS_API_HOST/arvados/v1/<%= @object.class.to_s.pluralize.underscore %>/<%= @object.uuid %> \
- <<EOF
-<%= JSON.pretty_generate({@object.attributes.keys[-3] => @object.attributes.values[-3]}) %>
-EOF
-      
-
- -
-
-arv --pretty <%= @object.class.to_s.underscore %> get \
- --uuid <%= @object.uuid %>
-
-arv <%= @object.class.to_s.underscore %> update \
- --uuid <%= @object.uuid %> \
- --<%= @object.class.to_s.underscore.gsub '_', '-' %> '<%= JSON.generate({@object.attributes.keys[-3] => @object.attributes.values[-3]}).gsub("'","'\''") %>'
-      
-
-
-import arvados
-
-x = arvados.api().<%= @object.class.to_s.pluralize.underscore %>().get(uuid='<%= @object.uuid %>').execute()
-      
-
- - <% end %> diff --git a/apps/workbench/app/views/application/_show_api.html.erb b/apps/workbench/app/views/application/_show_api.html.erb new file mode 100644 index 0000000000..df271e0591 --- /dev/null +++ b/apps/workbench/app/views/application/_show_api.html.erb @@ -0,0 +1,27 @@ +<% if @object.andand.uuid %> + +
+curl -X PUT \
+ -H "Authorization: OAuth2 $ARVADOS_API_TOKEN" \
+ --data-urlencode <%= @object.class.to_s.underscore %>@/dev/stdin \
+ https://$ARVADOS_API_HOST/arvados/v1/<%= @object.class.to_s.pluralize.underscore %>/<%= @object.uuid %> \
+ <<EOF
+<%= JSON.pretty_generate({@object.attributes.keys[-3] => @object.attributes.values[-3]}) %>
+EOF
+  
+ +
+arv --pretty <%= @object.class.to_s.underscore %> get \
+ --uuid <%= @object.uuid %>
+
+arv <%= @object.class.to_s.underscore %> update \
+ --uuid <%= @object.uuid %> \
+ --<%= @object.class.to_s.underscore.gsub '_', '-' %> '<%= JSON.generate({@object.attributes.keys[-3] => @object.attributes.values[-3]}).gsub("'","'\''") %>'
+      
+ +
+import arvados
+
+x = arvados.api().<%= @object.class.to_s.pluralize.underscore %>().get(uuid='<%= @object.uuid %>').execute()
+      
+<% end %> diff --git a/apps/workbench/app/views/application/_show_attributes.html.erb b/apps/workbench/app/views/application/_show_attributes.html.erb index 0e8d2a2bd8..965ec5a29e 100644 --- a/apps/workbench/app/views/application/_show_attributes.html.erb +++ b/apps/workbench/app/views/application/_show_attributes.html.erb @@ -1 +1,13 @@ -<%= render partial: 'arvados_object' %> +<%= form_for @object do |f| %> + + + + + <% @object.attributes_for_display.each do |attr, attrvalue| %> + <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %> + <% end %> + +
+ +<% end %> + diff --git a/apps/workbench/app/views/application/_show_json.html.erb b/apps/workbench/app/views/application/_show_json.html.erb new file mode 100644 index 0000000000..2f0cd21466 --- /dev/null +++ b/apps/workbench/app/views/application/_show_json.html.erb @@ -0,0 +1,3 @@ +
+<%= JSON.pretty_generate(@object.attributes.reject { |k,v| k == 'id' }) rescue nil %>
+
diff --git a/apps/workbench/app/views/application/_show_links.html.erb b/apps/workbench/app/views/application/_show_links.html.erb new file mode 100644 index 0000000000..8dcf3353ff --- /dev/null +++ b/apps/workbench/app/views/application/_show_links.html.erb @@ -0,0 +1,40 @@ +<% incoming = Link.where(tail_uuid: @object.uuid) %> +<% if incoming.items_available > 0 %> +

Incoming Links

+ + + + + <% incoming.each do |link| %> + + + + + + + + <% end %> + +
<%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "uuid", attrvalue: link.uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "link_class", attrvalue: link.link_class } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "name", attrvalue: link.name } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "head_uuid", attrvalue: link.head_uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "properties", attrvalue: link.properties } %>
+<% end %> + +<% outgoing = Link.where(head_uuid: @object.uuid) %> +<% if outgoing.items_available > 0 %> +

Outgoing Links

+ + + + + <% outgoing.each do |link| %> + + + + + + + + <% end %> + +
<%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "uuid", attrvalue: link.uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "link_class", attrvalue: link.link_class } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "name", attrvalue: link.name } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "tail_uuid", attrvalue: link.tail_uuid } %><%= render partial: 'application/arvados_attr_value', locals: { obj: link, attr: "properties", attrvalue: link.properties } %>
+<% end %> + diff --git a/apps/workbench/app/views/application/_svg_div.html.erb b/apps/workbench/app/views/application/_svg_div.html.erb index ddc8e61960..9f5f330cda 100644 --- a/apps/workbench/app/views/application/_svg_div.html.erb +++ b/apps/workbench/app/views/application/_svg_div.html.erb @@ -27,8 +27,8 @@ stroke-linecap: round;
- - + +
diff --git a/apps/workbench/app/views/application/index.html.erb b/apps/workbench/app/views/application/index.html.erb index 4ebedf6d69..26adf59c9f 100644 --- a/apps/workbench/app/views/application/index.html.erb +++ b/apps/workbench/app/views/application/index.html.erb @@ -7,6 +7,7 @@ { action: 'create', return_to: request.url }, { class: 'btn btn-primary pull-right' } %> <% end %> + <%= form_tag({action: 'compare', controller: params[:controller], method: 'get'}, {method: 'get', id: 'compare', class: 'pull-right small-form-margin'}) do |f| %> <%= submit_tag 'Compare selected', {class: 'btn btn-primary', disabled: true, style: 'display: none'} %>   @@ -14,24 +15,17 @@ <% pane_list = controller.index_pane_list rescue %w(recent) %> -<% if pane_list.length > 1 %> -
-
- <% pane_list.each_with_index do |pane, i| %> -
- <%= render partial: pane %> +<% pane_list.each_with_index do |pane, i| %> +
+
+ <%= render partial: pane %> +
- <% end %> -
- -<% else %> - <% pane_list.each_with_index do |pane, i| %> - <%= render partial: pane %> - <% end %> <% end %> +
diff --git a/apps/workbench/app/views/application/show.html.erb b/apps/workbench/app/views/application/show.html.erb index d2abd72b87..03a8f9bbb0 100644 --- a/apps/workbench/app/views/application/show.html.erb +++ b/apps/workbench/app/views/application/show.html.erb @@ -21,9 +21,8 @@ <% end %> <% end %> -<% pane_list = controller.show_pane_list rescue %w(attributes) %> +<% pane_list = controller.show_pane_list %> -