pywebexec 2.2.6__py3-none-any.whl → 2.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -226,6 +226,17 @@
226
226
  margin-right: 4px;
227
227
  }
228
228
  }
229
+ .alert {
230
+ padding: 5px 10px;
231
+ margin-bottom: 2px;
232
+ border: 1px solid transparent;
233
+ border-radius: 15px;
234
+ font-size: 14px;
235
+ font-family: Arial, Helvetica, sans-serif;
236
+ color: #a94442;
237
+ background-color: #f2dede;
238
+ border-color: #ebccd1;
239
+ }
229
240
  }
230
241
 
231
242
  .swagger-ui textarea {
@@ -260,7 +260,7 @@ paramsInput.addEventListener('focus', () => {
260
260
  const currentCmd = commandInput.value;
261
261
  paramsInput.name = currentCmd;
262
262
  if (gExecutables[currentCmd] && gExecutables[currentCmd].schema && gExecutables[currentCmd].schema.properties && paramsContainer.style.display == 'none') {
263
- createSchemaForm($('#schemaForm'), gExecutables[currentCmd].schema, async function (errors, values) {
263
+ jsForm = createSchemaForm($('#schemaForm'), gExecutables[currentCmd].schema, async function (errors, values) {
264
264
  const commandName = commandInput.value;
265
265
  fitAddon.fit();
266
266
  terminal.clear();
@@ -293,12 +293,18 @@ paramsInput.addEventListener('focus', () => {
293
293
  console.log('Error running command:', error);
294
294
  }
295
295
  }, currentCmd);
296
+ schemaFormPW = jsForm.root.ownerTree.domRoot;
296
297
  setHelpDivPosition();
297
298
  paramsContainer.style.display = 'block';
298
299
  const input1 = schemaFormPW.querySelector('input, select, textarea');
299
300
  if (input1) {
300
301
  input1.focus();
301
302
  }
303
+ schemaFormPW.addEventListener('submit', (event) => {
304
+ console.log('Form submitted');
305
+ paramsContainer.style.display = 'none';
306
+ event.preventDefault();
307
+ });
302
308
  } else {
303
309
  paramsContainer.style.display = 'none';
304
310
  }
@@ -318,7 +324,3 @@ paramsInput.addEventListener('blur', () => {
318
324
  window.addEventListener('resize', setHelpDivPosition);
319
325
  window.addEventListener('scroll', setHelpDivPosition);
320
326
 
321
- schemaFormPW.addEventListener('submit', (event) => {
322
- paramsContainer.style.display = 'none';
323
- event.preventDefault();
324
- });
@@ -92,8 +92,20 @@ function convertTextareaToArray(values, formDesc, schema) {
92
92
  return values;
93
93
  }
94
94
 
95
- // ...existing code...
96
-
95
+ function validateSchemaForm(form, formDesc, schema, values) {
96
+ err = form.querySelector('.alert');
97
+ err.style.display = 'none';
98
+ convertTextareaToArray(values, formDesc, schema);
99
+ env = JSV.createEnvironment();
100
+ report = env.validate(values, schema);
101
+ errors = report.errors;
102
+ if (errors.length > 0) {
103
+ err.innerText = errors[0].uri.split('#')[1].slice(1).replaceAll('/', '.') + ': ' + errors[0].message + ': ' + errors[0].details;
104
+ err.style.display = 'block';
105
+ return false;
106
+ }
107
+ return true;
108
+ }
97
109
  function createSchemaForm($form, schema, onSubmit, schemaName) {
98
110
  if (schema && schema.schema_options) {
99
111
  schema_options = schema.schema_options;
@@ -214,16 +226,14 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
214
226
  }
215
227
  }
216
228
  }
217
- schemaForm.classList.add('form-inline');
229
+ // schemaForm.classList.add('form-inline');
218
230
  jsform = $form.jsonForm({
219
231
  schema: schema,
220
232
  onSubmit: function (errors, values) {
221
- convertTextareaToArray(values, formDesc, schema);
222
- env = JSV.createEnvironment();
223
- report = env.validate(values, schema);
224
- errors = report.errors;
225
- if (errors.length > 0) {
226
- alert(errors[0].message);
233
+ if (! validateSchemaForm(event.target, formDesc, schema, values)) {
234
+ event.preventDefault();
235
+ event.stopPropagation();
236
+ event.stopImmediatePropagation();
227
237
  return false;
228
238
  }
229
239
  onSubmit(errors, values);
@@ -236,6 +246,11 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
236
246
  // }
237
247
  });
238
248
  schemaForm.firstChild.classList.add('form-inline');
249
+ err = document.createElement('div');
250
+ err.classList.add('alert');
251
+ err.style.display = 'none';
252
+ schemaForm.appendChild(err);
253
+ validateSchemaForm(schemaForm, formDesc, schema, value);
239
254
  schemaForm.querySelectorAll('textarea').forEach(txt => {
240
255
  txt.style.height = "0";
241
256
  setTimeout(() => adjustTxtHeight(txt), 1);
@@ -249,6 +264,9 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
249
264
  adjustInputWidth(e.target);
250
265
  }
251
266
  });
267
+ schemaForm.addEventListener('change', (e) => {
268
+ validateSchemaForm(schemaForm, formDesc, schema, jsform.root.getFormValues());
269
+ });
252
270
  formInputHandle();
253
271
  return jsform;
254
272
  }
@@ -14,6 +14,7 @@
14
14
  <script src="/static/js/swagger-ui/swagger-ui-standalone-preset.js"></script>
15
15
  <script type="text/javascript" src="/static/jsonform/deps/jquery.min.js"></script>
16
16
  <script type="text/javascript" src="/static/jsonform/deps/underscore.js"></script>
17
+ <script type="text/javascript" src="/static/jsonform/deps/jsv.js"></script>
17
18
  <script type="text/javascript" src="/static/jsonform/lib/jsonform.js"></script>
18
19
  <script type="text/javascript" src="/static/js/js-yaml/js-yaml.min.js"></script>
19
20
  <script src="/static/js/schemaform.js"></script>
pywebexec/version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.2.6'
21
- __version_tuple__ = version_tuple = (2, 2, 6)
20
+ __version__ = version = '2.2.7'
21
+ __version_tuple__ = version_tuple = (2, 2, 7)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywebexec
3
- Version: 2.2.6
3
+ Version: 2.2.7
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -2,8 +2,8 @@ pywebexec/__init__.py,sha256=197fHJy0UDBwTTpGCGortZRr-w2kTaD7MxqdbVmTEi0,61
2
2
  pywebexec/host_ip.py,sha256=Ud_HTflWVQ8789aoQ2RZdT1wGI-ccvrwSWGz_c7T3TI,1241
3
3
  pywebexec/pywebexec.py,sha256=R-jp9BiUMJZW7m9N9kQC6dpIueUgFVDo4n9_GFb1rOs,45734
4
4
  pywebexec/swagger.yaml,sha256=I_oLpp7Hqel8SDEEykvpmCT-Gv3ytGlziq9bvQOrtZY,7598
5
- pywebexec/version.py,sha256=2jX0JMD4JhBR3q6iGoTm9_8W9OruIxwEs3BpF5ozLt4,511
6
- pywebexec/static/css/form.css,sha256=7H9bt-Hm0Kwn0ATHvyrmcWV1Q1oWNugvZykOMd8QYao,5536
5
+ pywebexec/version.py,sha256=B6GrE_H3HdW5bYR7WQrOTlC8LfCumdx9DeJs14u4q5A,511
6
+ pywebexec/static/css/form.css,sha256=XC_0ES5yMHYz0S2OHR0RAboQN7fBUmg5ZIq8Qm5rHP0,5806
7
7
  pywebexec/static/css/markdown.css,sha256=br4-iK9wigTs54N2KHtjgZ4KLH0THVSvJo-XZAdMHiE,1970
8
8
  pywebexec/static/css/style.css,sha256=R1VOPNV2ztROKy9Fgf3tvUrtuKagY027tFJ8C866yWU,9991
9
9
  pywebexec/static/css/swagger-ui.css,sha256=xhXN8fnUaIACGHuPIEIr9-qmyYr6Zx0k2wv4Qy7Bg1Y,154985
@@ -33,9 +33,9 @@ pywebexec/static/images/resume.svg,sha256=99LP1Ya2JXakRCO9kW8JMuT_4a_CannF65Eiuw
33
33
  pywebexec/static/images/running.svg,sha256=fBCYwYb2O9K4N3waC2nURP25NRwZlqR4PbDZy6JQMww,610
34
34
  pywebexec/static/images/success.svg,sha256=NVwezvVMplt46ElW798vqGfrL21Mw_DWHUp_qiD_FU8,489
35
35
  pywebexec/static/images/swagger-ui.svg,sha256=FR0yeOVwe4zCYKZAjCGcT_m0Mf25NexIVaSXifIkoU0,2117
36
- pywebexec/static/js/executables.js,sha256=_Deyx1O8QyiFt6RcmaXnC9Vx9yagTQP4Vhz9GAXFR84,11774
36
+ pywebexec/static/js/executables.js,sha256=jB4QqWi4Qeq1uJflTSqqjsZy-ec9iy5ZmFvfNWMzXq4,11913
37
37
  pywebexec/static/js/popup.js,sha256=O3DEWnyb5yGW9tjODYycc-ujWndyAfnJMxulaQeogtc,9700
38
- pywebexec/static/js/schemaform.js,sha256=2kjdaquoIdh0hAuAuZdI0cqM5URPWslZtbYHAjtG1_4,8918
38
+ pywebexec/static/js/schemaform.js,sha256=7ktVteMY3v84iqHmT-N65Ee_rMyA6SitoYi8CN-HYDY,9686
39
39
  pywebexec/static/js/script.js,sha256=yQP2dWwTObWbg6ROeKFxwYi1NfDd2gxEn2e3oL-FWL8,18379
40
40
  pywebexec/static/js/swagger-form.js,sha256=CLcSHMhk5P4-_2MIRBoJLgEnIj_9keDDSzUugXHZjio,4565
41
41
  pywebexec/static/js/js-yaml/LICENSE,sha256=oHvCRGi5ZUznalR9R6LbKC0HcztxXbTHOpi9Y5YflVA,1084
@@ -66,10 +66,10 @@ pywebexec/static/jsonform/lib/jsonform.js,sha256=U-BvOgq5gCvSUo36qSAK7Y91RPKOq7v
66
66
  pywebexec/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
67
  pywebexec/templates/index.html,sha256=w18O2plH_yS8bqlPsu5hwFFmCj9H2hWLSV8B6ADcSwU,3900
68
68
  pywebexec/templates/popup.html,sha256=3kpMccKD_OLLhJ4Y9KRw6Ny8wQWjVaRrUfV9y5-bDiQ,1580
69
- pywebexec/templates/swagger_ui.html,sha256=9ngyldkyEdLonBjl97mbIZUlVk-jxwcHrvFzMSrveyU,1067
70
- pywebexec-2.2.6.dist-info/licenses/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
71
- pywebexec-2.2.6.dist-info/METADATA,sha256=OPnaK8AVJW0L52318LUXdrV_jH4ujnLqLsmK_Sm1lww,12832
72
- pywebexec-2.2.6.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
73
- pywebexec-2.2.6.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
74
- pywebexec-2.2.6.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
75
- pywebexec-2.2.6.dist-info/RECORD,,
69
+ pywebexec/templates/swagger_ui.html,sha256=MAPr-z96VERAecDvX37V8q2Nxph-O0fNDBul1x2w9SI,1147
70
+ pywebexec-2.2.7.dist-info/licenses/LICENSE,sha256=gRJf0JPT_wsZJsUGlWPTS8Vypfl9vQ1qjp6sNbKykuA,1064
71
+ pywebexec-2.2.7.dist-info/METADATA,sha256=6vJc9lg90rSQ7DfhHKoZwD1ncnyIGQ2Qk0yzNtewzD0,12832
72
+ pywebexec-2.2.7.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
73
+ pywebexec-2.2.7.dist-info/entry_points.txt,sha256=l52GBkPCXRkmlHfEyoVauyfBdg8o-CAtC8qQpOIjJK0,55
74
+ pywebexec-2.2.7.dist-info/top_level.txt,sha256=vHoHyzngrfGdm_nM7Xn_5iLmaCrf10XO1EhldgNLEQ8,10
75
+ pywebexec-2.2.7.dist-info/RECORD,,