Skip to content

Commit a39451d

Browse files
committed
Add jupyter download option
1 parent 72348d0 commit a39451d

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"dexie": "^3.2.2",
3535
"file-loader": "^6.2.0",
3636
"image-blob-reduce": "^3.0.1",
37+
"js-file-download": "^0.4.12",
3738
"jshashes": "^1.0.8",
3839
"jwt-decode": "^3.1.2",
3940
"katex": "^0.16.21",

src/ui/blackboard/jupyterhublet.jsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
3131
import { JupyterEdit } from '@fails-components/jupyter-react-edit'
3232
import { OverlayPanel } from 'primereact/overlaypanel'
3333
import powerByJupyterLogo from '../jupyterlogo/poweredbyjupyter-square-lightbg.svg'
34+
import fileDownload from 'js-file-download'
3435

3536
const jupyterProxyDomains =
3637
import.meta.env.REACT_APP_JUPYTER_PROXY_DOMAINS.split(' ').map(
@@ -1156,6 +1157,28 @@ export class JupyterHublet extends Component {
11561157
}}
11571158
/>
11581159
)}
1160+
{this.state.jupyterState?.dirty &&
1161+
this.props.appids?.appid === notebookEditPseudoAppid && (
1162+
<AppletButton
1163+
icon='pi pi-download'
1164+
className='p-button-text p-button-sm'
1165+
key='downloadbutton'
1166+
tooltip='Download jupyter notebook'
1167+
onClick={async () => {
1168+
if (this.jupyteredit.current) {
1169+
const toSave =
1170+
await this.jupyteredit.current.saveJupyter()
1171+
const theblob = new Blob([JSON.stringify(toSave)], {
1172+
type: 'application/x-ipynb+json'
1173+
})
1174+
fileDownload(
1175+
theblob,
1176+
this.props.ipynb?.filename || 'unknown.ipynb'
1177+
)
1178+
}
1179+
}}
1180+
/>
1181+
)}
11591182
{!master && this.props.makeAppletMaster && (
11601183
<AppletButton
11611184
icon={fiSteer}

0 commit comments

Comments
 (0)