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

User notebooks #30

Merged
merged 90 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
916fb43
remove /dev route, redirect to vlab instead
Jan 15, 2025
2196fa7
work on rendering using nbviewer
g-bar Jan 17, 2025
3d47e13
viz notebook
g-bar Jan 20, 2025
dd6029a
github
g-bar Jan 20, 2025
023b9b1
wop
g-bar Jan 21, 2025
6634abe
refactor fetch, sort columns
g-bar Jan 22, 2025
53be949
Work on popover
g-bar Jan 22, 2025
b1874e6
downloadZip
g-bar Jan 22, 2025
f00e039
on hover
g-bar Jan 22, 2025
8045bd3
implement search
g-bar Jan 23, 2025
46ddc4a
Search component
g-bar Jan 23, 2025
b0d155d
refactor hide columns, work on filters
g-bar Jan 24, 2025
96b5797
work on filters
g-bar Jan 24, 2025
94fed93
Use tree
g-bar Jan 24, 2025
524dd71
bug
g-bar Jan 24, 2025
af3a049
filter notebooks
g-bar Jan 24, 2025
d53527a
better filters
g-bar Jan 26, 2025
00b8c17
more filters
g-bar Jan 26, 2025
27002c8
customize style
g-bar Jan 26, 2025
923fdcb
clean up
g-bar Jan 26, 2025
700c489
show filter count
g-bar Jan 27, 2025
5ce6d09
linting
g-bar Jan 27, 2025
afe3482
Merge branch 'develop' into notebooks
g-bar Jan 27, 2025
6db15e3
Merge branch 'develop' into notebooks
g-bar Jan 27, 2025
08b6fe9
Merge branch 'notebooks' of https://github.com/openbraininstitute/cor…
g-bar Jan 27, 2025
069baa6
Move notebook to projec
g-bar Jan 27, 2025
d5781db
work on modals
g-bar Jan 27, 2025
c4a68cc
implements readme
g-bar Jan 28, 2025
f204de6
errorhandling
g-bar Jan 28, 2025
4ffe928
View notebook source
g-bar Jan 28, 2025
73bf956
obi notebooks
g-bar Jan 28, 2025
1ff994c
uneeded deps
g-bar Jan 28, 2025
e480cab
notebooks
g-bar Jan 29, 2025
5564124
obi notebooks
g-bar Jan 29, 2025
c8ee24e
Merge branch 'develop' into notebooks
g-bar Jan 29, 2025
bb30472
types
g-bar Jan 29, 2025
93adc54
types
g-bar Jan 29, 2025
8b74e9d
Merge branch 'notebooks' of https://github.com/openbraininstitute/cor…
g-bar Jan 29, 2025
44fe55d
notes
g-bar Jan 30, 2025
f68af33
saveAs
g-bar Jan 30, 2025
c4ab581
errors
g-bar Jan 30, 2025
e383d99
mr
g-bar Jan 30, 2025
5fb23fd
error
g-bar Jan 30, 2025
edb1875
icons?
g-bar Feb 3, 2025
a204df3
remove dayjs
g-bar Feb 3, 2025
f753895
delete unused files
g-bar Feb 3, 2025
40674de
minor
g-bar Feb 3, 2025
12fc37d
better errors
g-bar Feb 3, 2025
be4ffc8
show preview
g-bar Feb 3, 2025
e191e2e
remove auth
g-bar Feb 3, 2025
d295e3d
props spreading for custom allowed
g-bar Feb 4, 2025
8b09899
props spreading for custom allowed
g-bar Feb 4, 2025
812ae40
Merge branch 'notebooks' of https://github.com/openbraininstitute/cor…
g-bar Feb 4, 2025
f066f34
add rule back
g-bar Feb 5, 2025
a9d2d96
Merge branch 'develop' into notebooks
g-bar Feb 5, 2025
2e72fb8
json
g-bar Feb 5, 2025
63875d3
linting
g-bar Feb 5, 2025
d5b45cd
fix linter
g-bar Feb 5, 2025
affcf68
render notebook again
g-bar Feb 5, 2025
ad0d579
fix readme
g-bar Feb 5, 2025
e9ce734
fix notebooks
g-bar Feb 5, 2025
e56cc8a
fix preview
g-bar Feb 5, 2025
05d4a5f
work on zip
g-bar Feb 5, 2025
29af291
gets working again
g-bar Feb 5, 2025
4b011c0
lint
g-bar Feb 5, 2025
d67a2fd
Merge branch 'develop' into user_notebooks
g-bar Feb 5, 2025
180c54d
Merge branch 'develop' into user_notebooks
g-bar Feb 5, 2025
515efbd
Merge branch 'user_notebooks' of https://github.com/openbraininstitut…
g-bar Feb 5, 2025
745cef4
From url
g-bar Feb 5, 2025
5989334
parse metadata
g-bar Feb 5, 2025
ac18246
error messages
g-bar Feb 6, 2025
a74d70b
Merge branch 'develop' into user_notebooks_2
g-bar Feb 6, 2025
83eee6a
types
g-bar Feb 6, 2025
bb6be24
fix hiding column
g-bar Feb 6, 2025
c72f2a8
types
g-bar Feb 6, 2025
dc87d4e
columsn
g-bar Feb 6, 2025
07ff070
better table
g-bar Feb 6, 2025
578218f
fix titles
g-bar Feb 10, 2025
969cb3c
fetch one notebook
g-bar Feb 10, 2025
95289c3
fetch api data
g-bar Feb 10, 2025
37a2550
modals v1
g-bar Feb 10, 2025
0717b18
fetch user notebooks
g-bar Feb 10, 2025
97ace85
register user notebook
g-bar Feb 10, 2025
9baf5d2
delete notebooks
g-bar Feb 10, 2025
238b28c
add tabs
g-bar Feb 10, 2025
7bbe9e1
lint
g-bar Feb 10, 2025
9f257ec
fix zip
g-bar Feb 10, 2025
a1045c9
notebook schema
g-bar Feb 11, 2025
e173df5
loading
g-bar Feb 11, 2025
3836332
abort
g-bar Feb 11, 2025
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
1,063 changes: 983 additions & 80 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"react-dom": "18.3.1",
"react-error-boundary": "^4.0.4",
"react-intersection-observer": "^9.5.2",
"react-ipynb-renderer": "^2.2.4",
"react-markdown": "^9.0.3",
"react-pdf": "^7.7.0",
"react-plotly.js": "^2.6.0",
Expand Down
6 changes: 3 additions & 3 deletions src/app/api/github/download-notebook/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from 'next/server';
import { downloadZippedFolder } from '@/util/virtual-lab/github';
// import { downloadZippedNotebook } from '@/util/virtual-lab/github';
import { assertErrorMessage } from '@/util/utils';

