-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create app_view component and made app_page a Stripped page
- Loading branch information
1 parent
1ede2d2
commit c0dda6e
Showing
7 changed files
with
57 additions
and
23 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
2 changes: 1 addition & 1 deletion
2
core/systems/feldspar/internal.ex → core/systems/feldspar/_private.ex
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,37 +1,52 @@ | ||
defmodule Systems.Feldspar.AppPage do | ||
alias Systems.Feldspar | ||
use CoreWeb, :live_view | ||
use CoreWeb.Layouts.Stripped.Component, :projects | ||
|
||
import Feldspar.AppView | ||
|
||
@impl true | ||
def mount(%{"id" => app_id}, _session, socket) do | ||
app_url = Feldspar.Public.get_public_url(app_id) <> "/index.html" | ||
|
||
{:ok, assign(socket, app_url: app_url, error: nil)} | ||
{ | ||
:ok, | ||
socket | ||
|> update_menus() | ||
|> assign(app_url: app_url, error: nil) | ||
} | ||
end | ||
|
||
@impl true | ||
def handle_uri(socket), do: socket | ||
|
||
@impl true | ||
def render(assigns) do | ||
~H""" | ||
<div class="flex flex-col w-full h-screen"> | ||
<%!-- Ensure that updates don't alter the hierarchy in front of the iframe. | ||
Changing the preceding siblings of the iframe would result in a reload of the iframe | ||
due to Morphdom (https://github.com/patrick-steele-idem/morphdom/issues/200). | ||
--%> | ||
<div> | ||
<div :if={@error} class="bg-[#ff00ff] text-white p-8 text-xl"><%= @error %></div> | ||
</div> | ||
<div phx-update="ignore" id="web-app-frame" phx-hook="FeldsparApp"> | ||
<iframe src={@app_url} class="grow w-full h-screen"></iframe> | ||
</div> | ||
</div> | ||
<.stripped menus={@menus}> | ||
<.app_view url={@app_url} /> | ||
</.stripped> | ||
""" | ||
end | ||
|
||
@impl true | ||
def handle_event("app_event", params, socket) do | ||
{:noreply, assign(socket, :error, "Unsupported message: #{inspect(params)}")} | ||
def handle_event("app_event", %{"__type__" => type, "json_string" => event}, socket) do | ||
{ | ||
:noreply, | ||
socket |> handle(type, event) | ||
} | ||
end | ||
|
||
@impl true | ||
def handle_event("app_event", event, socket) do | ||
{ | ||
:noreply, | ||
socket |> handle(nil, inspect(event)) | ||
} | ||
end | ||
|
||
defp handle(socket, "CommandSystemDonate", event) do | ||
Frameworks.Pixel.Flash.put_error(socket, "Unsupported donation " <> event) | ||
end | ||
|
||
defp handle(socket, _, event) do | ||
Frameworks.Pixel.Flash.put_error(socket, "Unsupported " <> event) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Systems.Feldspar.AppView do | ||
use CoreWeb, :html | ||
|
||
attr(:url, :string, required: true) | ||
|
||
def app_view(assigns) do | ||
~H""" | ||
<div class="flex flex-col w-full h-full"> | ||
<%!-- Ensure that updates don't alter the hierarchy in front of the iframe. | ||
Changing the preceding siblings of the iframe would result in a reload of the iframe | ||
due to Morphdom (https://github.com/patrick-steele-idem/morphdom/issues/200). | ||
--%> | ||
<div class="w-full h-full" phx-update="ignore" id="web-app-frame" phx-hook="FeldsparApp"> | ||
<iframe src={@url} class="w-full h-full"></iframe> | ||
</div> | ||
</div> | ||
""" | ||
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