Migrate from channel to phoenix live view.

Move phoenix config to ui project.
Sync progress on page load.
This commit is contained in:
Pim Kunis 2019-10-23 14:38:11 +02:00
parent e888f1330b
commit ad24ec96ac
26 changed files with 120 additions and 164 deletions

View file

@ -1,25 +1,17 @@
defmodule UiWeb.PageController do
use UiWeb, :controller
alias Phoenix.LiveView
def index(conn, _params) do
conn |> send_resp(204, "")
send_resp(conn, 204, "")
end
def instructions(conn, _params) do
conn |> render(:instructions)
render(conn, :instructions)
end
def morse(conn, _params) do
conn |> render(:morse)
LiveView.Controller.live_render(conn, UiWeb.MorseLive, session: %{})
end
def start(conn, _params) do
response =
case Morse.Server.start_morse() do
:ok -> "Started."
{:error, :already_started} -> "The process is still in progress..."
end
conn |> text(response)
end
end