Class: Karafka::Web::Ui::Base
- Inherits:
-
Roda
- Object
- Roda
- Karafka::Web::Ui::Base
- Includes:
- Helpers::ApplicationHelper, Helpers::PathsHelper, Helpers::TailwindHelper, Helpers::TimeHelper, Helpers::TopicsHelper
- Defined in:
- lib/karafka/web/ui/base.rb
Overview
Base Roda application
Direct Known Subclasses
Constant Summary collapse
- CONTEXT_DETAILS =
Details that need to be evaluated in the context of OSS or Pro web UI. If those would be evaluated in the base, they would not be initialized as expected
lambda do plugin( :public, root: Karafka::Web.gem_root.join("lib/karafka/web/ui/public"), # Cache all static files for the end user for as long as possible # We can do it because we ship per version assets so they invalidate with gem bumps headers: { "Cache-Control" => "max-age=31536000, immutable" }, gzip: true, brotli: true ) plugin :render_each plugin :partials # The secret here will be reconfigured after Web UI configuration setup # This is why we assign here a random value as it will have to be changed by the end # user to make the Web UI work. plugin( :sessions, key: "_karafka_session", env_key: "karafka.session", secret: SecureRandom.hex(64) ) end
Constants included from Helpers::TailwindHelper
Helpers::TailwindHelper::TYPES
Constants included from Helpers::TopicsHelper
Helpers::TopicsHelper::DEFAULT_LIMIT
Instance Method Summary collapse
-
#build(consumer_class) ⇒ Object
Builds a consumer instance with all needed details.
-
#params ⇒ Karafka::Web::Ui::Controllers::Requests::Params
Curated params.
-
#render_response(response) ⇒ Object
Sets appropriate template variables based on the response object and renders the expected view.
Methods included from Helpers::TailwindHelper
#badge, #link_button, #tailwind_types
Methods included from Helpers::TopicsHelper
#topics_assignment_label, #topics_assignment_text, #topics_partition_identifier
Methods included from Helpers::TimeHelper
#human_readable_time, #poll_state_with_change_time_label, #relative_time, #time_with_label
Methods included from Helpers::ApplicationHelper
#deep_merge, #flat_hash, #format_memory, #icon, #kafka_state_badge, #lag_trend_badge, #lag_with_label, #lso_risk_state_badge, #lso_risk_state_bg, #nav_class, #normalized_metric, #number_with_delimiter, #object_value_to_s, #offset_with_label, #sort_link, #status_badge, #tags, #truncate, #view_title
Methods included from Helpers::PathsHelper
#action?, #asset_path, #consumer_path, #consumers_path, #explorer_messages_path, #explorer_path, #explorer_topics_path, #flatten_params, #root_path, #scheduled_messages_explorer_path, #topics_path
Instance Method Details
#build(consumer_class) ⇒ Object
Builds a consumer instance with all needed details
192 193 194 195 196 |
# File 'lib/karafka/web/ui/base.rb', line 192 def build(consumer_class) Controllers::Requests::ExecutionWrapper.new( consumer_class.new(params, session) ) end |
#params ⇒ Karafka::Web::Ui::Controllers::Requests::Params
Returns curated params.
212 213 214 |
# File 'lib/karafka/web/ui/base.rb', line 212 def params Controllers::Requests::Params.new(request.params) end |
#render_response(response) ⇒ Object
Sets appropriate template variables based on the response object and renders the expected view
201 202 203 204 205 206 207 208 209 |
# File 'lib/karafka/web/ui/base.rb', line 201 def render_response(response) response.attributes.each do |key, value| instance_variable_set( :"@#{key}", value ) end view(response.path) end |