Skip to content

Commit e9ee569

Browse files
authored
Merge pull request #111 from minjk-bl/devops
Hotfix for v2.0.0 (as v2.0.1)
2 parents 84361a6 + cbcf98a commit e9ee569

14 files changed

+122
-43
lines changed

css/boardFrame.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@
156156
flex-direction: column;
157157
justify-content: center;
158158
touch-action: none;
159-
cursor: pointer;
160159
color: var(--font-primary);
161160
font-family: 'AppleSDGothicNeo';
162161

@@ -180,6 +179,7 @@
180179
overflow: hidden;
181180
border: 2px solid transparent;
182181
border-radius: 2px;
182+
cursor: pointer;
183183
}
184184
.vp-block-left-holder {
185185
display: none;
@@ -197,6 +197,7 @@
197197
position: absolute;
198198
left: 0px;
199199
color: rgba(0,0,0,0.3);
200+
cursor: default;
200201
}
201202
.vp-block-num-info {
202203
color: #828282;

css/popupComponent.css

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,29 +115,29 @@
115115
height: 50px;
116116
}
117117
.vp-popup-button[data-type="code"] {
118-
position: absolute;
119-
left: 15px;
120-
top: 9px;
118+
float: left;
119+
margin-top: 9px;
120+
margin-left: 10px;
121121
}
122122
.vp-popup-button[data-type="data"] {
123-
position: absolute;
124-
left: 102px;
125-
top: 9px;
123+
float: left;
124+
margin-top: 9px;
125+
margin-left: 10px;
126126
}
127127
.vp-popup-button[data-type="cancel"] {
128-
position: absolute;
128+
float: right;
129129
background-color: #E4E4E4;
130-
top: 9px;
131-
right: 106px;
130+
margin-top: 9px;
131+
margin-right: 10px;
132132
}
133133
.vp-popup-runadd-box {
134-
position: absolute;
135-
top: 9px;
136-
right: 15px;
134+
float: right;
137135
width: fit-content;
138136
height: 30px;
139137
background: #F38504;
140138
border-radius: 2px;
139+
margin-top: 9px;
140+
margin-right: 10px;
141141
}
142142
.vp-popup-button[data-type="run"] {
143143
display: inline-block;
@@ -157,8 +157,8 @@
157157
background: white;
158158
border: 0.25px solid var(--border-gray-color);
159159
position: absolute;
160-
bottom: 35px;
161-
right: 0px;
160+
bottom: 45px;
161+
right: 10px;
162162
width: 120px;
163163
text-align: center;
164164
line-height: 30px;
@@ -172,10 +172,11 @@
172172
background: var(--light-gray-color);
173173
}
174174
.vp-popup-save-button {
175-
position: absolute;
176-
top: 9px;
177-
right: 15px;
175+
float: right;
178176
height: 30px;
177+
width: 100px;
178+
margin-top: 9px;
179+
margin-right: 10px;
179180
}
180181
/* writable codemirror style*/
181182
/* Code Option Codemirror */

data/libraries.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
"type" : "function",
385385
"level": 1,
386386
"name" : "elif",
387-
"tag" : "ELSE,LOGIC",
387+
"tag" : "ELIF,LOGIC",
388388
"path" : "visualpython - logic - control - elif",
389389
"desc" : "elif",
390390
"file" : "m_logic/Elif",

