Merge branch '2659-anonymous-share-projects' refs #2659
[arvados.git] / apps / workbench / app / controllers / jobs_controller.rb
index 536518277f1ca86da6256af0887a5be9ee7bc560..b90210f6a9b7be4c7bbea8a1193000ac9e8a7a56 100644 (file)
@@ -1,4 +1,10 @@
 class JobsController < ApplicationController
+  skip_around_filter :require_thread_api_token, if: proc { |ctrl|
+    Rails.configuration.anonymous_user_token and
+    'show' == ctrl.action_name
+  }
+
+  include JobsHelper
 
   def generate_provenance(jobs)
     return if params['tab_pane'] != "Provenance"
@@ -56,6 +62,20 @@ class JobsController < ApplicationController
     super
   end
 
+  def logs
+    @logs = Log.select(%w(event_type object_uuid event_at properties))
+               .order('event_at DESC')
+               .filter([["event_type",  "=", "stderr"],
+                        ["object_uuid", "in", [@object.uuid]]])
+               .limit(500)
+               .results
+               .to_a
+               .map{ |e| e.serializable_hash.merge({ 'prepend' => true }) }
+    respond_to do |format|
+      format.json { render json: @logs }
+    end
+  end
+
   def index_pane_list
     if params[:uuid]
       %w(Recent Provenance)
@@ -65,6 +85,8 @@ class JobsController < ApplicationController
   end
 
   def show_pane_list
-    %w(Status Log Details Provenance Advanced)
+    panes = %w(Status Log Details Provenance Advanced)
+    panes.delete 'Log' if !current_user
+    panes
   end
 end