-
-
Notifications
You must be signed in to change notification settings - Fork 908
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
139 changed files
with
2,379 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class EventAdditionalField < Avo::Fields::BaseField | ||
def nested_field | ||
return unless @model | ||
additional_type = @model.additional_type | ||
if additional_type.nil? | ||
return JsonViewerField.new(id, **@args) | ||
.hydrate(model:, resource:, action:, view:, panel_name:, user:) | ||
end | ||
|
||
NestedField.new(id, **@args) do | ||
additional_type.attribute_types.each do |attribute_name, type| | ||
case type | ||
when Types::GlobalId | ||
field attribute_name.to_sym, as: :global_id, show_on: :index | ||
when ActiveModel::Type::String | ||
field attribute_name.to_sym, as: :text, show_on: :index | ||
when ActiveModel::Type::Boolean | ||
field attribute_name.to_sym, as: :boolean, show_on: :index | ||
else | ||
field attribute_name.to_sym, as: :json_viewer, hide_on: :index | ||
end | ||
end | ||
end.hydrate(model:, resource:, action:, view:, panel_name:, user:) | ||
end | ||
|
||
methods = %i[fill_field value update_using to_permitted_param component_for_view visible get_fields] | ||
methods.each do |method| | ||
define_method(method, &lambda do |*args, **kwargs| | ||
nf = nested_field | ||
nf ? nf.send(method, *args, **kwargs) : super(*args, **kwargs) | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class GlobalIdField < Avo::Fields::BelongsToField | ||
include SemanticLogger::Loggable | ||
|
||
delegate(*%i[values_for_type custom?], to: :@nil) | ||
|
||
def value | ||
super.find | ||
rescue ActiveRecord::RecordNotFound | ||
nil | ||
end | ||
|
||
def view_component_name = "BelongsToField" | ||
|
||
def is_polymorphic? = true # rubocop:disable Naming/PredicateName | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class EventsRubygemEventResource < Avo::BaseResource | ||
self.title = :cache_key | ||
self.includes = %i[rubygem ip_address geoip_info] | ||
self.model_class = ::Events::RubygemEvent | ||
|
||
field :id, as: :id, hide_on: :index | ||
field :created_at, as: :date_time | ||
|
||
field :trace_id, as: :text, format_using: proc { | ||
if value.present? | ||
link_to( | ||
view == :index ? "🔗" : value, | ||
"https://app.datadoghq.com/logs?query=#{{ | ||
:@traceid => value, | ||
from_ts: (model.created_at - 12.hours).to_i * 1000, | ||
to_ts: (model.created_at + 12.hours).to_i * 1000 | ||
}.to_query}", | ||
{ target: :_blank, rel: :noopener } | ||
) | ||
end | ||
} | ||
|
||
field :tag, as: :text | ||
field :rubygem, as: :belongs_to | ||
field :ip_address, as: :belongs_to | ||
field :geoip_info, as: :belongs_to | ||
field :additional, as: :event_additional, show_on: :index | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class EventsUserEventResource < Avo::BaseResource | ||
self.title = :cache_key | ||
self.includes = %i[user ip_address geoip_info] | ||
self.model_class = ::Events::UserEvent | ||
|
||
field :id, as: :id, hide_on: :index | ||
|
||
field :created_at, as: :date_time | ||
field :trace_id, as: :text, format_using: proc { | ||
if value.present? | ||
link_to( | ||
view == :index ? "🔗" : value, | ||
"https://app.datadoghq.com/logs?query=#{{ | ||
:@traceid => value, | ||
from_ts: (model.created_at - 12.hours).to_i * 1000, | ||
to_ts: (model.created_at + 12.hours).to_i * 1000 | ||
}.to_query}", | ||
{ target: :_blank, rel: :noopener } | ||
) | ||
end | ||
} | ||
|
||
field :tag, as: :text | ||
field :user, as: :belongs_to | ||
field :ip_address, as: :belongs_to | ||
field :geoip_info, as: :belongs_to | ||
field :additional, as: :event_additional, show_on: :index | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class IpAddressResource < Avo::BaseResource | ||
self.title = :ip_address | ||
self.includes = [] | ||
|
||
self.hide_from_global_search = true | ||
self.search_query = lambda { | ||
scope.where("ip_address <<= inet ?", params[:q]) | ||
} | ||
|
||
field :id, as: :id | ||
|
||
field :ip_address, as: :text | ||
field :hashed_ip_address, as: :textarea | ||
field :geoip_info, as: :json_viewer | ||
|
||
tabs style: :pills do | ||
field :user_events, as: :has_many | ||
field :rubygem_events, as: :has_many | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
app/components/avo/fields/event_additional_field/index_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<%= index_field_wrapper **field_wrapper_args do %> | ||
<%= @field.value %> | ||
<% end %> |
4 changes: 4 additions & 0 deletions
4
app/components/avo/fields/event_additional_field/index_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Avo::Fields::EventAdditionalField::IndexComponent < Avo::Fields::IndexComponent | ||
end |
5 changes: 5 additions & 0 deletions
5
app/components/avo/fields/json_viewer_field/index_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= index_field_wrapper **field_wrapper_args do %> | ||
<% if @field.value.present? %> | ||
<pre><%= content_tag :code, YAML.dump(JSON.load(@field.value).compact).sub(/\A---(\R| {})/, "") %></pre> | ||
<% end %> | ||
<% end %> |
4 changes: 4 additions & 0 deletions
4
app/components/avo/fields/json_viewer_field/index_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Avo::Fields::JsonViewerField::IndexComponent < Avo::Fields::IndexComponent | ||
end |
13 changes: 13 additions & 0 deletions
13
app/components/avo/fields/nested_field/index_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%= index_field_wrapper **field_wrapper_args do %> | ||
<% if @field.value.present? %> | ||
<% resource = field_wrapper_args.fetch(:resource) or raise "missing resource for #{self}" %> | ||
<table><tbody> | ||
<% field.get_fields.each do |f| %> | ||
<tr class="!tw-py-0" > | ||
<td><%= f.name %></td> | ||
<%= render f.hydrate(view:, model: field.value, resource:).component_for_view(view).new(field: f, resource:, flush: true) %> | ||
</tr> | ||
<% end %> | ||
</tbody></table> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class Avo::Fields::NestedField::IndexComponent < Avo::Fields::IndexComponent | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<%= field_wrapper **field_wrapper_args, data: {} do %> | ||
<div class="divide-y"> | ||
<% field.get_fields.each do |f| %> | ||
<%= render f.hydrate(view:, model: field.value, resource:).component_for_view(view).new(field: f) %> | ||
<%= render f.hydrate(view:, model: field.value, resource:).component_for_view(view).new(field: f, resource:) %> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/2.0/controllers.html | ||
class Avo::EventsRubygemEventsController < Avo::ResourcesController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/2.0/controllers.html | ||
class Avo::EventsUserEventsController < Avo::ResourcesController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/2.0/controllers.html | ||
class Avo::IpAddressesController < Avo::ResourcesController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.