-
Notifications
You must be signed in to change notification settings - Fork 460
Add output panel #2109
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
Open
jannikbecher
wants to merge
45
commits into
livebook-dev:main
Choose a base branch
from
jannikbecher:jb-output-panel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add output panel #2109
Changes from 18 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
aba0b73
Add output panel
jannikbecher af32c3d
Add add/remove output from output panel functionality
jannikbecher e5798a7
Apply suggestions
jannikbecher 53038a5
Hide add/remove button when output already on output_panel
jannikbecher 6a1b59f
Apply suggestion
jannikbecher 8318200
Added functionality to reorder the output panel rows
jannikbecher dfef58e
Remove whole row when moved item is the only item in the row
jannikbecher 18a03f7
Fix not refreshing bug
jannikbecher b7d46b9
Make output panel independant scrollable from notebook
jannikbecher d2fb3ea
Add drag element
jannikbecher 9811b7d
Move output_panel to own file
jannikbecher 716a49a
Add multi column functionality
jannikbecher c79de30
Fix bug not able to move one item up into new row
jannikbecher 0bf5db5
Restructure js file and fix same bugs
jannikbecher df921eb
Handle iframes correctly in output panel
jannikbecher e7797c5
Fix iframe not repositioning
jannikbecher 1a3a746
Bug fixes..
jannikbecher d9fdb48
Add deployment
jannikbecher 531418c
Fix embedded scroll behaviour. Still vertical scroll though
jannikbecher 8225450
Restrucutre app_session data_view to not always recalc for all view t…
jannikbecher b6f91c9
Fix some warnings
jannikbecher 9acd116
Fix input_views
jannikbecher c553cab
Remove output from output panel when cell is removed
jannikbecher 6bcd42c
Updated tests, fixed some bugs
jannikbecher ad63d14
Fix bug when moving item to same location
jannikbecher 117c8d8
Only show move to output panel button when cell is evaluated
jannikbecher 4b35310
Reposition iframes without timeout
jannikbecher 34e283a
Restructure drop hooks and fix idrame hover
jannikbecher 8170ee7
removed header from output panel, fixed warning
jannikbecher 7bae074
Reposition iframe when output item is removed from panel
jannikbecher 214edb0
UI: Show iframe content while dragging
jannikbecher d3e8922
Merge branch 'main' into jb-output-panel
jannikbecher 3a48ecc
Fix warnings
jannikbecher 2cbe926
Improve layout
jannikbecher be313bf
Add app_menu to deployed output panel
jannikbecher 76583a2
Fix warning
jannikbecher 0899d07
Fix messed up session_live styles
jannikbecher c22ed52
Remove duplicate
jannikbecher c6a37f2
Remove test warnings
jannikbecher 79861f3
Merge branch 'main' into jb-output-panel
jannikbecher 6ce9da5
move send to output button before link button
jannikbecher 6b88be2
add evaluate cell functionality to output panel
jannikbecher 1c8731c
WIP
jannikbecher 8fa6761
WIP
jannikbecher 7a38d25
Fix dragging issues
jannikbecher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { getAttributeOrDefault, parseBoolean } from "../lib/attribute"; | ||
/** | ||
* A hook for external windows. | ||
*/ | ||
const ExternalWindow = { | ||
mounted() { | ||
this.props = this.getProps(); | ||
|
||
if (!this.props.isWindowEmbedded) { | ||
this.handleBeforeUnloadEvent = this.handleBeforeUnloadEvent.bind(this); | ||
window.addEventListener("beforeunload", this.handleBeforeUnloadEvent); | ||
this.getElement("external-window-close-button").addEventListener( | ||
"click", | ||
(event) => this.handleExternalWindowCloseClick() | ||
); | ||
this.getElement("external-window-popin-button").addEventListener( | ||
"click", | ||
(event) => this.handleExternalWindowPopinClick() | ||
); | ||
} | ||
}, | ||
updated() { | ||
this.props = this.getProps(); | ||
}, | ||
getProps() { | ||
return { | ||
isWindowEmbedded: this.el.hasAttribute("data-window-embedded"), | ||
}; | ||
}, | ||
handleBeforeUnloadEvent(event) { | ||
this.sendToParent("external_window_popin_clicked"); | ||
}, | ||
handleExternalWindowCloseClick() { | ||
window.removeEventListener("beforeunload", this.handleBeforeUnloadEvent); | ||
this.sendToParent("external_window_close_clicked"); | ||
}, | ||
handleExternalWindowPopinClick() { | ||
window.removeEventListener("beforeunload", this.handleBeforeUnloadEvent); | ||
this.sendToParent("external_window_popin_clicked"); | ||
}, | ||
getElement(name) { | ||
return document.querySelector(`[data-el-${name}]`); | ||
}, | ||
sendToParent(message) { | ||
window.opener.postMessage(message, window.location.origin); | ||
}, | ||
}; | ||
|
||
export default ExternalWindow; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { | ||
getAttributeOrThrow, | ||
getAttributeOrDefault, | ||
parseInteger, | ||
} from "../lib/attribute"; | ||
import { globalPubSub } from "../lib/pub_sub"; | ||
/** | ||
* A hook for the output panel. | ||
*/ | ||
|
||
const OutputPanel = { | ||
mounted() { | ||
this.props = this.getProps(); | ||
this.isDragging = false; | ||
this.draggedEl = null; | ||
|
||
this.el.addEventListener("dragstart", (event) => { | ||
this.startDragging(event.target); | ||
}); | ||
|
||
this.el.addEventListener("dragend", (event) => { | ||
this.stopDragging(); | ||
}); | ||
|
||
this.el.addEventListener("dragenter", (event) => { | ||
//console.log("Valid drop area", event); | ||
}); | ||
|
||
this.el.addEventListener("dragleave", (event) => { | ||
//console.log("Valid drop area left", event); | ||
}); | ||
|
||
this.el.addEventListener("dragover", (event) => { | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
}); | ||
|
||
this.el.addEventListener("drop", (event) => { | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
|
||
const dstEl = event.target.closest(`[phx-hook="Dropzone"]`); | ||
|
||
const srcEl = this.draggedEl.closest(`[data-el-output-panel-item]`); | ||
|
||
if (dstEl && srcEl) { | ||
const cellId = getAttributeOrThrow(srcEl, "data-cell-id"); | ||
const srcRow = getAttributeOrThrow( | ||
srcEl, | ||
"data-row-index", | ||
parseInteger | ||
); | ||
const srcCol = getAttributeOrThrow( | ||
srcEl, | ||
"data-col-index", | ||
parseInteger | ||
); | ||
let dstRow = getAttributeOrThrow(dstEl, "data-row-index", parseInteger); | ||
let dstCol = getAttributeOrDefault( | ||
dstEl, | ||
"data-col-index", | ||
null, | ||
parseInteger | ||
); | ||
|
||
if (dstCol !== null) { | ||
console.log("New position"); | ||
console.log("Rows", srcRow, "->", dstRow); | ||
console.log("Cols", srcCol, "->", dstCol); | ||
// when dropping on the right side, move element one column to the right | ||
if (srcRow !== dstRow && event.layerX > dstEl.offsetWidth / 2) | ||
dstCol += 1; | ||
if (srcRow === dstRow && srcCol < dstCol) dstCol += 1; | ||
|
||
this.pushEventTo(this.props.phxTarget, "handle_move_item", { | ||
cell_id: cellId, | ||
row_index: dstRow, | ||
col_index: dstCol, | ||
}); | ||
} else { | ||
console.log("New row"); | ||
console.log("Rows", srcRow, "->", dstRow); | ||
console.log("Cols", srcCol, "->", dstCol); | ||
this.pushEventTo( | ||
this.props.phxTarget, | ||
"handle_move_item_to_new_row", | ||
{ | ||
cell_id: cellId, | ||
row_index: dstRow, | ||
} | ||
); | ||
} | ||
} | ||
setTimeout( | ||
() => globalPubSub.broadcast("js_views", { type: "reposition" }), | ||
200 | ||
jannikbecher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
this.stopDragging(); | ||
}); | ||
}, | ||
update() { | ||
this.props = this.getProps(); | ||
}, | ||
getProps() { | ||
return { | ||
phxTarget: getAttributeOrThrow(this.el, "data-phx-target", parseInteger), | ||
}; | ||
}, | ||
startDragging(element) { | ||
if (!this.isDragging) { | ||
this.isDragging = true; | ||
this.draggedEl = element; | ||
|
||
this.el.setAttribute("data-js-dragging", ""); | ||
} | ||
}, | ||
stopDragging() { | ||
if (this.isDragging) { | ||
this.isDragging = false; | ||
this.el.removeAttribute("data-js-dragging"); | ||
} | ||
}, | ||
}; | ||
|
||
export default OutputPanel; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.