Skip to content

Commit

Permalink
fix Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
patodevilla committed Mar 21, 2024
1 parent bc2fb68 commit 9a63b36
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ gem 'debug', '>= 1.0.0'
gem 'minitest', '~> 5.14'
gem 'minitest-reporters', '~> 1.6'
gem 'rake', '~> 13.1'
gem 'super_hash', '0.3.2', git: 'https://github.com/prysmex/super_hash.git'

# rubocop
gem 'rubocop', '~> 1.62'
Expand Down
36 changes: 25 additions & 11 deletions lib/kibana/dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# frozen_string_literal: true

require 'securerandom'
require 'super_hash'

module Kibana
CLIENT_VERSION = '8.12.1'
module Dashboard

# @note This could be removed if classes inherit from ActiveSupport::HashWithIndifferentAccess
#
# Allows a hash to be initialized via .new({...})
module HashInit
def initialize(init_value = {})
# iterate init_value and set all values
if init_value.respond_to?(:each_pair)
init_value.each do |k, v|
self[k] = v
end
else
super
end
end
end

# PANELS_JSON_VISUALIZATION_VERSION = '8.9.1'.freeze
CORE_MIGRATION_VERSION = '8.8.0'
TYPE_MIGRATION_VERSION = '8.9.0'
Expand Down Expand Up @@ -33,8 +49,7 @@ module Dashboard
# }
#
class PanelJSON < Hash
# include SuperHash::Hasher
# instance_variable_set(:@allow_dynamic_attributes, true)
include HashInit

# Distance of right side of panel to left side of dashboard
#
Expand Down Expand Up @@ -86,8 +101,7 @@ def y2
# rubocop:enable Layout/LineLength
#
class Dashboard < Hash
# include SuperHash::Hasher
instance_variable_set(:@allow_dynamic_attributes, true)
include HashInit

DASHBOARD_MAX_WIDTH = 48

Expand Down Expand Up @@ -328,9 +342,9 @@ def insert_visualization_at(x:, y:, w:, h:, reference_id:, title:, panel_id: Sec

# add reference to the dashboard 'references' key
self['references'].push({
id: reference_id,
name: "#{panel_id}:panel_#{panel_id}",
type: 'visualization'
'id' => reference_id,
'name' => "#{panel_id}:panel_#{panel_id}",
'type' => 'visualization'
})
end

Expand Down Expand Up @@ -478,9 +492,9 @@ def add_tag(id)
return false if self['references'].find { |i| i['id'] == id }

self['references'].push({
id: id.to_s,
name: "tag-#{id}",
type: 'tag'
'id' => id.to_s,
'name' => "tag-#{id}",
'type' => 'tag'
})
end

Expand Down
2 changes: 1 addition & 1 deletion lib/kibana/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Kibana
VERSION = '0.8.6'
VERSION = '0.8.7'
end

0 comments on commit 9a63b36

Please sign in to comment.