-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
482 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule Beacon.Content.SiteInfoHandler do | ||
@moduledoc """ | ||
Beacon's representation of a LiveView [handle_info/2](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:handle_info/2) | ||
that applies to all of a site's pages. | ||
This is the Elixir code which will handle messages from other Elixir processes. | ||
> #### Do not create or edit site info handlers manually {: .warning} | ||
> | ||
> Use the public functions in `Beacon.Content` instead. | ||
> The functions in that module guarantee that all dependencies | ||
> are created correctly and all processes are updated. | ||
> Manipulating data manually will most likely result | ||
> in inconsistent behavior and crashes. | ||
""" | ||
|
||
use Beacon.Schema | ||
|
||
import Ecto.Changeset | ||
|
||
@type t :: %__MODULE__{ | ||
id: Ecto.UUID.t(), | ||
site: Beacon.Types.Site.t(), | ||
msg: binary(), | ||
code: binary(), | ||
inserted_at: DateTime.t(), | ||
updated_at: DateTime.t() | ||
} | ||
|
||
schema "beacon_site_info_handlers" do | ||
field :site, Beacon.Types.Site | ||
field :msg, :string | ||
field :code, :string | ||
|
||
timestamps() | ||
end | ||
|
||
@doc false | ||
def changeset(%__MODULE__{} = info_handler, attrs) do | ||
fields = ~w(site msg code)a | ||
|
||
info_handler | ||
|> cast(attrs, fields) | ||
|> validate_required(fields) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
<main class="px-4 py-20 sm:px-6 lg:px-8"> | ||
<div class="mx-auto max-w-6xl"> | ||
<Beacon.Web.CoreComponents.flash kind={:info} title="Success!" flash={@flash} /> | ||
<Beacon.Web.CoreComponents.flash kind={:error} title="Error!" flash={@flash} /> | ||
<Beacon.Web.CoreComponents.flash | ||
id="disconnected" | ||
kind={:error} | ||
title="We can't find the internet" | ||
phx-disconnected={Beacon.Web.CoreComponents.show("#disconnected")} | ||
phx-connected={Beacon.Web.CoreComponents.hide("#disconnected")} | ||
> | ||
Attempting to reconnect <Beacon.Web.CoreComponents.icon name="hero-arrow-path" class="ml-1 w-3 h-3 inline animate-spin" /> | ||
</Beacon.Web.CoreComponents.flash> | ||
<%= @inner_content %> | ||
</div> | ||
</main> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<Beacon.Web.CoreComponents.flash_group id="flash_group" flash={@flash} /> | ||
<%= render_dynamic_layout(assigns) %> |
Oops, something went wrong.