Module: Karafka::Web::Ui::Helpers::BadgesHelper
- Included in:
- Base
- Defined in:
- lib/karafka/web/ui/helpers/badges_helper.rb
Overview
Helpers mapping domain states (process status, kafka state, lag trend) to badge styles and rendering simple badge collections
Instance Method Summary collapse
-
#kafka_state_badge(state) ⇒ String
Takes a kafka report state and recommends background style color.
-
#lag_trend_badge(trend) ⇒ String
Takes the lag trend and gives it appropriate background style color for badge.
-
#status_badge(status) ⇒ String
Takes a status and recommends background style color.
-
#tags(tags_array) ⇒ String
Renders tags one after another.
Instance Method Details
#kafka_state_badge(state) ⇒ String
Takes a kafka report state and recommends background style color
53 54 55 56 57 58 59 60 61 |
# File 'lib/karafka/web/ui/helpers/badges_helper.rb', line 53 def kafka_state_badge(state) case state when "up" then "badge-success" when "active" then "badge-success" when "steady" then "badge-success" else "badge-warning" end end |
#lag_trend_badge(trend) ⇒ String
Takes the lag trend and gives it appropriate background style color for badge
33 34 35 36 37 38 |
# File 'lib/karafka/web/ui/helpers/badges_helper.rb', line 33 def lag_trend_badge(trend) bg = "badge-success" if trend.negative? bg ||= "badge-warning" if trend.positive? bg ||= "badge-secondary" bg end |
#status_badge(status) ⇒ String
Takes a status and recommends background style color
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/karafka/web/ui/helpers/badges_helper.rb', line 14 def status_badge(status) case status when "initialized" then "badge-success" when "supervising" then "badge-success" when "running" then "badge-success" when "quieting" then "badge-warning" when "quiet" then "badge-warning" when "stopping" then "badge-warning" when "stopped" then "badge-error" when "terminated" then "badge-error" else raise ::Karafka::Errors::UnsupportedCaseError, status end end |
#tags(tags_array) ⇒ String
Renders tags one after another
44 45 46 47 48 |
# File 'lib/karafka/web/ui/helpers/badges_helper.rb', line 44 def () .map { |tag| %(<span class="badge badge-info">#{tag}</span>) } .join(" ") end |