diff --git a/lib/livebook/session.ex b/lib/livebook/session.ex index fc3e586d3..68bc67cdd 100644 --- a/lib/livebook/session.ex +++ b/lib/livebook/session.ex @@ -115,7 +115,8 @@ defmodule Livebook.Session do @type app_info :: %{ slug: String.t(), status: Data.app_status(), - registered: boolean() + registered: boolean(), + public?: boolean() } @typedoc """ @@ -1529,7 +1530,8 @@ defmodule Livebook.Session do %{ slug: state.data.notebook.app_settings.slug, status: state.data.app_data.status, - registered: state.data.app_data.registered + registered: state.data.app_data.registered, + public?: state.data.notebook.app_settings.access_type == :public } end } diff --git a/lib/livebook_web/controllers/auth_controller.ex b/lib/livebook_web/controllers/auth_controller.ex index 29fb8d41b..858454b78 100644 --- a/lib/livebook_web/controllers/auth_controller.ex +++ b/lib/livebook_web/controllers/auth_controller.ex @@ -22,7 +22,12 @@ defmodule LivebookWeb.AuthController do end def index(conn, _params) do - render(conn, "index.html", errors: [], auth_mode: Livebook.Config.auth_mode()) + render(conn, "index.html", + errors: [], + auth_mode: Livebook.Config.auth_mode(), + app_sessions: app_sessions(), + empty_apps_path?: empty_apps_path?() + ) end def authenticate(conn, %{"password" => password}) do @@ -47,7 +52,13 @@ defmodule LivebookWeb.AuthController do defp render_form_error(conn, auth_mode) do errors = [{"%{auth_mode} is invalid", [auth_mode: auth_mode]}] - render(conn, "index.html", errors: errors, auth_mode: auth_mode) + + render(conn, "index.html", + errors: errors, + auth_mode: auth_mode, + app_sessions: app_sessions(), + empty_apps_path?: empty_apps_path?() + ) end defp redirect_to(conn) do @@ -63,4 +74,19 @@ defmodule LivebookWeb.AuthController do end) |> halt() end + + defp app_sessions() do + Livebook.Sessions.list_sessions() + |> Enum.filter(&(&1.mode == :app and &1.app_info.public? and &1.app_info.registered)) + |> Enum.sort_by(& &1.notebook_name) + end + + defp empty_apps_path?() do + if path = Livebook.Config.apps_path() do + pattern = Path.join([path, "**", "*.livemd"]) + Path.wildcard(pattern) == [] + else + false + end + end end diff --git a/lib/livebook_web/controllers/auth_html/index.html.heex b/lib/livebook_web/controllers/auth_html/index.html.heex index 9616eabb9..a7605c64e 100644 --- a/lib/livebook_web/controllers/auth_html/index.html.heex +++ b/lib/livebook_web/controllers/auth_html/index.html.heex @@ -1,53 +1,103 @@ -
-
- - livebook - -
- Authentication required -
+
+
+
+ + livebook + +
+ Authentication required +
-
- - Type password to access the Livebook. - - - Please check out the console for authentication URL or type the token directly - here.
To use password authentication, set the LIVEBOOK_PASSWORD - environment variable. -
-
-
-
- -
- - -
+ +
+ + +
+ + + +
+ + +
+
+
+ +
+
+
+ Public apps +
+
+ <.link + :for={session <- @app_sessions} + navigate={~p"/apps/#{session.app_info.slug}"} + class="px-4 py-3 border border-gray-200 rounded-xl text-gray-800 text-lg pointer hover:bg-gray-50 flex justify-between" + > + <%= session.notebook_name %> + <.remix_icon icon="arrow-right-line" class="" /> + +
+
+
+ No app notebooks found. To list your apps here follow these steps:
- - +
    +
  1. + Open a notebook +
  2. +
  3. + Click <.remix_icon icon="rocket-line" class="align-sub text-lg" /> + in the sidebar, configure the app and make sure it is public +
  4. +
  5. + Place the notebook in the + <%= Livebook.Config.apps_path() %> + folder +
  6. +
  7. + Relaunch your Livebook app +
  8. +
+