@@ -8,7 +8,6 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
88 import LogflareWeb.ModalLiveHelpers
99
1010 alias Logflare.DateTimeUtils
11- alias Logflare.Lql
1211 alias Logflare.Sources.Source
1312 alias Logflare.Lql
1413 alias Phoenix.LiveView.JS
@@ -32,14 +31,7 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
3231 < . log_event :for = { log <- @ search_op_log_events . rows } timezone = { @ search_timezone } log_event = { log } select_fields = { build_select_fields ( @ search_op ) } >
3332 { log . body [ "event_message" ] }
3433 <: actions phx-no-format >
35- < . link phx-click = "show_modal "
36- phx-value-event-id = { log . id }
37- class = "tw-text-[0.65rem] "
38- phx-value-log-event-timestamp = { log . body [ "timestamp" ] }
39- phx-value-lql = { @ querystring }
40- >
41- < span > view2</ span >
42- </ . link >
34+ < div class = { if ( Enum . any? ( @ select_fields ) , do: "tw-ml-[13rem] tw-pb-1.5" , else: "tw-inline" ) } >
4335 < . modal_link
4436 component = { LogflareWeb.Search.LogEventViewerComponent }
4537 class = "tw-text-[0.65rem] "
@@ -59,7 +51,7 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
5951 modal_id = { :log_event_context_viewer }
6052 title = "View Event Context "
6153 phx-value-log-event-id = { log . id }
62- phx-value-source-id = { @ search_op . source . id }
54+ phx-value-source-id = { @ search_op . source . id }
6355 phx-value-log-event-timestamp = { log . body [ "timestamp" ] }
6456 phx-value-timezone = { @ search_timezone }
6557 phx-value-querystring = { @ querystring }
@@ -72,83 +64,23 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
7264 phx-click = {
7365 JS . dispatch ( "logflare:copy-to-clipboard" ,
7466 detail: % {
75- text: " #{ LogflareWeb.SearchLive.LogEventComponents . formatted_timestamp ( log , assigns [ :search_timezone ] ) } #{ log . body [ "event_message" ] } "
67+ text: formatted_for_clipboard ( log , @ search_op )
7668 }
7769 )
7870 }
7971 data-toggle = "tooltip "
8072 data-placement = "top "
8173 title = "Copy to clipboard "
8274 > copy</ . link >
83- < . log_event_permalink log_event_id = { log . id } timestamp = { log . body [ "timestamp" ] } source = { @ search_op . source } lql = { @ querystring } class = "tw-text-[0.65rem] group-hover:tw-visible tw-invisible " />
75+ < . log_event_permalink log_event_id = { log . id } timestamp = { log . body [ "timestamp" ] } source = { @ search_op . source } lql = { lql_with_recommended_fields ( @ search_op . lql_rules , log , @ search_op . source ) } class = "tw-text-[0.65rem] group-hover:tw-visible tw-invisible " />
76+ </ div >
8477 </: actions >
8578 </ . log_event >
8679 </ ul >
8780 </ div >
8881 """
8982 end
9083
91- attr :log , :any , required: true
92- attr :recommended_query , :any , required: true
93- attr :tailing? , :boolean , default: false
94- attr :source , :any , required: true
95- attr :search_timezone , :string , required: true
96- attr :querystring , :string , required: true
97-
98- def logs_list_actions ( assigns ) do
99- ~H"""
100- <%= live_modal_show_link (
101- component: LogflareWeb.Search.LogEventViewerComponent ,
102- class: "tw-text-[0.65rem]" ,
103- modal_id: :log_event_viewer ,
104- title: "Log Event" ,
105- phx_value_log_event_id: @ log . id ,
106- phx_value_log_event_timestamp: @ log . body [ "timestamp" ] ,
107- phx_value_lql: @ recommended_query
108- ) do %>
109- < span > view</ span >
110- <% end %>
111- <%= live_modal_show_link (
112- component: LogflareWeb.SearchLive.EventContextComponent ,
113- click: JS . push ( "soft_pause" ) ,
114- close:
115- if ( @ tailing? ,
116- do:
117- JS . push ( "soft_play" , target: "#source-logs-search-control" )
118- |> JS . push ( "close" ) ,
119- else: nil
120- ) ,
121- class: "tw-text-[0.65rem]" ,
122- modal_id: :log_event_context_viewer ,
123- title: "View Event Context" ,
124- phx_value_log_event_id: @ log . id ,
125- phx_value_source_id: @ source . id ,
126- phx_value_log_event_timestamp: @ log . body [ "timestamp" ] ,
127- phx_value_timezone: @ search_timezone ,
128- phx_value_querystring: @ querystring
129- ) do %>
130- < span > context</ span >
131- <% end %>
132-
133- < . link
134- class = "tw-text-[0.65rem] group-hover:tw-visible tw-invisible "
135- phx-click = {
136- JS . dispatch ( "logflare:copy-to-clipboard" ,
137- detail: % {
138- text: "#{ formatted_timestamp ( @ log , @ search_timezone ) } #{ @ log . body [ "event_message" ] } "
139- }
140- )
141- }
142- data-toggle = "tooltip "
143- data-placement = "top "
144- title = "Copy to clipboard "
145- >
146- copy
147- </ . link >
148- < . log_event_permalink log_event_id = { @ log . id } timestamp = { @ log . body [ "timestamp" ] } source = { @ source } lql = { @ recommended_query } class = "tw-text-[0.65rem] group-hover:tw-visible tw-invisible " />
149- """
150- end
151-
15284 @ spec lql_with_recommended_fields ( Lql.Rules . lql_rules ( ) , Logflare.LogEvent . t ( ) , Source . t ( ) ) ::
15385 String . t ( )
15486 def lql_with_recommended_fields ( lql_rules , event , source ) do
@@ -262,7 +194,7 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
262194 <%= for field <- @ select_fields do %>
263195 < div class = "tw-text-neutral-200 tw-flex tw-leading-6 " >
264196 < div class = "tw-w-[13rem] tw-text-right " >
265- < span class = "tw-w-fit tw-px-1 tw-py-0.5 tw-bg-neutral-500/50 tw-text-white tw-mr-2 " > { field . display } </ span >
197+ < span class = "tw-whitespace-nowrap tw- w-fit tw-px-1 tw-py-0.5 tw-bg-neutral-600 tw-text-white tw-mr-2 " > { truncate_display ( field . display ) } </ span >
266198 </ div >
267199 < span class = "tw-text-white " > { get_field_value ( @ log_event . body , field . key ) } </ span >
268200 </ div >
@@ -290,7 +222,8 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
290222 |> Enum . map ( fn
291223 % { path: path , alias: nil } ->
292224 key = String . replace ( path , "." , "_" )
293- % { display: path , key: key }
225+ display = path |> String . split ( "." ) |> List . last ( )
226+ % { display: display , key: key }
294227
295228 % { path: _path , alias: alias } ->
296229 % { display: alias , key: alias }
@@ -299,4 +232,12 @@ defmodule LogflareWeb.SearchLive.LogEventComponents do
299232 end
300233
301234 defp build_select_fields ( _ ) , do: [ ]
235+
236+ defp truncate_display ( display ) when is_binary ( display ) do
237+ if String . length ( display ) > 23 do
238+ ( String . slice ( display , 0 , 23 ) <> "…" ) |> raw ( )
239+ else
240+ display
241+ end
242+ end
302243end
0 commit comments