Skip to content

Commit ca336e9

Browse files
committed
Tooltip and jupyter fixes
1 parent 43318f5 commit ca336e9

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

src/app.jsx

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,11 @@ class App extends Component {
11951195
}
11961196

11971197
pollTemplate(node) {
1198+
const ttopts = {
1199+
className: 'teal-tooltip',
1200+
position: 'top',
1201+
showDelay: 1000
1202+
}
11981203
let changepollid = node.id
11991204
if (node.type === 'add')
12001205
changepollid = Math.random().toString(36).substr(2, 9)
@@ -1278,6 +1283,7 @@ class App extends Component {
12781283
label={node.name}
12791284
className='p-button-text p-button-secondary fails-tree'
12801285
tooltip={'Question text'}
1286+
tooltipOptions={ttopts}
12811287
></Button>
12821288
) : (
12831289
<React.Fragment>
@@ -1292,12 +1298,14 @@ class App extends Component {
12921298
}
12931299
placeholder='Edit...'
12941300
tooltip={'Edit question'}
1301+
tooltipOptions={ttopts}
12951302
className='p-inputtext-sm'
12961303
></InputText>
12971304
<Button
12981305
icon='pi pi-save'
12991306
className='p-button-text p-button-sm'
13001307
tooltip={'Save edited question'}
1308+
tooltipOptions={ttopts}
13011309
iconPos='right'
13021310
onClick={changepolltext}
13031311
/>
@@ -1309,6 +1317,7 @@ class App extends Component {
13091317
onLabel='multiple'
13101318
offLabel='single'
13111319
tooltip={'Switch between single and multiple answers'}
1320+
tooltipOptions={ttopts}
13121321
onChange={(e) =>
13131322
this.changePoll({ id: changepollid, multi: e.value })
13141323
}
@@ -1319,6 +1328,7 @@ class App extends Component {
13191328
className='p-button-text p-button-sm'
13201329
iconPos='right'
13211330
tooltip={'Edit question text'}
1331+
tooltipOptions={ttopts}
13221332
onClick={starteditpoll}
13231333
/>
13241334
)}
@@ -1328,6 +1338,7 @@ class App extends Component {
13281338
label={node.note}
13291339
className='p-button-text p-button-secondary fails-tree'
13301340
tooltip={'Internal note'}
1341+
tooltipOptions={ttopts}
13311342
></Button>
13321343
)
13331344
) : (
@@ -1343,12 +1354,14 @@ class App extends Component {
13431354
}
13441355
placeholder='Internal note...'
13451356
tooltip={'Edit internal note'}
1357+
tooltipOptions={ttopts}
13461358
className='p-inputtext-sm'
13471359
></InputText>
13481360
<Button
13491361
icon='pi pi-save'
13501362
className='p-button-text p-button-sm'
13511363
tooltip={'Save edited internalnote'}
1364+
tooltipOptions={ttopts}
13521365
iconPos='right'
13531366
onClick={changepollnote}
13541367
/>
@@ -1360,13 +1373,15 @@ class App extends Component {
13601373
className='p-button-text p-button-sm'
13611374
iconPos='right'
13621375
tooltip={'Add/Edit internal note'}
1376+
tooltipOptions={ttopts}
13631377
onClick={starteditpollnote}
13641378
/>
13651379
)}
13661380
<Button
13671381
icon='pi pi-trash'
13681382
className='p-button-text p-button-sm p-button-danger'
13691383
tooltip={'Delete question'}
1384+
tooltipOptions={ttopts}
13701385
iconPos='right'
13711386
onClick={deletepoll}
13721387
/>
@@ -1381,6 +1396,7 @@ class App extends Component {
13811396
label={node.name}
13821397
className='p-button-text p-button-secondary fails-tree'
13831398
tooltip={'Answer text'}
1399+
tooltipOptions={ttopts}
13841400
></Button>
13851401
) : (
13861402
<React.Fragment>
@@ -1395,13 +1411,15 @@ class App extends Component {
13951411
}
13961412
placeholder='Edit...'
13971413
tooltip={'Edit answer text'}
1414+
tooltipOptions={ttopts}
13981415
className='p-inputtext-sm'
13991416
></InputText>
14001417
<Button
14011418
icon='pi pi-save'
14021419
className='p-button-text p-button-sm'
14031420
iconPos='right'
14041421
tooltip={'Save answer text'}
1422+
tooltipOptions={ttopts}
14051423
onClick={changepolltext}
14061424
/>
14071425
</React.Fragment>
@@ -1412,6 +1430,7 @@ class App extends Component {
14121430
className='p-button-text p-button-sm'
14131431
iconPos='right'
14141432
tooltip={'Edit answer text'}
1433+
tooltipOptions={ttopts}
14151434
onClick={starteditpoll}
14161435
/>
14171436
)}
@@ -1420,6 +1439,7 @@ class App extends Component {
14201439
className='p-button-text p-button-sm p-button-danger'
14211440
iconPos='right'
14221441
tooltip={'Delete question'}
1442+
tooltipOptions={ttopts}
14231443
onClick={deletepoll}
14241444
/>
14251445
</span>
@@ -1439,6 +1459,7 @@ class App extends Component {
14391459
}
14401460
placeholder='Add...'
14411461
tooltip={'Edit new text'}
1462+
tooltipOptions={ttopts}
14421463
className='p-inputtext-sm'
14431464
></InputText>
14441465
{this.state.polledittext[node.id] &&
@@ -1447,6 +1468,7 @@ class App extends Component {
14471468
icon='pi pi-plus'
14481469
className='p-button-rounded p-button-text'
14491470
tooltip={'Add element'}
1471+
tooltipOptions={ttopts}
14501472
onClick={changepolltext}
14511473
/>
14521474
)}
@@ -1490,6 +1512,11 @@ class App extends Component {
14901512
isStudent = true
14911513
}
14921514
}
1515+
const ttopts = {
1516+
className: 'teal-tooltip',
1517+
position: 'top',
1518+
showDelay: 1000
1519+
}
14931520
switch (node.type) {
14941521
case 'notebook': {
14951522
const starteditname = () => {
@@ -1554,6 +1581,7 @@ class App extends Component {
15541581
}
15551582
className='p-button-text p-button-secondary fails-tree'
15561583
tooltip={node.filename}
1584+
tooltipOptions={ttopts}
15571585
></Button>
15581586
) : (
15591587
<React.Fragment>
@@ -1568,13 +1596,15 @@ class App extends Component {
15681596
}
15691597
placeholder='Edit...'
15701598
tooltip={'Edit poll name'}
1599+
tooltipOptions={ttopts}
15711600
className='p-inputtext-sm'
15721601
></InputText>
15731602
<Button
15741603
icon='pi pi-save'
15751604
className='p-button-text p-button-sm'
15761605
iconPos='right'
15771606
tooltip={'Save poll name'}
1607+
tooltipOptions={ttopts}
15781608
onClick={changeeditname}
15791609
/>
15801610
</React.Fragment>
@@ -1588,6 +1618,7 @@ class App extends Component {
15881618
iconPos='right'
15891619
onClick={starteditname}
15901620
tooltip='Edit notebook name'
1621+
tooltipOptions={ttopts}
15911622
/>
15921623
)}
15931624
<ToggleButton
@@ -1615,6 +1646,7 @@ class App extends Component {
16151646
this.changeApplet({ id: node.id, presentDownload })
16161647
}}
16171648
tooltip='Select download and edit options for students.'
1649+
tooltipOptions={ttopts}
16181650
offLabel='No download'
16191651
/>
16201652
{!this.state.isjupytereditnote[node.id] ? (
@@ -1624,6 +1656,7 @@ class App extends Component {
16241656
label={node.note}
16251657
className='p-button-text p-button-secondary fails-tree'
16261658
tooltip='Internal note'
1659+
tooltipOptions={ttopts}
16271660
></Button>
16281661
)
16291662
) : (
@@ -1661,6 +1694,7 @@ class App extends Component {
16611694
iconPos='right'
16621695
onClick={starteditnote}
16631696
tooltip='Add/Edit interal note'
1697+
tooltipOptions={ttopts}
16641698
/>
16651699
)}
16661700
</Fragment>
@@ -1672,6 +1706,7 @@ class App extends Component {
16721706
className='p-button-text p-button-sm p-button-danger'
16731707
iconPos='right'
16741708
tooltip='Edit notebook'
1709+
tooltipOptions={ttopts}
16751710
onClick={() => {
16761711
fetch(node.url)
16771712
.then(async (response) => {
@@ -1688,6 +1723,7 @@ class App extends Component {
16881723
ipynbuploadname: node.name || 'Dummy title',
16891724
jupyterId: node.id,
16901725
jupyteredit: true,
1726+
jupyterRerunStartup: false,
16911727
selectedJupyterApp: undefined
16921728
})
16931729
})
@@ -1707,6 +1743,7 @@ class App extends Component {
17071743
className='p-button-text p-button-sm p-button-danger'
17081744
iconPos='right'
17091745
tooltip='Delete notebook'
1746+
tooltipOptions={ttopts}
17101747
onClick={() => {
17111748
this.patchLectureDetails({
17121749
removeipynb: {
@@ -1753,6 +1790,7 @@ class App extends Component {
17531790
})
17541791
}}
17551792
tooltip='Show or hide app for students outside of the lecture'
1793+
tooltipOptions={ttopts}
17561794
/>
17571795
)}
17581796
{node.presentToStudents && isStudent && (
@@ -1777,6 +1815,7 @@ class App extends Component {
17771815
ipynbuploadname: node.name || 'Dummy title',
17781816
jupyterId: node.ipynbid,
17791817
jupyteredit: true,
1818+
jupyterRerunStartup: true,
17801819
selectedJupyterApp: {
17811820
appid: node.id,
17821821
appname: node.name
@@ -1813,6 +1852,7 @@ class App extends Component {
18131852
}
18141853
placeholder='Enter name for new or upload notebook ...'
18151854
tooltip='Name for new jupyter notebook'
1855+
tooltipOptions={ttopts}
18161856
className='p-inputtext-sm'
18171857
size='35'
18181858
></InputText>
@@ -1822,6 +1862,7 @@ class App extends Component {
18221862
icon='pi pi-file'
18231863
className='p-button-rounded p-button-text'
18241864
tooltip='Create new jupyter notebook'
1865+
tooltipOptions={ttopts}
18251866
onClick={() => {
18261867
this.setState({
18271868
jupyterDocument: {
@@ -1848,6 +1889,7 @@ class App extends Component {
18481889
icon='pi pi-upload'
18491890
className='p-button-rounded p-button-text'
18501891
tooltip='Upload jupyter notebook'
1892+
tooltipOptions={ttopts}
18511893
onClick={() => {
18521894
fileInputRef?.current?.click()
18531895
}}
@@ -1866,6 +1908,7 @@ class App extends Component {
18661908
jupyterFilename: file.name,
18671909
jupyterId: newId,
18681910
jupyteredit: true,
1911+
jupyterRerunStartup: false,
18691912
selectedJupyterApp: undefined
18701913
})
18711914
} catch (error) {
@@ -2587,6 +2630,19 @@ class App extends Component {
25872630
}
25882631
></Button>
25892632
</div>
2633+
<div className='p-col-3'>
2634+
<Button
2635+
icon='pi pi-cog'
2636+
label='Get apps'
2637+
className='p-m-2'
2638+
onClick={() =>
2639+
this.doCopy({
2640+
fromuuid: this.state.selLecture,
2641+
what: 'ipynbs'
2642+
})
2643+
}
2644+
></Button>
2645+
</div>
25902646
<div className='p-col-3'>
25912647
<Button
25922648
icon='pi pi-file'
@@ -2723,7 +2779,6 @@ class App extends Component {
27232779
/>
27242780
)}
27252781
{this.state.jupyterState?.dirty &&
2726-
!jupytersave &&
27272782
!this.state.selectedJupyterApp && (
27282783
<Button
27292784
icon='pi pi-download'
@@ -2775,6 +2830,7 @@ class App extends Component {
27752830
accept: () => {
27762831
this.setState({
27772832
jupyteredit: false,
2833+
jupyterRerunStartup: false,
27782834
jupyterDocument: undefined,
27792835
jupyterFilename: undefined,
27802836
jupyterId: undefined,
@@ -2786,6 +2842,7 @@ class App extends Component {
27862842
} else {
27872843
this.setState({
27882844
jupyteredit: false,
2845+
jupyterRerunStartup: false,
27892846
jupyterDocument: undefined,
27902847
jupyterFilename: undefined,
27912848
jupyterId: undefined,
@@ -2841,6 +2898,7 @@ class App extends Component {
28412898
document={this.state.jupyterDocument}
28422899
filename={this.state.jupyterFilename}
28432900
appid={this.state.selectedJupyterApp?.appid}
2901+
rerunAtStartup={this.state.jupyterRerunStartup}
28442902
stateCallback={(stateChange) => {
28452903
this.setState((state) => ({
28462904
jupyterState: {

src/jupyteredit.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ export class JupyterEdit extends Component {
6060
this.sendToIFrame({
6161
type: 'loadJupyter',
6262
inLecture: !!this.props.appid,
63+
rerunAtStartup: !!this.props.rerunAtStartup,
64+
installScreenShotPatches: !!this.props.installScreenShotPatches,
6365
appid: this.props.appid,
6466
fileName: this.props.filename || 'example.ipynb',
6567
fileData: data,
66-
kernelName: 'python'
68+
kernelName: data?.metadata?.kernelspec ?? 'python'
6769
})
6870
}
6971

@@ -76,6 +78,14 @@ export class JupyterEdit extends Component {
7678
return fileToSaveObj.fileData
7779
}
7880

81+
async screenShot({ dpi }) {
82+
const { screenshot } = await this.sendToIFrameAndReceive({
83+
type: 'screenshotApp',
84+
dpi
85+
})
86+
return screenshot
87+
}
88+
7989
activateApp() {
8090
const appid = this.props.appid
8191
return this.sendToIFrameAndReceive({
@@ -154,12 +164,16 @@ export class JupyterEdit extends Component {
154164
}
155165
if (!retState.appletSizes) retState.appletSizes = {}
156166
retState.appletSizes[appid] = { width, height }
167+
this.props?.appletSizeChanged?.(appid, width, height)
157168
}
158169
return retState
159170
})
160171
}
161172
}
162173
break
174+
case 'reportKernelStatus':
175+
this.props?.kernelStatusCallback?.(data.status)
176+
break
163177
default:
164178
}
165179
}

0 commit comments

Comments
 (0)