Skip to content

Commit 7f43dd5

Browse files
committed
notebookEditMode for jupyter
1 parent f18ff33 commit 7f43dd5

File tree

3 files changed

+71
-22
lines changed

3 files changed

+71
-22
lines changed

src/ui/blackboard/blackboardnotepad.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { SHA1 } from 'jshashes'
2121
import React, { Component } from 'react'
2222
import Color from 'color'
2323
import { Blackboard } from './blackboard'
24+
import { notebookEditPseudoAppid } from './jupyterhublet'
2425

2526
function ToRGBANumber(color) {
2627
if (typeof color === 'number') return color // no need to convert
@@ -1387,6 +1388,19 @@ export class BlackboardNotepad extends Component {
13871388

13881389
onAppStart(id, sha, appid) {
13891390
const scrollheight = this.scrollheight()
1391+
if (appid === notebookEditPseudoAppid) {
1392+
this.props.outgoingsink.startApp(
1393+
undefined /* time */,
1394+
0.1,
1395+
Math.min(9 / 16, this.scrollheight()) * 0.1 + this.getCurScrollPos(),
1396+
0.8,
1397+
Math.min(9 / 16, this.scrollheight()) * 0.8, // typical screen ration
1398+
id,
1399+
sha,
1400+
appid
1401+
)
1402+
return
1403+
}
13901404
this.props.outgoingsink.startApp(
13911405
undefined /* time */,
13921406
0.15,

src/ui/blackboard/jupyterhublet.jsx

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const jupyterProxyDomains =
3737
(el) => 'https://' + el
3838
)
3939

40+
export const notebookEditPseudoAppid = '1e5584e0-718c-4228-a666-0bdaf57fb82e'
41+
4042
export class AppletButton extends Component {
4143
constructor(args) {
4244
super(args)
@@ -975,10 +977,12 @@ export class JupyterHublet extends Component {
975977
newwidth = Math.max(150, newwidth)
976978
newheight = Math.max(150, newheight)
977979
const destaspect = this.aspect
978-
if (newwidth > newheight) {
979-
newheight = newwidth / destaspect
980-
} else {
981-
newwidth = newheight * destaspect
980+
if (this.props.appids?.appid !== notebookEditPseudoAppid) {
981+
if (newwidth > newheight) {
982+
newheight = newwidth / destaspect
983+
} else {
984+
newwidth = newheight * destaspect
985+
}
982986
}
983987
newheight -= oldheight
984988
newwidth -= oldwidth
@@ -1002,7 +1006,10 @@ export class JupyterHublet extends Component {
10021006
}
10031007

10041008
checkAdjustAppletSize() {
1005-
if (this.props.master) {
1009+
if (
1010+
this.props.master &&
1011+
this.props.appids?.appid !== notebookEditPseudoAppid
1012+
) {
10061013
const oldaspect = this.props.pos.width / this.props.pos.height
10071014
const newaspect = this.aspect
10081015
if (oldaspect !== newaspect) {
@@ -1050,6 +1057,7 @@ export class JupyterHublet extends Component {
10501057
const applet = this.props.ipynb?.applets?.find?.(
10511058
(el) => this.props.appids?.appid === el.appid
10521059
)
1060+
const heading = applet?.appname || this.props.ipynb?.name
10531061
const master = this.props.master
10541062
const stopProp = (event) => event.stopPropagation()
10551063
const width =
@@ -1158,16 +1166,18 @@ export class JupyterHublet extends Component {
11581166
tooltip='Steer applet state'
11591167
/>
11601168
)}
1161-
{master && this.props.screenShotSaver && (
1162-
<AppletButton
1163-
icon={<FontAwesomeIcon icon={faCamera} />}
1164-
key='appletbutton'
1165-
onClick={() => {
1166-
this.doScreenshot()
1167-
}}
1168-
tooltip='Create picture from applet'
1169-
/>
1170-
)}
1169+
{master &&
1170+
this.props.appids?.appid !== notebookEditPseudoAppid &&
1171+
this.props.screenShotSaver && (
1172+
<AppletButton
1173+
icon={<FontAwesomeIcon icon={faCamera} />}
1174+
key='appletbutton'
1175+
onClick={() => {
1176+
this.doScreenshot()
1177+
}}
1178+
tooltip='Create picture from applet'
1179+
/>
1180+
)}
11711181
<AppletButton
11721182
icon={'pi pi-info-circle'}
11731183
key='infobutton'
@@ -1205,9 +1215,7 @@ export class JupyterHublet extends Component {
12051215
onPointerMove={(event) => this.onPointerMove('move', event)}
12061216
onPointerUp={(event) => this.onPointerUp('move', event)}
12071217
/>
1208-
<div className='appletHeadingText'>
1209-
{applet?.appname || 'Loading...'}
1210-
</div>
1218+
<div className='appletHeadingText'>{heading || 'Loading...'}</div>
12111219
<div
12121220
ref={this.kernelStatusRef}
12131221
className={
@@ -1270,7 +1278,10 @@ export class JupyterHublet extends Component {
12701278
ref={this.jupyteredit}
12711279
document={this.state.jupyterDocument}
12721280
filename={this.props.ipynb?.filename}
1273-
appid={this.props.appids?.appid}
1281+
appid={
1282+
this.props.appids?.appid !== notebookEditPseudoAppid &&
1283+
this.props.appids?.appid
1284+
}
12741285
stateCallback={(stateChange) => {
12751286
this.setState((state) => ({
12761287
jupyterState: {
@@ -1347,7 +1358,8 @@ export class JupyterHublet extends Component {
13471358
alt='powered by jupyter logo'
13481359
/>
13491360
<div style={{ marginLeft: '10px', textAlign: 'left' }}>
1350-
FAILS' apps are powered by Jupyter Lite{' '}
1361+
FAILS' apps and jupyter notebook support are powered by Jupyter
1362+
Lite{' '}
13511363
</div>
13521364
</div>
13531365
</h3>
@@ -1363,7 +1375,7 @@ export class JupyterHublet extends Component {
13631375
{' '}
13641376
OSS attribution and licensing{' '}
13651377
</button>{' '}
1366-
for app related content.
1378+
for jupyter related content.
13671379
<br /> <br />
13681380
</OverlayPanel>
13691381
</Fragment>

src/ui/failsboard.jsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { PictureSelect } from './widgets/pictureselect'
3636
import { ShortcutsMessage } from './widgets/shortcutsmessage'
3737
import Pica from 'pica'
3838
import ImageBlobReduce from 'image-blob-reduce'
39+
import { notebookEditPseudoAppid } from './blackboard/jupyterhublet'
3940

4041
export class FailsBoard extends FailsBasis {
4142
constructor(props) {
@@ -599,7 +600,29 @@ export class FailsBoard extends FailsBasis {
599600
</React.Fragment>
600601
)
601602
}
602-
return <b>{node.label}</b>
603+
return (
604+
<React.Fragment>
605+
<b>{node.label}</b>{' '}
606+
<Button
607+
icon='pi pi-file'
608+
className='p-button-text p-button-sm'
609+
tooltip={'Work individuelly at the notebook'}
610+
tooltipOptions={{
611+
className: 'teal-tooltip',
612+
position: 'top',
613+
showDelay: 1000
614+
}}
615+
iconPos='right'
616+
onClick={() => {
617+
this.onStartApplet({
618+
appid: notebookEditPseudoAppid,
619+
id: node.id,
620+
sha: node.sha
621+
})
622+
}}
623+
/>{' '}
624+
</React.Fragment>
625+
)
603626
}
604627

605628
render() {

0 commit comments

Comments
 (0)