Skip to content

Commit 39e3b58

Browse files
authored
Merge pull request #75 from minjk-bl/devops
Apps load/save
2 parents 7ba1abf + aaf2ca4 commit 39e3b58

17 files changed

Lines changed: 715 additions & 212 deletions

css/common/frameEditor.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221
position: absolute;
222222
width: 100%;
223223
height: 300px;
224-
bottom: 50px;
224+
bottom: 40px;
225225
background: #F7F7F7;
226226
border: 0.25px solid #E4E4E4;
227227
padding: 10px;
@@ -276,7 +276,7 @@
276276
width: 100%;
277277
height: 100px;
278278
position: absolute;
279-
bottom: 50px;
279+
bottom: 40px;
280280
background: #F7F7F7;
281281
border: 0.25px solid #E4E4E4;
282282
padding: 10px;
@@ -285,7 +285,7 @@
285285
/* Buttons */
286286
.vp-fe-btn-box {
287287
position: relative;
288-
height: 50px;
288+
height: 40px;
289289
border-top: 0.25px solid var(--border-gray-color);
290290
}
291291
.vp-fe-btn {

css/common/popupPage.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
width: 100%;
5656
height: 100px;
5757
position: absolute;
58-
bottom: 50px;
58+
bottom: 40px;
5959
background: #F7F7F7;
6060
border: 0.25px solid #E4E4E4;
6161
padding: 10px;
@@ -67,7 +67,7 @@
6767
bottom: 25px;
6868
right: 25px; */
6969
position: relative;
70-
height: 50px;
70+
height: 40px;
7171
border-top: 0.25px solid var(--border-gray-color);
7272
}
7373
.vp-pp-btn {

css/common/subsetEditor.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
width: 100%;
264264
height: 100px;
265265
position: absolute;
266-
bottom: 50px;
266+
bottom: 40px;
267267

268268
background: #F7F7F7;
269269
border: 0.25px solid #E4E4E4;
@@ -276,7 +276,7 @@
276276
bottom: 25px;
277277
right: 25px; */
278278
position: relative;
279-
height: 50px;
279+
height: 40px;
280280
border-top: 0.25px solid var(--border-gray-color);
281281
}
282282
.vp-ds-btn {
@@ -346,7 +346,7 @@
346346
position: absolute;
347347
width: 100%;
348348
height: 300px;
349-
bottom: 50px;
349+
bottom: 40px;
350350
background: #F7F7F7;
351351
border: 0.25px solid #E4E4E4;
352352
padding: 10px;

src/api_block/api.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ define([
2727
, STR_WHILE
2828
, STR_IMPORT
2929
, STR_API
30+
, STR_APPS
3031
, STR_TRY
3132
, STR_EXCEPT
3233
, STR_FINALLY
@@ -215,6 +216,10 @@ define([
215216
name = STR_API;
216217
break;
217218
}
219+
case BLOCK_CODELINE_TYPE.APPS: {
220+
name = STR_APPS;
221+
break;
222+
}
218223
case BLOCK_CODELINE_TYPE.TRY: {
219224
name = STR_TRY;
220225
break;

src/api_block/block.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ define([
183183

184184
, ERROR_AB0002_INFINITE_LOOP
185185

186-
, IMPORT_DEFAULT_DATA_LIST } = constData;
186+
, IMPORT_DEFAULT_DATA_LIST
187+
188+
, APPS_CONFIG } = constData;
187189

188190

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

302304
, metadata: null
303305
, funcID: STR_EMPTY
306+
307+
/** -------- apps menu data ---------- */
308+
, apps: {
309+
menu: '',
310+
code: '',
311+
state: {}
312+
}
304313
}
305314
this.state_backup = { ...this.state };
306315

@@ -1180,6 +1189,7 @@ define([
11801189
|| blockType == BLOCK_CODELINE_TYPE.PROPERTY
11811190
|| blockType == BLOCK_CODELINE_TYPE.TEXT
11821191
|| blockType == BLOCK_CODELINE_TYPE.API
1192+
|| blockType == BLOCK_CODELINE_TYPE.APPS
11831193
|| blockType == BLOCK_CODELINE_TYPE.NODE ) {
11841194
codeLineStr = this.getState(STATE_codeLine);
11851195
}
@@ -1211,9 +1221,7 @@ define([
12111221

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

12411249
break;
12421250
}
1251+
case BLOCK_CODELINE_TYPE.APPS: {
1252+
codeLine += thisBlock.getState(STATE_codeLine);
1253+
break;
1254+
}
12431255
//class
12441256
case BLOCK_CODELINE_TYPE.CLASS: {
12451257
codeLine += `${blockName.toLowerCase()}`;
@@ -1522,7 +1534,8 @@ define([
15221534
} else {
15231535
$(blockMainDom).css(STR_BACKGROUND_COLOR, COLOR_CONTROL);
15241536
}
1525-
} else if (blockType == BLOCK_CODELINE_TYPE.API) {
1537+
} else if (blockType == BLOCK_CODELINE_TYPE.API
1538+
|| blockType == BLOCK_CODELINE_TYPE.APPS) {
15261539
if (isReset == true) {
15271540
$(blockMainDom).css(STR_BACKGROUND_COLOR, COLOR_API_STRONG);
15281541
} else {
@@ -1773,6 +1786,23 @@ define([
17731786
blockOptionPageDom = InitTextBlockOption(thisBlock, optionPageSelector);
17741787
break;
17751788
}
1789+
1790+
case BLOCK_CODELINE_TYPE.APPS: {
1791+
var menu = thisBlock.state.apps.menu;
1792+
var { file, config } = APPS_CONFIG[menu];
1793+
if (config == undefined) {
1794+
config = {}
1795+
}
1796+
config = {
1797+
...config,
1798+
state: {
1799+
...thisBlock.state.apps.state
1800+
}
1801+
};
1802+
1803+
blockContainerThis.createAppsPage(menu, file, config);
1804+
break;
1805+
}
17761806
}
17771807

17781808

src/api_block/blockContainer.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ define([
227227
this.blockMenu = new BlockMenu(this);
228228

229229
// loadedAppsMenu
230+
this.apps = undefined;
230231
this.appsMenu = null;
231232
}
232233

@@ -802,7 +803,7 @@ define([
802803
createdBlock.state = {
803804
...createdBlock.state
804805
, blockOptionState
805-
}
806+
};
806807
createdBlock.setChildBlockUUIDList(childBlockUUIDList || nextBlockUUIDList);
807808

808809
createdBlockList.push(createdBlock);
@@ -1826,7 +1827,7 @@ define([
18261827
this.resetBlockListAndRenderThisBlock(createdBlock_api);
18271828
}
18281829

1829-
BlockContainer.prototype.createAppsPage = function(moduleFile, config={}, callback=undefined) {
1830+
BlockContainer.prototype.createAppsPage = function(appsKey, moduleFile, config={}, callback=undefined) {
18301831
var that = this;
18311832

18321833
// var loadUrl = 'markdown/markdown.js';
@@ -1835,8 +1836,11 @@ define([
18351836
requirejs([loadUrl], function (loaded) {
18361837
if (Object.keys(loaded).includes('initOption')) {
18371838
loaded.initOption(function(funcJS) {
1839+
// optionPage load callback
1840+
that.apps = appsKey;
18381841
that.appsMenu = new popupPage(funcJS, 'vp_appsCode');
18391842
funcJS.wrapSelector = that.appsMenu.wrapSelector;
1843+
funcJS.loadMeta(funcJS, config.state);
18401844
// library page
18411845
$(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM), vpCommon.formatString(".{0}", vpConst.API_OPTION_PAGE))).each(function() {
18421846
that.appsMenu.open({
@@ -1847,11 +1851,17 @@ define([
18471851
if (callback) {
18481852
callback(funcJS);
18491853
}
1850-
}, undefined);
1854+
}, config.state);
18511855
} else {
18521856
// save appsMenu object
1857+
that.apps = appsKey;
18531858
that.appsMenu = new loaded(null, 'vp_appsCode');
1854-
that.appsMenu.open();
1859+
that.appsMenu.open({
1860+
...config
1861+
});
1862+
if (callback) {
1863+
callback(that.appsMenu);
1864+
}
18551865
}
18561866

18571867

@@ -1932,7 +1942,8 @@ define([
19321942
|| blockType == BLOCK_CODELINE_TYPE.LAMBDA
19331943
|| blockType == BLOCK_CODELINE_TYPE.NODE
19341944
|| blockType == BLOCK_CODELINE_TYPE.TEXT
1935-
|| blockType == BLOCK_CODELINE_TYPE.API ) {
1945+
|| blockType == BLOCK_CODELINE_TYPE.API
1946+
|| blockType == BLOCK_CODELINE_TYPE.APPS ) {
19361947
blockName = '';
19371948
} else if (blockType == BLOCK_CODELINE_TYPE.PROPERTY) {
19381949
blockName = '@';
@@ -2017,6 +2028,7 @@ define([
20172028
|| blockType == BLOCK_CODELINE_TYPE.LAMBDA
20182029
|| blockType == BLOCK_CODELINE_TYPE.IMPORT
20192030
|| blockType == BLOCK_CODELINE_TYPE.API
2031+
|| blockType == BLOCK_CODELINE_TYPE.APPS
20202032

20212033
|| blockType == BLOCK_CODELINE_TYPE.ELSE
20222034
|| blockType == BLOCK_CODELINE_TYPE.FINALLY
@@ -2040,6 +2052,7 @@ define([
20402052
|| blockType == BLOCK_CODELINE_TYPE.COMMENT
20412053
|| blockType == BLOCK_CODELINE_TYPE.PROPERTY
20422054
|| blockType == BLOCK_CODELINE_TYPE.API
2055+
|| blockType == BLOCK_CODELINE_TYPE.APPS
20432056
|| blockType == BLOCK_CODELINE_TYPE.LAMBDA ) {
20442057
sbMainHeader.appendFormatLine("<strong class='{0}'>",'vp-block-header-name');
20452058
sbMainHeader.appendFormatLine("{0}", blockName);
@@ -2206,6 +2219,9 @@ define([
22062219
} else {
22072220
codeList.push(apiCodeLine);
22082221
}
2222+
} else if (blockType == BLOCK_CODELINE_TYPE.APPS) {
2223+
var { code } = block.getState('apps');
2224+
codeList.push(code);
22092225
} else {
22102226
var tmpCodeLine = block.setCodeLineAndGet(indentString, false)
22112227
if (asPreview && blockType == BLOCK_CODELINE_TYPE.TEXT && tmpCodeLine.length > 0) {
@@ -2250,14 +2266,17 @@ define([
22502266
var codeLine = STR_EMPTY;
22512267
var blockType = block.getBlockType();
22522268

2253-
if ( blockType == BLOCK_CODELINE_TYPE.API ) {
2269+
if ( blockType == BLOCK_CODELINE_TYPE.API) {
22542270
var apiCodeLine = block.setCodeLineAndGet(indentString, true);
22552271
if (apiCodeLine.indexOf('BREAK_RUN') != -1) {
22562272
// codeLineStr += 'BREAK_RUN';
22572273
// return true;
22582274
} else {
22592275
codeLine += apiCodeLine;
22602276
}
2277+
} else if (blockType == BLOCK_CODELINE_TYPE.APPS) {
2278+
var { code } = block.getState('apps');
2279+
codeLine += code;
22612280
} else {
22622281
codeLine += block.setCodeLineAndGet(indentString, false);
22632282
}

src/api_block/component/option/api_option.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ define([
4545
}
4646

4747
funcJS.loadMeta(funcJS, generatedMetaData);
48+
console.log('metadata', generatedMetaData);
4849
blockContainerThis.removeOptionDom(blockUUID);
4950
var blockOptionPageDom = makeUpGreenRoomHTML();
5051
thisBlock.setBlockOptionPageDom(blockOptionPageDom);

src/api_block/constData.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ define([
5252

5353
, COMMENT: 16
5454
, PRINT: 17
55+
56+
, APPS: 20
5557

5658
, ELIF: 100
5759
, ELSE: 200
@@ -274,6 +276,7 @@ define([
274276
const STR_WHILE = 'while';
275277
const STR_IMPORT = 'import';
276278
const STR_API = 'api';
279+
const STR_APPS = 'apps';
277280
const STR_TRY = 'try';
278281
const STR_EXCEPT = 'except';
279282
const STR_FINALLY = 'finally';
@@ -736,6 +739,46 @@ define([
736739
// const WHILE_OPERATOR_ARG4 = ['none', '==' ,'!=', '<', '>', '>=', '<=', 'and', 'or', 'in','not in'];
737740
// const WHILE_OPERATOR_ARG6 = ['==' ,'!=', '<', '>', '>=', '<=', 'and', 'or', 'in','not in'];
738741

742+
const APPS_CONFIG = {
743+
'import': {
744+
file: '/nbextensions/visualpython/src/file_io/import.js',
745+
config: { title: 'Import', width: '500px'}
746+
},
747+
'markdown': {
748+
file: '/nbextensions/visualpython/src/markdown/markdown.js',
749+
config: { title: 'Markdown' }
750+
},
751+
'snippets': {
752+
file: '/nbextensions/visualpython/src/file_io/udf.js',
753+
config: { title: 'Snippets' }
754+
},
755+
'variable': {
756+
file: '/nbextensions/visualpython/src/file_io/variables.js',
757+
config: { title: 'Variables' }
758+
},
759+
'file': {
760+
file: '/nbextensions/visualpython/src/file_io/fileio.js',
761+
config: { title: 'File', width: '500px' }
762+
},
763+
'instance': {
764+
file: '/nbextensions/visualpython/src/file_io/instance.js',
765+
config: { title: 'Instance' }
766+
},
767+
'subset': {
768+
file: 'nbextensions/visualpython/src/common/vpSubsetEditor',
769+
},
770+
'frame': {
771+
file: 'nbextensions/visualpython/src/common/vpFrameEditor'
772+
},
773+
'chart': {
774+
file: '/nbextensions/visualpython/src/matplotlib/plot.js',
775+
config: { title: 'Chart', width: '600px' }
776+
},
777+
'profiling': {
778+
file: 'nbextensions/visualpython/src/common/vpProfiling'
779+
}
780+
}
781+
739782
return {
740783
BLOCK_GROUP_TYPE
741784
, BLOCK_CODELINE_BTN_TYPE
@@ -848,6 +891,7 @@ define([
848891
, STR_WHILE
849892
, STR_IMPORT
850893
, STR_API
894+
, STR_APPS
851895
, STR_TRY
852896
, STR_EXCEPT
853897
, STR_FINALLY
@@ -1212,5 +1256,7 @@ define([
12121256
, DEF_PARAM_TYPE_LIST
12131257

12141258
, IMPORT_DEFAULT_DATA_LIST
1259+
1260+
, APPS_CONFIG
12151261
}
12161262
});

0 commit comments

Comments
 (0)