data/m_library/pandasLibrary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5119,7 +5119,7 @@ define([
51195119
name: 'Plot',
51205120
library: 'pandas',
51215121
description: 'create chart',
5122-
code: '${o0} = ${i0}.plot(${v}${etc})',
5122+
code: '${o0} = ${i0}.plot(${v}${etc})\nplt.show()',
51235123
input: [
51245124
{
51255125
name: 'i0',

html/popupComponent.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
<button type="button" class="vp-button vp-popup-button" data-type="code">Code view</button>
5252
<button type="button" class="vp-button vp-popup-button" data-type="data">Data view</button>
5353

54-
<button type="button" class="vp-button vp-popup-button" data-type="cancel">Cancel</button>
5554
<div class="vp-popup-runadd-box">
5655
<button type="button" class="vp-button activated vp-popup-button" data-type="run" title="Save to block & Run cell">Run</button>
5756
<button type="button" class="vp-button activated vp-popup-button" data-type="show-detail"><img src="/nbextensions/visualpython/img/arrow_short_up.svg"/></button>
@@ -60,7 +59,8 @@
6059
<div class="vp-popup-detail-button" data-type="add" title="Save to block & Add cell">Code to cell</div>
6160
</div>
6261
</div>
63-
<button type="button" class="vp-button activated vp-popup-button vp-popup-save-button" data-type="save" title="Save to block" style="display:none;">Save</button>
62+
<button type="button" class="vp-button activated vp-popup-button vp-popup-save-button" data-type="save" title="Save to block" style="display:none;">Save to block</button>
63+
<button type="button" class="vp-button vp-popup-button" data-type="cancel">Cancel</button>
6464
</div>
6565
</div>
6666
</div>

js/board/BlockMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ define([
7474
// run button
7575
sbBlockMenu.appendLine('<div id="vp_block_menu_run" class="vp-block-menu-item">Run</div>');
7676
// add button
77-
sbBlockMenu.appendLine('<div id="vp_block_menu_add" class="vp-block-menu-item">Add</div>');
77+
sbBlockMenu.appendLine('<div id="vp_block_menu_add" class="vp-block-menu-item">Code to cell</div>');
7878
// duplicate button
7979
sbBlockMenu.appendLine('<div id="vp_block_menu_duplicate" class="vp-block-menu-item">Duplicate</div>');
8080
// delete button

js/com/com_Config.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,17 @@ define([], function() {
9090
' except ValueError:',
9191
' return 0.0'
9292
]
93-
}
93+
},
94+
'vpimport': [
95+
{ library: 'numpy', alias:'np' },
96+
{ library: 'pandas', alias:'pd' },
97+
{ library: 'matplotlib.pyplot', alias:'plt',
98+
include: [
99+
'%matplotlib inline'
100+
]
101+
},
102+
{ library: 'seaborn', alias:'sns' }
103+
]
94104
}
95105

96106
this.data = {
@@ -165,7 +175,8 @@ define([], function() {
165175
Jupyter.notebook.config.loaded.then(function() {
166176
var data = Jupyter.notebook.config.data[configKey];
167177
if (data == undefined) {
168-
data = {};
178+
reject('No data available.');
179+
return;
169180
}
170181
if (dataKey == '') {
171182
resolve(data);
@@ -184,7 +195,7 @@ define([], function() {
184195
Jupyter.notebook.config.load();
185196
var data = Jupyter.notebook.config.data[configKey];
186197
if (data == undefined) {
187-
data = {};
198+
return undefined;
188199
}
189200
if (dataKey == '') {
190201
return data;

js/com/component/InstanceEditor.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ define([
433433
if (callback) {
434434
callback(varObj);
435435
}
436+
}).catch(function(resultObj) {
437+
let { result } = resultObj;
438+
// show alert
439+
com_util.renderAlertModal(result.ename + ': ' + result.evalue);
440+
// callback
441+
if (callback) {
442+
callback('');
443+
}
436444
});
437445

438446

js/com/component/PopupComponent.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,6 @@ define([
435435
}
436436
if (!dataview) {
437437
$(this.wrapSelector('.vp-popup-button[data-type="data"]')).hide();
438-
} else {
439-
if (!codeview) {
440-
$(this.wrapSelector('.vp-popup-button[data-type="data"]')).css({left: '15px', top: '9px'});
441-
}
442438
}
443439

444440
// footer

js/loadVisualpython.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@
238238
if (cfg.vp_section_display && vpFrame) {
239239
vpFrame.openVp();
240240
}
241+
242+
// Operations on kernel restart
243+
events.on('kernel_ready.Kernel', function (evt, info) {
244+
vpLog.display(VP_LOG_TYPE.LOG, 'vp operations for kernel ready...');
245+
// read vp functions
246+
_readKernelFunction();
247+
});
241248
}
242249

243250
return { initVisualpython: initVisualpython, readConfig: readConfig };

js/m_apps/Import.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ define([
8181
page.appendLine('</tr></thead>');
8282
page.appendLine('<tbody>');
8383
let that = this;
84-
this.state.importMeta.forEach((lib, idx) => {
84+
this.state.importMeta && this.state.importMeta.forEach((lib, idx) => {
8585
page.appendLine(that.templateForLibrary(idx, lib.library, lib.alias));
8686
});
8787
page.appendLine('</tbody>');

js/m_apps/Instance.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ define([
157157
let component = evt.component;
158158
component.close();
159159
});
160+
$(this.wrapSelector('#vp_instanceVariable')).on('focus_option_page', function(evt) {
161+
let component = evt.component;
162+
component.focus();
163+
});
160164
$(this.wrapSelector('#vp_instanceVariable')).on('apply_option_page', function(evt) {
161165
let component = evt.component;
162166
// apply its value
@@ -219,6 +223,21 @@ define([
219223
return sbCode.toString();
220224
}
221225

226+
hide() {
227+
super.hide();
228+
this.state.subsetEditor && this.state.subsetEditor.hide();
229+
}
230+
231+
close() {
232+
super.close();
233+
this.state.subsetEditor && this.state.subsetEditor.close();
234+
}
235+
236+
remove() {
237+
super.remove();
238+
this.state.subsetEditor && this.state.subsetEditor.remove();
239+
}
240+
222241
updateValue(value) {
223242
let cmObj = this.getCodemirror('vp_instanceVariable');
224243
if (cmObj && cmObj.cm) {

js/m_apps/Snippets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ define([
194194

195195
com_util.renderSuccessMessage('Default snippets imported');
196196
}
197+
$(that.wrapSelector('.vp-sn-menu-box')).hide();
197198
evt.stopPropagation();
198199
});
199200

js/m_logic/Elif.js

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*
22
* Project Name : Visual Python
33
* Description : GUI-based Python code generator
4-
* File Name : If.js
4+
* File Name : Elif.js
55
* Author : Black Logic
6-
* Note : Logic > if
6+
* Note : Logic > elif
77
* License : GNU GPLv3 with Visual Python special exception
88
* Date : 2021. 11. 18
99
* Change Date :
1010
*/
1111

1212
//============================================================================
13-
// [CLASS] If
13+
// [CLASS] Elif
1414
//============================================================================
1515
define([
1616
'vp_base/js/com/com_String',
@@ -20,9 +20,9 @@ define([
2020
], function(com_String, com_util, PopupComponent, SuggestInput) {
2121

2222
/**
23-
* If
23+
* Elif
2424
*/
25-
class If extends PopupComponent {
25+
class Elif extends PopupComponent {
2626
_init() {
2727
super._init();
2828
/** Write codes executed before rendering */
@@ -31,7 +31,7 @@ define([
3131
this.config.saveOnly = true;
3232

3333
this.state = {
34-
v1: [],
34+
v1: [{ type: 'condition', value: {} }],
3535
...this.state
3636
}
3737
}
@@ -43,11 +43,23 @@ define([
4343
// Add param
4444
$(this.wrapSelector('#vp_addCondition')).on('click', function() {
4545
that.state.v1.push({ type: 'condition', value: {} });
46-
$(that.wrapSelector('.v1 tbody')).append(that.templateForList(that.state.v1.length, {}));
46+
$(that.wrapSelector('.v1-table')).append(that.templateForList(that.state.v1.length, {}));
47+
48+
// enable and disable last one
49+
// enable all operator
50+
$(that.wrapSelector('.v1 .v1-i4')).prop('disabled', false);
51+
// disable last operator
52+
$(that.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
4753
});
4854
$(this.wrapSelector('#vp_addUserInput')).on('click', function() {
4955
that.state.v1.push({ type: 'input', value: {} });
50-
$(that.wrapSelector('.v1 tbody')).append(that.templateForInput(that.state.v1.length, {}));
56+
$(that.wrapSelector('.v1-table')).append(that.templateForInput(that.state.v1.length, {}));
57+
58+
// enable and disable last one
59+
// enable all operator
60+
$(that.wrapSelector('.v1 .v1-i4')).prop('disabled', false);
61+
// disable last operator
62+
$(that.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
5163
});
5264

5365
// Delete param
@@ -61,6 +73,9 @@ define([
6173
$(that.wrapSelector('.v1-tr')).each((idx, tag) => {
6274
$(tag).find('th').text(idx + 1);
6375
});
76+
77+
// disable last operator
78+
$(that.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
6479
});
6580
}
6681

@@ -94,7 +109,8 @@ define([
94109
var page = new com_String();
95110
page.appendLine('<table class="v1 wp100" style="margin: 10px 0">');
96111
// page.appendLine('<thead><tr><td></td><td>Parameter</td><td></td><td>Default Value</td></tr></thead>');
97-
page.appendLine('<tbody><colgroup><col width="20px"><col width="100px"><col width="100px"><col width="100px"><col width="100px"><col width="30px"></colgroup>');
112+
page.appendLine('<colgroup><col width="20px"><col width="100px"><col width="100px"><col width="100px"><col width="100px"><col width="30px"></colgroup>');
113+
page.appendLine('<tbody class="v1-table">');
98114
this.state.v1.forEach((v, idx) => {
99115
if (v.type == 'condition') {
100116
page.appendLine(this.templateForList(idx + 1, v.value));
@@ -118,8 +134,20 @@ define([
118134
page.appendFormatLine('<th>{0}</th>', idx);
119135
page.appendFormatLine('<td><input type="text" class="vp-input w100 {0}" value="{1}" placeholder="{2}"/></td>'
120136
, 'v1-i1', v.i1, 'Variable');
121-
page.appendFormatLine('<td><input type="text" class="vp-input w100 {0}" value="{1}" placeholder="{2}"/></td>'
122-
, 'v1-i2', v.i2, 'Operator');
137+
// suggestInput for operator
138+
let operList = ['', '==', '!=', 'in', 'not in', '<', '<=', '>', '>='];
139+
var suggestInput = new SuggestInput();
140+
suggestInput.addClass('vp-input w100 v1-i2');
141+
suggestInput.setSuggestList(function() { return operList; });
142+
suggestInput.setPlaceholder('Operator');
143+
suggestInput.setNormalFilter(false);
144+
suggestInput.setValue(v.i2);
145+
suggestInput.setSelectEvent(function(selectedValue) {
146+
// trigger change
147+
$(this.wrapSelector()).val(selectedValue);
148+
$(this.wrapSelector()).trigger('change');
149+
});
150+
page.appendFormatLine('<td>{0}</td>', suggestInput.toTagString());
123151
page.appendFormatLine('<td><input type="text" class="vp-input w100 {0}" value="{1}" placeholder="{2}"/></td>'
124152
, 'v1-i3', v.i3, 'Variable');
125153
page.appendFormatLine('<td><select class="vp-select w100 {0}">', 'v1-i4');
@@ -153,6 +181,13 @@ define([
153181
return page.toString();
154182
}
155183

184+
render() {
185+
super.render();
186+
187+
// disable last operator
188+
$(this.wrapSelector('.v1 tr:last .v1-i4')).prop('disabled', true);
189+
}
190+
156191
generateCode() {
157192
this.saveState();
158193

@@ -179,5 +214,5 @@ define([
179214

180215
}
181216

182-
return If;
217+
return Elif;
183218
});

0 commit comments

Comments
 (0)