Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions css/common/frameEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@
.vp-fe-preview .CodeMirror-code .cm-string {
background-color: rgba(246, 173, 85, 0.2);
}


.vp-fe-df-box {
display: grid;
grid-template-rows: 30px;
grid-row-gap: 5px;
}
.vp-fe-df-box label {
width: 80px;
font-weight: bold;
}
.vp-fe #vp_feVariable {
width: 153px;
Expand Down
1 change: 0 additions & 1 deletion css/common/subsetEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
background-color: rgba(246, 173, 85, 0.2);
}
.vp-ds-label {
color: #F37704;
font-weight: bold;
margin-left: 20px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/functions/pandasCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _vp_get_columns_list(df):
# value
if type(c).__name__ == 'str':
cInfo['value'] = "'{}'".format(c)
elif type(r).__name__ == 'Timestamp':
elif type(c).__name__ == 'Timestamp':
cInfo['value'] = str(c)
# category - iopub data rate limit issue...
if str(df[c].dtype) == 'object':
Expand Down
10 changes: 5 additions & 5 deletions src/api_block/blockContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ define([
*/
BlockContainer.prototype.setFocusedPageType = function(focusedPageType) {
// 추가: FOCUSED_PAGE_TYPE = NULL일 경우 주피터 단축키 활성화 / 아닐 경우 비활성화
if (focusedPageType == FOCUSED_PAGE_TYPE.NULL) {
// Jupyter.notebook.keyboard_manager.enable();
} else {
// Jupyter.notebook.keyboard_manager.disable();
}
// if (focusedPageType == FOCUSED_PAGE_TYPE.NULL) {
// Jupyter.notebook.keyboard_manager.enable();
// } else {
// Jupyter.notebook.keyboard_manager.disable();
// }
this.focusedPageType = focusedPageType;
}
BlockContainer.prototype.getFocusedPageType = function() {
Expand Down
36 changes: 35 additions & 1 deletion src/api_block/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ define([
// blockContainer.resetOptionPage();
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
});

$(vpCommon.wrapSelector(''))

/** Create block buttons page를 클릭했을 때 */
$(vpCommon.wrapSelector(VP_CLASS_PREFIX + VP_CLASS_APIBLOCK_BUTTONS)).click(function(event) {
Expand Down Expand Up @@ -574,7 +576,8 @@ define([
ctrlKey = 17,
cmdKey = 91,
vKey = 86,
cKey = 67;
cKey = 67,
escKey = 27;

$(document).keydown(function(e) {
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) {
Expand All @@ -583,12 +586,43 @@ define([
}).keyup(function(e) {
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) {
ctrlDown = false;
console.log(blockContainer.getFocusedPageType());
}
if (e.keyCode == escKey) {
// close popup on esc
if (blockContainer.getFocusedPageType() != FOCUSED_PAGE_TYPE.NULL) {
blockContainer.appsMenu.close();
}
}
}).click(function(e) {
// click event on jupyter side
if ($('#notebook').has(e.target).length > 0) {
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
}
// click event on visual python menu tab & button box
if ($(vpCommon.wrapSelector('.vp-apiblock-tab-header')).has(e.target).length > 0
|| $(vpCommon.wrapSelector('.vp-apiblock-board-button-container')).has(e.target).length > 0) {
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.BUTTONS);
}
// click event on popup menu
if ($(vpCommon.wrapSelector('.vp-ds')).has(e.target).length > 0
|| $(vpCommon.wrapSelector('.vp-fe')).has(e.target).length > 0
|| $(vpCommon.wrapSelector('.vp-pp')).has(e.target).length > 0
|| $(vpCommon.wrapSelector('.vp-ds-btn-box')).has(e.target).length > 0
|| $(vpCommon.wrapSelector('.vp-fe-btn-box')).has(e.target).length > 0
|| $(vpCommon.wrapSelector('.vp-pp-btn-box')).has(e.target).length > 0) {
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.OPTION);
}

// check modified
blockContainer.checkModified();
});

// focus event on codemirror of jupyter side
$(document).on('focus', '#notebook .CodeMirror', function(e){
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
});

$(document).change($(vpCommon.wrapSelector('.vp-apiblock-option input')), function() {
// check modified
blockContainer.checkModified();
Expand Down
76 changes: 54 additions & 22 deletions src/common/vpFrameEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ define([
FrameEditor.prototype.close = function() {
this.unbindEvent();
$(this.wrapSelector()).remove();
$(vpCommon.formatString('.{0}.{1}', VP_FE_BTN, this.uuid)).remove();
}

FrameEditor.prototype.init = function(state = undefined) {
Expand All @@ -190,6 +191,8 @@ define([
originObj: '',
tempObj: '_vp',
returnObj: '_vp',
columnList: [],
indexList: [],
selected: [],
axis: FRAME_AXIS.NONE,
lines: TABLE_LINES,
Expand Down Expand Up @@ -303,7 +306,7 @@ define([
page.appendFormatLine('<div class="{0}"><img src="{1}"/></div>', VP_FE_DF_REFRESH, '/nbextensions/visualpython/resource/refresh.svg');
page.appendLine('</div>');
page.appendLine('<div>');
page.appendFormatLine('<label for="{0}" class="{1}">{2}</label>', 'vp_feReturn', 'vp-orange-text', 'Allocate to');
page.appendFormatLine('<label for="{0}">{1}</label>', 'vp_feReturn', 'Allocate to');
page.appendFormatLine('<input type="text" class="{0}" id="{1}" placeholder="{2}"/>', 'vp-input', 'vp_feReturn', 'Variable name');
page.appendLine('</div>');
page.appendLine('</div>');
Expand Down Expand Up @@ -553,19 +556,39 @@ define([

// tab 4. apply
content.appendFormatLine('<div class="{0} {1}" style="display: none;">', 'vp-popup-tab', 'apply');
content.appendLine('<label>lambda x:</label>');
content.appendLine('<table><colgroup><col width="80px"><col width="*"></colgroup>');
content.appendLine('<tr><th><label>column</label></th>');
content.appendFormatLine('<td>{0}</td></tr>', this.renderColumnList(this.state.columnList));
content.appendLine('<tr><th><label>lambda x:</label></th>');
var suggestInput = new vpSuggestInputText.vpSuggestInputText();
suggestInput.setComponentID('vp_popupAddApply');
suggestInput.addClass('vp-input vp-popup-apply');
suggestInput.addClass('vp-input vp-popup-apply-lambda');
suggestInput.setSuggestList(function() { return ['x', 'min(x)', 'max(x)', 'sum(x)', 'mean(x)']; });
suggestInput.setValue('x');
suggestInput.setNormalFilter(false);
content.appendLine(suggestInput.toTagString());
content.appendFormatLine('<td>{0}</td>', suggestInput.toTagString());
content.appendLine('</tr></table>');
content.appendLine('</div>'); // end of vp-popup-tab apply
content.appendLine('</div>'); // end of vp-popup-addpage
return content.toString();
}

/**
* Render column list for [add column > apply]
* @param {Array} columnList
* @returns
*/
FrameEditor.prototype.renderColumnList = function(columnList) {
var selectTag = new sb.StringBuilder();
selectTag.appendFormatLine('<select class="{0}">', 'vp-popup-apply-column');
columnList && columnList.forEach((col, idx) => {
var colLabel = convertToStr(col, typeof col == 'string');
selectTag.appendFormatLine('<option value="{0}">{1}</option>', colLabel, col);
});
selectTag.appendLine('</select>');
return selectTag.toString();
}

FrameEditor.prototype.bindEventForPopupPage = function() {
var that = this;
///// add page
Expand Down Expand Up @@ -719,7 +742,8 @@ define([
}
}
} else if (tab == 'apply') {
content['apply'] = $(this.wrapSelector('.vp-popup-apply')).val();
content['column'] = $(this.wrapSelector('.vp-popup-apply-column')).val();
content['apply'] = $(this.wrapSelector('.vp-popup-apply-lambda')).val();
}
break;
case FRAME_EDIT_TYPE.ADD_ROW:
Expand Down Expand Up @@ -770,6 +794,7 @@ define([

/** open preview box */
FrameEditor.prototype.openPreview = function() {
this.closeDataview();
$(this.wrapSelector('.' + VP_FE_PREVIEW_BOX)).show();

if (!this.cmpreviewall) {
Expand Down Expand Up @@ -823,6 +848,7 @@ define([
}

FrameEditor.prototype.openDataview = function() {
this.closePreview();
this.dataviewOpened = true;
$(this.wrapSelector('.' + VP_FE_INFO)).show();
}
Expand Down Expand Up @@ -1058,7 +1084,7 @@ define([
}
code.append(')');
} else if (tab == 'apply') {
code.appendFormat("{0}[{1}] = {2}.apply(lambda x: {3})", tempObj, name, tempObj, content.apply);
code.appendFormat("{0}[{1}] = {2}[{3}].apply(lambda x: {4})", tempObj, name, tempObj, content.column, content.apply);
}
break;
case FRAME_EDIT_TYPE.ADD_ROW:
Expand Down Expand Up @@ -1090,11 +1116,14 @@ define([
kernelApi.executePython(code.toString(), function(result) {
try {
var data = JSON.parse(result.substr(1,result.length - 2).replaceAll('\\\\', '\\'));
// console.l og(data);
// console.log(data);
var columnList = data.columns;
var indexList = data.index;
var dataList = data.data;

that.state.columnList = columnList;
that.state.indexList = indexList;

// table
var table = new sb.StringBuilder();
// table.appendFormatLine('<table border="{0}" class="{1}">', 1, 'dataframe');
Expand Down Expand Up @@ -1191,11 +1220,11 @@ define([

FrameEditor.prototype.saveState = function() {
// if there's anything to save, you can properly save it here.
console.log('frame', 'saveState', this.state);
// console.log('frame', 'saveState', this.state);
}

FrameEditor.prototype.loadState = function(state) {
console.log('frame', 'loadState', state);
// console.log('frame', 'loadState', state);
var {
originObj,
returnObj,
Expand Down Expand Up @@ -1254,8 +1283,6 @@ define([
// close popup
$(document).on('click', this.wrapSelector('.' + VP_FE_CLOSE), function(event) {
that.close();

$(vpCommon.formatString('.{0}.{1}', VP_FE_BTN, this.uuid)).remove();
// vpCommon.removeHeadScript("vpSubsetEditor");
});

Expand Down Expand Up @@ -1343,8 +1370,13 @@ define([
// close menu
that.hideMenu();
}
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_DATAVIEW)) {
// close info
if (!$(evt.target).hasClass(VP_FE_BUTTON_PREVIEW)
&& !$(evt.target).hasClass(VP_FE_PREVIEW_BOX)
&& $(that.wrapSelector('.' + VP_FE_PREVIEW_BOX)).has(evt.target).length === 0) {
that.closePreview();
}
if (!$(evt.target).hasClass(VP_FE_BUTTON_DATAVIEW)
&& $(that.wrapSelector('.' + VP_FE_INFO)).has(evt.target).length === 0) {
that.closeDataview();
}
});
Expand Down Expand Up @@ -1589,7 +1621,7 @@ define([

// click preview
$(document).on('click', this.wrapSelector('.' + VP_FE_BUTTON_PREVIEW), function(evt) {
evt.stopPropagation();
// evt.stopPropagation();
if (that.previewOpened) {
that.closePreview();
} else {
Expand All @@ -1599,7 +1631,7 @@ define([

// click dataview
$(document).on('click', this.wrapSelector('.' + VP_FE_BUTTON_DATAVIEW), function(evt) {
evt.stopPropagation();
// evt.stopPropagation();
if (that.dataviewOpened) {
that.closeDataview();
} else {
Expand Down Expand Up @@ -1638,14 +1670,14 @@ define([

// click others
$(document).on('click.' + this.uuid, function(evt) {
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_DETAIL)) {
if (!$(evt.target).hasClass(VP_FE_BUTTON_DETAIL)) {
$(that.wrapSelector('.' + VP_FE_DETAIL_BOX)).hide();
}
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_PREVIEW)
if (!$(evt.target).hasClass(VP_FE_BUTTON_PREVIEW)
&& $(that.wrapSelector('.' + VP_FE_PREVIEW_BOX)).has(evt.target).length === 0) {
that.closePreview();
}
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_DATAVIEW)
if (!$(evt.target).hasClass(VP_FE_BUTTON_DATAVIEW)
&& $(that.wrapSelector('.' + VP_FE_INFO)).has(evt.target).length === 0) {
that.closeDataview();
}
Expand Down Expand Up @@ -1681,10 +1713,10 @@ define([
if (e.keyCode == keyCode.shiftKey) {
that.keyboardManager.keyCheck.shiftKey = false;
}
if (e.keyCode == keyCode.escKey) {
// close on esc
that.close();
}
// if (e.keyCode == keyCode.escKey) {
// // close on esc
// that.close();
// }
});
}

Expand Down
10 changes: 5 additions & 5 deletions src/common/vpPopupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ define([

// click preview
$(document).on('click', this.wrapSelector('.' + VP_PP_BUTTON_PREVIEW), function(evt) {
evt.stopPropagation();
// evt.stopPropagation();
if (that.previewOpened) {
that.closePreview();
} else {
Expand Down Expand Up @@ -291,10 +291,10 @@ define([
if (e.keyCode == keyCode.shiftKey) {
that.keyboardManager.keyCheck.shiftKey = false;
}
if (e.keyCode == keyCode.escKey) {
// close on esc
that.close();
}
// if (e.keyCode == keyCode.escKey) {
// // close on esc
// that.close();
// }
});
}

Expand Down
Loading