mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-15 01:14:46 +08:00
Adds Livebook Teams URL and some touch ups (#2120)
This commit is contained in:
parent
5ac14c18bb
commit
6ba0118c2d
6 changed files with 14 additions and 10 deletions
|
@ -25,7 +25,7 @@ config :mime, :types, %{
|
||||||
config :plug_cowboy, :log_exceptions_with_status_code, [407..599]
|
config :plug_cowboy, :log_exceptions_with_status_code, [407..599]
|
||||||
|
|
||||||
config :livebook,
|
config :livebook,
|
||||||
teams_url: "http://localhost:4100",
|
teams_url: "https://teams.livebook.dev",
|
||||||
app_service_name: nil,
|
app_service_name: nil,
|
||||||
app_service_url: nil,
|
app_service_url: nil,
|
||||||
authentication_mode: :token,
|
authentication_mode: :token,
|
||||||
|
|
|
@ -70,6 +70,7 @@ defmodule Livebook.Hubs.TeamClient do
|
||||||
derived_keys = Teams.derive_keys(team.teams_key)
|
derived_keys = Teams.derive_keys(team.teams_key)
|
||||||
|
|
||||||
headers = [
|
headers = [
|
||||||
|
{"x-lb-version", to_string(Application.spec(:livebook, :vsn))},
|
||||||
{"x-user", to_string(team.user_id)},
|
{"x-user", to_string(team.user_id)},
|
||||||
{"x-org", to_string(team.org_id)},
|
{"x-org", to_string(team.org_id)},
|
||||||
{"x-org-key", to_string(team.org_key_id)},
|
{"x-org-key", to_string(team.org_key_id)},
|
||||||
|
|
|
@ -12,6 +12,8 @@ defmodule Livebook.Teams.Connection do
|
||||||
@no_state :no_state
|
@no_state :no_state
|
||||||
@loop_ping_delay 5_000
|
@loop_ping_delay 5_000
|
||||||
|
|
||||||
|
@websocket_messages [:ssl, :tcp, :ssl_closed, :tcp_closed, :ssl_error, :tcp_error]
|
||||||
|
|
||||||
defstruct [:listener, :headers, :http_conn, :websocket, :ref]
|
defstruct [:listener, :headers, :http_conn, :websocket, :ref]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -79,11 +81,8 @@ defmodule Livebook.Teams.Connection do
|
||||||
:keep_state_and_data
|
:keep_state_and_data
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event(:info, {:tcp_closed, _port} = message, @no_state, %__MODULE__{} = data) do
|
def handle_event(:info, message, @no_state, %__MODULE__{} = data)
|
||||||
handle_websocket_message(message, data)
|
when elem(message, 0) in @websocket_messages do
|
||||||
end
|
|
||||||
|
|
||||||
def handle_event(:info, {:tcp, _port, _data} = message, @no_state, %__MODULE__{} = data) do
|
|
||||||
handle_websocket_message(message, data)
|
handle_websocket_message(message, data)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,11 @@ defmodule Livebook.Teams.Requests do
|
||||||
|
|
||||||
defp auth_headers(team) do
|
defp auth_headers(team) do
|
||||||
token = "#{team.user_id}:#{team.org_id}:#{team.org_key_id}:#{team.session_token}"
|
token = "#{team.user_id}:#{team.org_id}:#{team.org_key_id}:#{team.session_token}"
|
||||||
[{"authorization", "Bearer " <> token}]
|
|
||||||
|
[
|
||||||
|
{"x-lb-version", to_string(Application.spec(:livebook, :vsn))},
|
||||||
|
{"authorization", "Bearer " <> token}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp post(path, json, headers \\ []) do
|
defp post(path, json, headers \\ []) do
|
||||||
|
|
|
@ -158,7 +158,7 @@ defmodule LivebookWeb.Hub.Edit.TeamComponent do
|
||||||
language="dockerfile"
|
language="dockerfile"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ol class="text-gray-700">
|
<ol class="text-gray-700 mt-4 space-y-2 list-disc list-inside">
|
||||||
<li>
|
<li>
|
||||||
You must change <code>/path/to/my/notebooks</code> in the template above
|
You must change <code>/path/to/my/notebooks</code> in the template above
|
||||||
to point to a directory with the `.livemd` files you want to deploy
|
to point to a directory with the `.livemd` files you want to deploy
|
||||||
|
|
|
@ -86,7 +86,7 @@ defmodule LivebookWeb.Hub.SecretFormComponent do
|
||||||
|> push_redirect(to: socket.assigns.return_to)}
|
|> push_redirect(to: socket.assigns.return_to)}
|
||||||
else
|
else
|
||||||
{:error, changeset} ->
|
{:error, changeset} ->
|
||||||
{:noreply, assign(socket, changeset: changeset)}
|
{:noreply, assign(socket, changeset: Map.replace!(changeset, :action, :validate))}
|
||||||
|
|
||||||
{:transport_error, error} ->
|
{:transport_error, error} ->
|
||||||
{:noreply,
|
{:noreply,
|
||||||
|
@ -100,7 +100,7 @@ defmodule LivebookWeb.Hub.SecretFormComponent do
|
||||||
changeset =
|
changeset =
|
||||||
%Secret{}
|
%Secret{}
|
||||||
|> Secrets.change_secret(attrs)
|
|> Secrets.change_secret(attrs)
|
||||||
|> Map.put(:action, :validate)
|
|> Map.replace!(:action, :validate)
|
||||||
|
|
||||||
{:noreply, assign(socket, changeset: changeset)}
|
{:noreply, assign(socket, changeset: changeset)}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue