From aa116c86cd67b100f5a9c2520f40dab251002520 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 23 Feb 2023 19:58:00 +0900 Subject: [PATCH 01/13] Add items to gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 378a7a07..2db0536e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ dist/ +colab/visualpython +jupyternotebook/visualpython jupyterlab/lib/visualpython -test/ \ No newline at end of file +test/ From 44e76c7de95816572acf97d4314ae25a42caec02 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 16:56:46 +0900 Subject: [PATCH 02/13] Change DataSelector style --- visualpython/css/component/dataSelector.css | 6 +++--- visualpython/html/component/dataSelector.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/visualpython/css/component/dataSelector.css b/visualpython/css/component/dataSelector.css index 8e865b18..512a31d6 100644 --- a/visualpython/css/component/dataSelector.css +++ b/visualpython/css/component/dataSelector.css @@ -55,14 +55,14 @@ } .vp-ds-data-box { width: 100%; - height: 160px; + height: 150px; align-content: baseline; align-items: center; } .vp-ds-type-box, .vp-ds-variable-box { border: 0.25px solid var(--border-gray-color); - height: 160px; + height: 150px; grid-row-gap: 0px; align-content: baseline; } @@ -90,7 +90,7 @@ margin-top: 10px; } .vp-ds-option-inner-box { - height: calc(100% - 30px); + height: calc(100% - 35px); } .vp-ds-df-option-box { height: 100%; diff --git a/visualpython/html/component/dataSelector.html b/visualpython/html/component/dataSelector.html index 8090aace..2e402219 100644 --- a/visualpython/html/component/dataSelector.html +++ b/visualpython/html/component/dataSelector.html @@ -8,7 +8,7 @@
-
+
@@ -22,7 +22,7 @@
-
+
From 826ad90434c403b1a972b44c230990114d2c8714 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 16:57:50 +0900 Subject: [PATCH 03/13] Fix multiselector to able to click and delete manually added item --- visualpython/css/component/multiSelector.css | 6 + .../js/com/component/MultiSelector.js | 130 ++++++++++-------- 2 files changed, 79 insertions(+), 57 deletions(-) diff --git a/visualpython/css/component/multiSelector.css b/visualpython/css/component/multiSelector.css index 0b001277..eb3693d1 100644 --- a/visualpython/css/component/multiSelector.css +++ b/visualpython/css/component/multiSelector.css @@ -79,4 +79,10 @@ left: calc(100% - 25px); bottom: 23px; cursor: pointer; +} +.vp-cs-del-item { + position: relative; + float: right; + top: 4px; + cursor: pointer; } \ No newline at end of file diff --git a/visualpython/js/com/component/MultiSelector.js b/visualpython/js/com/component/MultiSelector.js index 774bb870..06cf0707 100644 --- a/visualpython/js/com/component/MultiSelector.js +++ b/visualpython/js/com/component/MultiSelector.js @@ -305,7 +305,7 @@ define([ // select - right tag.appendFormatLine('
', APP_SELECT_RIGHT); var selectedList = this.dataList.filter(data => that.selectedList.includes(data.code)); - tag.appendLine(this.renderSelectedBox(selectedList)); + tag.appendLine(this.renderSelectedBox(this.selectedList)); if (this.allowAdd) { // add item tag.appendLine(''); @@ -380,62 +380,6 @@ define([ that.bindDraggable(); }); - // item indexing - $(this.wrapSelector('.' + APP_SELECT_ITEM)).on('click', function(event) { - var dataIdx = $(this).attr('data-idx'); - var idx = $(this).index(); - var added = $(this).hasClass('added'); // right side added item? - var selector = ''; - - // remove selection for select box on the other side - if (added) { - // remove selection for left side - $(that.wrapSelector('.' + APP_SELECT_ITEM + ':not(.added)')).removeClass('selected'); - // set selector - selector = '.added'; - } else { - // remove selection for right(added) side - $(that.wrapSelector('.' + APP_SELECT_ITEM + '.added')).removeClass('selected'); - // set selector - selector = ':not(.added)'; - } - - if (vpEvent.keyManager.keyCheck.ctrlKey) { - // multi-select - that.pointer = { start: idx, end: -1 }; - $(this).toggleClass('selected'); - } else if (vpEvent.keyManager.keyCheck.shiftKey) { - // slicing - var startIdx = that.pointer.start; - - if (startIdx == -1) { - // no selection - that.pointer = { start: idx, end: -1 }; - } else if (startIdx > idx) { - // add selection from idx to startIdx - var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)); - for (var i = idx; i <= startIdx; i++) { - $(tags[i]).addClass('selected'); - } - that.pointer = { start: startIdx, end: idx }; - } else if (startIdx <= idx) { - // add selection from startIdx to idx - var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)); - for (var i = startIdx; i <= idx; i++) { - $(tags[i]).addClass('selected'); - } - that.pointer = { start: startIdx, end: idx }; - } - } else { - // single-select - that.pointer = { start: idx, end: -1 }; - // un-select others - $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)).removeClass('selected'); - // select this - $(this).addClass('selected'); - } - }); - // item indexing - add all $(this.wrapSelector('.' + APP_SELECT_ADD_ALL_BTN)).on('click', function(event) { $(that.wrapSelector('.' + APP_SELECT_BOX + '.left .' + APP_SELECT_ITEM)).appendTo( @@ -510,6 +454,75 @@ define([ that._addNewItem(newItemName); } }); + + this._bindItemClickEvent(); + } + + _bindItemClickEvent() { + let that = this; + // item indexing + $(this.wrapSelector('.' + APP_SELECT_ITEM)).off('click'); + $(this.wrapSelector('.' + APP_SELECT_ITEM)).on('click', function(event) { + var dataIdx = $(this).attr('data-idx'); + var idx = $(this).index(); + var added = $(this).hasClass('added'); // right side added item? + var selector = ''; + + // remove selection for select box on the other side + if (added) { + // remove selection for left side + $(that.wrapSelector('.' + APP_SELECT_ITEM + ':not(.added)')).removeClass('selected'); + // set selector + selector = '.added'; + } else { + // remove selection for right(added) side + $(that.wrapSelector('.' + APP_SELECT_ITEM + '.added')).removeClass('selected'); + // set selector + selector = ':not(.added)'; + } + + if (vpEvent.keyManager.keyCheck.ctrlKey) { + // multi-select + that.pointer = { start: idx, end: -1 }; + $(this).toggleClass('selected'); + } else if (vpEvent.keyManager.keyCheck.shiftKey) { + // slicing + var startIdx = that.pointer.start; + + if (startIdx == -1) { + // no selection + that.pointer = { start: idx, end: -1 }; + } else if (startIdx > idx) { + // add selection from idx to startIdx + var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)); + for (var i = idx; i <= startIdx; i++) { + $(tags[i]).addClass('selected'); + } + that.pointer = { start: startIdx, end: idx }; + } else if (startIdx <= idx) { + // add selection from startIdx to idx + var tags = $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)); + for (var i = startIdx; i <= idx; i++) { + $(tags[i]).addClass('selected'); + } + that.pointer = { start: startIdx, end: idx }; + } + } else { + // single-select + that.pointer = { start: idx, end: -1 }; + // un-select others + $(that.wrapSelector('.' + APP_SELECT_ITEM + selector)).removeClass('selected'); + // select this + $(this).addClass('selected'); + } + }); + + // item deleting (manually added item only) + $(this.wrapSelector('.vp-cs-del-item')).off('click'); + $(this.wrapSelector('.vp-cs-del-item')).on('click', function(event) { + $(this).closest('.' + APP_SELECT_ITEM).remove(); + that.pointer = { start: -1, end: -1 }; + }); } _addNewItem(newItemName) { @@ -551,6 +564,7 @@ define([ let newItemIndex = this.dataList.length; var targetTag = $(`
${newItemName} +
`); $(targetTag).appendTo( $(this.wrapSelector('.' + APP_SELECT_BOX + '.right')) @@ -560,6 +574,8 @@ define([ $(this.wrapSelector('.' + APP_SELECT_ITEM)).removeClass('selected'); // clear item input $(this.wrapSelector('.vp-cs-add-item-name')).val(''); + // bind click event + this._bindItemClickEvent(); // bind draggable this.bindDraggable(); } From 98a93165f87a3bb7a9e758abd67babfec3317fb1 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 16:58:34 +0900 Subject: [PATCH 04/13] Remove orange text style on allocate to --- visualpython/html/m_apps/file.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visualpython/html/m_apps/file.html b/visualpython/html/m_apps/file.html index 07bd8d82..c9d92782 100644 --- a/visualpython/html/m_apps/file.html +++ b/visualpython/html/m_apps/file.html @@ -74,7 +74,7 @@ - + From 50f4055be1c723fb5193f92b81d31751bd5954c0 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 16:59:10 +0900 Subject: [PATCH 05/13] Add output variable to required area --- visualpython/js/com/com_generatorV2.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/visualpython/js/com/com_generatorV2.js b/visualpython/js/com/com_generatorV2.js index 6113af7b..4278b66d 100644 --- a/visualpython/js/com/com_generatorV2.js +++ b/visualpython/js/com/com_generatorV2.js @@ -134,7 +134,7 @@ define([ package.options && package.options.forEach(function(o, i) { var obj = JSON.parse(JSON.stringify(o)); let newTag = vp_createTag(pageThis, obj, state); - if (obj.required) { + if (obj.required === true || obj.output === true) { tblInput.append(newTag); } else { tblOption.append(newTag); @@ -142,6 +142,9 @@ define([ }); // TODO: userOption + if (package.code.includes('${etc}')) { + + } bindAutoComponentEvent(pageThis); } @@ -163,7 +166,7 @@ define([ let value = state[name]; var requiredFontStyle = required == true? 'vp-orange-text' : ''; - var lblTag = $(``).attr({ + var lblTag = $(``).attr({ 'for': name, 'class': requiredFontStyle, 'title': '(' + name + ')' From 060dc4488c80566da5a8e95e2920dbc79be4fdbd Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 16:59:40 +0900 Subject: [PATCH 06/13] Add DataSelector to sample output variable --- visualpython/js/m_apps/File.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/visualpython/js/m_apps/File.js b/visualpython/js/m_apps/File.js index be00f7ad..95cd0e39 100644 --- a/visualpython/js/m_apps/File.js +++ b/visualpython/js/m_apps/File.js @@ -22,9 +22,10 @@ define([ 'vp_base/js/com/com_generatorV2', 'vp_base/data/m_library/pandasLibrary', 'vp_base/js/com/component/FileNavigation', - 'vp_base/js/com/component/SuggestInput' + 'vp_base/js/com/component/SuggestInput', + 'vp_base/js/com/component/DataSelector' ], function(fileHtml, fileCss, com_String, com_util, com_Const, PopupComponent - , pdGen, pandasLibrary, FileNavigation, SuggestInput) { + , pdGen, pandasLibrary, FileNavigation, SuggestInput, DataSelector) { /** * File @@ -286,7 +287,14 @@ define([ templateForBody() { /** Implement generating template */ - return fileHtml; + let page = $(fileHtml); + + let allocateSelector = new DataSelector({ + pageThis: this, id: 'vp_sampleReturn', placeholder: 'Variable name' + }); + $(page).find('#vp_sampleReturn').replaceWith(allocateSelector.toTagString()); + + return page; } renderPage(pageType) { From ff99abe0ff8ff20da0c96ffb3989c1a897c87672 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 17:00:51 +0900 Subject: [PATCH 07/13] Edit menu search box to show its category and Popup to show its category on the title --- visualpython/js/MainFrame.js | 4 ++-- .../js/com/component/PopupComponent.js | 4 +++- visualpython/js/menu/MenuFrame.js | 21 ++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/visualpython/js/MainFrame.js b/visualpython/js/MainFrame.js index f013ed66..9ce588eb 100644 --- a/visualpython/js/MainFrame.js +++ b/visualpython/js/MainFrame.js @@ -478,10 +478,10 @@ define([ let parentBlock = null; let prevBlock = null; loadStateList.forEach(obj => { - let { blockType, menuId, menuState, menuConfig, argIdx, position, afterAction } = obj; + let { file, blockType, menuId, menuState, menuConfig, argIdx, position, afterAction } = obj; // get OptionComponent Object // LAB: relative path needed - let OptionComponent = require('./' + menuConfig.file); + let OptionComponent = require('./' + file); if (OptionComponent) { let taskState = menuState.taskState; let blockState = menuState.blockState; diff --git a/visualpython/js/com/component/PopupComponent.js b/visualpython/js/com/component/PopupComponent.js index 8e6cf32c..44d52d6f 100644 --- a/visualpython/js/com/component/PopupComponent.js +++ b/visualpython/js/com/component/PopupComponent.js @@ -92,6 +92,7 @@ define([ this.id = this.state.config.id; this.name = this.state.config.name; this.path = this.state.config.path; + this.category = this.state.config.category; this.config = { @@ -530,7 +531,8 @@ define([ template() { this.$pageDom = $(popupComponentHtml.replaceAll('${vp_base}', com_Const.BASE_PATH)); // set title - this.$pageDom.find('.vp-popup-title').text(this.name); + // this.$pageDom.find('.vp-popup-title').text(this.category + ' > ' + this.name); + this.$pageDom.find('.vp-popup-title').html(`${this.category} > ${this.name}`); // set body let bodyTemplate = this.templateForBody(); // CHROME: check url keyword and replace it diff --git a/visualpython/js/menu/MenuFrame.js b/visualpython/js/menu/MenuFrame.js index 76aab784..998e6146 100644 --- a/visualpython/js/menu/MenuFrame.js +++ b/visualpython/js/menu/MenuFrame.js @@ -199,19 +199,19 @@ define([ return {}; } - getMenuLibrary(menuId, libraries=this.menuLibraries) { + getMenuLibrary(menuId, libraries=this.menuLibrariesFlatten) { for (var i=0; i < libraries.length; i++) { var item = libraries[i]; if (item) { if (item.id === menuId) { return item; } - if (item.type === 'package') { - var result = this.getMenuLibrary(menuId, item.item); - if (result) { - return result; - } - } + // if (item.type === 'package') { + // var result = this.getMenuLibrary(menuId, item.item); + // if (result) { + // return result; + // } + // } } } return null; @@ -243,7 +243,12 @@ define([ var that = this; var body = group.getBody(); var item = group.getItem(); + var state = group.getState(); item && item.forEach(child => { + // remember parent to navigate its parent menu + var category = state.category?(state.category + ' > ' + state.name):state.name; + child['category'] = category; + if (child.type == 'package') { // packages : MenuGroup var menuGroup = new MenuGroup($(body), child); @@ -289,7 +294,7 @@ define([ }); let functionList = this.menuLibrariesFlatten.map(menu => { - return { label: menu.name, value: menu.name, ...menu } + return { label: menu.name, value: menu.name, dtype: menu.category, ...menu } }); // render searchbox let searchBox = new SuggestInput(); From 04421863aee866c19230e655538b06c198f4fd06 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Tue, 28 Feb 2023 17:01:07 +0900 Subject: [PATCH 08/13] Add DataSelector to Instance app --- visualpython/js/m_apps/Instance.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/visualpython/js/m_apps/Instance.js b/visualpython/js/m_apps/Instance.js index a4f0e6c5..512c6f76 100644 --- a/visualpython/js/m_apps/Instance.js +++ b/visualpython/js/m_apps/Instance.js @@ -18,8 +18,9 @@ define([ 'vp_base/js/com/com_String', 'vp_base/js/com/component/PopupComponent', 'vp_base/js/com/component/InstanceEditor', + 'vp_base/js/com/component/DataSelector', 'vp_base/js/m_apps/Subset' -], function(insHtml, insCss, com_String, PopupComponent, InstanceEditor, Subset) { +], function(insHtml, insCss, com_String, PopupComponent, InstanceEditor, DataSelector, Subset) { const MAX_STACK_SIZE = 20; @@ -178,6 +179,13 @@ define([ templateForBody() { let page = $(insHtml); $(page).find('#vp_instanceVariable').val(this.state.vp_instanceVariable); + + let allocateSelector = new DataSelector({ + pageThis: this, id: 'vp_instanceAllocate', placeholder: 'Variable name' + }); + $(page).find('#vp_instanceAllocate').replaceWith(allocateSelector.toTagString()); + + return page; } From 17540cf84c328e12ca3b51aa05f33dc22bd53d0e Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 2 Mar 2023 12:25:38 +0900 Subject: [PATCH 09/13] Edit gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2db0536e..e239a27c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ dist/ -colab/visualpython -jupyternotebook/visualpython jupyterlab/lib/visualpython test/ From 64ac7dde8460bfc7ce4d504fae4aa52743a67319 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 2 Mar 2023 12:30:51 +0900 Subject: [PATCH 10/13] Edit auto-update on JupyterLab --- visualpython/js/com/com_Config.js | 51 +++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/visualpython/js/com/com_Config.js b/visualpython/js/com/com_Config.js index 98bfe98d..c71ed1b4 100644 --- a/visualpython/js/com/com_Config.js +++ b/visualpython/js/com/com_Config.js @@ -209,7 +209,7 @@ define([ vp_signature: 'VisualPython', vp_position: {}, // CHROME: default to display vp - vp_section_display: true, + vp_section_display: false, vp_note_display: false, vp_menu_width: Config.MENU_MIN_WIDTH, vp_note_width: Config.BOARD_MIN_WIDTH @@ -226,6 +226,8 @@ define([ // merge default config $.extend(true, this.defaultConfig, this.metadataSettings); + + console.log('test 1', this.defaultConfig); } _readUserCommandList() { @@ -485,7 +487,7 @@ define([ that._checkMounted().then(function() { that._readFromColab(configKey).then(function(result) { let data = result; - if (data == undefined || data == {}) { + if (data == undefined || Object.keys(data).length === 0) { resolve(data); return; } @@ -493,7 +495,7 @@ define([ resolve(data); return; } - if (Object.keys(data).length > 0) { + if (data instanceof Object && Object.keys(data).length === 0) { resolve(data[dataKey]); return; } @@ -509,7 +511,7 @@ define([ // LAB: use local .visualpython files that._readFromLab(configKey).then(function(result) { let data = result; - if (data == undefined || data == {}) { + if (data == undefined || Object.keys(data).length === 0) { resolve(data); return; } @@ -517,7 +519,7 @@ define([ resolve(data); return; } - if (Object.keys(data).length > 0) { + if (data instanceof Object && Object.keys(data).length === 0) { resolve(data[dataKey]); return; } @@ -779,6 +781,41 @@ define([ return Config.version; } + checkVersionTimestamp = function() { + let that = this; + // check version timestamp + let nowDate = new Date(); + this.getData('version_timestamp', 'vpcfg').then(function(data) { + let doCheckVersion = false; + vpLog.display(VP_LOG_TYPE.LOG, 'Checking its version timestamp... : ' + data); + if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) { + // no timestamp, check version + doCheckVersion = true; + } else if (data != '') { + let lastCheck = new Date(parseInt(data)); + let diffCheck_now = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate()); + let diffCheck_last = new Date(lastCheck.getFullYear(), lastCheck.getMonth() + 1, lastCheck.getDate()); + + let diff = Math.abs(diffCheck_now.getTime() - diffCheck_last.getTime()); + diff = Math.ceil(diff / (1000 * 3600 * 24)); + + if (diff >= 1) { + // if More than 1 day passed, check version + vpLog.display(VP_LOG_TYPE.LOG, 'timestamp diff : ' + diff); + doCheckVersion = true; + } + } + + // check version and update version_timestamp + if (doCheckVersion == true) { + that.checkVpVersion(true); + } + + }).catch(function(err) { + vpLog.display(VP_LOG_TYPE.ERROR, err); + }) + } + checkVpVersion(background=false) { let that = this; let nowVersion = this.getVpInstalledVersion(); @@ -818,6 +855,8 @@ define([ switch (clickedBtnIdx) { case 0: // cancel + // update version_timestamp + that.setData({ 'version_timestamp': new Date().getTime() }, 'vpcfg'); break; case 1: // update @@ -923,7 +962,7 @@ define([ /** * Version */ - Config.version = "2.3.2"; + Config.version = "2.3.2"; // TEST: /** * Type of mode From aec2fb3f365bff08f04a370612999758eeb67885 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 2 Mar 2023 12:31:04 +0900 Subject: [PATCH 11/13] small style changes --- visualpython/css/m_ml/modelInfo.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/visualpython/css/m_ml/modelInfo.css b/visualpython/css/m_ml/modelInfo.css index db81a970..1b63388b 100644 --- a/visualpython/css/m_ml/modelInfo.css +++ b/visualpython/css/m_ml/modelInfo.css @@ -1,3 +1,7 @@ +.vp-model-select-box { + grid-column-gap: 5px; + align-items: start; +} .vp-ins-select-title { font-weight: bold; color: var(--font-highlight); From 1004447db13b61955eae3365c1f3ba61d25518a3 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 2 Mar 2023 12:32:04 +0900 Subject: [PATCH 12/13] Edit auto-update on JupyterLab and Fix default-state of open vp initially on Jupyter Notebook --- visualpython/js/loadVisualpython.js | 39 ++++------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/visualpython/js/loadVisualpython.js b/visualpython/js/loadVisualpython.js index 5d401bb7..2e8ecc69 100644 --- a/visualpython/js/loadVisualpython.js +++ b/visualpython/js/loadVisualpython.js @@ -206,38 +206,6 @@ define([ } } - var _checkVersion = function() { - // check version timestamp - let nowDate = new Date(); - vpConfig.getData('version_timestamp', 'vpcfg').then(function(data) { - let doCheckVersion = false; - if (data == undefined) { - // no timestamp, check version - doCheckVersion = true; - } else if (data != '') { - let lastCheck = new Date(parseInt(data)); - let diffCheck_now = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate()); - let diffCheck_last = new Date(lastCheck.getFullYear(), lastCheck.getMonth() + 1, lastCheck.getDate()); - - let diff = Math.abs(diffCheck_now.getTime() - diffCheck_last.getTime()); - diff = Math.ceil(diff / (1000 * 3600 * 24)); - - if (diff >= 1) { - // if More than 1 day passed, check version - doCheckVersion = true; - } - } - - // check version and update version_timestamp - if (doCheckVersion == true) { - vpConfig.checkVpVersion(true); - } - - }).catch(function(err) { - vpLog.display(VP_LOG_TYPE.ERROR, err); - }) - } - //======================================================================== // External call function //======================================================================== @@ -290,9 +258,10 @@ define([ _addToolBarVpButton(); } _loadVpResource(cfg); - _checkVersion(); + vpConfig.checkVersionTimestamp(); - if (cfg.vp_section_display && vpFrame) { + if ((cfg.vp_section_display && vpFrame) + || vpConfig.extensionType === 'colab') { // CHROME: default to display vp vpFrame.openVp(); } @@ -319,11 +288,13 @@ define([ if (newValue.sessionContext.isReady) { vpLog.display(VP_LOG_TYPE.LOG, 'vp operations for kernel ready...'); vpConfig.readKernelFunction(); + vpConfig.checkVersionTimestamp(); } newValue.sessionContext._connectionStatusChanged.connect(function(s2, status) { if (status === 'connected') { vpLog.display(VP_LOG_TYPE.LOG, 'vp operations for kernel ready...'); vpConfig.readKernelFunction(); + vpConfig.checkVersionTimestamp(); } }); } else { From 724cf4471d2724cf64414c4325dbc24ba28eb2e6 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 2 Mar 2023 12:37:04 +0900 Subject: [PATCH 13/13] Edit auto-update on JupyterLab and Fix default-state of open vp initially on Jupyter Notebook --- visualpython/js/com/com_Config.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/visualpython/js/com/com_Config.js b/visualpython/js/com/com_Config.js index c71ed1b4..b5fbf090 100644 --- a/visualpython/js/com/com_Config.js +++ b/visualpython/js/com/com_Config.js @@ -208,7 +208,6 @@ define([ vp_config_version: '1.0.0', vp_signature: 'VisualPython', vp_position: {}, - // CHROME: default to display vp vp_section_display: false, vp_note_display: false, vp_menu_width: Config.MENU_MIN_WIDTH, @@ -226,8 +225,6 @@ define([ // merge default config $.extend(true, this.defaultConfig, this.metadataSettings); - - console.log('test 1', this.defaultConfig); } _readUserCommandList() { @@ -487,7 +484,7 @@ define([ that._checkMounted().then(function() { that._readFromColab(configKey).then(function(result) { let data = result; - if (data == undefined || Object.keys(data).length === 0) { + if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) { resolve(data); return; } @@ -495,7 +492,7 @@ define([ resolve(data); return; } - if (data instanceof Object && Object.keys(data).length === 0) { + if (data instanceof Object && Object.keys(data).length > 0) { resolve(data[dataKey]); return; } @@ -511,7 +508,7 @@ define([ // LAB: use local .visualpython files that._readFromLab(configKey).then(function(result) { let data = result; - if (data == undefined || Object.keys(data).length === 0) { + if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) { resolve(data); return; } @@ -519,7 +516,7 @@ define([ resolve(data); return; } - if (data instanceof Object && Object.keys(data).length === 0) { + if (data instanceof Object && Object.keys(data).length > 0) { resolve(data[dataKey]); return; } @@ -787,7 +784,7 @@ define([ let nowDate = new Date(); this.getData('version_timestamp', 'vpcfg').then(function(data) { let doCheckVersion = false; - vpLog.display(VP_LOG_TYPE.LOG, 'Checking its version timestamp... : ' + data); + vpLog.display(VP_LOG_TYPE.DEVELOP, 'Checking its version timestamp... : ' + data); if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) { // no timestamp, check version doCheckVersion = true; @@ -801,7 +798,6 @@ define([ if (diff >= 1) { // if More than 1 day passed, check version - vpLog.display(VP_LOG_TYPE.LOG, 'timestamp diff : ' + diff); doCheckVersion = true; } } @@ -962,7 +958,7 @@ define([ /** * Version */ - Config.version = "2.3.2"; // TEST: + Config.version = "2.3.2"; /** * Type of mode