pywebexec 2.4.9__py3-none-any.whl → 2.4.11__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/static/css/form.css +26 -2
- pywebexec/static/js/schemaform.js +88 -2
- pywebexec/static/js/tablefilter.js +2 -2
- pywebexec/static/jsonform/deps/ace/ace.js +23 -0
- pywebexec/static/jsonform/deps/ace/mode-json.js +8 -0
- pywebexec/static/jsonform/deps/ace/theme-github.js +8 -0
- pywebexec/static/jsonform/deps/ace/theme-github_light_default.js +8 -0
- pywebexec/static/jsonform/deps/ace/theme-twilight.js +8 -0
- pywebexec/static/jsonform/deps/ace/worker-json.js +1 -0
- pywebexec/templates/index.html +2 -0
- pywebexec/version.py +2 -2
- {pywebexec-2.4.9.dist-info → pywebexec-2.4.11.dist-info}/METADATA +1 -1
- {pywebexec-2.4.9.dist-info → pywebexec-2.4.11.dist-info}/RECORD +17 -11
- {pywebexec-2.4.9.dist-info → pywebexec-2.4.11.dist-info}/WHEEL +0 -0
- {pywebexec-2.4.9.dist-info → pywebexec-2.4.11.dist-info}/entry_points.txt +0 -0
- {pywebexec-2.4.9.dist-info → pywebexec-2.4.11.dist-info}/licenses/LICENSE +0 -0
- {pywebexec-2.4.9.dist-info → pywebexec-2.4.11.dist-info}/top_level.txt +0 -0
pywebexec/static/css/form.css
CHANGED
@@ -296,11 +296,11 @@
|
|
296
296
|
background-color: #f2dede;
|
297
297
|
border-color: #ebccd1;
|
298
298
|
}
|
299
|
-
#reset-form:hover {
|
299
|
+
#reset-form:hover, #save-form:hover, #del-form:hover {
|
300
300
|
background-color: #e8e8e8;
|
301
301
|
border-color: #adadad;
|
302
302
|
}
|
303
|
-
#reset-form {
|
303
|
+
#reset-form, #save-form, #del-form {
|
304
304
|
position: relative;
|
305
305
|
margin-bottom: 10px;
|
306
306
|
height: 24px;
|
@@ -311,6 +311,19 @@
|
|
311
311
|
color: #333;
|
312
312
|
padding: 3px 13px;
|
313
313
|
}
|
314
|
+
#save-form, #del-form {
|
315
|
+
position: relative;
|
316
|
+
margin-bottom: 2px;
|
317
|
+
height: 24px;
|
318
|
+
top: 0px;
|
319
|
+
background-color: #f5f5f5;
|
320
|
+
border-color: #ccc;
|
321
|
+
height: 24px;
|
322
|
+
color: #333;
|
323
|
+
padding: 3px 13px;
|
324
|
+
}
|
325
|
+
|
326
|
+
|
314
327
|
legend {
|
315
328
|
font-weight: bold;
|
316
329
|
}
|
@@ -342,6 +355,17 @@
|
|
342
355
|
gap: 0px 5px;
|
343
356
|
padding-bottom: 5px;
|
344
357
|
}
|
358
|
+
|
359
|
+
.fieldsavedoptions label {
|
360
|
+
display: none;
|
361
|
+
}
|
362
|
+
|
363
|
+
.ace_editor {
|
364
|
+
position: relative;
|
365
|
+
border: 1px solid #ccc;
|
366
|
+
border-radius: 5px;
|
367
|
+
resize: all;
|
368
|
+
}
|
345
369
|
}
|
346
370
|
|
347
371
|
.swagger-ui textarea {
|
@@ -143,6 +143,12 @@ function validateSchemaForm(form, formDesc, schema, values, schemaName) {
|
|
143
143
|
return true;
|
144
144
|
}
|
145
145
|
|
146
|
+
function expandFieldset(fieldsetClass) {
|
147
|
+
schemaForm.querySelector(`fieldset.${fieldsetClass}`).classList.add('expanded');
|
148
|
+
schemaForm.querySelector(`fieldset.${fieldsetClass} > legend`).setAttribute('aria-expanded', 'true');
|
149
|
+
schemaForm.querySelector(`fieldset.${fieldsetClass} > div`).style.display = 'inline-flex';
|
150
|
+
}
|
151
|
+
|
146
152
|
function createSchemaForm($form, schema, onSubmit, schemaName) {
|
147
153
|
schema_options = undefined;
|
148
154
|
schema_params_options = undefined;
|
@@ -152,7 +158,6 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
|
|
152
158
|
if (schema && schema.properties && schema.properties.params && schema.properties.params.schema_options) {
|
153
159
|
schema_params_options = schema.properties.params.schema_options;
|
154
160
|
}
|
155
|
-
|
156
161
|
formkeys = {};
|
157
162
|
formoptions = {};
|
158
163
|
if (schema_options) {
|
@@ -168,7 +173,17 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
|
|
168
173
|
formoptions[`params.${key}`] = foptions[key];
|
169
174
|
}
|
170
175
|
}
|
176
|
+
if(schema.properties['savedValues']) {
|
177
|
+
delete schema.properties['savedValues'];
|
178
|
+
}
|
171
179
|
formDesc = extractKeysAndPlaceholders(schema, formkeys, formoptions);
|
180
|
+
schema.properties["savedValues"] = {
|
181
|
+
type: "string",
|
182
|
+
title: " ",
|
183
|
+
};
|
184
|
+
if (savedValues[schemaName]) {
|
185
|
+
schema.properties["savedValues"].enum = [null, ...Object.keys(savedValues[schemaName]).sort()];
|
186
|
+
}
|
172
187
|
if (schemaValues[schemaName]) {
|
173
188
|
value = schemaValues[schemaName];
|
174
189
|
// convert array for textarea formDesc type to string separated by newlines
|
@@ -262,6 +277,58 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
|
|
262
277
|
items: items,
|
263
278
|
});
|
264
279
|
}
|
280
|
+
formDesc.push({
|
281
|
+
type: 'fieldset',
|
282
|
+
title: 'Favorites',
|
283
|
+
htmlClass: 'fieldsavedoptions',
|
284
|
+
expandable: true,
|
285
|
+
items: [
|
286
|
+
{
|
287
|
+
key: 'savedValues',
|
288
|
+
title: null,
|
289
|
+
placeholder: 'My Params',
|
290
|
+
htmlClass: 'fieldsavedoptions',
|
291
|
+
onChange: function (evt) {
|
292
|
+
evt.preventDefault();
|
293
|
+
evt.stopPropagation();
|
294
|
+
evt.stopImmediatePropagation();
|
295
|
+
const name = value = evt.target.value;
|
296
|
+
if (name in savedValues[schemaName]) {
|
297
|
+
schemaValues[schemaName] = savedValues[schemaName][name];
|
298
|
+
createSchemaForm($form, schema, onSubmit, schemaName);
|
299
|
+
}
|
300
|
+
}
|
301
|
+
},
|
302
|
+
{
|
303
|
+
type: 'button',
|
304
|
+
title: 'Save',
|
305
|
+
id: 'save-form',
|
306
|
+
onClick: function (evt) {
|
307
|
+
evt.preventDefault();
|
308
|
+
evt.stopPropagation();
|
309
|
+
evt.stopImmediatePropagation();
|
310
|
+
//const values = jsform.root.getFormValues();
|
311
|
+
saveFormValues(schemaValues[schemaName], schemaName);
|
312
|
+
createSchemaForm($form, schema, onSubmit, schemaName);
|
313
|
+
expandFieldset('fieldsavedoptions');
|
314
|
+
},
|
315
|
+
},
|
316
|
+
{
|
317
|
+
type: 'button',
|
318
|
+
title: 'Del',
|
319
|
+
id: 'del-form',
|
320
|
+
onClick: function (evt) {
|
321
|
+
evt.preventDefault();
|
322
|
+
evt.stopPropagation();
|
323
|
+
evt.stopImmediatePropagation();
|
324
|
+
delete savedValues[schemaName][schemaValues[schemaName].savedValues];
|
325
|
+
localStorage.setItem('savedValues', JSON.stringify(savedValues));
|
326
|
+
createSchemaForm($form, schema, onSubmit, schemaName);
|
327
|
+
},
|
328
|
+
},
|
329
|
+
]
|
330
|
+
});
|
331
|
+
|
265
332
|
formDesc.push({
|
266
333
|
type: 'actions',
|
267
334
|
items: [
|
@@ -329,6 +396,7 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
|
|
329
396
|
event.stopImmediatePropagation();
|
330
397
|
return false;
|
331
398
|
}
|
399
|
+
delete values['savedValues'];
|
332
400
|
onSubmit(errors, values);
|
333
401
|
},
|
334
402
|
form: formDesc,
|
@@ -359,11 +427,14 @@ function createSchemaForm($form, schema, onSubmit, schemaName) {
|
|
359
427
|
schemaForm.addEventListener('mouseup', (e) => {
|
360
428
|
// save form values when clicking on array buttons
|
361
429
|
setTimeout(() => validateSchemaForm(schemaForm, formDesc, schema, jsform.root.getFormValues(), schemaName), 1);
|
430
|
+
// resize input fields when dragging
|
431
|
+
setTimeout(() => formInputHandle(), 100);
|
362
432
|
});
|
363
433
|
divopt = schemaForm.querySelector("fieldset.expandable > div");
|
364
434
|
formInputHandle();
|
365
435
|
return jsform;
|
366
436
|
}
|
437
|
+
|
367
438
|
function adjustTxtHeight(txt) {
|
368
439
|
if (txt.value.includes('\n')) {
|
369
440
|
delta = 2;
|
@@ -373,6 +444,7 @@ function adjustTxtHeight(txt) {
|
|
373
444
|
txt.style.height = "0";
|
374
445
|
txt.style.height = `${txt.scrollHeight+delta}px`;
|
375
446
|
}
|
447
|
+
|
376
448
|
async function getSwaggerSpec() {
|
377
449
|
const response = await fetch('/swagger.yaml');
|
378
450
|
if (!response.ok) {
|
@@ -402,6 +474,20 @@ async function getPostParametersSchema() {
|
|
402
474
|
return result;
|
403
475
|
}
|
404
476
|
|
477
|
+
function saveFormValues(formValues, schemaName) {
|
478
|
+
const name = prompt('Enter name to save these values as:', formValues.savedValues);
|
479
|
+
if (!name) return;
|
480
|
+
if (!savedValues) {
|
481
|
+
savedValues = {};
|
482
|
+
}
|
483
|
+
if (!savedValues[schemaName]) {
|
484
|
+
savedValues[schemaName] = {};
|
485
|
+
}
|
486
|
+
formValues.savedValues = name;
|
487
|
+
savedValues[schemaName][name] = JSON.parse(JSON.stringify(formValues));
|
488
|
+
localStorage.setItem('savedValues', JSON.stringify(savedValues));
|
489
|
+
}
|
490
|
+
|
405
491
|
let schemaForm;
|
406
|
-
// let inputHandlers = [];
|
407
492
|
let schemaValues = JSON.parse(localStorage.getItem('schemaValues')) || {};
|
493
|
+
let savedValues = JSON.parse(localStorage.getItem('savedValues')) || {};
|
@@ -260,8 +260,8 @@ function exportToExcel(table) {
|
|
260
260
|
|
261
261
|
// Style header row
|
262
262
|
const headerRow = worksheet.getRow(1);
|
263
|
-
headerRow.font = { bold: true };
|
264
|
-
headerRow.alignment = { vertical: 'middle', horizontal: 'left' };
|
263
|
+
// headerRow.font = { bold: true };
|
264
|
+
// headerRow.alignment = { vertical: 'middle', horizontal: 'left' };
|
265
265
|
// headerRow.height = 20;
|
266
266
|
|
267
267
|
// Add table after all rows are defined
|