From bc3ef1e28a0d2f117e23fc940d810f6ca42233f0 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Wed, 27 Oct 2021 12:15:04 +0900 Subject: [PATCH 1/9] Resize bug fix - block min width --- css/api_block/index.css | 1 + 1 file changed, 1 insertion(+) diff --git a/css/api_block/index.css b/css/api_block/index.css index 4360fab4..daa6f6a7 100644 --- a/css/api_block/index.css +++ b/css/api_block/index.css @@ -324,6 +324,7 @@ } .vp-block { position: relative; + min-width: 205px; min-height: 25px; z-index: 1; text-align: left; From 487803b7b49705f20839921801abdd4cb49f3323 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 28 Oct 2021 14:14:32 +0900 Subject: [PATCH 2/9] Bind - label changed (Left/Righ Data) --- src/common/vpBind.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/vpBind.js b/src/common/vpBind.js index 2c7a0482..46499646 100644 --- a/src/common/vpBind.js +++ b/src/common/vpBind.js @@ -342,14 +342,14 @@ define([ page.appendFormatLine('
', 'vp-bd-type-box', 'merge', this.state.type=='merge'?'':'style="display: none;"'); // left dataframe page.appendLine('
'); - page.appendFormatLine('', 'vp_bdLeftDataframe', 'vp-orange-text wp100', 'Left Dataframe'); + page.appendFormatLine('', 'vp_bdLeftDataframe', 'vp-orange-text wp100', 'Left Data'); page.appendFormatLine(''); page.appendFormatLine('
', 'vp-bd-df-refresh', 'Refresh all dataframe list', '/nbextensions/visualpython/resource/refresh.svg'); page.appendLine('
'); // right dataframe page.appendLine('
'); - page.appendFormatLine('', 'vp_bdRightDataframe', 'vp-orange-text wp100', 'Right Dataframe'); + page.appendFormatLine('', 'vp_bdRightDataframe', 'vp-orange-text wp100', 'Right Data'); page.appendFormatLine(''); page.appendLine('
'); From fc90c854b9d1421daf738e83950eb5fcc1cff4cb Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Thu, 28 Oct 2021 20:07:15 +0900 Subject: [PATCH 3/9] Variable update --- src/file_io/variables.js | 98 ++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 59 deletions(-) diff --git a/src/file_io/variables.js b/src/file_io/variables.js index 7436f7b3..bc71d8f8 100644 --- a/src/file_io/variables.js +++ b/src/file_io/variables.js @@ -8,7 +8,7 @@ define([ , 'nbextensions/visualpython/src/pandas/common/commonPandas' , 'nbextensions/visualpython/src/pandas/common/pandasGenerator' ], function (requirejs, $, vpCommon, vpConst, sb, vpFuncJS, libPandas, pdGen) { - // 옵션 속성 + // option property const funcOptProp = { stepCount : 1 , funcName : "Variables" @@ -17,74 +17,73 @@ define([ } /** - * html load 콜백. 고유 id 생성하여 부과하며 js 객체 클래스 생성하여 컨테이너로 전달 - * @param {function} callback 호출자(컨테이너) 의 콜백함수 + * html load callback. 고유 id 생성하여 부과하며 js 객체 클래스 생성하여 컨테이너로 전달 + * @param {function} callback container's callback */ var optionLoadCallback = function(callback, meta) { - // document.getElementsByTagName("head")[0].appendChild(link); - // 컨테이너에서 전달된 callback 함수가 존재하면 실행. + // execute callback function if available if (typeof(callback) === 'function') { var uuid = 'u' + vpCommon.getUUID(); - // 최대 10회 중복되지 않도록 체크 + // maximum 10 duplication allowed for (var idx = 0; idx < 10; idx++) { - // 이미 사용중인 uuid 인 경우 다시 생성 + // uuid check and re-generate if ($(vpConst.VP_CONTAINER_ID).find("." + uuid).length > 0) { uuid = 'u' + vpCommon.getUUID(); } } $(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM))).find(vpCommon.formatString(".{0}", vpConst.API_OPTION_PAGE)).addClass(uuid); - // 옵션 객체 생성 + // create object var varPackage = new VariablePackage(uuid); varPackage.metadata = meta; - // 옵션 속성 할당. + // set option property varPackage.setOptionProp(funcOptProp); - // html 설정. + // html setting varPackage.initHtml(); - callback(varPackage); // 공통 객체를 callback 인자로 전달 + callback(varPackage); } } /** - * html 로드. - * @param {function} callback 호출자(컨테이너) 의 콜백함수 + * Load html + * @param {function} callback container's callback */ var initOption = function(callback, meta) { vpCommon.loadHtml(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM)), "file_io/variables.html", optionLoadCallback, callback, meta); } /** - * 본 옵션 처리 위한 클래스 - * @param {String} uuid 고유 id + * Option package + * @param {String} uuid unique id */ var VariablePackage = function(uuid) { this.uuid = uuid; // Load html 영역의 uuid. - // pandas 함수 + // pandas function this.package = libPandas._PANDAS_FUNCTION[funcOptProp.libID]; } /** - * vpFuncJS 에서 상속 + * Extend vpFuncJS */ VariablePackage.prototype = Object.create(vpFuncJS.VpFuncJS.prototype); /** - * 유효성 검사 - * @returns 유효성 검사 결과. 적합시 true + * Validation + * @returns true if it's valid */ VariablePackage.prototype.optionValidation = function() { return true; - // 부모 클래스 유효성 검사 호출. + // parent's validation // vpFuncJS.VpFuncJS.prototype.optionValidation.apply(this); } /** - * html 내부 binding 처리 + * html inner binding */ VariablePackage.prototype.initHtml = function() { this.showFunctionTitle(); @@ -98,7 +97,7 @@ define([ } /** - * 선택한 패키지명 입력 + * package title */ VariablePackage.prototype.showFunctionTitle = function() { $(this.wrapSelector('.vp_functionName')).text(funcOptProp.funcName); @@ -115,43 +114,43 @@ define([ } /** - * Variables 조회 + * Search variables */ VariablePackage.prototype.loadVariables = function() { var that = this; - // 조회가능한 변수 data type 정의 FIXME: 조회 필요한 변수 유형 추가 + // Searchable variable types var types = [ - // pandas 객체 + // pandas object 'DataFrame', 'Series', 'Index', 'Period', 'GroupBy', 'Timestamp' - // Index 하위 유형 + // Index type object , 'RangeIndex', 'CategoricalIndex', 'MultiIndex', 'IntervalIndex', 'DatetimeIndex', 'TimedeltaIndex', 'PeriodIndex', 'Int64Index', 'UInt64Index', 'Float64Index' - // GroupBy 하위 유형 + // GroupBy type object , 'DataFrameGroupBy', 'SeriesGroupBy' - // Plot 관련 유형 + // Plot type , 'Figure', 'AxesSubplot' // Numpy , 'ndarray' - // Python 변수 + // Python variable , 'str', 'int', 'float', 'bool', 'dict', 'list', 'tuple' ]; var tagTable = this.wrapSelector('#vp_var_variableBox table'); - // 변수 정보 표시 + // variable list table var tagDetailTable = this.wrapSelector("#vp_varDetailTable"); // initialize tags $(tagTable).find('tr:not(:first)').remove(); $(tagDetailTable).html(''); - // HTML 구성 + // HTML rendering pdGen.vp_searchVarList(types, function(result) { // var jsonVars = result.replace(/'/gi, `"`); // var varList = JSON.parse(jsonVars); var varList = JSON.parse(result); - // table 에 변수목록 추가 + // add variable list in table varList.forEach(varObj => { if (types.includes(varObj.varType) && varObj.varName[0] !== '_') { var tagTr = document.createElement('tr'); @@ -167,30 +166,12 @@ define([ $(tagTr).append(tagTdName); $(tagTr).append(tagTdType); - $(tagTdName).attr({ - 'title': 'Click to copy' - }); - // 변수이름 클릭 시 클립보드에 복사 - $(tagTdName).click(function() { - // // 클립보드 복사 시작 - var tempElem = document.createElement('input'); - tempElem.value = varObj.varName; - document.body.appendChild(tempElem); - - tempElem.select(); - document.execCommand("copy"); - document.body.removeChild(tempElem); - // 클립보드 복사 완료 - vpCommon.renderSuccessMessage('Copied!'); - }); - - // 변수 선택 시 표시 + // variable click $(tagTr).click(function() { $(this).parent().find('tr').removeClass('selected'); $(this).addClass('selected'); - // TEST: 변수 선택 시 변수 정보를 하단에 표시 - // vpFuncJS.kernelExecute 에서는 callback에 msg.content["text"]를 전달해주기 때문에 따로 구현함 + // show variable information on clicking variable Jupyter.notebook.kernel.execute( varObj.varName, { @@ -202,14 +183,14 @@ define([ $(tagDetailTable).html(''); if (htmlResult != undefined) { - // 1. HTML 태그로 구성되어 반환되는 경우 + // 1. HTML tag $(tagDetailTable).append(htmlResult); } else if (imgResult != undefined) { - // 2. 이미지 데이터가 반환되는 경우 (base64) + // 2. Image data (base64) var imgTag = ''; $(tagDetailTable).append(imgTag); } else if (textResult != undefined) { - // 3. 텍스트 데이터가 반환되는 경우 + // 3. Text data var preTag = document.createElement('pre'); $(preTag).text(textResult); $(tagDetailTable).html(preTag); @@ -221,7 +202,6 @@ define([ }, { silent: false } ); - // TEST: END }) $(tagTable).append(tagTr); @@ -231,14 +211,14 @@ define([ }; /** - * 코드 생성 - * @param {boolean} exec 실행여부 + * Generate code + * @param {boolean} exec do execute */ VariablePackage.prototype.generateCode = function(addCell, exec) { var sbCode = new sb.StringBuilder(); - // TODO: 변수 내용 조회 + // show selected variable var selectedVariable = $(this.wrapSelector('#vp_var_variableBox table tr.selected')); if (selectedVariable) { var varName = selectedVariable.attr('data-var-name'); From 406278952c713fde722e3f51dbb1bf26ea00adf5 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 1 Nov 2021 12:34:11 +0900 Subject: [PATCH 4/9] Chart - import option fix --- src/matplotlib/plot.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/matplotlib/plot.js b/src/matplotlib/plot.js index 78a8fb1f..e87dcade 100644 --- a/src/matplotlib/plot.js +++ b/src/matplotlib/plot.js @@ -127,7 +127,7 @@ define([ // Box 1. Import var accBoxImport = this.createOptionContainer('Import Options'); - // accBoxImport.setOpenBox(true); + accBoxImport.setOpenBox(true); sbTagString.clear(); sbTagString.appendFormatLine('
', 'vp-import-box'); // figure size @@ -141,8 +141,6 @@ define([ sbTagString.appendFormatLine('', 'vp_plStyle', '', 'Style sheet'); sbTagString.appendFormatLine('', 'vp_plStyle', 'style name'); sbTagString.appendLine('
'); - // divider - sbTagString.appendLine('
'); // system font sbTagString.appendLine('
'); sbTagString.appendFormatLine('', 'vp_plFontName', '', 'System font'); @@ -152,11 +150,11 @@ define([ sbTagString.appendLine('
'); sbTagString.appendFormatLine('', 'vp_plFontSize', '', 'Font size'); sbTagString.appendFormatLine('', 'vp_plFontSize', 'size', 10); - sbTagString.appendLine('
'); - // import button - sbTagString.appendLine('
'); sbTagString.appendFormatLine('', 'vp_plImportRun', 'vp-button activated vp-pl-import-run', 'Apply'); sbTagString.appendLine('
'); + // // apply button + // sbTagString.appendLine('
'); + // sbTagString.appendLine('
'); sbTagString.appendLine('
'); accBoxImport.appendContent(sbTagString.toString()); From 4bdce4ed037569c0571f20fbccb79e5c61115576 Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 1 Nov 2021 18:05:54 +0900 Subject: [PATCH 5/9] MultiSelector - info title bug fixed --- src/common/component/vpMultiSelector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/component/vpMultiSelector.js b/src/common/component/vpMultiSelector.js index b01916fe..636e25da 100644 --- a/src/common/component/vpMultiSelector.js +++ b/src/common/component/vpMultiSelector.js @@ -233,8 +233,8 @@ define([ dataList && dataList.forEach((data, idx) => { // for column : data.array parsing var info = vpCommon.safeString(data.array); - if (info) { - info = data.value + ':\n'; + if (info && info != 'undefined') { + info = data.value + ':\n' + info; } else { info = ''; } From 549ed440fe95c93ad87c66e1716d4d714721dc7d Mon Sep 17 00:00:00 2001 From: minjk-bl Date: Mon, 1 Nov 2021 18:06:06 +0900 Subject: [PATCH 6/9] Frame - as_type --- src/common/vpFrameEditor.js | 346 ++++++++++++++++++++++-------------- 1 file changed, 211 insertions(+), 135 deletions(-) diff --git a/src/common/vpFrameEditor.js b/src/common/vpFrameEditor.js index e305b095..100c8f94 100644 --- a/src/common/vpFrameEditor.js +++ b/src/common/vpFrameEditor.js @@ -88,6 +88,7 @@ define([ SET_IDX: 7, RESET_IDX: 8, REPLACE: 9, + AS_TYPE: 10, ADD_COL: 97, ADD_ROW: 98, @@ -213,6 +214,15 @@ define([ }; } + // numpy.dtype or python type + this.astypeList = [ + 'datetime64', + 'int', 'int32', 'int64', + 'float', 'float64', + 'object', 'category', + 'bool', 'str' + ]; + this.codepreview = undefined; this.cmpreviewall = undefined; this.previewOpened = false; @@ -368,18 +378,18 @@ define([ var page = new sb.StringBuilder(); // Menus page.appendFormatLine('