Skip to content

Commit e7ed167

Browse files
authored
Merge pull request #82 from minjk-bl/devops
Devops
2 parents 6a7054d + 5856924 commit e7ed167

13 files changed

Lines changed: 130 additions & 69 deletions

File tree

css/common/frameEditor.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,16 @@
7474
.vp-fe-preview .CodeMirror-code .cm-string {
7575
background-color: rgba(246, 173, 85, 0.2);
7676
}
77+
78+
7779
.vp-fe-df-box {
7880
display: grid;
7981
grid-template-rows: 30px;
8082
grid-row-gap: 5px;
8183
}
8284
.vp-fe-df-box label {
8385
width: 80px;
86+
font-weight: bold;
8487
}
8588
.vp-fe #vp_feVariable {
8689
width: 153px;

css/common/subsetEditor.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
background-color: rgba(246, 173, 85, 0.2);
7676
}
7777
.vp-ds-label {
78-
color: #F37704;
7978
font-weight: bold;
8079
margin-left: 20px;
8180
}

src/api/functions/pandasCommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _vp_get_columns_list(df):
3333
# value
3434
if type(c).__name__ == 'str':
3535
cInfo['value'] = "'{}'".format(c)
36-
elif type(r).__name__ == 'Timestamp':
36+
elif type(c).__name__ == 'Timestamp':
3737
cInfo['value'] = str(c)
3838
# category - iopub data rate limit issue...
3939
if str(df[c].dtype) == 'object':

