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); 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(); } 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 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(); diff --git a/visualpython/js/m_apps/Import.js b/visualpython/js/m_apps/Import.js index 645114d8..bc0321d5 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' || lib.checked === true))); } else { - page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, lib.checked)); + page.appendLine(that.templateForModule(idx, lib.i0, lib.i1, (lib.checked === 'checked' || lib.checked === true))); } }); 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; 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; }