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