Class: ActiveAdmin::ElasticStats

Inherits:
Arbre::Component
  • Object
show all
Defined in:
lib/active_admin/elastic_stats.rb

Constant Summary collapse

CONTAINER_STYLE =
'display: flex; justify-content: center; align-items: center;'
VALUE_STYLE =
'display: flex; flex:1; justify-content: center; align-items: center; flex-direction: column; align-self: baseline; text-align: center;'

Instance Method Summary collapse

Instance Method Details

#build(model, attributes = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/active_admin/elastic_stats.rb', line 8

def build(model, attributes = {})
  super(attributes)

  index_name = model.index_name
  panel("Elastic #{index_name.titleize} Stats") do
    div(style: CONTAINER_STYLE) do
      begin
        if Elasticsearch::Model.client.indices.exists(index: index_name)
          build_fields(index_name)
        else
          show_error(index_name)
        end
      rescue Faraday::ConnectionFailed => e
        h2 e.message
      end
    end
  end
end