From 8b9c3445776aca88f82308b74e1f1c913883b930 Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Wed, 29 May 2024 15:25:05 -0400 Subject: [PATCH] Show a table of servers --- .../components/layouts/app.html.heex | 27 ++++---- .../components/layouts/root.html.heex | 2 +- lib/chronoscope_web/live/index_live.ex | 17 ++--- lib/chronoscope_web/live/index_live.html.heex | 66 +++++++++++++++++-- lib/chronoscope_web/router.ex | 8 +-- 5 files changed, 80 insertions(+), 40 deletions(-) diff --git a/lib/chronoscope_web/components/layouts/app.html.heex b/lib/chronoscope_web/components/layouts/app.html.heex index 0997ae9..cc5a745 100644 --- a/lib/chronoscope_web/components/layouts/app.html.heex +++ b/lib/chronoscope_web/components/layouts/app.html.heex @@ -1,28 +1,25 @@
-
-
- - +
+
+ + Chronoscope -

- v<%= Application.spec(:phoenix, :vsn) %> +

+ v<%= Application.spec(:chronoscope, :vsn) %>

-
-
+
<.flash_group flash={@flash} /> <%= @inner_content %>
diff --git a/lib/chronoscope_web/components/layouts/root.html.heex b/lib/chronoscope_web/components/layouts/root.html.heex index 9032ef4..156dd6f 100644 --- a/lib/chronoscope_web/components/layouts/root.html.heex +++ b/lib/chronoscope_web/components/layouts/root.html.heex @@ -11,7 +11,7 @@ - + <%= @inner_content %> diff --git a/lib/chronoscope_web/live/index_live.ex b/lib/chronoscope_web/live/index_live.ex index d92d539..de8ec66 100644 --- a/lib/chronoscope_web/live/index_live.ex +++ b/lib/chronoscope_web/live/index_live.ex @@ -1,21 +1,16 @@ defmodule ChronoscopeWeb.IndexLive do use ChronoscopeWeb, :live_view - @topic "test" + alias Chronoscope.NTS + + @topic "nts-servers" def mount(_params, _session, socket) do ChronoscopeWeb.Endpoint.subscribe(@topic) - ChronoscopeWeb.Endpoint.broadcast_from(self(), @topic, "", %{temperature: 100}) - {:ok, assign(socket, :temperature, 100)} + {:ok, assign(socket, %{servers: NTS.list()})} end - def handle_event("inc_temperature", _params, socket) do - updated = socket.assigns.temperature + 1 - ChronoscopeWeb.Endpoint.broadcast_from(self(), @topic, "", %{temperature: updated}) - {:noreply, assign(socket, :temperature, updated)} - end - - def handle_info(%{topic: @topic, payload: state}, socket) do - {:noreply, assign(socket, state)} + def handle_info(%{topic: @topic, payload: servers}, socket) do + {:noreply, assign(socket, %{servers: servers})} end end diff --git a/lib/chronoscope_web/live/index_live.html.heex b/lib/chronoscope_web/live/index_live.html.heex index c938938..cc7b4c5 100644 --- a/lib/chronoscope_web/live/index_live.html.heex +++ b/lib/chronoscope_web/live/index_live.html.heex @@ -1,6 +1,60 @@ -
- Live! -
- Current temperature: <%= @temperature %>°F - -
+ + + + + + + + + + + + + <% {status, response} = server.key_establishment_response %> + + <%= if (status == :ok) do %> + + + + + + + <% else %> + + + + + + <% end %> + + +
+ Host + + Status + + Algorithm + + Cookies + + Cookie Length +
+ <%= server.server.host %>:<%= server.server.port %> + + <%= status %> + + <%= Enum.at(response.aead_algorithms, 0) %> + + <%= length(response.cookies) %> + + <%= response.cookie_length %> + + <%= server.server.host %>:<%= server.server.port %> + + + <%= status %> + + <%= response %> + + + - - -
diff --git a/lib/chronoscope_web/router.ex b/lib/chronoscope_web/router.ex index a6b3e48..d6cac2d 100644 --- a/lib/chronoscope_web/router.ex +++ b/lib/chronoscope_web/router.ex @@ -14,16 +14,10 @@ defmodule ChronoscopeWeb.Router do plug :accepts, ["json"] end - scope "/test", ChronoscopeWeb do - pipe_through :browser - - live "/", IndexLive - end - scope "/", ChronoscopeWeb do pipe_through :browser - get "/", PageController, :home + live "/", IndexLive end scope "/api/v1", ChronoscopeWeb.API.V1 do