Skip to content

Commit

Permalink
feat(adding bookmarks and annotations): bookmarks/annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachCutler04 committed Nov 9, 2023
1 parent ed94f89 commit 52a9de0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/widgets/trrack/Trrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,31 @@ export function Trrack({ cell, setCurrentNodeTarget, scroll }: Props) {
changeCurrent: (nodeId: NodeId) => {
manager.trrack.to(nodeId);
},
bookmarkNode: null,
labelWidth: 100,
labelWidth: 1000,
verticalSpace: 25,
marginRight: 10,
marginTop: 25,
gutter: 25,
marginLeft: 15,
animationDuration: 200,
annotateNode: null,
annotateNode: (id: NodeId, annotation: string) => {
cell.trrackManager.trrack.annotations.add(annotation, id);
cell.trrackManager.saveToJupyter();
},
getAnnotation: (id: NodeId) => {
return cell.trrackManager.trrack.annotations.latest(id) || '';
},
bookmarkNode: (nodeId: NodeId) => {
if (cell.trrackManager.trrack.bookmarks.is(nodeId)) {
cell.trrackManager.trrack.bookmarks.remove(nodeId);
} else {
cell.trrackManager.trrack.bookmarks.add(nodeId);
}
cell.trrackManager.saveToJupyter();
},
isBookmarked: (nodeId: NodeId) => {
return cell.trrackManager.trrack.bookmarks.is(nodeId);
},
nodeExtra: {
'*':
dataframeRecords.length > 0 ? (
Expand All @@ -109,8 +126,9 @@ export function Trrack({ cell, setCurrentNodeTarget, scroll }: Props) {
</Text>

<Group spacing="5px">
{dataframeRecords.map(record => (
{dataframeRecords.map((record, i) => (
<DataframeNameBadge
key={i}
cell={cell}
dfRecord={record}
actions={{
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/trrack/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export class TrrackManager {
this._cell.generatedDataframesState.set({});
}

saveToJupyter() {
this._cell.trrackGraphState.set(this._graph);
}

loadTrrack(graphToLoad: Nullable<TrrackGraph> = null) {
const onCurrentChange = () => {
this._cell.trrackGraphState.set(this._graph);
Expand Down

0 comments on commit 52a9de0

Please sign in to comment.