', VP_FE, this.uuid);
+ page.appendFormatLine('
', VP_FE_CONTAINER);
+
+ // menu box
+ page.appendLine(this.renderMenuBox());
+ // input popup
+ page.appendLine(this.renderInputPopup());
+
+ // title
+ page.appendFormat('
{1}
'
+ , VP_FE_TITLE
+ , 'Frame Editor');
+
+ // close button
+ page.appendFormatLine('
'
+ , VP_FE_CLOSE, 'fa fa-close');
+
+ // body start
+ page.appendFormatLine('
', VP_FE_BODY);
+
+ // preview code board
+ page.appendFormatLine('
'
+ , VP_FE_PREVIEW, "vp_fePreviewCode");
+
+ // Select DataFrame
+ page.appendFormatLine('
', VP_FE_DF_BOX);
+ page.appendFormatLine('', 'vp_feVariable', 'vp-orange-text', 'DataFrame');
+ page.appendFormatLine('');
+ page.appendFormatLine('', VP_FE_DF_REFRESH, 'fa fa-refresh');
+ page.appendLine('
');
+
+ // Table
+ page.appendFormatLine('
', VP_FE_TABLE);
+
+ page.appendLine('
'); // End of Table
+
+ // Info Box
+ page.appendFormatLine('
', VP_FE_INFO);
+ page.appendFormatLine('
Info
', VP_FE_INFO_TITLE);
+ page.appendFormatLine('
content
', VP_FE_INFO_CONTENT);
+ page.appendLine('
'); // End of VP_FE_INFO
+
+ page.appendLine('
'); // VP_FE_BODY
+
+ // apply button
+ page.appendFormatLine('
', VP_FE_BUTTON_BOX);
+ page.appendFormatLine(''
+ , VP_FE_BUTTON_CANCEL, 'Cancel');
+ page.appendFormatLine(''
+ , VP_FE_BUTTON_APPLY, 'Apply');
+ page.appendLine('
');
+
+ page.appendLine('
'); // VP_FE_CONTAINER
+ page.appendLine('
'); // VP_FE
+
+ $('#vp-wrapper').append(page.toString());
+ $(this.wrapSelector()).hide();
+ }
+
+ FrameEditor.prototype.renderMenuBox = function() {
+ var page = new sb.StringBuilder();
+ // Menus
+ page.appendFormatLine('', VP_FE_MENU_BOX);
+ // menu 1. Add Column
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-add-column', FRAME_EDIT_TYPE.ADD_COL, 'Add Column');
+ // menu 2. Add Row
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-add-row', FRAME_EDIT_TYPE.ADD_ROW, 'Add Row');
+ // menu 3. drop
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-drop', FRAME_EDIT_TYPE.DROP, 'Drop'
+ , 'fa fa-caret-right', 'padding-left: 5px;'); //TODO: NA & Duplicate selection needed
+ // sub-menu 1.
+ page.appendFormatLine('
', VP_FE_MENU_SUB_BOX, 'top: 50px;');
+ // menu 3-1. drop
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-drop', FRAME_EDIT_TYPE.DROP, 'Drop');
+ // menu 3-2. drop-na
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-drop-na', FRAME_EDIT_TYPE.DROP_NA, 'Drop NA');
+ // menu 3-3. drop-duplicate
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-drop-duplicate', FRAME_EDIT_TYPE.DROP_DUP, 'Drop Duplicate');
+ page.appendLine('
'); // end of sub-menu 1
+ page.appendLine('
'); // end of menu 3
+ // menu 4. rename
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-rename', FRAME_EDIT_TYPE.RENAME, 'Rename');
+ // menu 5. one-hot encoding
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-ohe', FRAME_EDIT_TYPE.ONE_HOT_ENCODING, 'One-Hot Encoding');
+ // menu 6. set/reset index
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-index', FRAME_EDIT_TYPE.SET_IDX, 'Set Index');
+ // menu 7. replace
+ page.appendFormatLine('
{3}
'
+ , VP_FE_MENU_ITEM, 'vp-fe-menu-replace', FRAME_EDIT_TYPE.REPLACE, 'Replace');
+ page.appendLine('
'); // End of Menus
+ return page.toString();
+ }
+
+ FrameEditor.prototype.renderInputPopup = function() {
+ var page = new sb.StringBuilder();
+ page.appendFormatLine('', VP_FE_POPUP_BOX);
+ // popup title
+ page.appendFormat('
{1}
'
+ , VP_FE_TITLE
+ , 'Input');
+ // close button
+ page.appendFormatLine('
'
+ , VP_FE_POPUP_CLOSE, 'fa fa-close');
+ page.appendFormatLine('
', VP_FE_POPUP_BODY);
+
+
+
+ page.appendLine('
'); // End of Body
+
+ // apply button
+ page.appendFormatLine('
', VP_FE_POPUP_BUTTON_BOX);
+ page.appendFormatLine(''
+ , VP_FE_POPUP_CANCEL, 'Cancel');
+ page.appendFormatLine(''
+ , VP_FE_POPUP_OK, 'OK');
+ page.appendLine('
');
+
+ page.appendLine('
'); // End of Popup
+ return page.toString();
+ }
+
+ FrameEditor.prototype.loadVariableList = function() {
+ var that = this;
+ // load using kernel
+ var dataTypes = ['DataFrame'];
+ kernelApi.searchVarList(dataTypes, function(result) {
+ try {
+ var varList = JSON.parse(result);
+ // render variable list
+ // replace
+ $(that.wrapSelector('#vp_feVariable')).replaceWith(function() {
+ return that.renderVariableList(varList);
+ });
+ $(that.wrapSelector('#vp_feVariable')).trigger('change');
+ } catch (ex) {
+ // console.log(ex);
+ }
+ });
+ }
+
+ FrameEditor.prototype.renderVariableList = function(varList) {
+ var tag = new sb.StringBuilder();
+ var beforeValue = $(this.wrapSelector('#vp_feVariable')).val();
+ tag.appendFormatLine('', VP_FE_TABLE, 'rendered_html');
+ if (isHtml) {
+ tag.appendFormatLine('
', renderedText);
+ // More button
+ tag.appendFormatLine('
More...
', VP_FE_TABLE_MORE, 'vp-button');
+ } else {
+ tag.appendFormatLine('
{0}', renderedText);
+ }
+ tag.appendLine('
'); // End of Table
+ return tag.toString();
+ }
+
+ FrameEditor.prototype.renderAddPage = function(type) {
+ var content = new sb.StringBuilder();
+ content.appendLine('