update to phoenix 1.6
This commit is contained in:
		| @@ -1,35 +0,0 @@ | ||||
| defmodule CanneryWeb.UserSocket do | ||||
|   use Phoenix.Socket | ||||
|  | ||||
|   ## Channels | ||||
|   # channel "room:*", CanneryWeb.RoomChannel | ||||
|  | ||||
|   # Socket params are passed from the client and can | ||||
|   # be used to verify and authenticate a user. After | ||||
|   # verification, you can put default assigns into | ||||
|   # the socket that will be set for all channels, ie | ||||
|   # | ||||
|   #     {:ok, socket |> assign(:user_id, verified_user_id)} | ||||
|   # | ||||
|   # To deny connection, return `:error`. | ||||
|   # | ||||
|   # See `Phoenix.Token` documentation for examples in | ||||
|   # performing token verification on connect. | ||||
|   @impl true | ||||
|   def connect(_params, socket, _connect_info) do | ||||
|     {:ok, socket} | ||||
|   end | ||||
|  | ||||
|   # Socket id's are topics that allow you to identify all sockets for a given user: | ||||
|   # | ||||
|   #     def id(socket), do: "user_socket:#{socket.assigns.user_id}" | ||||
|   # | ||||
|   # Would allow you to broadcast a "disconnect" event and terminate | ||||
|   # all active sockets and channels for a given user: | ||||
|   # | ||||
|   #     CanneryWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{}) | ||||
|   # | ||||
|   # Returning `nil` makes this socket anonymous. | ||||
|   @impl true | ||||
|   def id(_socket), do: nil | ||||
| end | ||||
| @@ -3,6 +3,7 @@ defmodule CanneryWeb.UserAuth do | ||||
|   import Phoenix.Controller | ||||
|  | ||||
|   alias Cannery.Accounts | ||||
|   alias CanneryWeb.{HomeLive} | ||||
|   alias CanneryWeb.Router.Helpers, as: Routes | ||||
|  | ||||
|   # Make the remember me cookie valid for 60 days. | ||||
| @@ -138,7 +139,7 @@ defmodule CanneryWeb.UserAuth do | ||||
|       |> halt() | ||||
|     end | ||||
|   end | ||||
|    | ||||
|  | ||||
|   @doc """ | ||||
|   Used for routes that require the user to be an admin. | ||||
|   """ | ||||
| @@ -149,7 +150,7 @@ defmodule CanneryWeb.UserAuth do | ||||
|       conn | ||||
|       |> put_flash(:error, "You are not authorized to view this page.") | ||||
|       |> maybe_store_return_to() | ||||
|       |> redirect(to: Routes.home_path(conn, :index)) | ||||
|       |> redirect(to: Routes.live_path(conn, HomeLive)) | ||||
|       |> halt() | ||||
|     end | ||||
|   end | ||||
|   | ||||
| @@ -3,7 +3,7 @@ defmodule CanneryWeb.UserRegistrationController do | ||||
|  | ||||
|   alias Cannery.{Accounts, Invites} | ||||
|   alias Cannery.Accounts.User | ||||
|   alias CanneryWeb.UserAuth | ||||
|   alias CanneryWeb.{HomeLive, UserAuth} | ||||
|  | ||||
|   def new(conn, %{"invite" => invite_token}) do | ||||
|     invite = Invites.get_invite_by_token(invite_token) | ||||
| @@ -13,7 +13,7 @@ defmodule CanneryWeb.UserRegistrationController do | ||||
|     else | ||||
|       conn | ||||
|       |> put_flash(:error, "Sorry, this invite was not found or expired") | ||||
|       |> redirect(to: Routes.home_path(CanneryWeb.Endpoint, :index)) | ||||
|       |> redirect(to: Routes.live_path(CanneryWeb.Endpoint, HomeLive)) | ||||
|     end | ||||
|   end | ||||
|  | ||||
| @@ -23,7 +23,7 @@ defmodule CanneryWeb.UserRegistrationController do | ||||
|     else | ||||
|       conn | ||||
|       |> put_flash(:error, "Sorry, public registration is disabled") | ||||
|       |> redirect(to: Routes.home_path(CanneryWeb.Endpoint, :index)) | ||||
|       |> redirect(to: Routes.live_path(CanneryWeb.Endpoint, HomeLive)) | ||||
|     end | ||||
|   end | ||||
|  | ||||
| @@ -41,7 +41,7 @@ defmodule CanneryWeb.UserRegistrationController do | ||||
|     else | ||||
|       conn | ||||
|       |> put_flash(:error, "Sorry, this invite was not found or expired") | ||||
|       |> redirect(to: Routes.home_path(CanneryWeb.Endpoint, :index)) | ||||
|       |> redirect(to: Routes.live_path(CanneryWeb.Endpoint, HomeLive)) | ||||
|     end | ||||
|   end | ||||
|  | ||||
| @@ -51,7 +51,7 @@ defmodule CanneryWeb.UserRegistrationController do | ||||
|     else | ||||
|       conn | ||||
|       |> put_flash(:error, "Sorry, public registration is disabled") | ||||
|       |> redirect(to: Routes.home_path(CanneryWeb.Endpoint, :index)) | ||||
|       |> redirect(to: Routes.live_path(CanneryWeb.Endpoint, HomeLive)) | ||||
|     end | ||||
|   end | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ defmodule CanneryWeb.UserSettingsController do | ||||
|   use CanneryWeb, :controller | ||||
|  | ||||
|   alias Cannery.Accounts | ||||
|   alias CanneryWeb.UserAuth | ||||
|   alias CanneryWeb.{HomeLive, UserAuth} | ||||
|  | ||||
|   plug :assign_email_and_password_changesets | ||||
|  | ||||
| @@ -70,7 +70,7 @@ defmodule CanneryWeb.UserSettingsController do | ||||
|  | ||||
|       conn | ||||
|       |> put_flash(:error, "Your account has been deleted") | ||||
|       |> redirect(to: Routes.home_path(conn, :index)) | ||||
|       |> redirect(to: Routes.live_path(conn, HomeLive)) | ||||
|     else | ||||
|       conn | ||||
|       |> put_flash(:error, "Unable to delete user") | ||||
|   | ||||
| @@ -7,13 +7,9 @@ defmodule CanneryWeb.Endpoint do | ||||
|   @session_options [ | ||||
|     store: :cookie, | ||||
|     key: "_cannery_key", | ||||
|     signing_salt: "fxAnJltS" | ||||
|     signing_salt: "N8eMKwCG" | ||||
|   ] | ||||
|  | ||||
|   socket "/socket", CanneryWeb.UserSocket, | ||||
|     websocket: true, | ||||
|     longpoll: false | ||||
|  | ||||
|   socket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]] | ||||
|  | ||||
|   # Serve at "/" the static files from "priv/static" directory. | ||||
|   | ||||
| @@ -13,7 +13,7 @@ | ||||
|     <li class="flex flex-row justify-center space-x-2"> | ||||
|       <b>Easy to Use:</b> | ||||
|       <p> | ||||
|         Cannery lets you easily keep an eye on your ammo levels after range day | ||||
|         Cannery lets you easily keep an eye on your ammo levels before and after range day | ||||
|       </p> | ||||
|     </li> | ||||
|     <li class="flex flex-row justify-center space-x-2"> | ||||
|   | ||||
| @@ -26,7 +26,7 @@ defmodule CanneryWeb.ModalComponent do | ||||
|  | ||||
|         <%# modal content %> | ||||
|         <div class="w-full flex flex-col space-y-4 justify-center items-center"> | ||||
|           <%= live_component @socket, @component, @opts %> | ||||
|           <%= live_component @component, @opts %> | ||||
|         </div> | ||||
|       </div> | ||||
|     </div> | ||||
|   | ||||
| @@ -24,7 +24,7 @@ defmodule CanneryWeb.Router do | ||||
|   scope "/", CanneryWeb do | ||||
|     pipe_through :browser | ||||
|  | ||||
|     live "/", HomeLive, :index | ||||
|     live "/", HomeLive | ||||
|   end | ||||
|  | ||||
|   ## Authentication routes | ||||
| @@ -94,4 +94,16 @@ defmodule CanneryWeb.Router do | ||||
|     post "/users/confirm", UserConfirmationController, :create | ||||
|     get "/users/confirm/:token", UserConfirmationController, :confirm | ||||
|   end | ||||
|  | ||||
|   # Enables the Swoosh mailbox preview in development. | ||||
|   # | ||||
|   # Note that preview only shows emails that were sent by the same | ||||
|   # node running the Phoenix server. | ||||
|   if Mix.env() == :dev do | ||||
|     scope "/dev" do | ||||
|       pipe_through :browser | ||||
|  | ||||
|       forward "/mailbox", Plug.Swoosh.MailboxPreview | ||||
|     end | ||||
|   end | ||||
| end | ||||
|   | ||||
| @@ -31,11 +31,27 @@ defmodule CanneryWeb.Telemetry do | ||||
|       ), | ||||
|  | ||||
|       # Database Metrics | ||||
|       summary("cannery.repo.query.total_time", unit: {:native, :millisecond}), | ||||
|       summary("cannery.repo.query.decode_time", unit: {:native, :millisecond}), | ||||
|       summary("cannery.repo.query.query_time", unit: {:native, :millisecond}), | ||||
|       summary("cannery.repo.query.queue_time", unit: {:native, :millisecond}), | ||||
|       summary("cannery.repo.query.idle_time", unit: {:native, :millisecond}), | ||||
|       summary("cannery.repo.query.total_time", | ||||
|         unit: {:native, :millisecond}, | ||||
|         description: "The sum of the other measurements" | ||||
|       ), | ||||
|       summary("cannery.repo.query.decode_time", | ||||
|         unit: {:native, :millisecond}, | ||||
|         description: "The time spent decoding the data received from the database" | ||||
|       ), | ||||
|       summary("cannery.repo.query.query_time", | ||||
|         unit: {:native, :millisecond}, | ||||
|         description: "The time spent executing the query" | ||||
|       ), | ||||
|       summary("cannery.repo.query.queue_time", | ||||
|         unit: {:native, :millisecond}, | ||||
|         description: "The time spent waiting for a database connection" | ||||
|       ), | ||||
|       summary("cannery.repo.query.idle_time", | ||||
|         unit: {:native, :millisecond}, | ||||
|         description: | ||||
|           "The time the connection spent waiting before being checked out for the query" | ||||
|       ), | ||||
|  | ||||
|       # VM Metrics | ||||
|       summary("vm.memory.total", unit: {:byte, :kilobyte}), | ||||
|   | ||||
| @@ -2,20 +2,20 @@ | ||||
|   <header class="mb-4 px-8 py-4 w-full bg-primary-400"> | ||||
|     <%= render "topbar.html", assigns %> | ||||
|   </header> | ||||
|    | ||||
| 
 | ||||