export async function GET(request: Request): Promise<NextResponse> {
Expand All @@ -11,9 +11,9 @@ export async function GET(request: Request): Promise<NextResponse> {
}

try {
const zipContent = await downloadZippedFolder(folder);
// const zipContent = await downloadZippedFolder(folder);

return new NextResponse(zipContent, {
return new NextResponse(null, {
headers: {
'Content-Type': 'application/zip',
'Content-Disposition': `attachment; filename="${folder}.zip"`,
Expand Down
4 changes: 2 additions & 2 deletions src/app/api/github/fetch-file/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NextResponse } from 'next/server';
import { fetchFile } from '@/util/virtual-lab/github';
import { fetchGithubFile } from '@/util/virtual-lab/github';

export async function GET(request: Request): Promise<NextResponse> {
const { searchParams } = new URL(request.url);
Expand All @@ -9,7 +9,7 @@ export async function GET(request: Request): Promise<NextResponse> {
return NextResponse.json({ error: 'Missing required parameters' }, { status: 400 });
}

const file = await fetchFile(path);
const file = await fetchGithubFile(path);

return new NextResponse(file, {
headers: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,53 +1,75 @@
import { useEffect, useState } from 'react';
import { Modal } from 'antd/lib';
import ReactMarkdown from 'react-markdown';
import { basePath, notebookRepository } from '@/config';
import { IpynbRenderer } from 'react-ipynb-renderer';
import { Notebook } from '@/util/virtual-lab/github';
import { basePath } from '@/config';

import 'react-ipynb-renderer/dist/styles/monokai.css';

import 'github-markdown-css';
import { notification } from '@/api/notifications';

export default function ContentModal({
file,
notebook,
onCancel,
display,
}: {
file: { path: string; type: 'notebook' | 'text' } | null;
notebook: Notebook | null;
display: 'notebook' | 'readme' | null;
onCancel: () => void;
}) {
const [content, setContent] = useState<string | null>(null);

useEffect(() => {
const controller = new AbortController();

async function fetchFile() {
if (!file) return;
const res = await fetch(
`${basePath}/api/github/fetch-file?path=${encodeURIComponent(file.path)}`
);

if (!res.ok) {
setContent('Cannot display the contents, ensure the repository is public');
} else {
setContent(await res.text());
if (!notebook || !display) return;

try {
const res = await fetch(
`${basePath}/api/github/fetch-file?path=${encodeURIComponent(display === 'notebook' ? notebook.notebookUrl : notebook.readmeUrl)}`,
{ signal: controller.signal }
);

if (!res.ok) {
notification.error('Cannot display the contents, ensure the repository is public');
} else {
setContent(await res.text());
}
} catch (error) {
if (error instanceof Error && error.name !== 'AbortError') {
notification.error('An error occurred while fetching the file');
}
}
}

fetchFile();
}, [file]);

return () => controller.abort();
}, [notebook, display]);

return (
<Modal open={!!file && !!content} onCancel={onCancel} footer={false} width="70%">
<Modal
open={!!notebook && !!content}
onCancel={() => {
setContent(null);
onCancel();
}}
footer={false}
width="70%"
>
<div>
{file?.type === 'text' && (
{display === 'readme' && !!content && (
<div className="markdown-body">
<ReactMarkdown>{content}</ReactMarkdown>
</div>
)}

{file?.type === 'notebook' && content && (
<div className="h-[80vh] w-full">
<iframe
title={file.path}
src={`https://nbviewer.org/github/${notebookRepository.user}/${notebookRepository.repository}/blob/main/${encodeURIComponent(file.path)}`}
width="100%"
height="100%"
/>
{display === 'notebook' && !!notebook && !!content && (
<div className="h-[80vh] w-full overflow-y-scroll">
<IpynbRenderer ipynb={JSON.parse(content)} />
</div>
)}
</div>
Expand Down
Loading
Loading