From 1d9e221b009f43bb3b1ea2638f4e23e283564abc Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 16:37:31 +0900 Subject: [PATCH 1/7] Edit version updater for lab with v2.5.0 --- visualpython/js/com/com_Config.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/visualpython/js/com/com_Config.js b/visualpython/js/com/com_Config.js index 3b136011..2744f577 100644 --- a/visualpython/js/com/com_Config.js +++ b/visualpython/js/com/com_Config.js @@ -850,7 +850,7 @@ define([ throw new Error('Error', response); } }).then(function (data) { - resolve(data.info.version); + resolve(data.info.version, data.releases); }).catch(function(err) { let errMsg = err.message; if (errMsg.includes('Failed to fetch')) { @@ -910,11 +910,27 @@ define([ packageName = 'jupyterlab-visualpython'; } this.getPackageVersion(packageName).then(function(latestVersion) { - if (nowVersion === latestVersion) { + let showUpdater = false; + if (nowVersion !== latestVersion) { + let nowVerParts = nowVersion.split('.').map(x => ~~x); + let latVerParts = latestVersion.split('.').map(x => ~~x); + if (packageName === 'visualpython') { + // show updater only for notebook extension (for v2.5.0) + for (var i = 0; i < nowVerParts.length; i++) { + const a = nowVerParts[i]; + const b = latVerParts[i]; + if (a < b) { + showUpdater = true; + break; + } + } + } + } + if (showUpdater === false) { // if it's already up to date // hide version update icon $('#vp_versionUpdater').hide(); - if (background) { + if (background === true) { ; } else { let msg = com_util.formatString('Visual Python is up to date. ({0})', latestVersion); From 686e1b880be2b2ccbfc3b8e86c333301bf944a9a Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 16:38:45 +0900 Subject: [PATCH 2/7] Edit widget change event's api getting prepared for lab4x --- visualpython/js/loadVisualpython.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/visualpython/js/loadVisualpython.js b/visualpython/js/loadVisualpython.js index d7f57aa5..206f2d94 100644 --- a/visualpython/js/loadVisualpython.js +++ b/visualpython/js/loadVisualpython.js @@ -287,8 +287,10 @@ define([ } else if (vpConfig.extensionType === 'lab' || vpConfig.extensionType === 'lite') { // LAB: if widget is ready or changed, ready for lab kernel connected, and restart vp vpLab.shell._currentChanged.connect(function(s1, value) { - var { newValue } = value; - vpLog.display(VP_LOG_TYPE.DEVELOP, 'jupyterlab shell currently changed', s1, value); + // var { newValue } = value; + // LAB 4.x: get currentWidget + var newValue = s1.currentWidget; + vpLog.display(VP_LOG_TYPE.DEVELOP, 'jupyterlab shell currently changed', s1, newValue); // kernel restart for notebook and console if (newValue && newValue.sessionContext) { vpConfig.hideProtector(); From 4b52c7cdfcde9399eb369e28914c26032fc9b8dd Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 16:56:43 +0900 Subject: [PATCH 3/7] Edit basic codemirror style --- visualpython/lib/codemirror/lib/codemirror.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visualpython/lib/codemirror/lib/codemirror.css b/visualpython/lib/codemirror/lib/codemirror.css index f4d5718a..0a80f68d 100644 --- a/visualpython/lib/codemirror/lib/codemirror.css +++ b/visualpython/lib/codemirror/lib/codemirror.css @@ -3,7 +3,7 @@ .CodeMirror { /* Set height, width, borders, and global font properties here */ font-family: monospace; - height: 300px; + /* height: 300px; */ color: black; direction: ltr; } From 166bc26e7611ab13c360c5b98d94bdcd5ce0e299 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 17:08:20 +0900 Subject: [PATCH 4/7] Edit Import app --- visualpython/js/m_apps/Import.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/visualpython/js/m_apps/Import.js b/visualpython/js/m_apps/Import.js index 645114d8..ad99c0e6 100644 --- a/visualpython/js/m_apps/Import.js +++ b/visualpython/js/m_apps/Import.js @@ -22,27 +22,27 @@ define([ const importTemplates = { 'data-analysis': [ - { i0: 'numpy', i1: 'np', type: 'module'}, - { i0: 'pandas', i1: 'pd', type: 'module'}, + { i0: 'numpy', i1: 'np', type: 'module', checked: 'checked'}, + { i0: 'pandas', i1: 'pd', type: 'module', checked: 'checked'}, { i0: 'matplotlib.pyplot', i1: 'plt', type: 'module' , include: [ '%matplotlib inline' - ] + ], checked: 'checked' }, - { i0: 'seaborn', i1: 'sns', type: 'module'}, + { i0: 'seaborn', i1: 'sns', type: 'module', checked: 'checked'}, { i0: 'plotly.express', i1: 'px', type: 'module' , include: [ 'from plotly.offline import init_notebook_mode', 'init_notebook_mode(connected=True)' - ], checked: false + ], checked: '' }, - { i0: 'pyarrow', i1: 'pa', type: 'module', checked: false}, + { i0: 'pyarrow', i1: 'pa', type: 'module', checked: ''}, ], 'machine-learning': [ - { i0: 'sklearn.model_selection', i1: 'train_test_split', type: 'function' }, - { i0: 'sklearn', i1: 'metrics', type: 'function' } + { i0: 'sklearn.model_selection', i1: 'train_test_split', type: 'function', checked: 'checked' }, + { i0: 'sklearn', i1: 'metrics', type: 'function', checked: 'checked' } ] } @@ -175,9 +175,9 @@ define([ let that = this; libraries && libraries.forEach((lib, idx) => { if (lib.type == 'function') { - page.appendLine(that.templateForFunction(idx, lib.i0, lib.i1, lib.checked)); + page.appendLine(that.templateForFunction(idx, lib.i0, lib.i1, lib.checked === 'checked')); } else { - page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, lib.checked)); + page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, lib.checked === 'checked')); } }); page.appendLine(''); @@ -246,7 +246,7 @@ define([ if (pacI0 == "") { continue; } - if (pacChecked) { + if (pacChecked === true) { if (sbCode.toString().trim().length > 0) { sbCode.appendLine(); } @@ -270,7 +270,7 @@ define([ } } - importMeta.push({ i0: pacI0, i1: pacI1, type: pacType, checked: pacChecked }); + importMeta.push({ i0: pacI0, i1: pacI1, type: pacType, checked: (pacChecked?'checked':'') }); } this.state.importMeta = importMeta; From 5515d60acbf9b6f0ef6a87ebaffffc5e5e7b3c4a Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 17:10:27 +0900 Subject: [PATCH 5/7] Fix Import app --- visualpython/js/m_apps/Import.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/visualpython/js/m_apps/Import.js b/visualpython/js/m_apps/Import.js index ad99c0e6..bc0321d5 100644 --- a/visualpython/js/m_apps/Import.js +++ b/visualpython/js/m_apps/Import.js @@ -175,9 +175,9 @@ define([ let that = this; libraries && libraries.forEach((lib, idx) => { if (lib.type == 'function') { - page.appendLine(that.templateForFunction(idx, lib.i0, lib.i1, lib.checked === 'checked')); + page.appendLine(that.templateForFunction(idx, lib.i0, lib.i1, (lib.checked === 'checked' || lib.checked === true))); } else { - page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, lib.checked === 'checked')); + page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, (lib.checked === 'checked' || lib.checked === true))); } }); page.appendLine(''); From bdcd71aff4150f36062bf7dbdb1100bacf3dc12f Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 17:12:43 +0900 Subject: [PATCH 6/7] Fix loop for preventing lab4x bug --- visualpython/js/com/com_Kernel.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/visualpython/js/com/com_Kernel.js b/visualpython/js/com/com_Kernel.js index 4282c1ad..3540d1f0 100644 --- a/visualpython/js/com/com_Kernel.js +++ b/visualpython/js/com/com_Kernel.js @@ -473,14 +473,27 @@ define([ getLabNotebookPanel(){ var mainWidgets = this.app.shell.widgets('main'); var widget = mainWidgets.next(); - while(widget){ - if(widget.sessionContext){ + while (widget) { + if (widget.sessionContext) { var type = widget.sessionContext.type; if(type == 'notebook' || type == 'console'){ //other wigets might be of type DocumentWidget if (widget.isVisible){ return widget; } } + } else if (widget.value !== undefined && widget.done === false) { + // for upper lab 4 + let widgetObj = widget.value; + if (widgetObj.sessionContext) { + var type = widgetObj.sessionContext.type; + if(type == 'notebook' || type == 'console'){ //other wigets might be of type DocumentWidget + if (widgetObj.isVisible){ + return widgetObj; + } + } + } + } else if (widget.done === true) { + break; } widget = mainWidgets.next(); } @@ -494,6 +507,14 @@ define([ while (widget) { if (widget.sessionContext) { widgetList.push(widget); + } else if (widget.value !== undefined && widget.done === false) { + // for upper lab 4 + let widgetObj = widget.value; + if (widgetObj.sessionContext) { + widgetList.push(widgetObj); + } + } else if (widget.done === true) { + break; } widget = mainWidgets.next(); } From a726faa62d069fc1176a7e1f983a24ad5fad78c1 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Sep 2023 17:19:19 +0900 Subject: [PATCH 7/7] Edit lab console's markdown cell code --- visualpython/js/com/com_interface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visualpython/js/com/com_interface.js b/visualpython/js/com/com_interface.js index 4c12f1e5..cbdd11f5 100644 --- a/visualpython/js/com/com_interface.js +++ b/visualpython/js/com/com_interface.js @@ -145,7 +145,7 @@ define([ var widget = labConsole.widgets[0]; if (type === 'markdown') { // add # before the lines - command = '#' + command.split('\n').join('#'); + command = '#' + command.split('\n').join('\n#'); } // execute or not