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
6 changes: 3 additions & 3 deletions css/common/frameEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
position: absolute;
width: 100%;
height: 300px;
bottom: 50px;
bottom: 40px;
background: #F7F7F7;
border: 0.25px solid #E4E4E4;
padding: 10px;
Expand Down Expand Up @@ -276,7 +276,7 @@
width: 100%;
height: 100px;
position: absolute;
bottom: 50px;
bottom: 40px;
background: #F7F7F7;
border: 0.25px solid #E4E4E4;
padding: 10px;
Expand All @@ -285,7 +285,7 @@
/* Buttons */
.vp-fe-btn-box {
position: relative;
height: 50px;
height: 40px;
border-top: 0.25px solid var(--border-gray-color);
}
.vp-fe-btn {
Expand Down
4 changes: 2 additions & 2 deletions css/common/popupPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
width: 100%;
height: 100px;
position: absolute;
bottom: 50px;
bottom: 40px;
background: #F7F7F7;
border: 0.25px solid #E4E4E4;
padding: 10px;
Expand All @@ -67,7 +67,7 @@
bottom: 25px;
right: 25px; */
position: relative;
height: 50px;
height: 40px;
border-top: 0.25px solid var(--border-gray-color);
}
.vp-pp-btn {
Expand Down
6 changes: 3 additions & 3 deletions css/common/subsetEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
width: 100%;
height: 100px;
position: absolute;
bottom: 50px;
bottom: 40px;

background: #F7F7F7;
border: 0.25px solid #E4E4E4;
Expand All @@ -276,7 +276,7 @@
bottom: 25px;
right: 25px; */
position: relative;
height: 50px;
height: 40px;
border-top: 0.25px solid var(--border-gray-color);
}
.vp-ds-btn {
Expand Down Expand Up @@ -346,7 +346,7 @@
position: absolute;
width: 100%;
height: 300px;
bottom: 50px;
bottom: 40px;
background: #F7F7F7;
border: 0.25px solid #E4E4E4;
padding: 10px;
Expand Down
5 changes: 5 additions & 0 deletions src/api_block/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ define([
, STR_WHILE
, STR_IMPORT
, STR_API
, STR_APPS
, STR_TRY
, STR_EXCEPT
, STR_FINALLY
Expand Down Expand Up @@ -215,6 +216,10 @@ define([
name = STR_API;
break;
}
case BLOCK_CODELINE_TYPE.APPS: {
name = STR_APPS;
break;
}
case BLOCK_CODELINE_TYPE.TRY: {
name = STR_TRY;
break;
Expand Down
40 changes: 35 additions & 5 deletions src/api_block/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ define([

, ERROR_AB0002_INFINITE_LOOP

, IMPORT_DEFAULT_DATA_LIST } = constData;
, IMPORT_DEFAULT_DATA_LIST

, APPS_CONFIG } = constData;


var Block = function(blockContainerThis, type , blockData, isGroupBlock=false) {
Expand Down Expand Up @@ -301,6 +303,13 @@ define([

, metadata: null
, funcID: STR_EMPTY

/** -------- apps menu data ---------- */
, apps: {
menu: '',
code: '',
state: {}
}
}
this.state_backup = { ...this.state };

Expand Down Expand Up @@ -1180,6 +1189,7 @@ define([
|| blockType == BLOCK_CODELINE_TYPE.PROPERTY
|| blockType == BLOCK_CODELINE_TYPE.TEXT
|| blockType == BLOCK_CODELINE_TYPE.API
|| blockType == BLOCK_CODELINE_TYPE.APPS
|| blockType == BLOCK_CODELINE_TYPE.NODE ) {
codeLineStr = this.getState(STATE_codeLine);
}
Expand Down Expand Up @@ -1211,9 +1221,7 @@ define([

/** API List Pakage가 없을 때 */
if (!thisBlock.getImportPakage()) {
// console.log('no api list package');
// return 'BREAK_RUN';
// TODO: 없으면 기존 metadata의 code로 처리
// 없으면 기존 metadata의 code로 처리
codeLine += GenerateApiCode(thisBlock);
} else {
var apiListPackage = thisBlock.getImportPakage();
Expand All @@ -1240,6 +1248,10 @@ define([

break;
}
case BLOCK_CODELINE_TYPE.APPS: {
codeLine += thisBlock.getState(STATE_codeLine);
break;
}
//class
case BLOCK_CODELINE_TYPE.CLASS: {
codeLine += `${blockName.toLowerCase()}`;
Expand Down Expand Up @@ -1522,7 +1534,8 @@ define([
} else {
$(blockMainDom).css(STR_BACKGROUND_COLOR, COLOR_CONTROL);
}
} else if (blockType == BLOCK_CODELINE_TYPE.API) {
} else if (blockType == BLOCK_CODELINE_TYPE.API
|| blockType == BLOCK_CODELINE_TYPE.APPS) {
if (isReset == true) {
$(blockMainDom).css(STR_BACKGROUND_COLOR, COLOR_API_STRONG);
} else {
Expand Down Expand Up @@ -1773,6 +1786,23 @@ define([
blockOptionPageDom = InitTextBlockOption(thisBlock, optionPageSelector);
break;
}

case BLOCK_CODELINE_TYPE.APPS: {
var menu = thisBlock.state.apps.menu;
var { file, config } = APPS_CONFIG[menu];
if (config == undefined) {
config = {}
}
config = {
...config,
state: {
...thisBlock.state.apps.state
}
};

blockContainerThis.createAppsPage(menu, file, config);
break;
}
}


Expand Down
31 changes: 25 additions & 6 deletions src/api_block/blockContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ define([
this.blockMenu = new BlockMenu(this);

// loadedAppsMenu
this.apps = undefined;
this.appsMenu = null;
}

Expand Down Expand Up @@ -802,7 +803,7 @@ define([
createdBlock.state = {
...createdBlock.state
, blockOptionState
}
};
createdBlock.setChildBlockUUIDList(childBlockUUIDList || nextBlockUUIDList);

createdBlockList.push(createdBlock);
Expand Down Expand Up @@ -1826,7 +1827,7 @@ define([
this.resetBlockListAndRenderThisBlock(createdBlock_api);
}

BlockContainer.prototype.createAppsPage = function(moduleFile, config={}, callback=undefined) {
BlockContainer.prototype.createAppsPage = function(appsKey, moduleFile, config={}, callback=undefined) {
var that = this;

// var loadUrl = 'markdown/markdown.js';
Expand All @@ -1835,8 +1836,11 @@ define([
requirejs([loadUrl], function (loaded) {
if (Object.keys(loaded).includes('initOption')) {
loaded.initOption(function(funcJS) {
// optionPage load callback
that.apps = appsKey;
that.appsMenu = new popupPage(funcJS, 'vp_appsCode');
funcJS.wrapSelector = that.appsMenu.wrapSelector;
funcJS.loadMeta(funcJS, config.state);
// library page
$(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM), vpCommon.formatString(".{0}", vpConst.API_OPTION_PAGE))).each(function() {
that.appsMenu.open({
Expand All @@ -1847,11 +1851,17 @@ define([
if (callback) {
callback(funcJS);
}
}, undefined);
}, config.state);
} else {
// save appsMenu object
that.apps = appsKey;
that.appsMenu = new loaded(null, 'vp_appsCode');
that.appsMenu.open();
that.appsMenu.open({
...config
});
if (callback) {
callback(that.appsMenu);
}
}


Expand Down Expand Up @@ -1932,7 +1942,8 @@ define([
|| blockType == BLOCK_CODELINE_TYPE.LAMBDA
|| blockType == BLOCK_CODELINE_TYPE.NODE
|| blockType == BLOCK_CODELINE_TYPE.TEXT
|| blockType == BLOCK_CODELINE_TYPE.API ) {
|| blockType == BLOCK_CODELINE_TYPE.API
|| blockType == BLOCK_CODELINE_TYPE.APPS ) {
blockName = '';
} else if (blockType == BLOCK_CODELINE_TYPE.PROPERTY) {
blockName = '@';
Expand Down Expand Up @@ -2017,6 +2028,7 @@ define([
|| blockType == BLOCK_CODELINE_TYPE.LAMBDA
|| blockType == BLOCK_CODELINE_TYPE.IMPORT
|| blockType == BLOCK_CODELINE_TYPE.API
|| blockType == BLOCK_CODELINE_TYPE.APPS

|| blockType == BLOCK_CODELINE_TYPE.ELSE
|| blockType == BLOCK_CODELINE_TYPE.FINALLY
Expand All @@ -2040,6 +2052,7 @@ define([
|| blockType == BLOCK_CODELINE_TYPE.COMMENT
|| blockType == BLOCK_CODELINE_TYPE.PROPERTY
|| blockType == BLOCK_CODELINE_TYPE.API
|| blockType == BLOCK_CODELINE_TYPE.APPS
|| blockType == BLOCK_CODELINE_TYPE.LAMBDA ) {
sbMainHeader.appendFormatLine("<strong class='{0}'>",'vp-block-header-name');
sbMainHeader.appendFormatLine("{0}", blockName);
Expand Down Expand Up @@ -2206,6 +2219,9 @@ define([
} else {
codeList.push(apiCodeLine);
}
} else if (blockType == BLOCK_CODELINE_TYPE.APPS) {
var { code } = block.getState('apps');
codeList.push(code);
} else {
var tmpCodeLine = block.setCodeLineAndGet(indentString, false)
if (asPreview && blockType == BLOCK_CODELINE_TYPE.TEXT && tmpCodeLine.length > 0) {
Expand Down Expand Up @@ -2250,14 +2266,17 @@ define([
var codeLine = STR_EMPTY;
var blockType = block.getBlockType();

if ( blockType == BLOCK_CODELINE_TYPE.API ) {
if ( blockType == BLOCK_CODELINE_TYPE.API) {
var apiCodeLine = block.setCodeLineAndGet(indentString, true);
if (apiCodeLine.indexOf('BREAK_RUN') != -1) {
// codeLineStr += 'BREAK_RUN';
// return true;
} else {
codeLine += apiCodeLine;
}
} else if (blockType == BLOCK_CODELINE_TYPE.APPS) {
var { code } = block.getState('apps');
codeLine += code;
} else {
codeLine += block.setCodeLineAndGet(indentString, false);
}
Expand Down
1 change: 1 addition & 0 deletions src/api_block/component/option/api_option.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ define([
}

funcJS.loadMeta(funcJS, generatedMetaData);
console.log('metadata', generatedMetaData);
blockContainerThis.removeOptionDom(blockUUID);
var blockOptionPageDom = makeUpGreenRoomHTML();
thisBlock.setBlockOptionPageDom(blockOptionPageDom);
Expand Down
46 changes: 46 additions & 0 deletions src/api_block/constData.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ define([

, COMMENT: 16
, PRINT: 17

, APPS: 20

, ELIF: 100
, ELSE: 200
Expand Down Expand Up @@ -274,6 +276,7 @@ define([
const STR_WHILE = 'while';
const STR_IMPORT = 'import';
const STR_API = 'api';
const STR_APPS = 'apps';
const STR_TRY = 'try';
const STR_EXCEPT = 'except';
const STR_FINALLY = 'finally';
Expand Down Expand Up @@ -736,6 +739,46 @@ define([
// const WHILE_OPERATOR_ARG4 = ['none', '==' ,'!=', '<', '>', '>=', '<=', 'and', 'or', 'in','not in'];
// const WHILE_OPERATOR_ARG6 = ['==' ,'!=', '<', '>', '>=', '<=', 'and', 'or', 'in','not in'];

const APPS_CONFIG = {
'import': {
file: '/nbextensions/visualpython/src/file_io/import.js',
config: { title: 'Import', width: '500px'}
},
'markdown': {
file: '/nbextensions/visualpython/src/markdown/markdown.js',
config: { title: 'Markdown' }
},
'snippets': {
file: '/nbextensions/visualpython/src/file_io/udf.js',
config: { title: 'Snippets' }
},
'variable': {
file: '/nbextensions/visualpython/src/file_io/variables.js',
config: { title: 'Variables' }
},
'file': {
file: '/nbextensions/visualpython/src/file_io/fileio.js',
config: { title: 'File', width: '500px' }
},
'instance': {
file: '/nbextensions/visualpython/src/file_io/instance.js',
config: { title: 'Instance' }
},
'subset': {
file: 'nbextensions/visualpython/src/common/vpSubsetEditor',
},
'frame': {
file: 'nbextensions/visualpython/src/common/vpFrameEditor'
},
'chart': {
file: '/nbextensions/visualpython/src/matplotlib/plot.js',
config: { title: 'Chart', width: '600px' }
},
'profiling': {
file: 'nbextensions/visualpython/src/common/vpProfiling'
}
}

return {
BLOCK_GROUP_TYPE
, BLOCK_CODELINE_BTN_TYPE
Expand Down Expand Up @@ -848,6 +891,7 @@ define([
, STR_WHILE
, STR_IMPORT
, STR_API
, STR_APPS
, STR_TRY
, STR_EXCEPT
, STR_FINALLY
Expand Down Expand Up @@ -1212,5 +1256,7 @@ define([
, DEF_PARAM_TYPE_LIST

, IMPORT_DEFAULT_DATA_LIST

, APPS_CONFIG
}
});
Loading