Packages
livebook
0.12.1
0.19.8
0.19.7
0.19.6
0.19.5
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.6
0.18.5
0.18.4
0.18.3
0.18.2
0.18.1
0.18.0
0.17.3
0.17.2
0.17.1
0.17.0
0.16.4
0.16.3
0.16.2
0.16.1
0.16.0
0.15.5
0.15.4
0.15.3
0.15.2
0.15.1
0.15.0
0.14.7
0.14.6
0.14.5
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.14.0-rc.1
0.14.0-rc.0
0.13.3
0.13.2
0.13.1
0.13.0
0.12.1
0.12.0
0.11.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.0
0.9.3
0.9.2
0.9.1
0.9.0
0.8.2
0.8.1
0.8.0
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.2
0.3.1
0.3.0
0.2.3
0.2.2
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
Automate code & data workflows with interactive notebooks
Current section
Files
Jump to
Current section
Files
lib/livebook_web/live/apps_live.ex
defmodule LivebookWeb.AppsLive do
use LivebookWeb, :live_view
@impl true
def mount(_params, _session, socket) do
if connected?(socket) do
Livebook.Apps.subscribe()
end
apps = Livebook.Apps.list_apps()
empty_apps_path? = Livebook.Apps.empty_apps_path?()
{:ok, assign(socket, apps: apps, empty_apps_path?: empty_apps_path?)}
end
@impl true
def render(assigns) do
~H"""
<div class="h-full flex flex-col overflow-y-auto">
<div class="px-4 py-3 flex items-center justify-between">
<div class="w-10 h-10">
<.link navigate={~p"/"}>
<img src={~p"/images/logo.png"} height="40" widthz="40" alt="logo livebook" />
</.link>
</div>
<div>
<.link navigate={~p"/apps-dashboard"} class="flex items-center text-blue-600">
<span class="font-semibold">Dashboard</span>
<.remix_icon icon="arrow-right-line" class="align-middle ml-1" />
</.link>
</div>
</div>
<div class="w-full max-w-screen-lg px-4 md:px-20 py-4 mx-auto">
<div class="flex flex-col items-center">
<h1 class="text-2xl text-gray-800 font-medium">
Apps
</h1>
<div :if={@apps != []} class="w-full mt-5 max-w-[400px]">
<div class="w-full flex flex-col space-y-4">
<.link
:for={app <- apps_listing(@apps)}
navigate={~p"/apps/#{app.slug}"}
class="px-4 py-3 border border-gray-200 rounded-xl text-gray-800 pointer hover:bg-gray-50 flex items-center justify-between"
>
<span class="font-semibold"><%= app.notebook_name %></span>
<.remix_icon :if={not app.public?} icon="lock-password-line" />
</.link>
</div>
</div>
<div
:if={@apps == [] and not @empty_apps_path?}
class="mt-5 flex flex-col w-full max-w-[400px]"
>
<.no_entries :if={@apps == []}>
No apps running.
</.no_entries>
</div>
<div :if={@apps == [] and @empty_apps_path?} class="mt-5 text-gray-600">
<div>
No app notebooks found. Follow these steps to list your apps here:
</div>
<ol class="mt-4 pl-4 flex flex-col space-y-1 list-decimal list-inside">
<li>
Open a notebook
</li>
<li>
Click <.remix_icon icon="rocket-line" class="align-baseline text-lg" />
in the sidebar and configure the app as public
</li>
<li>
Save the notebook to the
<span class="font-medium"><%= Livebook.Config.apps_path() %></span>
folder
</li>
<li>
Relaunch your Livebook app
</li>
</ol>
</div>
</div>
</div>
</div>
"""
end
@impl true
def handle_info({type, _app} = event, socket)
when type in [:app_created, :app_updated, :app_closed] do
{:noreply, update(socket, :apps, &LivebookWeb.AppHelpers.update_app_list(&1, event))}
end
def handle_info(_message, socket), do: {:noreply, socket}
defp apps_listing(apps) do
Enum.sort_by(apps, & &1.notebook_name)
end
end