From 885a37384af5c3252f81518e6bcedc2abf50489b Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 2 Jun 2014 03:16:08 -0400 Subject: [PATCH] 2872: Add recent jobs and pipelines to folder index, use as root url. --- .../app/controllers/application_controller.rb | 8 +++++++ .../_index_jobs_and_pipelines.html.erb | 21 ++++++++++++++++++ .../app/views/folders/index.html.erb | 22 +++++++++++++++++++ apps/workbench/config/routes.rb | 2 +- 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 apps/workbench/app/views/folders/_index_jobs_and_pipelines.html.erb diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index c1e82eb621..4347b9b718 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -496,6 +496,14 @@ class ApplicationController < ActionController::Base end end + helper_method :recent_jobs_and_pipelines + def recent_jobs_and_pipelines + (Job.limit(10) | PipelineInstance.limit(10)). + sort_by do |x| + x.finished_at || x.started_at || x.created_at rescue x.created_at + end + end + helper_method :get_object def get_object uuid if @get_object.nil? and @objects diff --git a/apps/workbench/app/views/folders/_index_jobs_and_pipelines.html.erb b/apps/workbench/app/views/folders/_index_jobs_and_pipelines.html.erb new file mode 100644 index 0000000000..fb688b435d --- /dev/null +++ b/apps/workbench/app/views/folders/_index_jobs_and_pipelines.html.erb @@ -0,0 +1,21 @@ +
+ <% recent_jobs_and_pipelines[0..9].each do |object| %> + <% any = true %> +
+
+ <%= render :partial => "show_object_button", :locals => {object: object, size: 'xs'} %> + <%= render_editable_attribute object, 'name', nil %> +
+
+ <%= render_controller_partial( + 'show_object_description_cell.html', + controller_name: object.controller_name, + locals: {object: object}) + %> +
+
+ <% end %> + <% if not defined? any %> + No jobs or pipelines to display. + <% end %> +
diff --git a/apps/workbench/app/views/folders/index.html.erb b/apps/workbench/app/views/folders/index.html.erb index 7666e54611..5197f84677 100644 --- a/apps/workbench/app/views/folders/index.html.erb +++ b/apps/workbench/app/views/folders/index.html.erb @@ -54,4 +54,26 @@ +
+
+
+
+
+ <%= link_to jobs_path, class: 'btn btn-default btn-xs' do %> + All jobs + <% end %> + <%= link_to pipeline_instances_path, class: 'btn btn-default btn-xs' do %> + All pipelines + <% end %> +
+

+ Recent jobs and pipelines +

+
+
+ <%= render partial: 'index_jobs_and_pipelines' %> +
+
+
+
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb index a28cc69b89..94e2a11529 100644 --- a/apps/workbench/config/routes.rb +++ b/apps/workbench/config/routes.rb @@ -62,7 +62,7 @@ ArvadosWorkbench::Application.routes.draw do post 'actions' => 'actions#post' get 'websockets' => 'websocket#index' - root :to => 'users#welcome' + root :to => 'folders#index' # Send unroutable requests to an arbitrary controller # (ends up at ApplicationController#render_not_found) -- 2.30.2