-
Notifications
You must be signed in to change notification settings - Fork 97
/
_details.html.erb
195 lines (183 loc) · 8.35 KB
/
_details.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<p>
<%= link_to(_('Auto Reload'), '', class: %w(btn btn-sm btn-default reload-button hidden)) %>
<% if authorized_for(:permission => :edit_foreman_tasks, :auth_object => @task) %>
<%= link_to(_('Dynflow console'),
format((defined?(Rails) ? request.script_name : '') + '/foreman_tasks/dynflow/%s', @task.external_id),
class: %w(btn btn-sm btn-default), target: '_blank') if Setting['dynflow_enable_console'] %>
<%= link_to(_('Resume'),
resume_foreman_tasks_task_path(@task),
class: ['btn', 'btn-sm', 'btn-primary', ('disabled' unless @task.resumable?)].compact,
method: :post) %>
<%= link_to(_('Cancel'),
cancel_foreman_tasks_task_path(@task),
class: ['btn', 'btn-sm', 'btn-primary', ('disabled' unless @task.cancellable?)].compact,
method: :post) %>
<% if @task.parent_task %>
<%= link_to(_("Parent task"), foreman_tasks_task_path(@task.parent_task), class: ['btn', 'btn-sm', 'btn-default']) %>
<% end %>
<% if @task.sub_tasks.any? %>
<%= link_to(_("Sub tasks"), sub_tasks_foreman_tasks_task_path(@task), class: ['btn', 'btn-sm', 'btn-default']) %>
<% end %>
<% if Setting['dynflow_allow_dangerous_actions'] %>
<%= link_to(_('Unlock'),
'',
class: ['btn', 'btn-sm', 'btn-warning', 'reload-button-stop', ('disabled' unless @task.state == 'paused')].compact,
:'data-toggle' => "modal",
:'data-target' => "#unlock_modal") %>
<%= link_to(_('Force Unlock'),
'',
class: ['btn', 'btn-sm', 'btn-danger', 'reload-button-stop', ('disabled' if @task.state == 'stopped')].compact,
:'data-toggle' => "modal",
:'data-target' => "#force_unlock_modal") %>
<% end %>
<% end %>
</p>
<div class="modal fade" id="unlock_modal" tabindex="-1" role="dialog" aria-labelledby="Deploy" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2 class="modal-title" id="deploy_modal_label">
<span class="glyphicon glyphicon-warning-sign"></span>
<%= _("Unlock") %>
</h2>
</div>
<div class="modal-body">
<%= _("This will unlock the resources that the task is running against. Please note that this might lead to inconsistent state and should be used with caution, after making sure that the task can't be resumed.") %>
<div>
<input class="disable-unlock" type="checkbox"/>
<%= _("I understand that this may cause harm and have working database backups of all backend services.") %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
<%= link_to(_("Unlock"), unlock_foreman_tasks_task_path(@task), method: :post, class: 'btn btn-warning modal-submit disabled') %>
</div>
</div>
</div>
</div>
<div class="modal fade" id="force_unlock_modal" tabindex="-1" role="dialog" aria-labelledby="Deploy" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2 class="modal-title" id="deploy_modal_label">
<span class="glyphicon glyphicon-exclamation-sign"></span>
<%= _("Force Unlock") %>
</h2>
</div>
<div class="modal-body">
<%= _("Resources will be unlocked and will not prevent other tasks from being run. As the task might be still running, it should be avoided to use this unless you are really sure the task got stuck") %>
<div>
<input class="disable-unlock" type="checkbox"/>
<%= _("I understand that this may cause harm and have working database backups of all backend services.") %>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
<%= link_to(_("Force Unlock"), force_unlock_foreman_tasks_task_path(@task), method: :post, class: 'btn btn-danger modal-submit disabled') %>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div>
<span class="param-name list-group-item-heading"><%= _("Name") %>:</span>
<% task_label = format_task_input(@task) %>
<span class="param-value" data-original-title="<%= task_label %>" rel="twipsy"> <%= truncate(task_label, :length => 50) %></span>
</div>
<div>
<span class="param-name list-group-item-heading"><%= _("Result") %>:</span>
<span class="param-value">
<% if @task.state != 'stopped' %>
<%= content_tag(:i, ' '.html_safe, :class => 'task-status pficon-help') %>
<% else %>
<%= content_tag(:i, ' '.html_safe, :class => task_result_icon_class(@task)) + content_tag(:span, @task.result) %>
<% end %>
</span>
</div>
<div>
<span class="param-name list-group-item-heading"><%= _("Triggered by") %>:</span>
<span class="param-value">
<% if @task.owner.present? && @task.username != User::ANONYMOUS_API_ADMIN && @task.username != User::ANONYMOUS_ADMIN %>
<%= link_to_if_authorized(@task.username, hash_for_edit_user_path(@task.owner)) %>
<% else %>
<%= @task.username %>
<% end %>
</span>
</div>
<div>
<span class="param-name list-group-item-heading"><%= _("Execution type") %>:</span>
<span class="param-value"><%= _(@task.execution_type) %> <%= _("(Disabled)") if @task.frozen %></span>
</div>
</div>
<div class="col-md-6">
<div>
<span class="param-name list-group-item-heading"><%= _("Start at") %>:</span>
<span class="param-value"><%= @task.start_at.nil? ? '-' : time_in_words_span(@task.start_at) %></span>
</div>
<div>
<span class="param-name list-group-item-heading"><%= _("Started at") %>:</span>
<span class="param-value"><%= time_in_words_span @task.started_at.try(:in_time_zone) %></span>
</div>
<div>
<span class="param-name list-group-item-heading"><%= _("Ended at") %>:</span>
<span class="param-value"><%= time_in_words_span @task.ended_at.try(:in_time_zone) %></span>
</div>
<div>
<span class="param-name list-group-item-heading"><%= _("Start before") %>:</span>
<span class="param-value"><%= @task.start_before.nil? ? '-' : time_in_words_span(@task.start_before) %></span>
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-xs-12">
<% progress = 100 * @task.progress %>
<% progress_class = if @task.state == 'running'
nil
else
case @task.result
when 'success'
'progress-bar-success'
when 'error'
'progress-bar-danger'
when 'warning'
'progress-bar-warning'
else
nil
end
end %>
<div class="progress-description <%= 'active' if @task.state == 'running' %>">
<span class="list-group-item-heading">State:</span> <%= @task.state %>
</div>
<div class="progress progress-striped progress-label-top-right">
<div class="progress-bar <%= progress_class %>"
role="progressbar"
aria-valuenow="<%= progress %>"
aria-valuemin="0"
aria-valuemax="100"
style="width: <%= progress %>%;">
<span><%= progress.round %>% Complete</span>
</div>
</div>
</div>
</div>
<%= troubleshooting_info %>
<% unless @task.humanized[:output].blank? %>
<div>
<span class="param-name list-group-item-heading"><%= _("Output") %>:</span>
<span class="param-value">
<pre><%= @task.humanized[:output] %></pre>
</span>
</div>
<% end %>
<% unless @task.humanized[:errors].blank? %>
<p>
<span class="param-name"><b><%= _("Errors") %>:</b></span>
<span class="param-value">
<pre><%=Array(@task.humanized[:errors]).join("\n") %></pre>
</span>
</p>
<% end %>