|   <div class="mx-8 my-2 flex flex-col space-y-4 text-center"> | ||||
|     <%= if get_flash(@conn, :info) do %> | ||||
|       <p class="alert alert-info" role="alert"> | ||||
|         <%= get_flash(@conn, :info) %> | ||||
|       </p> | ||||
|     <% end %> | ||||
|      | ||||
| 
 | ||||
|     <%= if get_flash(@conn, :error) do %> | ||||
|       <p class="alert alert-danger" role="alert"> | ||||
|         <%= get_flash(@conn, :error) %> | ||||
|       </p> | ||||
|     <% end %> | ||||
|   </div> | ||||
|    | ||||
| 
 | ||||
|   <%= @inner_content %> | ||||
| </main> | ||||
| @@ -1,16 +1,21 @@ | ||||
| <main role="main" class="container min-w-full min-h-full"> | ||||
| 
 | ||||
| <main class="container min-w-full min-h-full"> | ||||
|   <header> | ||||
|     <%= live_component CanneryWeb.Live.Component.Topbar, current_user: assigns[:current_user] %> | ||||
|    | ||||
| 
 | ||||
|     <div class="mx-8 my-2 flex flex-col space-y-4 text-center"> | ||||
|       <%= if live_flash(@flash, :info) do %> | ||||
|         <p class="alert alert-info" role="alert"> | ||||
|         <p class="alert alert-info" role="alert" | ||||
|           phx-click="lv:clear-flash" | ||||
|           phx-value-key="info"> | ||||
|           <%= live_flash(@flash, :info) %> | ||||
|         </p> | ||||
|       <% end %> | ||||
|        | ||||
| 
 | ||||