src/api_block/blockContainer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,11 +621,11 @@ define([
621621
*/
622622
BlockContainer.prototype.setFocusedPageType = function(focusedPageType) {
623623
// 추가: FOCUSED_PAGE_TYPE = NULL일 경우 주피터 단축키 활성화 / 아닐 경우 비활성화
624-
if (focusedPageType == FOCUSED_PAGE_TYPE.NULL) {
625-
// Jupyter.notebook.keyboard_manager.enable();
626-
} else {
627-
// Jupyter.notebook.keyboard_manager.disable();
628-
}
624+
// if (focusedPageType == FOCUSED_PAGE_TYPE.NULL) {
625+
// Jupyter.notebook.keyboard_manager.enable();
626+
// } else {
627+
// Jupyter.notebook.keyboard_manager.disable();
628+
// }
629629
this.focusedPageType = focusedPageType;
630630
}
631631
BlockContainer.prototype.getFocusedPageType = function() {

src/api_block/init.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ define([
519519
// blockContainer.resetOptionPage();
520520
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
521521
});
522+
523+
$(vpCommon.wrapSelector(''))
522524

523525
/** Create block buttons page를 클릭했을 때 */
524526
$(vpCommon.wrapSelector(VP_CLASS_PREFIX + VP_CLASS_APIBLOCK_BUTTONS)).click(function(event) {
@@ -574,7 +576,8 @@ define([
574576
ctrlKey = 17,
575577
cmdKey = 91,
576578
vKey = 86,
577-
cKey = 67;
579+
cKey = 67,
580+
escKey = 27;
578581

579582
$(document).keydown(function(e) {
580583
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) {
@@ -583,12 +586,43 @@ define([
583586
}).keyup(function(e) {
584587
if (e.keyCode == ctrlKey || e.keyCode == cmdKey) {
585588
ctrlDown = false;
589+
console.log(blockContainer.getFocusedPageType());
590+
}
591+
if (e.keyCode == escKey) {
592+
// close popup on esc
593+
if (blockContainer.getFocusedPageType() != FOCUSED_PAGE_TYPE.NULL) {
594+
blockContainer.appsMenu.close();
595+
}
586596
}
587597
}).click(function(e) {
598+
// click event on jupyter side
599+
if ($('#notebook').has(e.target).length > 0) {
600+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
601+
}
602+
// click event on visual python menu tab & button box
603+
if ($(vpCommon.wrapSelector('.vp-apiblock-tab-header')).has(e.target).length > 0
604+
|| $(vpCommon.wrapSelector('.vp-apiblock-board-button-container')).has(e.target).length > 0) {
605+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.BUTTONS);
606+
}
607+
// click event on popup menu
608+
if ($(vpCommon.wrapSelector('.vp-ds')).has(e.target).length > 0
609+
|| $(vpCommon.wrapSelector('.vp-fe')).has(e.target).length > 0
610+
|| $(vpCommon.wrapSelector('.vp-pp')).has(e.target).length > 0
611+
|| $(vpCommon.wrapSelector('.vp-ds-btn-box')).has(e.target).length > 0
612+
|| $(vpCommon.wrapSelector('.vp-fe-btn-box')).has(e.target).length > 0
613+
|| $(vpCommon.wrapSelector('.vp-pp-btn-box')).has(e.target).length > 0) {
614+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.OPTION);
615+
}
616+
588617
// check modified
589618
blockContainer.checkModified();
590619
});
591620

621+
// focus event on codemirror of jupyter side
622+
$(document).on('focus', '#notebook .CodeMirror', function(e){
623+
blockContainer.setFocusedPageType(FOCUSED_PAGE_TYPE.NULL);
624+
});
625+
592626
$(document).change($(vpCommon.wrapSelector('.vp-apiblock-option input')), function() {
593627
// check modified
594628
blockContainer.checkModified();

src/common/vpFrameEditor.js

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ define([
182182
FrameEditor.prototype.close = function() {
183183
this.unbindEvent();
184184
$(this.wrapSelector()).remove();
185+
$(vpCommon.formatString('.{0}.{1}', VP_FE_BTN, this.uuid)).remove();
185186
}
186187

187188
FrameEditor.prototype.init = function(state = undefined) {
@@ -190,6 +191,8 @@ define([
190191
originObj: '',
191192
tempObj: '_vp',
192193
returnObj: '_vp',
194+
columnList: [],
195+
indexList: [],
193196
selected: [],
194197
axis: FRAME_AXIS.NONE,
195198
lines: TABLE_LINES,
@@ -303,7 +306,7 @@ define([
303306
page.appendFormatLine('<div class="{0}"><img src="{1}"/></div>', VP_FE_DF_REFRESH, '/nbextensions/visualpython/resource/refresh.svg');
304307
page.appendLine('</div>');
305308
page.appendLine('<div>');
306-
page.appendFormatLine('<label for="{0}" class="{1}">{2}</label>', 'vp_feReturn', 'vp-orange-text', 'Allocate to');
309+
page.appendFormatLine('<label for="{0}">{1}</label>', 'vp_feReturn', 'Allocate to');
307310
page.appendFormatLine('<input type="text" class="{0}" id="{1}" placeholder="{2}"/>', 'vp-input', 'vp_feReturn', 'Variable name');
308311
page.appendLine('</div>');
309312
page.appendLine('</div>');
@@ -553,19 +556,39 @@ define([
553556

554557
// tab 4. apply
555558
content.appendFormatLine('<div class="{0} {1}" style="display: none;">', 'vp-popup-tab', 'apply');
556-
content.appendLine('<label>lambda x:</label>');
559+
content.appendLine('<table><colgroup><col width="80px"><col width="*"></colgroup>');
560+
content.appendLine('<tr><th><label>column</label></th>');
561+
content.appendFormatLine('<td>{0}</td></tr>', this.renderColumnList(this.state.columnList));
562+
content.appendLine('<tr><th><label>lambda x:</label></th>');
557563
var suggestInput = new vpSuggestInputText.vpSuggestInputText();
558564
suggestInput.setComponentID('vp_popupAddApply');
559-
suggestInput.addClass('vp-input vp-popup-apply');
565+
suggestInput.addClass('vp-input vp-popup-apply-lambda');
560566
suggestInput.setSuggestList(function() { return ['x', 'min(x)', 'max(x)', 'sum(x)', 'mean(x)']; });
561567
suggestInput.setValue('x');
562568
suggestInput.setNormalFilter(false);
563-
content.appendLine(suggestInput.toTagString());
569+
content.appendFormatLine('<td>{0}</td>', suggestInput.toTagString());
570+
content.appendLine('</tr></table>');
564571
content.appendLine('</div>'); // end of vp-popup-tab apply
565572
content.appendLine('</div>'); // end of vp-popup-addpage
566573
return content.toString();
567574
}
568575

576+
/**
577+
* Render column list for [add column > apply]
578+
* @param {Array} columnList
579+
* @returns
580+
*/
581+
FrameEditor.prototype.renderColumnList = function(columnList) {
582+
var selectTag = new sb.StringBuilder();
583+
selectTag.appendFormatLine('<select class="{0}">', 'vp-popup-apply-column');
584+
columnList && columnList.forEach((col, idx) => {
585+
var colLabel = convertToStr(col, typeof col == 'string');
586+
selectTag.appendFormatLine('<option value="{0}">{1}</option>', colLabel, col);
587+
});
588+
selectTag.appendLine('</select>');
589+
return selectTag.toString();
590+
}
591+
569592
FrameEditor.prototype.bindEventForPopupPage = function() {
570593
var that = this;
571594
///// add page
@@ -719,7 +742,8 @@ define([
719742
}
720743
}
721744
} else if (tab == 'apply') {
722-
content['apply'] = $(this.wrapSelector('.vp-popup-apply')).val();
745+
content['column'] = $(this.wrapSelector('.vp-popup-apply-column')).val();
746+
content['apply'] = $(this.wrapSelector('.vp-popup-apply-lambda')).val();
723747
}
724748
break;
725749
case FRAME_EDIT_TYPE.ADD_ROW:
@@ -770,6 +794,7 @@ define([
770794

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

775800
if (!this.cmpreviewall) {
@@ -823,6 +848,7 @@ define([
823848
}
824849

825850
FrameEditor.prototype.openDataview = function() {
851+
this.closePreview();
826852
this.dataviewOpened = true;
827853
$(this.wrapSelector('.' + VP_FE_INFO)).show();
828854
}
@@ -1058,7 +1084,7 @@ define([
10581084
}
10591085
code.append(')');
10601086
} else if (tab == 'apply') {
1061-
code.appendFormat("{0}[{1}] = {2}.apply(lambda x: {3})", tempObj, name, tempObj, content.apply);
1087+
code.appendFormat("{0}[{1}] = {2}[{3}].apply(lambda x: {4})", tempObj, name, tempObj, content.column, content.apply);
10621088
}
10631089
break;
10641090
case FRAME_EDIT_TYPE.ADD_ROW:
@@ -1090,11 +1116,14 @@ define([
10901116
kernelApi.executePython(code.toString(), function(result) {
10911117
try {
10921118
var data = JSON.parse(result.substr(1,result.length - 2).replaceAll('\\\\', '\\'));
1093-
// console.l og(data);
1119+
// console.log(data);
10941120
var columnList = data.columns;
10951121
var indexList = data.index;
10961122
var dataList = data.data;
10971123

1124+
that.state.columnList = columnList;
1125+
that.state.indexList = indexList;
1126+
10981127
// table
10991128
var table = new sb.StringBuilder();
11001129
// table.appendFormatLine('<table border="{0}" class="{1}">', 1, 'dataframe');
@@ -1191,11 +1220,11 @@ define([
11911220

11921221
FrameEditor.prototype.saveState = function() {
11931222
// if there's anything to save, you can properly save it here.
1194-
console.log('frame', 'saveState', this.state);
1223+
// console.log('frame', 'saveState', this.state);
11951224
}
11961225

11971226
FrameEditor.prototype.loadState = function(state) {
1198-
console.log('frame', 'loadState', state);
1227+
// console.log('frame', 'loadState', state);
11991228
var {
12001229
originObj,
12011230
returnObj,
@@ -1254,8 +1283,6 @@ define([
12541283
// close popup
12551284
$(document).on('click', this.wrapSelector('.' + VP_FE_CLOSE), function(event) {
12561285
that.close();
1257-
1258-
$(vpCommon.formatString('.{0}.{1}', VP_FE_BTN, this.uuid)).remove();
12591286
// vpCommon.removeHeadScript("vpSubsetEditor");
12601287
});
12611288

@@ -1343,8 +1370,13 @@ define([
13431370
// close menu
13441371
that.hideMenu();
13451372
}
1346-
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_DATAVIEW)) {
1347-
// close info
1373+
if (!$(evt.target).hasClass(VP_FE_BUTTON_PREVIEW)
1374+
&& !$(evt.target).hasClass(VP_FE_PREVIEW_BOX)
1375+
&& $(that.wrapSelector('.' + VP_FE_PREVIEW_BOX)).has(evt.target).length === 0) {
1376+
that.closePreview();
1377+
}
1378+
if (!$(evt.target).hasClass(VP_FE_BUTTON_DATAVIEW)
1379+
&& $(that.wrapSelector('.' + VP_FE_INFO)).has(evt.target).length === 0) {
13481380
that.closeDataview();
13491381
}
13501382
});
@@ -1589,7 +1621,7 @@ define([
15891621

15901622
// click preview
15911623
$(document).on('click', this.wrapSelector('.' + VP_FE_BUTTON_PREVIEW), function(evt) {
1592-
evt.stopPropagation();
1624+
// evt.stopPropagation();
15931625
if (that.previewOpened) {
15941626
that.closePreview();
15951627
} else {
@@ -1599,7 +1631,7 @@ define([
15991631

16001632
// click dataview
16011633
$(document).on('click', this.wrapSelector('.' + VP_FE_BUTTON_DATAVIEW), function(evt) {
1602-
evt.stopPropagation();
1634+
// evt.stopPropagation();
16031635
if (that.dataviewOpened) {
16041636
that.closeDataview();
16051637
} else {
@@ -1638,14 +1670,14 @@ define([
16381670

16391671
// click others
16401672
$(document).on('click.' + this.uuid, function(evt) {
1641-
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_DETAIL)) {
1673+
if (!$(evt.target).hasClass(VP_FE_BUTTON_DETAIL)) {
16421674
$(that.wrapSelector('.' + VP_FE_DETAIL_BOX)).hide();
16431675
}
1644-
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_PREVIEW)
1676+
if (!$(evt.target).hasClass(VP_FE_BUTTON_PREVIEW)
16451677
&& $(that.wrapSelector('.' + VP_FE_PREVIEW_BOX)).has(evt.target).length === 0) {
16461678
that.closePreview();
16471679
}
1648-
if (!$(evt.target).hasClass('.' + VP_FE_BUTTON_DATAVIEW)
1680+
if (!$(evt.target).hasClass(VP_FE_BUTTON_DATAVIEW)
16491681
&& $(that.wrapSelector('.' + VP_FE_INFO)).has(evt.target).length === 0) {
16501682
that.closeDataview();
16511683
}
@@ -1681,10 +1713,10 @@ define([
16811713
if (e.keyCode == keyCode.shiftKey) {
16821714
that.keyboardManager.keyCheck.shiftKey = false;
16831715
}
1684-
if (e.keyCode == keyCode.escKey) {
1685-
// close on esc
1686-
that.close();
1687-
}
1716+
// if (e.keyCode == keyCode.escKey) {
1717+
// // close on esc
1718+
// that.close();
1719+
// }
16881720
});
16891721
}
16901722

src/common/vpPopupPage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ define([
213213

214214
// click preview
215215
$(document).on('click', this.wrapSelector('.' + VP_PP_BUTTON_PREVIEW), function(evt) {
216-
evt.stopPropagation();
216+
// evt.stopPropagation();
217217
if (that.previewOpened) {
218218
that.closePreview();
219219
} else {
@@ -291,10 +291,10 @@ define([
291291
if (e.keyCode == keyCode.shiftKey) {
292292
that.keyboardManager.keyCheck.shiftKey = false;
293293
}
294-
if (e.keyCode == keyCode.escKey) {
295-
// close on esc
296-
that.close();
297-
}
294+
// if (e.keyCode == keyCode.escKey) {
295+
// // close on esc
296+
// that.close();
297+
// }
298298
});
299299
}
300300

0 commit comments

Comments
 (0)