1
|
module ContainersHelper
|
2
|
def managed_icon(container, resource)
|
3
|
if managed?(container, resource)
|
4
|
'<span class="glyphicon glyphicon-check"></span>'.html_safe
|
5
|
else
|
6
|
'<span class="glyphicon glyphicon-unchecked"></span>'.html_safe
|
7
|
end
|
8
|
end
|
9
|
|
10
|
def managed?(container, resource)
|
11
|
uuids_in_resource(resource).include? container.identity
|
12
|
end
|
13
|
|
14
|
def uuids_in_resource(resource)
|
15
|
Container.where(:compute_resource_id => resource.id).pluck(:uuid)
|
16
|
end
|
17
|
|
18
|
def link_to_container(container, resource)
|
19
|
link_to_if_authorized container.name[1..-1].titleize,
|
20
|
container_link_hash(container, resource)
|
21
|
end
|
22
|
|
23
|
def container_link_hash(container, resource)
|
24
|
if managed?(container, resource)
|
25
|
hash_for_container_path(:id => Container.find_by_uuid(container.identity).id)
|
26
|
else
|
27
|
hash_for_compute_resource_vm_path(:compute_resource_id => resource,
|
28
|
:id => container.identity)
|
29
|
end
|
30
|
end
|
31
|
|
32
|
def container_title_actions(container)
|
33
|
@compute_resource = container.compute_resource
|
34
|
title_actions(
|
35
|
button_group(
|
36
|
link_to(_('Commit'), '#commit-modal', :'data-toggle' => 'modal')
|
37
|
),
|
38
|
button_group(vm_power_action(container.in_fog)),
|
39
|
button_group(
|
40
|
display_delete_if_authorized(
|
41
|
hash_for_container_path(:id => container.id)
|
42
|
.merge(:auth_object => container,
|
43
|
:auth_action => 'destroy',
|
44
|
:authorizer => authorizer),
|
45
|
:confirm => _("Delete %s?") % container.name)
|
46
|
)
|
47
|
)
|
48
|
end
|
49
|
|
50
|
def auto_complete_search(name, val, options = {})
|
51
|
options.merge!(:class => "form-control", :'data-url' => options.delete(:path))
|
52
|
text_field_tag(name, val, options)
|
53
|
end
|
54
|
end
|