imcp 0.1.5 → 0.1.6

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 (186) hide show
  1. package/.github/ISSUE_TEMPLATE/JitAccess.yml +28 -0
  2. package/.github/acl/access.yml +20 -0
  3. package/.github/compliance/inventory.yml +5 -0
  4. package/.github/policies/jit.yml +19 -0
  5. package/.github/workflows/build.yml +28 -0
  6. package/.roo/rules-code/rules.md +88 -0
  7. package/docs/ONBOARDING_PAGE_DESIGN.md +260 -0
  8. package/docs/Telemetry.md +136 -0
  9. package/memory-bank/activeContext.md +26 -0
  10. package/memory-bank/decisionLog.md +91 -0
  11. package/memory-bank/productContext.md +41 -0
  12. package/memory-bank/progress.md +35 -0
  13. package/memory-bank/systemPatterns.md +10 -0
  14. package/package.json +1 -5
  15. package/src/cli/commands/install.ts +139 -0
  16. package/src/cli/commands/list.ts +113 -0
  17. package/src/cli/commands/pull.ts +16 -0
  18. package/src/cli/commands/serve.ts +39 -0
  19. package/src/cli/commands/uninstall.ts +64 -0
  20. package/src/cli/index.ts +82 -0
  21. package/src/core/installers/clients/BaseClientInstaller.ts +341 -0
  22. package/src/core/installers/clients/ClientInstaller.ts +222 -0
  23. package/src/core/installers/clients/ClientInstallerFactory.ts +43 -0
  24. package/src/core/installers/clients/ClineInstaller.ts +35 -0
  25. package/src/core/installers/clients/ExtensionInstaller.ts +165 -0
  26. package/src/core/installers/clients/GithubCopilotInstaller.ts +79 -0
  27. package/src/core/installers/clients/MSRooCodeInstaller.ts +32 -0
  28. package/src/core/installers/index.ts +11 -0
  29. package/src/core/installers/requirements/BaseInstaller.ts +85 -0
  30. package/src/core/installers/requirements/CommandInstaller.ts +231 -0
  31. package/src/core/installers/requirements/GeneralInstaller.ts +133 -0
  32. package/src/core/installers/requirements/InstallerFactory.ts +114 -0
  33. package/src/core/installers/requirements/NpmInstaller.ts +271 -0
  34. package/src/core/installers/requirements/NugetInstaller.ts +203 -0
  35. package/src/core/installers/requirements/PipInstaller.ts +207 -0
  36. package/src/core/installers/requirements/RequirementInstaller.ts +42 -0
  37. package/src/core/loaders/ConfigurationLoader.ts +298 -0
  38. package/src/core/loaders/ConfigurationProvider.ts +462 -0
  39. package/src/core/loaders/InstallOperationManager.ts +367 -0
  40. package/src/core/loaders/ServerSchemaLoader.ts +117 -0
  41. package/src/core/loaders/ServerSchemaProvider.ts +99 -0
  42. package/src/core/loaders/SystemSettingsManager.ts +278 -0
  43. package/src/core/metadatas/constants.ts +122 -0
  44. package/src/core/metadatas/recordingConstants.ts +65 -0
  45. package/src/core/metadatas/types.ts +202 -0
  46. package/src/core/onboard/FeedOnboardService.ts +501 -0
  47. package/src/core/onboard/OnboardProcessor.ts +356 -0
  48. package/src/core/onboard/OnboardStatus.ts +60 -0
  49. package/src/core/onboard/OnboardStatusManager.ts +416 -0
  50. package/src/core/validators/FeedValidator.ts +135 -0
  51. package/src/core/validators/IServerValidator.ts +21 -0
  52. package/src/core/validators/SSEServerValidator.ts +43 -0
  53. package/src/core/validators/ServerValidatorFactory.ts +51 -0
  54. package/src/core/validators/StdioServerValidator.ts +313 -0
  55. package/src/index.ts +44 -0
  56. package/src/services/InstallationService.ts +102 -0
  57. package/src/services/MCPManager.ts +249 -0
  58. package/src/services/RequirementService.ts +627 -0
  59. package/src/services/ServerService.ts +161 -0
  60. package/src/services/TelemetryService.ts +59 -0
  61. package/src/utils/UpdateCheckTracker.ts +86 -0
  62. package/src/utils/adoUtils.ts +293 -0
  63. package/src/utils/clientUtils.ts +72 -0
  64. package/src/utils/feedUtils.ts +31 -0
  65. package/src/utils/githubAuth.ts +212 -0
  66. package/src/utils/githubUtils.ts +164 -0
  67. package/src/utils/logger.ts +195 -0
  68. package/src/utils/macroExpressionUtils.ts +104 -0
  69. package/src/utils/osUtils.ts +700 -0
  70. package/src/utils/versionUtils.ts +114 -0
  71. package/src/web/contract/serverContract.ts +74 -0
  72. package/src/web/public/css/detailsWidget.css +235 -0
  73. package/src/web/public/css/modal.css +757 -0
  74. package/src/web/public/css/notifications.css +101 -0
  75. package/src/web/public/css/onboard.css +107 -0
  76. package/src/web/public/css/serverCategoryList.css +120 -0
  77. package/src/web/public/css/serverDetails.css +139 -0
  78. package/src/web/public/index.html +359 -0
  79. package/src/web/public/js/api.js +132 -0
  80. package/src/web/public/js/detailsWidget.js +264 -0
  81. package/src/web/public/js/flights/flights.js +127 -0
  82. package/src/web/public/js/modal/index.js +52 -0
  83. package/src/web/public/js/modal/installModal.js +162 -0
  84. package/src/web/public/js/modal/installation.js +266 -0
  85. package/src/web/public/js/modal/loadingModal.js +182 -0
  86. package/src/web/public/js/modal/modalSetup.js +595 -0
  87. package/src/web/public/js/modal/modalUtils.js +37 -0
  88. package/src/web/public/js/modal/versionUtils.js +20 -0
  89. package/src/web/public/js/modal.js +42 -0
  90. package/src/web/public/js/notifications.js +137 -0
  91. package/src/web/public/js/onboard/formProcessor.js +1037 -0
  92. package/src/web/public/js/onboard/index.js +374 -0
  93. package/src/web/public/js/onboard/publishHandler.js +172 -0
  94. package/src/web/public/js/onboard/state.js +76 -0
  95. package/src/web/public/js/onboard/templates.js +342 -0
  96. package/src/web/public/js/onboard/uiHandlers.js +1076 -0
  97. package/src/web/public/js/onboard/validationHandlers.js +493 -0
  98. package/src/web/public/js/serverCategoryDetails.js +364 -0
  99. package/src/web/public/js/serverCategoryList.js +241 -0
  100. package/src/web/public/js/settings.js +314 -0
  101. package/src/web/public/modal.html +84 -0
  102. package/src/web/public/onboard.html +296 -0
  103. package/src/web/public/settings.html +135 -0
  104. package/src/web/public/styles.css +277 -0
  105. package/src/web/server.ts +478 -0
  106. package/tsconfig.json +18 -0
  107. package/wiki/Installation.md +3 -0
  108. package/wiki/Publish.md +3 -0
  109. package/dist/cli/commands/install.js.map +0 -1
  110. package/dist/cli/commands/list.js.map +0 -1
  111. package/dist/cli/commands/pull.js.map +0 -1
  112. package/dist/cli/commands/serve.js.map +0 -1
  113. package/dist/cli/commands/start.js.map +0 -1
  114. package/dist/cli/commands/sync.js.map +0 -1
  115. package/dist/cli/commands/uninstall.js.map +0 -1
  116. package/dist/cli/index.js.map +0 -1
  117. package/dist/core/ConfigurationLoader.js.map +0 -1
  118. package/dist/core/ConfigurationProvider.js.map +0 -1
  119. package/dist/core/InstallationService.js.map +0 -1
  120. package/dist/core/MCPManager.js.map +0 -1
  121. package/dist/core/RequirementService.js.map +0 -1
  122. package/dist/core/ServerSchemaLoader.js.map +0 -1
  123. package/dist/core/ServerSchemaProvider.js.map +0 -1
  124. package/dist/core/constants.js.map +0 -1
  125. package/dist/core/installers/BaseInstaller.js.map +0 -1
  126. package/dist/core/installers/ClientInstaller.js.map +0 -1
  127. package/dist/core/installers/CommandInstaller.js.map +0 -1
  128. package/dist/core/installers/GeneralInstaller.js.map +0 -1
  129. package/dist/core/installers/InstallerFactory.js.map +0 -1
  130. package/dist/core/installers/NpmInstaller.js.map +0 -1
  131. package/dist/core/installers/PipInstaller.js.map +0 -1
  132. package/dist/core/installers/RequirementInstaller.js.map +0 -1
  133. package/dist/core/installers/clients/BaseClientInstaller.js.map +0 -1
  134. package/dist/core/installers/clients/ClientInstaller.js.map +0 -1
  135. package/dist/core/installers/clients/ClientInstallerFactory.js.map +0 -1
  136. package/dist/core/installers/clients/ClineInstaller.js.map +0 -1
  137. package/dist/core/installers/clients/ExtensionInstaller.js.map +0 -1
  138. package/dist/core/installers/clients/GithubCopilotInstaller.js.map +0 -1
  139. package/dist/core/installers/clients/MSRooCodeInstaller.js.map +0 -1
  140. package/dist/core/installers/index.js.map +0 -1
  141. package/dist/core/installers/requirements/BaseInstaller.js.map +0 -1
  142. package/dist/core/installers/requirements/CommandInstaller.js.map +0 -1
  143. package/dist/core/installers/requirements/GeneralInstaller.js.map +0 -1
  144. package/dist/core/installers/requirements/InstallerFactory.js.map +0 -1
  145. package/dist/core/installers/requirements/NpmInstaller.js.map +0 -1
  146. package/dist/core/installers/requirements/NugetInstaller.js.map +0 -1
  147. package/dist/core/installers/requirements/PipInstaller.js.map +0 -1
  148. package/dist/core/installers/requirements/RequirementInstaller.js.map +0 -1
  149. package/dist/core/loaders/ConfigurationLoader.js.map +0 -1
  150. package/dist/core/loaders/ConfigurationProvider.js.map +0 -1
  151. package/dist/core/loaders/InstallOperationManager.js.map +0 -1
  152. package/dist/core/loaders/ServerSchemaLoader.js.map +0 -1
  153. package/dist/core/loaders/ServerSchemaProvider.js.map +0 -1
  154. package/dist/core/loaders/SystemSettingsManager.js.map +0 -1
  155. package/dist/core/metadatas/constants.js.map +0 -1
  156. package/dist/core/metadatas/recordingConstants.js.map +0 -1
  157. package/dist/core/metadatas/types.js.map +0 -1
  158. package/dist/core/onboard/FeedOnboardService.js.map +0 -1
  159. package/dist/core/onboard/OnboardProcessor.js.map +0 -1
  160. package/dist/core/onboard/OnboardStatus.js.map +0 -1
  161. package/dist/core/onboard/OnboardStatusManager.js.map +0 -1
  162. package/dist/core/types.js.map +0 -1
  163. package/dist/core/validators/FeedValidator.js.map +0 -1
  164. package/dist/core/validators/IServerValidator.js.map +0 -1
  165. package/dist/core/validators/SSEServerValidator.js.map +0 -1
  166. package/dist/core/validators/ServerValidatorFactory.js.map +0 -1
  167. package/dist/core/validators/StdioServerValidator.js.map +0 -1
  168. package/dist/index.js.map +0 -1
  169. package/dist/services/InstallRequestValidator.js.map +0 -1
  170. package/dist/services/InstallationService.js.map +0 -1
  171. package/dist/services/MCPManager.js.map +0 -1
  172. package/dist/services/RequirementService.js.map +0 -1
  173. package/dist/services/ServerService.js.map +0 -1
  174. package/dist/services/TelemetryService.js.map +0 -1
  175. package/dist/utils/UpdateCheckTracker.js.map +0 -1
  176. package/dist/utils/adoUtils.js.map +0 -1
  177. package/dist/utils/clientUtils.js.map +0 -1
  178. package/dist/utils/feedUtils.js.map +0 -1
  179. package/dist/utils/githubAuth.js.map +0 -1
  180. package/dist/utils/githubUtils.js.map +0 -1
  181. package/dist/utils/logger.js.map +0 -1
  182. package/dist/utils/macroExpressionUtils.js.map +0 -1
  183. package/dist/utils/osUtils.js.map +0 -1
  184. package/dist/utils/versionUtils.js.map +0 -1
  185. package/dist/web/contract/serverContract.js.map +0 -1
  186. package/dist/web/server.js.map +0 -1
