Module: ContainersHelper

Defined in:
app/helpers/containers_helper.rb

Instance Method Summary collapse

Instance Method Details

#auto_complete_docker_search(name, val, options = {}) ⇒ Object



54
55
56
57
# File 'app/helpers/containers_helper.rb', line 54

def auto_complete_docker_search(name, val, options = {})
  addClass options, 'form-control'
  text_field_tag(name, val, options)
end


27
28
29
30
31
32
33
34
# File 'app/helpers/containers_helper.rb', line 27

def container_link_hash(container, resource)
  if managed?(container, resource)
    hash_for_container_path(:id => Container.find_by_uuid(container.identity).id)
  else
    hash_for_compute_resource_vm_path(:compute_resource_id => resource,
                                      :id                  => container.identity)
  end
end

#container_title_actions(container) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/helpers/containers_helper.rb', line 36

def container_title_actions(container)
  @compute_resource = container.compute_resource
  title_actions(
      button_group(
        link_to(_('Commit'), '#commit-modal', :'data-toggle' => 'modal')
      ),
      button_group(vm_power_action(container.in_fog)),
      button_group(
        display_delete_if_authorized(
          hash_for_container_path(:id => container.id)
                                  .merge(:auth_object => container,
                                         :auth_action => 'destroy',
                                         :authorizer  => authorizer),
          :confirm     => _("Delete %s?") % container.name)
      )
  )
end

#hub_url(image) ⇒ Object



59
60
61
62
63
64
65
# File 'app/helpers/containers_helper.rb', line 59

def hub_url(image)
  if image['is_official']
    "https://registry.hub.docker.com/_/#{image['name']}"
  else
    "https://registry.hub.docker.com/u/#{image['name']}"
  end
end


16
17
18
19
# File 'app/helpers/containers_helper.rb', line 16

def link_to_container(container, resource)
  link_to_if_authorized container.name[1..-1].titleize,
                        container_link_hash(container, resource)
end


21
22
23
24
25
# File 'app/helpers/containers_helper.rb', line 21

def link_to_taxonomies(taxonomies)
  taxonomies.map do |taxonomy|
    link_to(taxonomy)
  end.join(' ')
end

#managed?(container, resource) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/helpers/containers_helper.rb', line 6

def managed?(container, resource)
  uuids_in_resource(resource).include? container.identity
end

#managed_icon(container, resource) ⇒ Object



2
3
4
# File 'app/helpers/containers_helper.rb', line 2

def managed_icon(container, resource)
  icon_text(managed?(container, resource) ? 'check' : 'unchecked')
end

#uuids_in_resource(resource) ⇒ Object



10
11
12
13
14
# File 'app/helpers/containers_helper.rb', line 10

def uuids_in_resource(resource)
  @uuids_in_resource ||= {}
  @uuids_in_resource[resource.id] ||= Container.where(:compute_resource_id => resource.id)
                                               .pluck(:uuid)
end