Class: Cosmo::Web::Controllers::Streams
- Inherits:
-
Application
- Object
- Application
- Cosmo::Web::Controllers::Streams
- Defined in:
- lib/cosmo/web/controllers/streams.rb
Constant Summary
Constants included from Renderer
Renderer::ASSETS_ROOT, Renderer::VIEWS_ROOT
Instance Method Summary collapse
Methods inherited from Application
#content_for, #hx_request?, #initialize, #params, #path, #render
Methods included from Renderer
#no_content, #not_found, #ok, #redirect_to, #serve, #url_for
Constructor Details
This class inherits a constructor from Cosmo::Web::Controllers::Application
Instance Method Details
#_info ⇒ Object
36 37 38 39 40 |
# File 'lib/cosmo/web/controllers/streams.rb', line 36 def _info name = Rack::Utils.unescape(@request.params["name"]) state = API::Stream.new(name).info.merge(name:) ok render("streams/_info", state) end |
#_table ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cosmo/web/controllers/streams.rb', line 24 def _table streams = API::Stream.all.map do |stream| state, config = stream.info.values { name: stream.name, messages: state., bytes: state.bytes, first_seq: state.first_seq, last_seq: state.last_seq, consumer_count: state.consumer_count, subjects: config.subjects } end ok render("streams/_table", { streams: streams }) end |
#index ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cosmo/web/controllers/streams.rb', line 9 def index return _table if hx_request? content_for :title, "Streams" ok render("streams/index", layout: true) end |
#info ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cosmo/web/controllers/streams.rb', line 16 def info name = Rack::Utils.unescape(@request.params["name"]) return _info if hx_request? content_for :title, "Streams" ok render("streams/info", { name: name }, layout: true) end |