Skip to content

Commit 64ac7dd

Browse files
author
minjk-bl
committed
Edit auto-update on JupyterLab
1 parent 17540cf commit 64ac7dd

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

visualpython/js/com/com_Config.js

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ define([
209209
vp_signature: 'VisualPython',
210210
vp_position: {},
211211
// CHROME: default to display vp
212-
vp_section_display: true,
212+
vp_section_display: false,
213213
vp_note_display: false,
214214
vp_menu_width: Config.MENU_MIN_WIDTH,
215215
vp_note_width: Config.BOARD_MIN_WIDTH
@@ -226,6 +226,8 @@ define([
226226

227227
// merge default config
228228
$.extend(true, this.defaultConfig, this.metadataSettings);
229+
230+
console.log('test 1', this.defaultConfig);
229231
}
230232

231233
_readUserCommandList() {
@@ -485,15 +487,15 @@ define([
485487
that._checkMounted().then(function() {
486488
that._readFromColab(configKey).then(function(result) {
487489
let data = result;
488-
if (data == undefined || data == {}) {
490+
if (data == undefined || Object.keys(data).length === 0) {
489491
resolve(data);
490492
return;
491493
}
492494
if (dataKey == '') {
493495
resolve(data);
494496
return;
495497
}
496-
if (Object.keys(data).length > 0) {
498+
if (data instanceof Object && Object.keys(data).length === 0) {
497499
resolve(data[dataKey]);
498500
return;
499501
}
@@ -509,15 +511,15 @@ define([
509511
// LAB: use local .visualpython files
510512
that._readFromLab(configKey).then(function(result) {
511513
let data = result;
512-
if (data == undefined || data == {}) {
514+
if (data == undefined || Object.keys(data).length === 0) {
513515
resolve(data);
514516
return;
515517
}
516518
if (dataKey == '') {
517519
resolve(data);
518520
return;
519521
}
520-
if (Object.keys(data).length > 0) {
522+
if (data instanceof Object && Object.keys(data).length === 0) {
521523
resolve(data[dataKey]);
522524
return;
523525
}
@@ -779,6 +781,41 @@ define([
779781
return Config.version;
780782
}
781783

784+
checkVersionTimestamp = function() {
785+
let that = this;
786+
// check version timestamp
787+
let nowDate = new Date();
788+
this.getData('version_timestamp', 'vpcfg').then(function(data) {
789+
let doCheckVersion = false;
790+
vpLog.display(VP_LOG_TYPE.LOG, 'Checking its version timestamp... : ' + data);
791+
if (data == undefined || (data instanceof Object && Object.keys(data).length === 0)) {
792+
// no timestamp, check version
793+
doCheckVersion = true;
794+
} else if (data != '') {
795+
let lastCheck = new Date(parseInt(data));
796+
let diffCheck_now = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate());
797+
let diffCheck_last = new Date(lastCheck.getFullYear(), lastCheck.getMonth() + 1, lastCheck.getDate());
798+
799+
let diff = Math.abs(diffCheck_now.getTime() - diffCheck_last.getTime());
800+
diff = Math.ceil(diff / (1000 * 3600 * 24));
801+
802+
if (diff >= 1) {
803+
// if More than 1 day passed, check version
804+
vpLog.display(VP_LOG_TYPE.LOG, 'timestamp diff : ' + diff);
805+
doCheckVersion = true;
806+
}
807+
}
808+
809+
// check version and update version_timestamp
810+
if (doCheckVersion == true) {
811+
that.checkVpVersion(true);
812+
}
813+
814+
}).catch(function(err) {
815+
vpLog.display(VP_LOG_TYPE.ERROR, err);
816+
})
817+
}
818+
782819
checkVpVersion(background=false) {
783820
let that = this;
784821
let nowVersion = this.getVpInstalledVersion();
@@ -818,6 +855,8 @@ define([
818855
switch (clickedBtnIdx) {
819856
case 0:
820857
// cancel
858+
// update version_timestamp
859+
that.setData({ 'version_timestamp': new Date().getTime() }, 'vpcfg');
821860
break;
822861
case 1:
823862
// update
@@ -923,7 +962,7 @@ define([
923962
/**
924963
* Version
925964
*/
926-
Config.version = "2.3.2";
965+
Config.version = "2.3.2"; // TEST:
927966

928967
/**
929968
* Type of mode

0 commit comments

Comments
 (0)