pywebexec 2.1.15__py3-none-any.whl → 2.1.17__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.
pywebexec/pywebexec.py CHANGED
@@ -871,7 +871,7 @@ def run_dynamic_command(cmd):
871
871
  params += f"{prefix} "
872
872
  continue
873
873
  if isinstance(value, dict) or convert_values.get(param, None) == "json":
874
- value = shlex.quote(json.dumps(value))
874
+ value = shlex.quote(json.dumps(value, indent=2, sort_keys=False))
875
875
  elif convert_values.get(param, None) == "quote":
876
876
  value = shlex.quote(str(value))
877
877
  else:
@@ -209,6 +209,7 @@
209
209
  }
210
210
  ._jsonform-array-addmore, ._jsonform-array-deletecurrent {
211
211
  box-shadow: unset;
212
+ outline: 0;
212
213
  }
213
214
  }
214
215
 
@@ -256,6 +256,7 @@ async function fetchExecutables() {
256
256
 
257
257
  }
258
258
 
259
+ let schemaValues = {};
259
260
 
260
261
  paramsInput.addEventListener('focus', () => {
261
262
  const currentCmd = commandInput.value;
@@ -266,11 +267,16 @@ paramsInput.addEventListener('focus', () => {
266
267
  if (gExecutables[currentCmd] && gExecutables[currentCmd].schema && gExecutables[currentCmd].schema.properties && paramsContainer.style.display == 'none') {
267
268
  createSchemaForm($('#schemaForm'), gExecutables[currentCmd].schema, async function (errors, values) {
268
269
  if (errors) {
270
+ schemaValues[currentCmd] = values;
271
+
269
272
  console.log(errors);
273
+ alert(errors[0].message);
274
+ return false;
270
275
  } else {
271
276
  const commandName = commandInput.value;
272
277
  fitAddon.fit();
273
278
  terminal.clear();
279
+ schemaValues[currentCmd] = values;
274
280
  payload = { params: values, rows: terminal.rows, cols: terminal.cols }
275
281
  if ('parallel' in values) {
276
282
  payload['parallel'] = values['parallel'];
@@ -300,7 +306,7 @@ paramsInput.addEventListener('focus', () => {
300
306
  console.log('Error running command:', error);
301
307
  }
302
308
  }
303
- });
309
+ }, schemaValues[currentCmd]);
304
310
  setHelpDivPosition();
305
311
  paramsContainer.style.display = 'block';
306
312
  const input1 = schemaFormPW.querySelector('input, select, textarea');
@@ -20,7 +20,11 @@ function formInputHandle() {
20
20
  } else {
21
21
  size = 12;
22
22
  }
23
+ if (input.value) {
24
+ size = 2;
25
+ }
23
26
  input.setAttribute('size', size);
27
+ setTimeout(() => adjustInputWidth(input), 1);
24
28
  input.addEventListener('input', () => adjustInputWidth(input));
25
29
  inputHandlers.push(input);
26
30
  }
@@ -49,7 +53,7 @@ function extractKeysAndPlaceholders(obj, formoptions, prefix = '') {
49
53
  return result;
50
54
  }
51
55
 
52
- function createSchemaForm(form, schema, onSubmit) {
56
+ function createSchemaForm(form, schema, onSubmit, value={}) {
53
57
  if (schema && schema.schema_options) {
54
58
  schema_options = schema.schema_options;
55
59
  } else {
@@ -141,6 +145,7 @@ function createSchemaForm(form, schema, onSubmit) {
141
145
  schema: schema,
142
146
  onSubmit: onSubmit,
143
147
  form: formDesc,
148
+ value: value,
144
149
  // params: {
145
150
  // fieldHtmlClass: "input-small",
146
151
  // }
@@ -152,18 +157,18 @@ function createSchemaForm(form, schema, onSubmit) {
152
157
  formInputHandle();
153
158
 
154
159
  form[0].querySelectorAll('textarea').forEach(txt => {
155
- txt.style.height = "0";
156
- txt.style.height = txt.scrollHeight + "px";
157
- txt.setAttribute("spellcheck", "false")
158
- txt.addEventListener("input", (e) => {
159
- e.target.style.height = "0";
160
- e.target.style.height = (e.target.scrollHeight+2) + "px";
161
- });
160
+ txt.style.height = "0";
161
+ setTimeout(() => adjustTxtHeight(txt), 1);
162
+ txt.setAttribute("spellcheck", "false");
163
+ txt.addEventListener("input", () => adjustTxtHeight(txt));
162
164
  });
163
165
 
164
166
  return jsform;
165
167
  }
166
-
168
+ function adjustTxtHeight(txt) {
169
+ txt.style.height = "0";
170
+ txt.style.height = txt.scrollHeight + "px";
171
+ }
167
172
  async function getSwaggerSpec() {
168
173
  const response = await fetch('/swagger.yaml');
169
174
  if (!response.ok) {
@@ -262,7 +262,7 @@ async function viewOutput(command_id) {
262
262
  const commandInfo = document.getElementById('commandInfo');
263
263
  const command = `${data.command.replace(/^\.\//, '')} ${data.params.join(' ')}`;
264
264
  setCommandStatus(data.status)
265
- commandInfo.innerText = command;
265
+ commandInfo.innerHTML = command;
266
266
  commandInfo.setAttribute('title', command);
267
267
  if (data.command == 'term')
268
268
  terminal.options.cursorInactiveStyle = 'outline';