Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output panel #2109

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
aba0b73
Add output panel
jannikbecher Jul 25, 2023
af32c3d
Add add/remove output from output panel functionality
jannikbecher Jul 25, 2023
e5798a7
Apply suggestions
jannikbecher Jul 25, 2023
53038a5
Hide add/remove button when output already on output_panel
jannikbecher Jul 25, 2023
6a1b59f
Apply suggestion
jannikbecher Jul 25, 2023
8318200
Added functionality to reorder the output panel rows
jannikbecher Jul 26, 2023
dfef58e
Remove whole row when moved item is the only item in the row
jannikbecher Jul 26, 2023
18a03f7
Fix not refreshing bug
jannikbecher Jul 26, 2023
b7d46b9
Make output panel independant scrollable from notebook
jannikbecher Jul 26, 2023
d2fb3ea
Add drag element
jannikbecher Jul 26, 2023
9811b7d
Move output_panel to own file
jannikbecher Jul 27, 2023
716a49a
Add multi column functionality
jannikbecher Jul 27, 2023
c79de30
Fix bug not able to move one item up into new row
jannikbecher Jul 27, 2023
0bf5db5
Restructure js file and fix same bugs
jannikbecher Jul 27, 2023
df921eb
Handle iframes correctly in output panel
jannikbecher Jul 28, 2023
e7797c5
Fix iframe not repositioning
jannikbecher Jul 28, 2023
1a3a746
Bug fixes..
jannikbecher Jul 28, 2023
d9fdb48
Add deployment
jannikbecher Jul 28, 2023
531418c
Fix embedded scroll behaviour. Still vertical scroll though
jannikbecher Jul 28, 2023
8225450
Restrucutre app_session data_view to not always recalc for all view t…
jannikbecher Jul 28, 2023
b6f91c9
Fix some warnings
jannikbecher Jul 28, 2023
9acd116
Fix input_views
jannikbecher Jul 28, 2023
c553cab
Remove output from output panel when cell is removed
jannikbecher Jul 29, 2023
6bcd42c
Updated tests, fixed some bugs
jannikbecher Jul 29, 2023
ad63d14
Fix bug when moving item to same location
jannikbecher Jul 29, 2023
117c8d8
Only show move to output panel button when cell is evaluated
jannikbecher Jul 29, 2023
4b35310
Reposition iframes without timeout
jannikbecher Jul 29, 2023
34e283a
Restructure drop hooks and fix idrame hover
jannikbecher Jul 29, 2023
8170ee7
removed header from output panel, fixed warning
jannikbecher Jul 29, 2023
7bae074
Reposition iframe when output item is removed from panel
jannikbecher Jul 30, 2023
214edb0
UI: Show iframe content while dragging
jannikbecher Jul 30, 2023
d3e8922
Merge branch 'main' into jb-output-panel
jannikbecher Aug 15, 2023
3a48ecc
Fix warnings
jannikbecher Aug 15, 2023
2cbe926
Improve layout
jannikbecher Aug 15, 2023
be313bf
Add app_menu to deployed output panel
jannikbecher Aug 15, 2023
76583a2
Fix warning
jannikbecher Aug 15, 2023
0899d07
Fix messed up session_live styles
jannikbecher Aug 16, 2023
c22ed52
Remove duplicate
jannikbecher Aug 16, 2023
c6a37f2
Remove test warnings
jannikbecher Aug 31, 2023
79861f3
Merge branch 'main' into jb-output-panel
jannikbecher Aug 31, 2023
6ce9da5
move send to output button before link button
jannikbecher Sep 1, 2023
6b88be2
add evaluate cell functionality to output panel
jannikbecher Sep 1, 2023
1c8731c
WIP
jannikbecher Sep 1, 2023
8fa6761
WIP
jannikbecher Sep 2, 2023
7a38d25
Fix dragging issues
jannikbecher Sep 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/livebook/notebook.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Livebook.Notebook do

alias Livebook.Notebook.{Section, Cell, AppSettings}
alias Livebook.Utils.Graph
import Livebook.Utils, only: [access_by_id: 1]
import Livebook.Utils, only: [access_by_id: 1, access_by_id: 2]

