Revision e6eb1c48
Added by Dmitri Dolguikh over 8 years ago
app/helpers/containers_helper.rb | ||
---|---|---|
39 | 39 |
button_group( |
40 | 40 |
link_to(_('Commit'), '#commit-modal', :'data-toggle' => 'modal') |
41 | 41 |
), |
42 |
button_group(vm_power_action(container.in_fog)),
|
|
42 |
button_group(container_power_action(container.in_fog)),
|
|
43 | 43 |
button_group( |
44 | 44 |
display_delete_if_authorized( |
45 | 45 |
hash_for_container_path(:id => container.id) |
... | ... | |
51 | 51 |
) |
52 | 52 |
end |
53 | 53 |
|
54 |
def container_power_action(vm, authorizer = nil) |
|
55 |
if managed?(vm, @compute_resource) |
|
56 |
id = Container.find_by_uuid(vm.identity).id |
|
57 |
opts = hash_for_power_container_path(:id => id) |
|
58 |
.merge(:auth_object => @compute_resource, |
|
59 |
:permission => 'power_compute_resources_vms', |
|
60 |
:authorizer => authorizer) |
|
61 |
else |
|
62 |
opts = hash_for_power_compute_resource_vm_path(:compute_resource_id => @compute_resource, |
|
63 |
:id => vm.identity) |
|
64 |
.merge(:auth_object => @compute_resource, :permission => 'power_compute_resources_vms', |
|
65 |
:authorizer => authorizer) |
|
66 |
end |
|
67 |
html = if vm.ready? |
|
68 |
{ :confirm => power_on_off_message(vm), :class => "btn btn-danger" } |
|
69 |
else |
|
70 |
{ :class => "btn btn-info" } |
|
71 |
end |
|
72 |
|
|
73 |
display_link_if_authorized "Power #{action_string(vm)}", opts, html.merge(:method => :put) |
|
74 |
end |
|
75 |
|
|
76 |
def power_on_off_message(vm) |
|
77 |
_("Are you sure you want to power %{act} %{vm}?") % { :act => action_string(vm).downcase.strip, |
|
78 |
:vm => vm } |
|
79 |
end |
|
80 |
|
|
54 | 81 |
def auto_complete_docker_search(name, val, options = {}) |
55 | 82 |
addClass options, 'form-control' |
56 | 83 |
text_field_tag(name, val, options) |
Also available in: Unified diff
fixes #8033: container power on/off redirects to container view now