@@ -0,0 +1,314 @@
1
+ import { buildUrlWithFlights } from './flights/flights.js';
2
+
3
+ // Toast notification function
4
+ function showToast(message, type = 'success') {
5
+ const toastContainer = document.querySelector('.toast-container');
6
+ if (!toastContainer) return;
7
+
8
+ const toastId = `toast-${Date.now()}`;
9
+ const toastHTML = `
10
+ <div id="${toastId}" class="toast align-items-center text-white bg-${type === 'success' ? 'success' : 'danger'} border-0" role="alert" aria-live="assertive" aria-atomic="true">
11
+ <div class="d-flex">
12
+ <div class="toast-body">
13
+ ${message}
14
+ </div>
15
+ <button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
16
+ </div>
17
+ </div>
18
+ `;
19
+ toastContainer.insertAdjacentHTML('beforeend', toastHTML);
20
+ const toastElement = document.getElementById(toastId);
21
+ const toast = new bootstrap.Toast(toastElement, { delay: 3000 });
22
+ toast.show();
23
+ toastElement.addEventListener('hidden.bs.toast', () => {
24
+ toastElement.remove();
25
+ });
26
+ }
27
+
28
+ document.addEventListener('DOMContentLoaded', () => {
29
+ // All DOM element queries and event listeners must be inside this block!
30
+ const settingsForm = document.getElementById('settingsForm');
31
+ const nodePathInput = document.getElementById('nodePath');
32
+ const browserPathInput = document.getElementById('browserPath');
33
+ const systemEnvironmentsDiv = document.getElementById('systemEnvironments');
34
+
35
+ // Python Environments elements
36
+ const pythonEnvsContainer = document.getElementById('pythonEnvsContainer');
37
+ const addPythonEnvButton = document.getElementById('addPythonEnvButton');
38
+ const pythonEnvsLoadingMsg = document.getElementById('pythonEnvsLoadingMsg');
39
+
40
+ // User Configurations elements
41
+ const userConfigurationsContainer = document.getElementById('userConfigurationsContainer');
42
+ const addUserConfigButton = document.getElementById('addUserConfigButton');
43
+ const userConfigLoadingMsg = document.getElementById('userConfigLoadingMsg');
44
+
45
+ const cancelButton = document.getElementById('cancelButton');
46
+ const setupButton = document.getElementById('setupButton');
47
+
48
+ // (Removed duplicate showToast function here)
49
+
50
+
51
+ async function loadSettings() {
52
+ try {
53
+ const response = await fetch('/api/settings');
54
+ if (!response.ok) {
55
+ const errorData = await response.json();
56
+ throw new Error(errorData.error || `HTTP error! status: ${response.status}`);
57
+ }
58
+ const apiResponse = await response.json();
59
+ if (apiResponse.success && apiResponse.data) {
60
+ const settings = apiResponse.data;
61
+
62
+ // Populate Python Environments
63
+ if(pythonEnvsLoadingMsg) pythonEnvsLoadingMsg.remove(); // Remove loading message
64
+ pythonEnvsContainer.innerHTML = ''; // Clear previous entries
65
+
66
+ if (settings.pythonEnvs && Object.keys(settings.pythonEnvs).length > 0) {
67
+ Object.entries(settings.pythonEnvs).forEach(([server, path]) => {
68
+ renderPythonEnvInput(server, path);
69
+ });
70
+ } else if (settings.pythonEnv) {
71
+ // Handle legacy pythonEnv
72
+ renderPythonEnvInput('system', settings.pythonEnv);
73
+ } else {
74
+ if (!pythonEnvsContainer.querySelector('.python-env-row')) { // Add placeholder if no rows exist
75
+ const p = document.createElement('p');
76
+ p.className = 'text-gray-500 python-env-placeholder';
77
+ p.textContent = 'No Python environments defined. Click "Add Python Environment" to add one.';
78
+ pythonEnvsContainer.appendChild(p);
79
+ }
80
+ }
81
+
82
+ nodePathInput.value = settings.nodePath || '';
83
+ browserPathInput.value = settings.browserPath || '';
84
+
85
+ // Populate System Environments
86
+ systemEnvironmentsDiv.innerHTML = ''; // Clear loading message
87
+ if (settings.systemEnvironments && Object.keys(settings.systemEnvironments).length > 0) {
88
+ // Create a modern, scrollable list (not a table)
89
+ const list = document.createElement('div');
90
+ list.className = 'flex flex-col';
91
+
92
+ Object.entries(settings.systemEnvironments).forEach(([key, value], idx) => {
93
+ const item = document.createElement('div');
94
+ item.className =
95
+ 'flex flex-col sm:flex-row sm:items-center bg-white rounded-md border border-gray-200 px-4 py-2 shadow-sm hover:shadow transition group';
96
+ item.innerHTML = `
97
+ <div class="flex items-center min-w-0 w-full sm:w-1/4 sm:mb-0">
98
+ <i class='bx bx-cog text-blue-400 mr-2'></i>
99
+ <span class="font-mono font-semibold text-gray-800 text-base truncate" title="${key}">${key}</span>
100
+ </div>
101
+ <div class="flex-1 min-w-0 break-all text-gray-700 text-sm pl-7 sm:pl-4">
102
+ ${value}
103
+ </div>
104
+ `;
105
+ list.appendChild(item);
106
+ });
107
+
108
+ // Restore frame styling for the new layout
109
+ systemEnvironmentsDiv.classList.remove('shadow');
110
+ systemEnvironmentsDiv.classList.add('rounded-lg', 'bg-white', 'border', 'border-gray-200', 'border-1');
111
+ systemEnvironmentsDiv.classList.remove('border-2', 'border-4', 'border-8');
112
+ systemEnvironmentsDiv.classList.add('p-0');
113
+ systemEnvironmentsDiv.style.padding = '0.5rem 0.5rem 0.5rem 0.5rem';
114
+ systemEnvironmentsDiv.appendChild(list);
115
+ } else {
116
+ systemEnvironmentsDiv.innerHTML = '<p class="text-gray-500">No system environment variables loaded or available.</p>';
117
+ }
118
+
119
+ // Populate User Configurations
120
+ if(userConfigLoadingMsg) userConfigLoadingMsg.remove(); // Remove loading message
121
+ userConfigurationsContainer.innerHTML = ''; // Clear previous entries
122
+ if (settings.userConfigurations && Object.keys(settings.userConfigurations).length > 0) {
123
+ Object.entries(settings.userConfigurations).forEach(([key, value]) => {
124
+ renderUserConfigInput(key, value);
125
+ });
126
+ } else {
127
+ if (!userConfigurationsContainer.querySelector('.user-config-row')) { // Add placeholder if no rows exist
128
+ const p = document.createElement('p');
129
+ p.className = 'text-gray-500 user-config-placeholder';
130
+ p.textContent = 'No user configurations defined. Click "Add User Configuration" to add one.';
131
+ userConfigurationsContainer.appendChild(p);
132
+ }
133
+ }
134
+
135
+ } else {
136
+ throw new Error(apiResponse.error || 'Failed to load settings.');
137
+ }
138
+ } catch (error) {
139
+ console.error('Error loading settings:', error);
140
+ showToast(`Error loading settings: ${error.message}`, 'danger');
141
+ systemEnvironmentsDiv.innerHTML = `<p class="text-red-500">Error loading environment variables: ${error.message}</p>`;
142
+ if(userConfigLoadingMsg) userConfigLoadingMsg.textContent = `Error loading user configurations: ${error.message}`;
143
+ }
144
+ }
145
+
146
+ function renderPythonEnvInput(server = 'system', path = '') {
147
+ const placeholder = pythonEnvsContainer.querySelector('.python-env-placeholder');
148
+ if (placeholder) placeholder.remove();
149
+
150
+ const uniqueId = `python-env-${Date.now()}-${Math.random().toString(36).substr(2, 5)}`;
151
+ const div = document.createElement('div');
152
+ div.className = 'python-env-row flex items-center gap-3 mb-2';
153
+ div.innerHTML = `
154
+ <input type="text" value="${server}" class="form-input form-control w-1/3 px-3 py-2 rounded-md python-env-server" placeholder="Server Name (e.g., system)">
155
+ <input type="text" value="${path}" class="form-input form-control w-2/3 px-3 py-2 rounded-md python-env-path" placeholder="e.g., /usr/bin/python3 or C:/Python39/python.exe">
156
+ <button type="button" class="btn btn-danger btn-sm remove-python-env-button flex items-center">
157
+ <i class='bx bx-trash'></i>
158
+ </button>
159
+ `;
160
+ pythonEnvsContainer.appendChild(div);
161
+ div.querySelector('.remove-python-env-button').addEventListener('click', function() {
162
+ this.closest('.python-env-row').remove();
163
+ if (!pythonEnvsContainer.querySelector('.python-env-row')) { // Add placeholder if no rows exist after removal
164
+ const p = document.createElement('p');
165
+ p.className = 'text-gray-500 python-env-placeholder';
166
+ p.textContent = 'No Python environments defined. Click "Add Python Environment" to add one.';
167
+ pythonEnvsContainer.appendChild(p);
168
+ }
169
+ });
170
+ }
171
+
172
+ function renderUserConfigInput(key = '', value = '') {
173
+ const placeholder = userConfigurationsContainer.querySelector('.user-config-placeholder');
174
+ if (placeholder) placeholder.remove();
175
+
176
+ const uniqueId = `user-config-${Date.now()}-${Math.random().toString(36).substr(2, 5)}`;
177
+ const div = document.createElement('div');
178
+ div.className = 'user-config-row flex items-center gap-3 mb-2';
179
+ const isSecret = key.toLowerCase().includes('key');
180
+ const valueInputType = isSecret ? 'password' : 'text';
181
+
182
+ // Key Input
183
+ const keyInputHTML = `<input type="text" value="${key}" class="form-input form-control w-1/3 px-3 py-2 rounded-md user-config-key" placeholder="Key">`;
184
+
185
+ // Value Input & Eye Icon (if secret)
186
+ let valueSectionHTML;
187
+ if (isSecret) {
188
+ valueSectionHTML = `
189
+ <div class="relative w-2/3">
190
+ <input type="${valueInputType}" value="${value}" class="form-input form-control w-full px-3 py-2 rounded-md user-config-value pr-10" placeholder="Value">
191
+ <button type="button" class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-500 hover:text-gray-700 toggle-visibility-button" style="background: transparent; border: none;">
192
+ <i class='bx bx-show text-lg'></i>
193
+ </button>
194
+ </div>
195
+ `;
196
+ } else {
197
+ valueSectionHTML = `<input type="${valueInputType}" value="${value}" class="form-input form-control w-2/3 px-3 py-2 rounded-md user-config-value" placeholder="Value">`;
198
+ }
199
+
200
+ // Remove Button
201
+ const removeButtonHTML = `
202
+ <button type="button" class="btn btn-danger btn-sm remove-user-config-button flex items-center">
203
+ <i class='bx bx-trash'></i>
204
+ </button>
205
+ `;
206
+
207
+ div.innerHTML = keyInputHTML + valueSectionHTML + removeButtonHTML;
208
+ userConfigurationsContainer.appendChild(div);
209
+
210
+ if (isSecret) {
211
+ const toggleButton = div.querySelector('.toggle-visibility-button');
212
+ const valueInput = div.querySelector('.user-config-value');
213
+ const eyeIcon = toggleButton.querySelector('i');
214
+
215
+ toggleButton.addEventListener('click', (e) => {
216
+ e.preventDefault(); // Prevent form submission if inside a form
217
+ if (valueInput.type === 'password') {
218
+ valueInput.type = 'text';
219
+ eyeIcon.classList.remove('bx-show');
220
+ eyeIcon.classList.add('bx-hide');
221
+ } else {
222
+ valueInput.type = 'password';
223
+ eyeIcon.classList.remove('bx-hide');
224
+ eyeIcon.classList.add('bx-show');
225
+ }
226
+ });
227
+ }
228
+
229
+ div.querySelector('.remove-user-config-button').addEventListener('click', function() {
230
+ this.closest('.user-config-row').remove();
231
+ if (!userConfigurationsContainer.querySelector('.user-config-row')) { // Add placeholder if no rows exist after removal
232
+ const p = document.createElement('p');
233
+ p.className = 'text-gray-500 user-config-placeholder';
234
+ p.textContent = 'No user configurations defined. Click "Add User Configuration" to add one.';
235
+ userConfigurationsContainer.appendChild(p);
236
+ }
237
+ });
238
+ }
239
+
240
+
241
+ async function saveSettings(event) {
242
+ event.preventDefault();
243
+ setupButton.disabled = true;
244
+ setupButton.innerHTML = `<i class='bx bx-loader-alt bx-spin mr-2'></i>Saving...`;
245
+
246
+ const pythonEnvs = {};
247
+ document.querySelectorAll('.python-env-row').forEach(row => {
248
+ const serverInput = row.querySelector('.python-env-server');
249
+ const pathInput = row.querySelector('.python-env-path');
250
+ if (serverInput && pathInput && serverInput.value.trim()) {
251
+ pythonEnvs[serverInput.value.trim()] = pathInput.value.trim();
252
+ }
253
+ });
254
+
255
+ const userConfigs = {};
256
+ document.querySelectorAll('.user-config-row').forEach(row => {
257
+ const keyInput = row.querySelector('.user-config-key');
258
+ const valueInput = row.querySelector('.user-config-value');
259
+ if (keyInput && valueInput && keyInput.value.trim()) {
260
+ userConfigs[keyInput.value.trim()] = valueInput.value.trim();
261
+ }
262
+ });
263
+
264
+ const settingsData = {
265
+ pythonEnvs: pythonEnvs,
266
+ // Include pythonEnv for backward compatibility (use system value if available)
267
+ pythonEnv: pythonEnvs['system'] || null,
268
+ nodePath: nodePathInput.value.trim() || null,
269
+ browserPath: browserPathInput.value.trim() || null,
270
+ userConfigurations: userConfigs,
271
+ };
272
+
273
+ try {
274
+ const response = await fetch('/api/settings', {
275
+ method: 'POST',
276
+ headers: {
277
+ 'Content-Type': 'application/json',
278
+ },
279
+ body: JSON.stringify(settingsData),
280
+ });
281
+
282
+ const apiResponse = await response.json();
283
+
284
+ if (response.ok && apiResponse.success) {
285
+ showToast('Settings saved successfully!', 'success');
286
+ // Optionally, reload settings to reflect any backend-applied defaults
287
+ await loadSettings();
288
+ } else {
289
+ throw new Error(apiResponse.error || `HTTP error! status: ${response.status}`);
290
+ }
291
+ } catch (error) {
292
+ console.error('Error saving settings:', error);
293
+ showToast(`Error saving settings: ${error.message}`, 'danger');
294
+ } finally {
295
+ setupButton.disabled = false;
296
+ setupButton.innerHTML = `<i class='bx bx-save mr-2'></i>Save Settings`;
297
+ }
298
+ }
299
+
300
+ cancelButton.addEventListener('click', () => {
301
+ // Navigate back to index.html, preserving flight parameters
302
+ window.location.href = buildUrlWithFlights('index.html');
303
+ });
304
+
305
+ addPythonEnvButton.addEventListener('click', () => renderPythonEnvInput());
306
+ addUserConfigButton.addEventListener('click', () => renderUserConfigInput());
307
+
308
+ settingsForm.addEventListener('submit', saveSettings);
309
+
310
+ // Initial load
311
+ loadSettings();
312
+
313
+ // (Collapse/expand functionality removed as requested)
314
+ });
@@ -0,0 +1,84 @@
1
+ <div id="installModal" class="modal">
2
+ <div class="modal-content">
3
+ <span class="close" onclick="closeModal()">&times;</span>
4
+ <div class="modal-header">
5
+ <h2 id="modalTitle" class="text-2xl font-bold text-gray-800"></h2>
6
+ <p class="text-gray-600 mt-2">Configure your installation settings below</p>
7
+ </div>
8
+
9
+ <div class="modal-sections">
10
+ <!-- Requirements Section -->
11
+ <div class="section-container">
12
+ <div id="modalRequirements"></div>
13
+ </div>
14
+
15
+ <!-- Client Status Section -->
16
+ <div class="section-container">
17
+ <div id="modalTargets" class="client-grid"></div>
18
+ </div>
19
+
20
+ <div class="section-container">
21
+ <div id="modalEnvInputs" class="space-y-4">
22
+ <!-- Environment Variables will be injected here -->
23
+ </div>
24
+ </div>
25
+
26
+ <div class="section-container">
27
+ <div id="modalArguments" class="space-y-4">
28
+ <!-- Arguments will be injected here -->
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+
34
+
35
+ <form id="installForm" class="mt-8">
36
+ <!-- Arguments Section -->
37
+ <div id="modalArguments" class="mb-6 space-y-4">
38
+ <!-- Arguments will be injected here -->
39
+ </div>
40
+
41
+ <div class="flex justify-end space-x-4">
42
+ <button type="button" onclick="closeModal()"
43
+ class="px-6 py-2.5 text-gray-600 hover:text-gray-800 font-medium rounded-lg hover:bg-gray-100 transition-colors">
44
+ Cancel
45
+ </button>
46
+ <button type="submit" class="submit-button">
47
+ Apply
48
+ </button>
49
+ </div>
50
+ </form>
51
+ </div>
52
+ </div>
53
+
54
+ <!-- Loading Modal -->
55
+ <div id="installLoadingModal" class="modal" style="display:none; z-index:2000;">
56
+ <div class="modal-content"
57
+ style="display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 340px; pointer-events:auto; position:relative;">
58
+ <button class="modal-close-button" onclick="hideInstallLoadingModal()" aria-label="Close">&times;</button>
59
+ <div style="width: 100%;">
60
+ <div style="display: flex; flex-direction: column; align-items: center; width: 100%;">
61
+ <div class="loading-icon" style="margin-bottom:8px;">
62
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none"
63
+ style="display: block; margin-left: auto; margin-right: auto;">
64
+ <circle cx="24" cy="24" r="20" stroke="#888" stroke-width="4" opacity="0.2" />
65
+ <circle cx="24" cy="24" r="20" stroke="#3498db" stroke-width="4" stroke-linecap="round"
66
+ stroke-dasharray="100" stroke-dashoffset="60">
67
+ <animateTransform attributeName="transform" type="rotate" from="0 24 24" to="360 24 24"
68
+ dur="1s" repeatCount="indefinite" />
69
+ </circle>
70
+ </svg>
71
+ </div>
72
+ <div class="loading-title"
73
+ style="font-size:1.5rem; font-weight:bold; margin-bottom:8px; text-align:center;">Installing...
74
+ </div>
75
+ <div id="installLoadingMessage"
76
+ style="min-height:48px; max-height:160px; overflow:auto; background:#f8f8f8; border-radius:6px; padding:12px; font-size:1rem; color:#444; text-align:left; width:100%;">
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+
83
+ <link rel="stylesheet" href="/css/modal.css">
84
+ <link rel="stylesheet" href="/css/modal.css">