@type t :: %__MODULE__{
name: String.t(),
Expand Down Expand Up @@ -74,9 +74,8 @@ defmodule Livebook.Notebook do
@type output_panel_row :: %{items: list(output_panel_item)}

@type output_panel_item :: %{
id: Livebook.Utils.id(),
width: 1..12,
outputs: list(Cell.indexed_output())
cell_id: Livebook.Utils.id(),
width: 1..12
}

@version "1.0"
Expand Down Expand Up @@ -112,8 +111,7 @@ defmodule Livebook.Notebook do
"""
@spec add_output_to_output_panel(t(), Cell.id()) :: t()
def add_output_to_output_panel(notebook, cell_id) do
{:ok, cell, _section} = fetch_cell_and_section(notebook, cell_id)
row = %{items: [%{id: cell_id, width: 12, outputs: cell.outputs}]}
row = %{items: [%{cell_id: cell_id, width: 12}]}
put_in(notebook.output_panel.rows, notebook.output_panel.rows ++ [row])
end

Expand All @@ -128,7 +126,7 @@ defmodule Livebook.Notebook do
Access.key(:rows),
Access.all(),
Access.key(:items),
access_by_id(cell_id)
access_by_id(cell_id, :cell_id)
])

notebook
Expand Down Expand Up @@ -159,7 +157,7 @@ defmodule Livebook.Notebook do
Access.all(),
Access.key(:items),
Access.all(),
Access.key(:id)
Access.key(:cell_id)
])
|> List.flatten()
end
Expand Down
3 changes: 1 addition & 2 deletions lib/livebook/session/data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ defmodule Livebook.Session.Data do
end

def apply_operation(data, {:add_output_to_output_panel, _client_id, cell_id}) do
with {:ok, cell, _section} <- Notebook.fetch_cell_and_section(data.notebook, cell_id),
eval_info <- data.cell_infos[cell_id].eval,
with eval_info <- data.cell_infos[cell_id].eval,
true <- eval_info.validity == :evaluated,
false <- cell_id in Notebook.output_panel_ids(data.notebook) do
data
Expand Down
8 changes: 4 additions & 4 deletions lib/livebook/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ defmodule Livebook.Utils do
** (RuntimeError) Livebook.Utils.access_by_id/1 expected a list, got: %{}

"""
@spec access_by_id(term()) ::
@spec access_by_id(term(), atom()) ::
Access.access_fun(data :: struct() | map(), current_value :: term())
def access_by_id(id) do
def access_by_id(id, field \\ :id) do
fn
:get, data, next when is_list(data) ->
data
|> Enum.find(fn item -> item.id == id end)
|> Enum.find(fn item -> Map.get(item, field) == id end)
jannikbecher marked this conversation as resolved.
Show resolved Hide resolved
|> next.()

:get_and_update, data, next when is_list(data) ->
case Enum.split_while(data, fn item -> item.id != id end) do
case Enum.split_while(data, fn item -> Map.get(item, field) != id end) do
{prev, [item | cons]} ->
case next.(item) do
{get, update} ->
Expand Down
14 changes: 11 additions & 3 deletions lib/livebook_web/live/session_live/external_window_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ defmodule LivebookWeb.SessionLive.ExternalWindowLive do

%{
notebook_name: data.notebook.name,
output_panel: data.notebook.output_panel
output_view: update_in(data.notebook.output_panel, [
Access.key(:rows),
Access.all(),
Access.key(:items),
Access.all()
], fn item ->
{:ok, cell, _section} = Notebook.fetch_cell_and_section(data.notebook, item.cell_id)
Map.put(item, :outputs, cell.outputs)
end)
}
end

Expand All @@ -71,15 +79,15 @@ defmodule LivebookWeb.SessionLive.ExternalWindowLive do
</h1>
</div>
<div class="grid grid-cols-12">
<%= for output_row <- @data_view.output_panel.rows do %>
<%= for output_row <- @data_view.output_view.rows do %>
<div :for={item <- output_row.items} class="grid col-span-12">
<LivebookWeb.Output.outputs
outputs={item.outputs}
dom_id_map={%{}}
session_id={@session.id}
session_pid={@session.pid}
client_id={@client_id}
cell_id={item.id}
cell_id={item.cell_id}
input_views={%{}}
/>
</div>
Expand Down