4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'app/controllers/solid_log/ui/streams_controller.rb', line 4
def index
search_params = (params[:filters] || {}).merge(
before_id: params[:before_id],
after_id: params[:after_id],
limit: params[:limit] || 200
)
@search_service = SolidLog::Core::SearchService.new(
search_params,
facet_cache_ttl: SolidLog::UI.configuration.facet_cache_ttl
)
@entries = SolidLog.without_logging do
@search_service.search
end
@available_filters = SolidLog.without_logging do
@search_service.available_facets
end
@current_filters = current_filters
@timeline_data = if (params[:after_id].present? || params[:before_id].present?) && !params[:timeline_only].present?
{ buckets: [] }
else
SolidLog.without_logging do
generate_timeline_data
end
end
respond_to do |format|
format.html
format.turbo_stream do
if params[:timeline_only].present?
render turbo_stream: [
turbo_stream.replace("timeline-container", partial: "timeline", locals: { timeline_data: @timeline_data, current_filters: @current_filters })
]
elsif params[:before_id].present?
if @entries.any?
render turbo_stream: [
turbo_stream.prepend("log-stream-content", partial: "log_entries", locals: { entries: @entries, query: @current_filters[:query] })
]
else
head :no_content
end
elsif params[:after_id].present?
if @entries.any?
render turbo_stream: [
turbo_stream.append("log-stream-content", partial: "log_entries", locals: { entries: @entries, query: @current_filters[:query] })
]
else
head :no_content
end
else
render turbo_stream: [
turbo_stream.replace("log-stream-content", partial: "log_stream_content", locals: { entries: @entries, query: @current_filters[:query] }),
turbo_stream.replace("timeline-container", partial: "timeline", locals: { timeline_data: @timeline_data, current_filters: @current_filters }),
turbo_stream.append("toast-container", partial: "solid_log/ui/shared/toast_message", locals: { message: "Jumped to live - showing latest logs", type: "success" })
]
end
end
end
end
|