|       <%= if live_flash(@flash, :error) do %> | ||||
|         <p class="alert alert-danger" role="alert"> | ||||
|         <p class="alert alert-danger" role="alert" | ||||
|           phx-click="lv:clear-flash" | ||||
|           phx-value-key="error"> | ||||
|           <%= live_flash(@flash, :error) %> | ||||
|         </p> | ||||
|       <% end %> | ||||
| @@ -6,8 +6,8 @@ | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"/> | ||||
|     <%= csrf_meta_tag() %> | ||||
|     <%= live_title_tag assigns[:page_title] || "Cannery", suffix: "" %> | ||||
|     <link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/> | ||||
|     <script defer phx-track-static type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script> | ||||
|     <link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")}/> | ||||
|     <script defer phx-track-static type="text/javascript" src={Routes.static_path(@conn, "/js/app.js")}></script> | ||||
|   </head> | ||||
|   <body class="m-0 p-0 min-w-full min-h-full"> | ||||
|     <%= @inner_content %> | ||||
| @@ -1,6 +1,6 @@ | ||||
| <nav role="navigation"> | ||||
|   <div class="flex flex-row justify-between items-center space-x-4"> | ||||
|     <%= link to: Routes.home_path(CanneryWeb.Endpoint, :index) do %> | ||||
|     <%= link to: Routes.live_path(CanneryWeb.Endpoint, HomeLive) do %> | ||||
|       <h1 class="leading-5 text-xl text-white hover:underline">Cannery</h1> | ||||
|     <% end %> | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,12 @@ | ||||
| defmodule CanneryWeb.LayoutView do | ||||
|   use CanneryWeb, :view | ||||
|   alias Cannery.{Accounts} | ||||
|    | ||||
|   alias CanneryWeb.{HomeLive} | ||||
|  | ||||
|   # Phoenix LiveDashboard is available only in development by default, | ||||
|   # so we instruct Elixir to not warn if the dashboard route is missing. | ||||
|   @compile {:no_warn_undefined, {Routes, :live_dashboard_path, 2}} | ||||
|  | ||||
|   def get_title(conn) do | ||||
|     if conn.assigns |> Map.has_key?(:title) do | ||||
|       "Cannery | #{conn.assigns.title}" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user