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_PASSWORD
- environment variable.
-
-