pywebexec 1.2.7__tar.gz → 1.2.9__tar.gz

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.
Files changed (35) hide show
  1. {pywebexec-1.2.7/pywebexec.egg-info → pywebexec-1.2.9}/PKG-INFO +1 -1
  2. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/css/style.css +8 -2
  3. pywebexec-1.2.9/pywebexec/static/js/commands.js +215 -0
  4. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/js/script.js +3 -1
  5. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/templates/index.html +1 -1
  6. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/version.py +2 -2
  7. {pywebexec-1.2.7 → pywebexec-1.2.9/pywebexec.egg-info}/PKG-INFO +1 -1
  8. pywebexec-1.2.7/pywebexec/static/js/commands.js +0 -183
  9. {pywebexec-1.2.7 → pywebexec-1.2.9}/.github/workflows/python-publish.yml +0 -0
  10. {pywebexec-1.2.7 → pywebexec-1.2.9}/.gitignore +0 -0
  11. {pywebexec-1.2.7 → pywebexec-1.2.9}/LICENSE +0 -0
  12. {pywebexec-1.2.7 → pywebexec-1.2.9}/README.md +0 -0
  13. {pywebexec-1.2.7 → pywebexec-1.2.9}/pyproject.toml +0 -0
  14. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/__init__.py +0 -0
  15. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/pywebexec.py +0 -0
  16. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/css/xterm.css +0 -0
  17. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/aborted.svg +0 -0
  18. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/copy.svg +0 -0
  19. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/copy_ok.svg +0 -0
  20. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/down-arrow.svg +0 -0
  21. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/failed.svg +0 -0
  22. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/favicon.svg +0 -0
  23. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/running.gif +0 -0
  24. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/images/success.svg +0 -0
  25. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/js/xterm/LICENSE +0 -0
  26. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/js/xterm/ansi_up.min.js +0 -0
  27. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/js/xterm/xterm-addon-fit.js +0 -0
  28. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/static/js/xterm/xterm.js +0 -0
  29. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec/templates/__init__.py +0 -0
  30. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec.egg-info/SOURCES.txt +0 -0
  31. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec.egg-info/dependency_links.txt +0 -0
  32. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec.egg-info/entry_points.txt +0 -0
  33. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec.egg-info/requires.txt +0 -0
  34. {pywebexec-1.2.7 → pywebexec-1.2.9}/pywebexec.egg-info/top_level.txt +0 -0
  35. {pywebexec-1.2.7 → pywebexec-1.2.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.2.7
3
+ Version: 1.2.9
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -31,9 +31,15 @@ th {
31
31
  width: 100%;
32
32
  }
33
33
  select { /* Safari bug */
34
+ -webkit-appearance: none;
35
+ -webkit-border-radius: none;
36
+ appearance: none;
37
+ outline: none;
34
38
  font-size: 15px;
35
39
  border: #aaa solid 1px;
36
40
  border-radius: 5px;
41
+ padding: 0px 5px 5px 0px;
42
+ min-width: 150px;
37
43
  }
38
44
  .output {
39
45
  white-space: pre-wrap;
@@ -178,7 +184,7 @@ form {
178
184
  border: 1px solid #aaa;
179
185
  border-radius: 5px;
180
186
  padding: 0px 5px 0px 5px;
181
- max-height: 300px;
187
+ margin-top: 2px;
182
188
  overflow-y: auto;
183
189
  z-index: 1000;
184
190
  }
@@ -188,7 +194,7 @@ form {
188
194
  cursor: pointer;
189
195
  }
190
196
 
191
- .command-item:hover {
197
+ .command-item:hover, .command-item.highlighted {
192
198
  background-color: #eee;
193
199
  }
194
200
 
@@ -0,0 +1,215 @@
1
+ // commands.js
2
+ let commandInput = document.getElementById('commandName');
3
+ let paramsInput = document.getElementById('params');
4
+ let commandListSelect = document.getElementById('commandList');
5
+ let showCommandListButton = document.getElementById('showCommandListButton');
6
+ let isHandlingKeydown = false;
7
+
8
+ function unfilterCommands() {
9
+ const options = commandListSelect.options;
10
+ for (let i = 0; i < options.length; i++) {
11
+ options[i].style.display = 'block';
12
+ }
13
+ commandListSelect.size = Math.min(20, commandListSelect.options.length);
14
+ }
15
+
16
+ function filterCommands() {
17
+ const value = commandInput.value.slice(0, commandInput.selectionStart);
18
+ const options = commandListSelect.options;
19
+ let nbVisibleItems = 0;
20
+ for (let i = 0; i < options.length; i++) {
21
+ if (options[i].text.startsWith(value)) {
22
+ options[i].style.display = 'block';
23
+ nbVisibleItems += 1;
24
+ } else {
25
+ options[i].style.display = 'none';
26
+ }
27
+ }
28
+ if (nbVisibleItems>1) {
29
+ commandListSelect.size = Math.min(20, nbVisibleItems);
30
+ commandListSelect.style.display = 'block';
31
+ } else {
32
+ commandListSelect.style.display = 'none';
33
+ }
34
+ }
35
+
36
+ function setCommandListPosition() {
37
+ const rect = commandInput.getBoundingClientRect();
38
+ commandListSelect.style.left = `${rect.left}px`;
39
+ commandListSelect.style.top = `${rect.bottom}px`;
40
+ }
41
+
42
+ function adjustInputWidth(input) {
43
+ input.style.width = 'auto';
44
+ input.style.width = `${input.scrollWidth}px`;
45
+ }
46
+
47
+
48
+ paramsInput.addEventListener('input', () => adjustInputWidth(paramsInput));
49
+ commandInput.addEventListener('input', () => {
50
+ adjustInputWidth(commandInput);
51
+ filterCommands(); // Filter commands on input
52
+ });
53
+
54
+ paramsInput.addEventListener('mouseover', () => {
55
+ paramsInput.focus();
56
+ paramsInput.setSelectionRange(0, paramsInput.value.length);
57
+ });
58
+
59
+ commandInput.addEventListener('mouseover', () => {
60
+ commandInput.focus();
61
+ commandInput.setSelectionRange(0, commandInput.value.length);
62
+ });
63
+
64
+ commandInput.addEventListener('input', (event) => {
65
+ if (event.inputType === 'deleteContentBackward') {
66
+ const newValue = commandInput.value.slice(0, -1);
67
+ commandInput.value = newValue;
68
+ commandInput.setSelectionRange(newValue.length, newValue.length);
69
+ }
70
+ const value = commandInput.value;
71
+ const options = commandListSelect.options;
72
+ if (value) {
73
+ const match = Array.from(options).find(option => option.text.startsWith(value));
74
+ if (match) {
75
+ commandInput.value = match.text;
76
+ commandInput.setSelectionRange(value.length, match.text.length);
77
+ } else {
78
+ commandInput.value = value.slice(0, -1);
79
+ }
80
+ }
81
+ filterCommands();
82
+ adjustInputWidth(commandInput); // Adjust width on input
83
+ });
84
+
85
+ commandInput.addEventListener('keydown', (event) => {
86
+ if (event.key === ' ' || event.key === 'ArrowRight') {
87
+ event.preventDefault();
88
+ paramsInput.focus();
89
+ paramsInput.setSelectionRange(0, paramsInput.value.length);
90
+ } else if (event.key === 'ArrowDown') {
91
+ /*setCommandListPosition();*/
92
+ unfilterCommands();
93
+ commandListSelect.style.display = 'block';
94
+ commandListSelect.focus();
95
+ commandListSelect.selectedIndex = 0;
96
+ event.preventDefault();
97
+ }
98
+ });
99
+
100
+ paramsInput.addEventListener('keydown', (event) => {
101
+ if (paramsInput.selectionStart > 0) return;
102
+ if (event.key === 'ArrowLeft') {
103
+ commandInput.focus();
104
+ commandInput.setSelectionRange(0, commandInput.value.length);
105
+ event.preventDefault();
106
+ return;
107
+ }
108
+ if (event.key === 'Backspace') {
109
+ val = paramsInput.value
110
+ paramsInput.value = val.slice(0, paramsInput.selectionStart) + val.slice(paramsInput.selectionEnd)
111
+ commandInput.focus();
112
+ commandInput.setSelectionRange(0, commandInput.value.length);
113
+ event.preventDefault();
114
+ }
115
+ });
116
+
117
+ commandListSelect.addEventListener('keydown', (event) => {
118
+ if (event.key === 'Enter') {
119
+ event.preventDefault(); // Prevent form submission
120
+ const selectedOption = commandListSelect.options[commandListSelect.selectedIndex];
121
+ commandInput.value = selectedOption.text;
122
+ commandListSelect.style.display = 'none';
123
+ adjustInputWidth(commandInput);
124
+ paramsInput.focus();
125
+ return;
126
+ }
127
+ if (event.key === 'ArrowUp' && commandListSelect.selectedIndex == 0) {
128
+ commandInput.focus();
129
+ commandListSelect.style.display = 'none'
130
+ }
131
+ });
132
+
133
+ commandListSelect.addEventListener('click', (event) => {
134
+ event.preventDefault(); // Prevent form submission
135
+ const selectedOption = commandListSelect.options[commandListSelect.selectedIndex];
136
+ commandInput.value = selectedOption.text;
137
+ commandListSelect.style.display = 'none';
138
+ adjustInputWidth(commandInput);
139
+ paramsInput.focus();
140
+ });
141
+
142
+
143
+ commandInput.addEventListener('click', () => {
144
+ setCommandListPosition();
145
+ if (commandListSelect.style.display == 'none')
146
+ commandListSelect.style.display = 'block';
147
+ else
148
+ commandListSelect.style.display = 'none';
149
+ filterCommands();
150
+ });
151
+
152
+ commandInput.addEventListener('blur', (event) => {
153
+ if (event.relatedTarget === showCommandListButton || event.relatedTarget === commandListSelect) {
154
+ event.preventDefault();
155
+ return;
156
+ }
157
+ commandListSelect.style.display = 'none';
158
+ adjustInputWidth(commandInput);
159
+ });
160
+
161
+ showCommandListButton.addEventListener('click', (event) => {
162
+ event.preventDefault();
163
+ setCommandListPosition();
164
+ if (commandListSelect.style.display == 'none')
165
+ commandListSelect.style.display = 'block';
166
+ else
167
+ commandListSelect.style.display = 'none';
168
+ unfilterCommands();
169
+ });
170
+
171
+ window.addEventListener('click', (event) => {
172
+ if (!commandInput.contains(event.target) && !commandListSelect.contains(event.target) && !showCommandListButton.contains(event.target)) {
173
+ commandListSelect.style.display = 'none';
174
+ }
175
+ });
176
+
177
+ window.addEventListener('keydown', (event) => {
178
+ if ([commandInput, paramsInput, commandListSelect].includes(document.activeElement)) return;
179
+ if (event.code === `Key${event.key.toUpperCase()}`) {
180
+ commandInput.focus();
181
+ commandInput.dispatchEvent(new KeyboardEvent('keydown', event));
182
+ }
183
+ });
184
+
185
+ window.addEventListener('resize', () => {
186
+ setCommandListPosition();
187
+ });
188
+
189
+ window.addEventListener('load', () => {
190
+ fetchExecutables();
191
+ adjustInputWidth(paramsInput); // Adjust width on load
192
+ adjustInputWidth(commandInput); // Adjust width on load
193
+ setCommandListPosition();
194
+ });
195
+
196
+ async function fetchExecutables() {
197
+ try {
198
+ const response = await fetch('/executables');
199
+ if (!response.ok) {
200
+ throw new Error('Failed to fetch command status');
201
+ }
202
+ const executables = await response.json();
203
+ commandListSelect.innerHTML = '';
204
+ executables.forEach(executable => {
205
+ const option = document.createElement('option');
206
+ option.className = 'command-item';
207
+ option.text = executable;
208
+ commandListSelect.appendChild(option);
209
+ });
210
+ } catch (error) {
211
+ alert("Failed to fetch executables");
212
+ }
213
+ commandListSelect.size = Math.min(20, commandListSelect.options.length)
214
+
215
+ }
@@ -53,9 +53,11 @@ document.getElementById('launchForm').addEventListener('submit', async (event) =
53
53
  throw new Error('Failed to launch command');
54
54
  }
55
55
  const data = await response.json();
56
- await new Promise(r => setTimeout(r, 200));
56
+ await new Promise(r => setTimeout(r, 300));
57
57
  fetchCommands();
58
58
  viewOutput(data.command_id);
59
+ commandInput.focus()
60
+ commandInput.setSelectionRange(0, commandInput.value.length)
59
61
  } catch (error) {
60
62
  console.log('Error running command:', error);
61
63
  }
@@ -19,11 +19,11 @@
19
19
  <div id="showCommandListButton" class="show-command-list-button">
20
20
  <span class="arrow">&#9660;</span>
21
21
  </div>
22
+ <select id="commandList" class="command-list" size="20"></select>
22
23
  <input type="text" id="params" name="params" oninput="this.style.width = ((this.value.length + 1) * 8) + 'px';">
23
24
  </div>
24
25
  <button type="submit">Run</button>
25
26
  </form>
26
- <div id="commandList" class="command-list"></div>
27
27
  <div class="table-container" id="tableContainer">
28
28
  <table>
29
29
  <thead>
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.2.7'
16
- __version_tuple__ = version_tuple = (1, 2, 7)
15
+ __version__ = version = '1.2.9'
16
+ __version_tuple__ = version_tuple = (1, 2, 9)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pywebexec
3
- Version: 1.2.7
3
+ Version: 1.2.9
4
4
  Summary: Simple Python HTTP Exec Server
5
5
  Home-page: https://github.com/joknarf/pywebexec
6
6
  Author: Franck Jouvanceau
@@ -1,183 +0,0 @@
1
- // commands.js
2
- let commandInput = document.getElementById('commandName');
3
- let paramsInput = document.getElementById('params');
4
- let commandListDiv = document.getElementById('commandList');
5
- let showCommandListButton = document.getElementById('showCommandListButton');
6
-
7
- function unfilterCommands() {
8
- const items = commandListDiv.getElementsByClassName('command-item');
9
- Array.from(items).forEach(item => {
10
- item.style.display = 'block';
11
- });
12
- adjustCommandListWidth();
13
- }
14
-
15
- function filterCommands() {
16
- const value = commandInput.value;
17
- const items = commandListDiv.getElementsByClassName('command-item');
18
- let hasVisibleItems = false;
19
- Array.from(items).forEach(item => {
20
- if (item.textContent.startsWith(value)) {
21
- item.style.display = 'block';
22
- hasVisibleItems = true;
23
- } else {
24
- item.style.display = 'none';
25
- }
26
- });
27
- commandListDiv.style.display = hasVisibleItems ? 'block' : 'none';
28
- if (hasVisibleItems) {
29
- commandListDiv.classList.add('show');
30
- } else {
31
- commandListDiv.classList.remove('show');
32
- }
33
- adjustCommandListWidth(); // Adjust width after filtering commands
34
- }
35
-
36
- function setCommandListPosition() {
37
- const rect = commandInput.getBoundingClientRect();
38
- commandListDiv.style.left = `${rect.left}px`;
39
- commandListDiv.style.top = `${rect.bottom}px`;
40
- commandListDiv.style.minWidth = `${rect.width}px`;
41
- }
42
-
43
- function adjustInputWidth(input) {
44
- input.style.width = 'auto';
45
- input.style.width = `${input.scrollWidth}px`;
46
- }
47
-
48
- function adjustCommandListWidth() {
49
- commandListDiv.style.width = 'auto'; // Reset width before recalculating
50
- const items = Array.from(commandListDiv.getElementsByClassName('command-item'));
51
- let maxWidth = 0;
52
- items.forEach(item => {
53
- if (item.style.display !== 'none') {
54
- const itemWidth = item.scrollWidth;
55
- if (itemWidth > maxWidth) {
56
- maxWidth = itemWidth;
57
- }
58
- }
59
- });
60
- commandListDiv.style.width = `${maxWidth}px`;
61
- }
62
-
63
- paramsInput.addEventListener('input', () => adjustInputWidth(paramsInput));
64
- commandInput.addEventListener('input', () => {
65
- adjustInputWidth(commandInput);
66
- filterCommands(); // Filter commands on input
67
- });
68
-
69
- paramsInput.addEventListener('mouseover', () => {
70
- paramsInput.focus();
71
- paramsInput.setSelectionRange(0, paramsInput.value.length);
72
- });
73
-
74
- commandInput.addEventListener('mouseover', () => {
75
- commandInput.focus();
76
- commandInput.setSelectionRange(0, commandInput.value.length);
77
- });
78
-
79
- commandInput.addEventListener('input', (event) => {
80
- if (event.inputType === 'deleteContentBackward') {
81
- const newValue = commandInput.value.slice(0, -1);
82
- commandInput.value = newValue;
83
- commandInput.setSelectionRange(newValue.length, newValue.length);
84
- }
85
- const value = commandInput.value;
86
- const items = Array.from(commandListDiv.getElementsByClassName('command-item'));
87
- if (value) {
88
- const match = items.find(item => item.textContent.startsWith(value));
89
- if (match) {
90
- commandInput.value = match.textContent;
91
- commandInput.setSelectionRange(value.length, match.textContent.length);
92
- } else {
93
- commandInput.value = value.slice(0, -1);
94
- }
95
- }
96
- filterCommands();
97
- adjustInputWidth(commandInput); // Adjust width on input
98
- });
99
-
100
- commandInput.addEventListener('click', () => {
101
- setCommandListPosition();
102
- commandListDiv.style.display = 'block';
103
- filterCommands();
104
- });
105
-
106
- commandInput.addEventListener('keydown', (event) => {
107
- if (event.key === 'ArrowDown') {
108
- setCommandListPosition();
109
- commandListDiv.style.display = 'block';
110
- unfilterCommands();
111
- }
112
- });
113
-
114
- commandInput.addEventListener('blur', (event) => {
115
- if (event.relatedTarget === showCommandListButton) {
116
- event.preventDefault();
117
- return;
118
- }
119
- commandListDiv.style.display = 'none';
120
- commandListDiv.classList.remove('show');
121
- adjustInputWidth(commandInput);
122
- });
123
-
124
- showCommandListButton.addEventListener('mousedown', (event) => {
125
- event.preventDefault();
126
- setCommandListPosition();
127
- commandListDiv.style.display = 'block';
128
- unfilterCommands();
129
- });
130
-
131
- window.addEventListener('click', (event) => {
132
- if (!commandInput.contains(event.target) && !commandListDiv.contains(event.target) && !showCommandListButton.contains(event.target)) {
133
- commandListDiv.style.display = 'none';
134
- commandListDiv.classList.remove('show');
135
- adjustInputWidth(commandInput);
136
- }
137
- });
138
-
139
- window.addEventListener('keydown', (event) => {
140
- if (document.activeElement !== paramsInput) {
141
- commandInput.focus();
142
- commandInput.dispatchEvent(new KeyboardEvent('keydown', event));
143
- }
144
- });
145
-
146
- window.addEventListener('resize', () => {
147
- setCommandListPosition();
148
- });
149
-
150
- window.addEventListener('load', () => {
151
- fetchExecutables();
152
- adjustInputWidth(paramsInput); // Adjust width on load
153
- adjustInputWidth(commandInput); // Adjust width on load
154
- setCommandListPosition();
155
- });
156
-
157
- async function fetchExecutables() {
158
- try {
159
- const response = await fetch('/executables');
160
- if (!response.ok) {
161
- throw new Error('Failed to fetch command status');
162
- }
163
- const executables = await response.json();
164
- commandListDiv.innerHTML = '';
165
- executables.forEach(executable => {
166
- const div = document.createElement('div');
167
- div.className = 'command-item';
168
- div.textContent = executable;
169
- div.addEventListener('mousedown', () => {
170
- commandInput.value = executable;
171
- commandListDiv.style.display = 'none';
172
- commandListDiv.classList.remove('show');
173
- adjustInputWidth(commandInput);
174
- paramsInput.focus();
175
- });
176
- commandListDiv.appendChild(div);
177
- });
178
- // Ensure the elements are rendered before measuring their widths
179
- requestAnimationFrame(adjustCommandListWidth);
180
- } catch (error) {
181
- alert("Failed to fetch executables");
182
- }
183
- }
File without changes
File without changes
File without changes
File without changes
File without changes