pywebexec 1.9.13__py3-none-any.whl → 1.9.15__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.
@@ -7,6 +7,8 @@ let isHandlingKeydown = false;
7
7
  let firstVisibleItem = 0;
8
8
  let gExecutables = {};
9
9
  let helpDiv = document.getElementById('paramsHelp');
10
+ let paramsContainer = document.getElementById('paramsContainer');
11
+ let schemaForm = document.getElementById('schemaForm');
10
12
 
11
13
  function unfilterCommands() {
12
14
  const items = commandListDiv.children;
@@ -48,8 +50,8 @@ function setCommandListPosition() {
48
50
  // Update helpDiv position relative to paramsInput
49
51
  function setHelpDivPosition() {
50
52
  const rect = commandInput.getBoundingClientRect();
51
- helpDiv.style.left = `${rect.left}px`;
52
- helpDiv.style.top = `${rect.bottom + 2}px`;
53
+ paramsContainer.style.left = `${rect.left}px`;
54
+ paramsContainer.style.top = `${rect.bottom + 2}px`;
53
55
  }
54
56
 
55
57
  function adjustInputWidth(input) {
@@ -98,11 +100,13 @@ commandInput.addEventListener('input', (event) => {
98
100
  commandInput.addEventListener('keydown', (event) => {
99
101
  if (event.key === ' ' || event.key === 'ArrowRight' || event.key === 'Tab') {
100
102
  event.preventDefault();
103
+ paramsContainer.style.display = 'none';
101
104
  paramsInput.focus();
102
105
  paramsInput.setSelectionRange(0, paramsInput.value.length);
103
106
  commandListDiv.style.display = 'none'
104
107
  } else if (event.key === 'ArrowDown') {
105
108
  if (commandListDiv.children.length > 1) {
109
+ paramsContainer.style.display = 'none';
106
110
  commandListDiv.style.display = 'block';
107
111
  commandListDiv.children[firstVisibleItem].focus();
108
112
  }
@@ -203,16 +207,20 @@ window.addEventListener('click', (event) => {
203
207
  if (!commandInput.contains(event.target) && !commandListDiv.contains(event.target) && !showCommandListButton.contains(event.target)) {
204
208
  commandListDiv.style.display = 'none';
205
209
  }
206
- });
207
-
208
- window.addEventListener('keydown', (event) => {
209
- if ([commandInput, paramsInput, commandListDiv].includes(document.activeElement)) return;
210
- if (event.code === `Key${event.key.toUpperCase()}`) {
211
- commandInput.focus();
212
- commandInput.dispatchEvent(new KeyboardEvent('keydown', event));
210
+ if (!paramsContainer.contains(event.target) && !commandListDiv.contains(event.target) && !paramsInput.contains(event.target)) {
211
+ paramsContainer.style.display = 'none';
213
212
  }
213
+
214
214
  });
215
215
 
216
+ // window.addEventListener('keydown', (event) => {
217
+ // if ([commandInput, paramsInput, commandListDiv].includes(document.activeElement)) return;
218
+ // if (event.code === `Key${event.key.toUpperCase()}`) {
219
+ // commandInput.focus();
220
+ // commandInput.dispatchEvent(new KeyboardEvent('keydown', event));
221
+ // }
222
+ // });
223
+
216
224
  window.addEventListener('resize', () => {
217
225
  setCommandListPosition();
218
226
  });
@@ -257,18 +265,68 @@ async function fetchExecutables() {
257
265
  paramsInput.addEventListener('focus', () => {
258
266
  const currentCmd = commandInput.value;
259
267
  paramsInput.name = currentCmd;
268
+ if (paramsContainer.style.display == 'none') {
269
+ $('#schemaForm').html('');
270
+ }
271
+ if (gExecutables[currentCmd] && gExecutables[currentCmd].schema && paramsContainer.style.display == 'none') {
272
+ $('#schemaForm').jsonForm({
273
+ schema: gExecutables[currentCmd].schema,
274
+ onSubmit: async function (errors, values) {
275
+ if (errors) {
276
+ console.log(errors);
277
+ } else {
278
+ const commandName = commandInput.value;
279
+ fitAddon.fit();
280
+ terminal.clear();
281
+ try {
282
+ const response = await fetch(`/commands/${commandName}`, {
283
+ method: 'POST',
284
+ headers: {
285
+ 'Content-Type': 'application/json'
286
+ },
287
+ body: JSON.stringify({ params: values, rows: terminal.rows, cols: terminal.cols })
288
+ });
289
+ if (!response.ok) {
290
+ throw new Error('Failed to launch command');
291
+ }
292
+ const data = await response.json();
293
+ viewOutput(data.command_id);
294
+ fetchCommands();
295
+ commandInput.focus();
296
+ commandInput.setSelectionRange(0, commandInput.value.length);
297
+ } catch (error) {
298
+ console.log('Error running command:', error);
299
+ }
300
+ }
301
+ },
302
+ form: [
303
+ "*",
304
+ {
305
+ type: 'submit',
306
+ title: 'Run',
307
+ }
308
+ ]
309
+ });
310
+ schemaForm.firstChild.classList.add('form-inline');
311
+ setHelpDivPosition();
312
+ paramsContainer.style.display = 'block';
313
+ }
260
314
  if (gExecutables[currentCmd] && gExecutables[currentCmd].help) {
261
315
  helpDiv.innerHTML = marked.parse(gExecutables[currentCmd].help);
262
316
  setHelpDivPosition();
263
- helpDiv.style.display = 'block';
317
+ paramsContainer.style.display = 'block';
264
318
  } else {
265
- helpDiv.style.display = 'none';
319
+ paramsContainer.style.display = 'none';
266
320
  }
267
321
  });
268
322
 
269
323
  paramsInput.addEventListener('blur', () => {
270
- helpDiv.style.display = 'none';
324
+ //paramsContainer.style.display = 'none';
271
325
  });
272
326
 
273
327
  window.addEventListener('resize', setHelpDivPosition);
274
328
  window.addEventListener('scroll', setHelpDivPosition);
329
+
330
+ schemaForm.addEventListener('submit', (event) => {
331
+ event.preventDefault();
332
+ });
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012-2020 Joshfire and contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ JSON Form dependencies
2
+ ======================
3
+
4
+ This folder contains required and optional dependencies for JSON Form.
5
+
6
+ Required
7
+ --------
8
+ - [jQuery](http://jquery.com/) v1.7.2 or above
9
+ - [Underscore.js](http://documentcloud.github.com/underscore/) v1.3.3 or above
10
+
11
+
12
+ Optional
13
+ --------
14
+ The libraries in the ```opt``` subfolder are optional as long as you do not use the feature they enable:
15
+ - [JSON Schema Validator](https://github.com/garycourt/JSV) is required to validate sumbitted values against the JSON schema that gave birth to the form. This folder includes a "build" of the validator (basically a merge of its different components scoped to avoid leaking variables to the global context.
16
+ - [Bootstrap](http://twitter.github.com/bootstrap/) v2.0.3 or above for styling purpose (JSON Form only uses the ```bootstrap.css``` file)
17
+ - [wysihtml5](http://jhollingworth.github.com/bootstrap-wysihtml5/) if the form uses ```wysihtml5``` textarea fields
18
+ - [jQuery UI Sortable](http://jqueryui.com/demos/sortable/) v1.8.20 or above for drag-and-drop support within arrays and tabarrays. Note the plugin itself depends on jQuery IU Core, jQuery UI Mouse, and jQuery UI Widget.