diff --git a/priv/assets/css/ldf.css b/priv/assets/css/ldf.css index 6cb7954..dc42459 100644 --- a/priv/assets/css/ldf.css +++ b/priv/assets/css/ldf.css @@ -97,6 +97,8 @@ input[type="datetime-local"] { color-scheme: dark; } input[type=text]:focus, input[type="datetime-local"]:focus { outline: none; border-color: var(--live-dim); box-shadow: 0 0 0 3px rgba(46,230,166,.12); } input::placeholder { color: var(--faint); } .hint { color: var(--faint); font-size: 11px; margin: 8px 0 0; } +.hint a { color: var(--live); text-decoration: none; border-bottom: 1px dotted var(--live-dim); } +.hint a:hover { border-bottom-style: solid; } .btn { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; diff --git a/src/controllers/ldf_www_controller.erl b/src/controllers/ldf_www_controller.erl index 949711a..e211f7a 100644 --- a/src/controllers/ldf_www_controller.erl +++ b/src/controllers/ldf_www_controller.erl @@ -67,11 +67,11 @@ remove_listener(#{bindings := #{~"callbackid" := CallbackId}}) -> submit_history(Req0) -> case datastar_nova:read_signals(Req0) of {{ok, #{~"type" := Type, ~"value" := Value} = Signals}, _Req} when Value =/= ~"" -> - Timestamp = ldf_format:datetime_to_ms(maps:get(~"timestamp", Signals, ~"")), + Timestamp = maps:get(~"timestamp_ms", Signals, 0), ldf_srv:get_history( thoas:encode(#{type => Type, value => Value, timestamp => Timestamp}) ), - status_patch(~"Request submitted."); + status_patch(~"Request submitted - matching messages appear in the Receiver tab."); _ -> status_patch(~"Target type and value are required.") end. diff --git a/src/ldf_format.erl b/src/ldf_format.erl index 05f9be4..bd7cbc1 100644 --- a/src/ldf_format.erl +++ b/src/ldf_format.erl @@ -1,6 +1,6 @@ -module(ldf_format). --export([pretty_xml/1, html_escape/1, datetime_to_ms/1]). +-export([pretty_xml/1, html_escape/1]). pretty_xml(Xml) -> Spaced = binary:replace(Xml, ~"><", ~">\n<", [global]), @@ -38,20 +38,3 @@ html_escape(Bin) -> Amp = binary:replace(Bin, ~"&", ~"&", [global]), Lt = binary:replace(Amp, ~"<", ~"<", [global]), binary:replace(Lt, ~">", ~">", [global]). - -datetime_to_ms( - <> -) -> - Seconds = - case Rest of - <<":", S:2/binary>> -> binary_to_integer(S); - _ -> 0 - end, - DateTime = { - {binary_to_integer(Y), binary_to_integer(Mo), binary_to_integer(D)}, - {binary_to_integer(H), binary_to_integer(Mi), Seconds} - }, - Epoch = 62167219200, - (calendar:datetime_to_gregorian_seconds(DateTime) - Epoch) * 1000; -datetime_to_ms(_) -> - 0. diff --git a/src/views/history.dtl b/src/views/history.dtl index 0d8c63a..8adfc97 100644 --- a/src/views/history.dtl +++ b/src/views/history.dtl @@ -4,7 +4,7 @@

History submission

Replay stored messages for a target as historic interception, from a given timestamp.

-
+

Submit history request

@@ -13,10 +13,10 @@
- +
-

Replays messages from this point in time onward (UTC).

+

Requires an active listener for this target — add one on the Listeners tab first. Matching messages replay into the Receiver tab, from the chosen local time onward.

 
diff --git a/test/ldf_format_tests.erl b/test/ldf_format_tests.erl index 9c71716..2723720 100644 --- a/test/ldf_format_tests.erl +++ b/test/ldf_format_tests.erl @@ -16,18 +16,3 @@ pretty_xml_with_prolog_test() -> html_escape_test() -> ?assertEqual(~"<a>&b", ldf_format:html_escape(~"&b")). - -datetime_to_ms_with_seconds_test() -> - Expected = - (calendar:datetime_to_gregorian_seconds({{2024, 6, 25}, {15, 0, 30}}) - 62167219200) * - 1000, - ?assertEqual(Expected, ldf_format:datetime_to_ms(~"2024-06-25T15:00:30")). - -datetime_to_ms_without_seconds_test() -> - Expected = - (calendar:datetime_to_gregorian_seconds({{2024, 6, 25}, {15, 0, 0}}) - 62167219200) * - 1000, - ?assertEqual(Expected, ldf_format:datetime_to_ms(~"2024-06-25T15:00")). - -datetime_to_ms_empty_test() -> - ?assertEqual(0, ldf_format:datetime_to_ms(~"")).