Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #38130 - add info to job details #939

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/api/v2/job_invocations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def index
param :host_status, :bool, required: false, desc: N_('Show Job status for the hosts')
def show
set_hosts_and_template_invocations
@job_organization = Taxonomy.find_by(id: @job_invocation.task.input[:current_organization_id])
@job_location = Taxonomy.find_by(id: @job_invocation.task.input[:current_location_id])
if params[:host_status] == 'true'
set_statuses_and_smart_proxies
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/v2/job_invocations/base.json.rabl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object @job_invocation

attributes :id, :description, :job_category, :targeting_id, :status, :start_at, :status_label, :ssh_user, :time_to_pickup
attributes :id, :description, :job_category, :targeting_id, :status, :start_at, :status_label, :ssh_user, :time_to_pickup, :concurrency_level, :execution_timeout_interval

node do |invocation|
pattern_template = invocation.pattern_template_invocations.first
Expand Down
38 changes: 38 additions & 0 deletions app/views/api/v2/job_invocations/show.json.rabl
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
object @job_invocation

attribute :pattern_template_invocations

extends 'api/v2/job_invocations/main'

node :job_organization do
@job_organization
end

node :job_location do
@job_location
end

# node :inputs do
# # @job_invocation.pattern_template_invocations[0][:input_values]
# @job_invocation.pattern_template_invocations[0].input_values
# # @job_invocation.pattern_template_invocations.map(&:input_values)
# # @job_invocation.pattern_template_invocations.map{ |invocation| invocation.input_values
# # }
# end

# child @job_invocation.pattern_template_invocations => :pattern_template_invocations do |template|
# puts template.inspect
# # @job_invocation.pattern_template_invocations
# child template.input_values => :input_values do
# attributes :template_input_name, :template_input_id
# node :value do |iv|
# iv.template_input.respond_to?(:hidden_value) && iv.template_input.hidden_value? ? '*' * 5 : iv.value
# end
# end
# end

# child @inputs do
# child :input_values do
# attributes :template_input_name, :template_input_id
# node :value do |iv|
# iv.template_input.respond_to?(:hidden_value) && iv.template_input.hidden_value? ? '*' * 5 : iv.value
# end
# end
# end
Comment on lines +15 to +41
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamruzicka I couldnt figure out how to extract the inputs from the pattern, could you advise on it?
tab_overview does

template_invocations = job_invocation.pattern_template_invocations
template_invocations.each do |template_invocation|
 render :partial => 'card_user_input', :locals => { :template_invocation => template_invocation } 

card_user does template_invocation.input_values.joins(:template_input).each do |input_value|

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we already sort of have that in https://github.com/theforeman/foreman_remote_execution/blob/master/app/views/api/v2/job_invocations/main.json.rabl#L37 ? It takes inputs from all the template invocations, not just the pattern. In the frontend you should be able to look at the data you get and then pick the one which has null host_id.

1 change: 1 addition & 0 deletions app/views/job_invocations/_tab_overview.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% template_invocations = job_invocation.pattern_template_invocations %>
<%= job_invocation.pattern_template_invocations[0].input_values.inspect %>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftovers to remove

<div class='row'>
<div class="col-xs-6 col-sm-6 col-md-6">
<%= render :partial => 'card_results', :locals => { :job_invocation => job_invocation } %>
Expand Down
Loading
Loading