imcp 0.1.3 → 0.1.5

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 (239) hide show
  1. package/README.md +21 -4
  2. package/dist/cli/commands/install.js.map +1 -0
  3. package/dist/cli/commands/list.js.map +1 -0
  4. package/dist/cli/commands/pull.js.map +1 -0
  5. package/dist/cli/commands/serve.js.map +1 -0
  6. package/dist/cli/commands/start.d.ts +2 -0
  7. package/dist/cli/commands/start.js +32 -0
  8. package/dist/cli/commands/start.js.map +1 -0
  9. package/dist/cli/commands/sync.d.ts +2 -0
  10. package/dist/cli/commands/sync.js +17 -0
  11. package/dist/cli/commands/sync.js.map +1 -0
  12. package/dist/cli/commands/uninstall.js.map +1 -0
  13. package/dist/cli/index.js +0 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/core/ConfigurationLoader.d.ts +32 -0
  16. package/{src/core/loaders/ConfigurationLoader.ts → dist/core/ConfigurationLoader.js} +236 -298
  17. package/dist/core/ConfigurationLoader.js.map +1 -0
  18. package/dist/core/ConfigurationProvider.d.ts +35 -0
  19. package/{src/core/loaders/ConfigurationProvider.ts → dist/core/ConfigurationProvider.js} +375 -462
  20. package/dist/core/ConfigurationProvider.js.map +1 -0
  21. package/dist/core/InstallationService.d.ts +50 -0
  22. package/dist/core/InstallationService.js +350 -0
  23. package/dist/core/InstallationService.js.map +1 -0
  24. package/dist/core/MCPManager.d.ts +28 -0
  25. package/dist/core/MCPManager.js +188 -0
  26. package/dist/core/MCPManager.js.map +1 -0
  27. package/dist/core/RequirementService.d.ts +40 -0
  28. package/dist/core/RequirementService.js +110 -0
  29. package/dist/core/RequirementService.js.map +1 -0
  30. package/dist/core/ServerSchemaLoader.d.ts +11 -0
  31. package/dist/core/ServerSchemaLoader.js +43 -0
  32. package/dist/core/ServerSchemaLoader.js.map +1 -0
  33. package/dist/core/ServerSchemaProvider.d.ts +17 -0
  34. package/dist/core/ServerSchemaProvider.js +120 -0
  35. package/dist/core/ServerSchemaProvider.js.map +1 -0
  36. package/dist/core/constants.d.ts +47 -0
  37. package/dist/core/constants.js +94 -0
  38. package/dist/core/constants.js.map +1 -0
  39. package/dist/core/installers/BaseInstaller.d.ts +74 -0
  40. package/dist/core/installers/BaseInstaller.js +253 -0
  41. package/dist/core/installers/BaseInstaller.js.map +1 -0
  42. package/dist/core/installers/ClientInstaller.d.ts +23 -0
  43. package/dist/core/installers/ClientInstaller.js +564 -0
  44. package/dist/core/installers/ClientInstaller.js.map +1 -0
  45. package/dist/core/installers/CommandInstaller.d.ts +37 -0
  46. package/{src/core/installers/requirements/CommandInstaller.ts → dist/core/installers/CommandInstaller.js} +173 -231
  47. package/dist/core/installers/CommandInstaller.js.map +1 -0
  48. package/dist/core/installers/GeneralInstaller.d.ts +33 -0
  49. package/dist/core/installers/GeneralInstaller.js +85 -0
  50. package/dist/core/installers/GeneralInstaller.js.map +1 -0
  51. package/dist/core/installers/InstallerFactory.d.ts +54 -0
  52. package/{src/core/installers/requirements/InstallerFactory.ts → dist/core/installers/InstallerFactory.js} +97 -112
  53. package/dist/core/installers/InstallerFactory.js.map +1 -0
  54. package/dist/core/installers/NpmInstaller.d.ts +26 -0
  55. package/dist/core/installers/NpmInstaller.js +127 -0
  56. package/dist/core/installers/NpmInstaller.js.map +1 -0
  57. package/dist/core/installers/PipInstaller.d.ts +28 -0
  58. package/dist/core/installers/PipInstaller.js +127 -0
  59. package/dist/core/installers/PipInstaller.js.map +1 -0
  60. package/{src/core/installers/requirements/RequirementInstaller.ts → dist/core/installers/RequirementInstaller.d.ts} +33 -42
  61. package/dist/core/installers/RequirementInstaller.js +3 -0
  62. package/dist/core/installers/RequirementInstaller.js.map +1 -0
  63. package/dist/core/installers/clients/BaseClientInstaller.js.map +1 -0
  64. package/dist/core/installers/clients/ClientInstaller.js.map +1 -0
  65. package/dist/core/installers/clients/ClientInstallerFactory.js.map +1 -0
  66. package/dist/core/installers/clients/ClineInstaller.js.map +1 -0
  67. package/dist/core/installers/clients/ExtensionInstaller.js.map +1 -0
  68. package/dist/core/installers/clients/GithubCopilotInstaller.js.map +1 -0
  69. package/dist/core/installers/clients/MSRooCodeInstaller.js.map +1 -0
  70. package/dist/core/installers/index.js.map +1 -0
  71. package/dist/core/installers/requirements/BaseInstaller.js.map +1 -0
  72. package/dist/core/installers/requirements/CommandInstaller.js.map +1 -0
  73. package/dist/core/installers/requirements/GeneralInstaller.js.map +1 -0
  74. package/dist/core/installers/requirements/InstallerFactory.js +2 -0
  75. package/dist/core/installers/requirements/InstallerFactory.js.map +1 -0
  76. package/dist/core/installers/requirements/NpmInstaller.js.map +1 -0
  77. package/dist/core/installers/requirements/NugetInstaller.d.ts +37 -0
  78. package/dist/core/installers/requirements/NugetInstaller.js +189 -0
  79. package/dist/core/installers/requirements/NugetInstaller.js.map +1 -0
  80. package/dist/core/installers/requirements/PipInstaller.js.map +1 -0
  81. package/dist/core/installers/requirements/RequirementInstaller.js.map +1 -0
  82. package/dist/core/loaders/ConfigurationLoader.js.map +1 -0
  83. package/dist/core/loaders/ConfigurationProvider.js.map +1 -0
  84. package/dist/core/loaders/InstallOperationManager.js.map +1 -0
  85. package/dist/core/loaders/ServerSchemaLoader.js.map +1 -0
  86. package/dist/core/loaders/ServerSchemaProvider.js.map +1 -0
  87. package/dist/core/loaders/SystemSettingsManager.js.map +1 -0
  88. package/dist/core/metadatas/constants.js.map +1 -0
  89. package/dist/core/metadatas/recordingConstants.d.ts +2 -0
  90. package/dist/core/metadatas/recordingConstants.js +2 -0
  91. package/dist/core/metadatas/recordingConstants.js.map +1 -0
  92. package/dist/core/metadatas/types.d.ts +1 -1
  93. package/dist/core/metadatas/types.js.map +1 -0
  94. package/dist/core/onboard/FeedOnboardService.js +1 -22
  95. package/dist/core/onboard/FeedOnboardService.js.map +1 -0
  96. package/dist/core/onboard/OnboardProcessor.js.map +1 -0
  97. package/dist/core/onboard/OnboardStatus.js.map +1 -0
  98. package/dist/core/onboard/OnboardStatusManager.js.map +1 -0
  99. package/dist/core/types.d.ts +166 -0
  100. package/dist/core/types.js +16 -0
  101. package/dist/core/types.js.map +1 -0
  102. package/dist/core/validators/FeedValidator.js.map +1 -0
  103. package/dist/core/validators/IServerValidator.js.map +1 -0
  104. package/dist/core/validators/SSEServerValidator.js.map +1 -0
  105. package/dist/core/validators/ServerValidatorFactory.js.map +1 -0
  106. package/dist/core/validators/StdioServerValidator.js +5 -5
  107. package/dist/core/validators/StdioServerValidator.js.map +1 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/services/InstallRequestValidator.d.ts +21 -0
  110. package/dist/services/InstallRequestValidator.js +99 -0
  111. package/dist/services/InstallRequestValidator.js.map +1 -0
  112. package/dist/services/InstallationService.js.map +1 -0
  113. package/dist/services/MCPManager.js.map +1 -0
  114. package/dist/services/RequirementService.js.map +1 -0
  115. package/dist/services/ServerService.js.map +1 -0
  116. package/dist/services/TelemetryService.js.map +1 -0
  117. package/dist/utils/UpdateCheckTracker.js.map +1 -0
  118. package/dist/utils/adoUtils.js.map +1 -0
  119. package/dist/utils/clientUtils.js.map +1 -0
  120. package/dist/utils/feedUtils.js.map +1 -0
  121. package/dist/utils/githubAuth.js.map +1 -0
  122. package/dist/utils/githubUtils.js.map +1 -0
  123. package/dist/utils/logger.js.map +1 -0
  124. package/dist/utils/macroExpressionUtils.js.map +1 -0
  125. package/dist/utils/osUtils.d.ts +11 -0
  126. package/dist/utils/osUtils.js +100 -0
  127. package/dist/utils/osUtils.js.map +1 -0
  128. package/dist/utils/versionUtils.js.map +1 -0
  129. package/dist/web/contract/serverContract.js.map +1 -0
  130. package/dist/web/public/index.html +1 -1
  131. package/dist/web/public/js/modal/installHandler.js +227 -0
  132. package/dist/web/public/js/modal/loadingUI.js +74 -0
  133. package/dist/web/public/js/modal/messageQueue.js +101 -45
  134. package/dist/web/public/js/modal/modalUI.js +214 -0
  135. package/{src/web/public/js/modal/versionUtils.js → dist/web/public/js/modal/version.js} +1 -1
  136. package/dist/web/public/js/onboard/templates.js +1 -0
  137. package/dist/web/public/js/serverCategoryList.js +3 -3
  138. package/dist/web/public/onboard.html +4 -4
  139. package/dist/web/server.js.map +1 -0
  140. package/package.json +5 -1
  141. package/.github/ISSUE_TEMPLATE/JitAccess.yml +0 -28
  142. package/.github/acl/access.yml +0 -20
  143. package/.github/compliance/inventory.yml +0 -5
  144. package/.github/policies/jit.yml +0 -19
  145. package/.roo/rules-code/rules.md +0 -88
  146. package/dist/core/onboard/InstallOperationManager.d.ts +0 -23
  147. package/dist/core/onboard/InstallOperationManager.js +0 -144
  148. package/docs/ONBOARDING_PAGE_DESIGN.md +0 -260
  149. package/docs/Telemetry.md +0 -136
  150. package/memory-bank/activeContext.md +0 -26
  151. package/memory-bank/decisionLog.md +0 -91
  152. package/memory-bank/productContext.md +0 -41
  153. package/memory-bank/progress.md +0 -35
  154. package/memory-bank/systemPatterns.md +0 -10
  155. package/src/cli/commands/install.ts +0 -139
  156. package/src/cli/commands/list.ts +0 -113
  157. package/src/cli/commands/pull.ts +0 -16
  158. package/src/cli/commands/serve.ts +0 -39
  159. package/src/cli/commands/uninstall.ts +0 -64
  160. package/src/cli/index.ts +0 -82
  161. package/src/core/installers/clients/BaseClientInstaller.ts +0 -341
  162. package/src/core/installers/clients/ClientInstaller.ts +0 -222
  163. package/src/core/installers/clients/ClientInstallerFactory.ts +0 -43
  164. package/src/core/installers/clients/ClineInstaller.ts +0 -35
  165. package/src/core/installers/clients/ExtensionInstaller.ts +0 -165
  166. package/src/core/installers/clients/GithubCopilotInstaller.ts +0 -79
  167. package/src/core/installers/clients/MSRooCodeInstaller.ts +0 -32
  168. package/src/core/installers/index.ts +0 -11
  169. package/src/core/installers/requirements/BaseInstaller.ts +0 -85
  170. package/src/core/installers/requirements/GeneralInstaller.ts +0 -133
  171. package/src/core/installers/requirements/NpmInstaller.ts +0 -271
  172. package/src/core/installers/requirements/PipInstaller.ts +0 -207
  173. package/src/core/loaders/InstallOperationManager.ts +0 -367
  174. package/src/core/loaders/ServerSchemaLoader.ts +0 -117
  175. package/src/core/loaders/ServerSchemaProvider.ts +0 -99
  176. package/src/core/loaders/SystemSettingsManager.ts +0 -278
  177. package/src/core/metadatas/constants.ts +0 -122
  178. package/src/core/metadatas/recordingConstants.ts +0 -62
  179. package/src/core/metadatas/types.ts +0 -202
  180. package/src/core/onboard/FeedOnboardService.ts +0 -524
  181. package/src/core/onboard/OnboardProcessor.ts +0 -356
  182. package/src/core/onboard/OnboardStatus.ts +0 -60
  183. package/src/core/onboard/OnboardStatusManager.ts +0 -416
  184. package/src/core/validators/FeedValidator.ts +0 -135
  185. package/src/core/validators/IServerValidator.ts +0 -21
  186. package/src/core/validators/SSEServerValidator.ts +0 -43
  187. package/src/core/validators/ServerValidatorFactory.ts +0 -51
  188. package/src/core/validators/StdioServerValidator.ts +0 -312
  189. package/src/index.ts +0 -44
  190. package/src/services/InstallationService.ts +0 -102
  191. package/src/services/MCPManager.ts +0 -249
  192. package/src/services/RequirementService.ts +0 -627
  193. package/src/services/ServerService.ts +0 -161
  194. package/src/services/TelemetryService.ts +0 -59
  195. package/src/utils/UpdateCheckTracker.ts +0 -86
  196. package/src/utils/adoUtils.ts +0 -293
  197. package/src/utils/clientUtils.ts +0 -72
  198. package/src/utils/feedUtils.ts +0 -31
  199. package/src/utils/githubAuth.ts +0 -212
  200. package/src/utils/githubUtils.ts +0 -164
  201. package/src/utils/logger.ts +0 -195
  202. package/src/utils/macroExpressionUtils.ts +0 -104
  203. package/src/utils/osUtils.ts +0 -597
  204. package/src/utils/versionUtils.ts +0 -114
  205. package/src/web/contract/serverContract.ts +0 -74
  206. package/src/web/public/css/detailsWidget.css +0 -235
  207. package/src/web/public/css/modal.css +0 -757
  208. package/src/web/public/css/notifications.css +0 -101
  209. package/src/web/public/css/onboard.css +0 -107
  210. package/src/web/public/css/serverCategoryList.css +0 -120
  211. package/src/web/public/css/serverDetails.css +0 -139
  212. package/src/web/public/index.html +0 -359
  213. package/src/web/public/js/api.js +0 -132
  214. package/src/web/public/js/detailsWidget.js +0 -264
  215. package/src/web/public/js/flights/flights.js +0 -127
  216. package/src/web/public/js/modal/index.js +0 -52
  217. package/src/web/public/js/modal/installModal.js +0 -162
  218. package/src/web/public/js/modal/installation.js +0 -266
  219. package/src/web/public/js/modal/loadingModal.js +0 -182
  220. package/src/web/public/js/modal/modalSetup.js +0 -595
  221. package/src/web/public/js/modal/modalUtils.js +0 -37
  222. package/src/web/public/js/modal.js +0 -42
  223. package/src/web/public/js/notifications.js +0 -137
  224. package/src/web/public/js/onboard/formProcessor.js +0 -1037
  225. package/src/web/public/js/onboard/index.js +0 -374
  226. package/src/web/public/js/onboard/publishHandler.js +0 -172
  227. package/src/web/public/js/onboard/state.js +0 -76
  228. package/src/web/public/js/onboard/templates.js +0 -341
  229. package/src/web/public/js/onboard/uiHandlers.js +0 -1076
  230. package/src/web/public/js/onboard/validationHandlers.js +0 -493
  231. package/src/web/public/js/serverCategoryDetails.js +0 -364
  232. package/src/web/public/js/serverCategoryList.js +0 -241
  233. package/src/web/public/js/settings.js +0 -314
  234. package/src/web/public/modal.html +0 -84
  235. package/src/web/public/onboard.html +0 -296
  236. package/src/web/public/settings.html +0 -135
  237. package/src/web/public/styles.css +0 -277
  238. package/src/web/server.ts +0 -478
  239. package/tsconfig.json +0 -18
@@ -1,266 +0,0 @@
1
- // import { delayedAppendInstallLoadingMessage } from './messageQueue.js'; // No longer used directly for steps
2
- import { showInstallLoadingModal, updateOverallInstallStatus, addInstallationStep } from './loadingModal.js';
3
- import { showToast } from '../notifications.js';
4
-
5
- /**
6
- * Handle bulk client installations
7
- * @param {string} categoryName - The category name
8
- * @param {string} serverName - The server name
9
- * @param {string[]} targets - Target clients
10
- * @param {Object} envVars - Environment variables
11
- * @param {string} installingMessage - Installation message
12
- * @param {Object} serverData - Server data
13
- * @param {Object} serverInstallOptions - Server installation options
14
- */
15
- export async function handleBulkClientInstall(categoryName, serverName, targets, envVars = {}, installingMessage = "Starting installation...", serverData = null, serverInstallOptions = null) {
16
- console.log('[LoadingModal] handleBulkClientInstall called', { categoryName, serverName, targets, envVars, serverInstallOptions });
17
- // Hide install modal, show loading modal
18
- const installModal = document.getElementById('installModal');
19
- console.log('[LoadingModal] installModal:', installModal);
20
- if (installModal) installModal.style.display = "none";
21
-
22
- // Store category and server name for potential refresh
23
- if (categoryName) {
24
- localStorage.setItem('lastSelectedCategory', categoryName);
25
- }
26
- if (serverName) {
27
- localStorage.setItem('lastSelectedServerName', serverName);
28
- }
29
-
30
- // If serverData is provided, extract the installing message from it (latest status)
31
- if (serverData?.data?.installationStatus?.serversStatus) {
32
- const serverStatuses = serverData.data.installationStatus.serversStatus;
33
- const serverStatus = serverStatuses[serverName] || { installedStatus: {} };
34
- if (targets?.length > 0) {
35
- const target = targets[0];
36
- const msg = serverStatus.installedStatus?.[target]?.message;
37
- if (msg) installingMessage = msg;
38
- }
39
- // Append the installing message for user visibility
40
- if (installingMessage && installingMessage !== "Starting installation...") {
41
- delayedAppendInstallLoadingMessage(installingMessage);
42
- }
43
- }
44
-
45
- showInstallLoadingModal(`Installing ${serverName}`); // Pass initial server name
46
- // delayedAppendInstallLoadingMessage(installingMessage); // Old way
47
-
48
- try {
49
- // delayedAppendInstallLoadingMessage("Installing, please wait..."); // Old way
50
-
51
- // Use serverInstallOptions if provided, otherwise build the traditional options
52
- const requestBody = {
53
- serverList: {
54
- [serverName]: serverInstallOptions || {
55
- targetClients: targets,
56
- env: envVars
57
- }
58
- }
59
- };
60
-
61
- const response = await fetch(`/api/categories/${categoryName}/install`, {
62
- method: 'POST',
63
- headers: {
64
- 'Content-Type': 'application/json',
65
- 'Accept': 'application/json'
66
- },
67
- body: JSON.stringify(requestBody)
68
- });
69
-
70
- console.log('[LoadingModal] fetch install response:', response);
71
-
72
- if (!response.ok) {
73
- const errorData = await response.text();
74
- // delayedAppendInstallLoadingMessage(`<span style="color:#f59e0b;">Failed: ${errorData || response.statusText}</span>`); // Old way
75
- updateOverallInstallStatus('failed', `Installation request failed: ${errorData || response.statusText}`);
76
- console.error('[LoadingModal] Failed:', errorData || response.statusText);
77
- throw new Error(`Installation failed: ${errorData || response.statusText}`);
78
- }
79
-
80
- const result = await response.json();
81
- console.log('[LoadingModal] install result:', result);
82
- if (!result.success) {
83
- // delayedAppendInstallLoadingMessage(`<span style="color:#f59e0b;">${result.error || 'Operation failed'}</span>`); // Old way
84
- updateOverallInstallStatus('failed', result.error || 'Installation operation failed to start.');
85
- console.error('[LoadingModal] Error:', result.error || 'Operation failed');
86
- throw new Error(result.error || 'Installation failed');
87
- }
88
-
89
- // Start polling for install status
90
- pollNewInstallStatus(categoryName, serverName, 2000); // New polling
91
- } catch (error) {
92
- console.error('[LoadingModal] Error applying configuration:', error);
93
- // delayedAppendInstallLoadingMessage(`<span style="color:red;">Error: ${error.message}</span>`); // Old way
94
- updateOverallInstallStatus('failed', `Error: ${error.message}`);
95
- }
96
- }
97
-
98
- /**
99
- * Poll install status using the new API endpoint for detailed steps.
100
- * @param {string} categoryName - The category name
101
- * @param {string} serverName - The server name
102
- * @param {number} interval - Polling interval in milliseconds
103
- */
104
- async function pollNewInstallStatus(categoryName, serverName, interval = 2000) {
105
- let completionMessageSent = false;
106
- const startTime = Date.now();
107
- const maxTimeout = 10 * 60 * 1000; // 10 minutes
108
-
109
- while (Date.now() - startTime < maxTimeout && !completionMessageSent) {
110
- try {
111
- const resp = await fetch(`/api/categories/${categoryName}/servers/${serverName}/installation/status`);
112
- if (resp.ok) {
113
- const result = await resp.json();
114
- if (result.success && result.data) {
115
- const { steps, overallStatus, error } = result.data;
116
-
117
- updateOverallInstallStatus(overallStatus, error || `Installation ${overallStatus}`);
118
-
119
- // Always update or insert each step, so UI stays in sync with backend
120
- steps.forEach(step => {
121
- addInstallationStep(step.name, step.message, step.status, step.timestamp);
122
- });
123
-
124
- if (overallStatus === 'completed' || overallStatus === 'failed') {
125
- completionMessageSent = true;
126
- // The hideInstallLoadingModal will be called by the user or after a timeout.
127
- // We can add a "Close" button or auto-close logic here if needed.
128
- // For now, just stop polling.
129
- // Ensure final status is displayed
130
- const finalMessage = overallStatus === 'completed' ?
131
- `Installation completed successfully for ${serverName}.` :
132
- `Installation failed for ${serverName}`;
133
- updateOverallInstallStatus(overallStatus, finalMessage);
134
- return;
135
- }
136
- } else if (!result.success && resp.status === 404) {
137
- // Still waiting for the status file to be created.
138
- updateOverallInstallStatus('in-progress', `Waiting for installation to start for ${serverName}...`);
139
- } else if (!result.success) {
140
- updateOverallInstallStatus('failed', `Error fetching status: ${result.error || 'Unknown error'}`);
141
- completionMessageSent = true; // Stop polling on error
142
- return;
143
- }
144
- } else if (resp.status === 404) {
145
- updateOverallInstallStatus('in-progress', `Installation status not yet available for ${serverName}. Retrying...`);
146
- } else {
147
- const errorText = await resp.text();
148
- updateOverallInstallStatus('failed', `Error fetching status: ${errorText || resp.statusText}`);
149
- completionMessageSent = true; // Stop polling on error
150
- return;
151
- }
152
- } catch (error) {
153
- console.error('[LoadingModal] Error polling new install status:', error);
154
- updateOverallInstallStatus('failed', `Error polling status: ${error.message}`);
155
- completionMessageSent = true; // Stop polling on error
156
- return;
157
- }
158
- await new Promise(resolve => setTimeout(resolve, interval));
159
- }
160
-
161
- if (!completionMessageSent) {
162
- updateOverallInstallStatus('failed', `Operation timed out for ${serverName} - Please check logs or refresh.`);
163
- }
164
- }
165
-
166
- /**
167
- * Handle client uninstallation for multiple targets
168
- * @param {string} categoryName - The category name
169
- * @param {Object} serverList - List of servers to uninstall
170
- * @param {string[]} targets - Target clients
171
- */
172
- export async function uninstallTools(categoryName, serverList, targets) {
173
-
174
- console.log('[LoadingModal] uninstallTools called', { categoryName, serverList, targets });
175
- // Store category and server name for potential refresh
176
- if (categoryName) {
177
- console.log('[LoadingModal] Setting lastSelectedCategory:', categoryName);
178
- localStorage.setItem('lastSelectedCategory', categoryName);
179
- }
180
-
181
- // Get selected targets from window.selectedClients or the provided targets
182
- const selectedTargets = window.selectedClients || (Array.isArray(targets) ? targets : [targets]);
183
-
184
- // Validate selected targets
185
- if (!selectedTargets || selectedTargets.length === 0) {
186
- showToast('Please select at least one client to uninstall.', 'error');
187
- return;
188
- }
189
-
190
- // Ensure showInstallLoadingModal is called if not already visible,
191
- // or ensure overall status is updated if it is.
192
- // For simplicity, we assume the modal is shown by the caller (e.g., modalSetup.js)
193
- // Add uninstall started step
194
- if (typeof addInstallationStep === 'function') {
195
- addInstallationStep(
196
- 'Uninstalling',
197
- `Uninstallation process started for ${Object.keys(serverList).join(', ')}`,
198
- 'in-progress',
199
- new Date().toISOString()
200
- );
201
- }
202
- updateOverallInstallStatus('in-progress', `Starting uninstallation for ${Object.keys(serverList).join(', ')}...`);
203
-
204
- try {
205
- const serverListKeys = Object.keys(serverList);
206
- serverListKeys.forEach(server => {
207
- console.log('[LoadingModal] Setting lastSelectedServerName:', server);
208
- localStorage.setItem('lastSelectedServerName', server);
209
- });
210
-
211
- const response = await fetch(`/api/categories/${categoryName}/uninstall`, {
212
- method: 'POST',
213
- headers: { 'Content-Type': 'application/json' },
214
- body: JSON.stringify({
215
- serverList: serverList,
216
- options: {
217
- targets: selectedTargets,
218
- removeData: true
219
- }
220
- })
221
- });
222
-
223
- if (!response.ok) {
224
- const errorData = await response.text();
225
- updateOverallInstallStatus('failed', `Uninstallation request failed: ${errorData || response.statusText}`);
226
- throw new Error(`Uninstallation failed: ${errorData || response.statusText}`);
227
- }
228
-
229
- const result = await response.json();
230
- if (!result.success) {
231
- updateOverallInstallStatus('failed', `Uninstallation failed: ${result.error || 'Operation failed'}`);
232
- throw new Error(result.error || 'Uninstallation failed');
233
- }
234
-
235
- // Add uninstall finished step with 1s delay before updating overall status
236
- if (typeof addInstallationStep === 'function') {
237
- await new Promise(resolve => setTimeout(resolve, 1000));
238
- addInstallationStep(
239
- 'Uninstalling',
240
- `Uninstallation process finished for ${Object.keys(serverList).join(', ')}`,
241
- 'completed',
242
- new Date().toISOString()
243
- );
244
- await new Promise(resolve => setTimeout(resolve, 1000));
245
- addInstallationStep(
246
- 'Uninstall Finished',
247
- `Uninstallation finished for ${Object.keys(serverList).join(', ')}`,
248
- 'completed',
249
- new Date().toISOString()
250
- );
251
- }
252
- await new Promise(resolve => setTimeout(resolve, 1000));
253
- updateOverallInstallStatus('completed', `Successfully uninstalled from ${selectedTargets.join(', ')}.`);
254
- window.selectedClients = []; // Clear selected clients
255
-
256
- } catch (error) {
257
- console.error('Error uninstalling tools:', error);
258
- // The status should have been updated by the specific error handlers above.
259
- // If an error occurs before those, update status here.
260
- const overallStatusTextEl = document.getElementById('overallStatusText'); // Check if element exists
261
- if (overallStatusTextEl && overallStatusTextEl.textContent.startsWith('Starting uninstallation')) {
262
- updateOverallInstallStatus('failed', `Error uninstalling tools: ${error.message}`);
263
- }
264
- showToast(`Error uninstalling tools: ${error.message}`, 'error');
265
- }
266
- }
@@ -1,182 +0,0 @@
1
- // import { delayedAppendInstallLoadingMessage } from './messageQueue.js'; // Not directly used here anymore for appending
2
-
3
- const ICONS = {
4
- IN_PROGRESS: '<div class="status-spinner"></div>',
5
- COMPLETED: '<div class="status-icon-circled icon-check-container"><span class="status-icon icon-check">✓</span></div>',
6
- FAILED: '<span class="status-icon icon-cross">✗</span>', // Assuming cross doesn't need a circle for now
7
- CANCELED: '<span class="status-icon icon-minus">–</span>', // Simple minus for canceled
8
- };
9
-
10
- let overallStatusIconEl, overallStatusTextEl, installStepDetailsListEl;
11
-
12
- /**
13
- * Display the installation loading modal and prepare it for messages.
14
- * @param {string} [initialOperationText='Installing'] - The initial overall operation text.
15
- */
16
- export function showInstallLoadingModal(initialOperationText = 'Installing') {
17
- const loadingModal = document.getElementById('installLoadingModal');
18
- // Assuming modal-content is the direct child where content should be placed.
19
- const modalContent = loadingModal ? loadingModal.querySelector('.modal-content') : null;
20
-
21
- if (loadingModal && modalContent) {
22
- modalContent.innerHTML = `
23
- <button id="installLoadingModalCloseBtn" class="modal-close-btn">&times;</button>
24
- <div class="installation-status-header">
25
- <div id="overallStatusIconContainer" class="overall-status-icon">
26
- ${ICONS.IN_PROGRESS}
27
- </div>
28
- <h3 id="overallStatusText" class="overall-status-text">${initialOperationText}...</h3>
29
- </div>
30
- <div class="installation-steps-container">
31
- <ul id="installStepDetailsList" class="install-step-details-list"></ul>
32
- </div>
33
- `;
34
-
35
- overallStatusIconEl = modalContent.querySelector('#overallStatusIconContainer');
36
- overallStatusTextEl = modalContent.querySelector('#overallStatusText');
37
- installStepDetailsListEl = modalContent.querySelector('#installStepDetailsList');
38
-
39
- const closeButton = modalContent.querySelector('#installLoadingModalCloseBtn');
40
- if (closeButton) {
41
- closeButton.addEventListener('click', hideInstallLoadingModal);
42
- }
43
-
44
- loadingModal.style.display = 'block';
45
- } else {
46
- console.error('[LoadingModal] Required elements not found: #installLoadingModal or .modal-content');
47
- }
48
- }
49
-
50
- /**
51
- * Updates the overall status display in the loading modal.
52
- * @param {'in-progress' | 'completed' | 'failed'} status - The overall status.
53
- * @param {string} message - The message to display for the overall status.
54
- */
55
- export function updateOverallInstallStatus(status, message) {
56
- if (!overallStatusIconEl || !overallStatusTextEl) {
57
- // console.warn('[LoadingModal] Overall status elements not initialized or found.');
58
- return;
59
- }
60
-
61
- let iconHtml = ICONS.IN_PROGRESS;
62
- let statusClass = 'in-progress';
63
-
64
- switch (status) {
65
- case 'completed':
66
- iconHtml = ICONS.COMPLETED;
67
- statusClass = 'completed';
68
- break;
69
- case 'failed':
70
- iconHtml = ICONS.FAILED;
71
- statusClass = 'failed';
72
- break;
73
- case 'in-progress':
74
- default:
75
- // iconHtml and statusClass already set
76
- break;
77
- }
78
-
79
- overallStatusIconEl.innerHTML = iconHtml;
80
- overallStatusIconEl.className = `overall-status-icon ${statusClass}`; // Update class for styling
81
- overallStatusTextEl.textContent = message || (status.charAt(0).toUpperCase() + status.slice(1));
82
- }
83
-
84
- /**
85
- * Adds a step to the installation details list.
86
- * @param {string} stepName - The name/title of the step.
87
- * @param {string} message - The message associated with the step.
88
- * @param {'pending'|'in-progress'|'completed'|'failed'|'canceled'} status - The status of the step.
89
- * @param {string} timestamp - ISO timestamp string for the step.
90
- */
91
- export function addInstallationStep(stepName, message, status, timestamp) {
92
- if (!installStepDetailsListEl) {
93
- return;
94
- }
95
-
96
- // Use stepName as a unique identifier for the step
97
- const stepId = `install-step-${stepName.replace(/[^a-zA-Z0-9_-]/g, '_')}`;
98
- let listItem = document.getElementById(stepId);
99
-
100
- let statusClass = '';
101
- let stepIcon = '';
102
-
103
- switch (status) {
104
- case 'completed':
105
- statusClass = 'success';
106
- stepIcon = '<span class="step-icon icon-check-small">✓</span>';
107
- break;
108
- case 'failed':
109
- statusClass = 'error';
110
- stepIcon = '<span class="step-icon icon-cross-small">✗</span>';
111
- break;
112
- case 'canceled':
113
- statusClass = 'canceled';
114
- stepIcon = '<span class="step-icon icon-minus-small">–</span>';
115
- break;
116
- case 'in-progress':
117
- case 'pending':
118
- default:
119
- statusClass = 'in-progress';
120
- stepIcon = '<div class="status-spinner step-spinner"></div>';
121
- break;
122
- }
123
-
124
- let timeString = '';
125
- if (timestamp) {
126
- try {
127
- timeString = new Date(timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false });
128
- } catch (e) { /* ignore */ }
129
- }
130
-
131
- const innerHTML = `
132
- ${stepIcon}
133
- <div class="step-info">
134
- <span class="step-name">${stepName}</span>
135
- <span class="step-message">${message || (
136
- status === 'completed' ? 'Completed' :
137
- status === 'failed' ? 'Failed' :
138
- status === 'canceled' ? 'Canceled' :
139
- 'In Progress'
140
- )}</span>
141
- </div>
142
- <span class="step-timestamp">${timeString}</span>
143
- `;
144
-
145
- if (listItem) {
146
- // Update existing step
147
- listItem.className = `step-detail-item ${statusClass}`;
148
- listItem.innerHTML = innerHTML;
149
- } else {
150
- // Create new step
151
- listItem = document.createElement('li');
152
- listItem.id = stepId;
153
- listItem.className = `step-detail-item ${statusClass}`;
154
- listItem.innerHTML = innerHTML;
155
- installStepDetailsListEl.appendChild(listItem);
156
- // Scroll to the bottom of the list
157
- installStepDetailsListEl.scrollTop = installStepDetailsListEl.scrollHeight;
158
- }
159
- }
160
-
161
-
162
- /**
163
- * Hide the install loading modal.
164
- */
165
- export function hideInstallLoadingModal() {
166
- console.log('[LoadingModal] Hiding installation modal');
167
- const loadingModal = document.getElementById('installLoadingModal');
168
- if (loadingModal) {
169
- loadingModal.style.display = 'none';
170
-
171
- // Clear references to avoid stale elements if modal is reshown
172
- overallStatusIconEl = null;
173
- overallStatusTextEl = null;
174
- installStepDetailsListEl = null;
175
-
176
- // Dispatch an event to signal that the main modal content should be refreshed
177
- document.dispatchEvent(new CustomEvent('refreshMainModalContent'));
178
- console.log('[LoadingModal] Dispatched refreshMainModalContent event.');
179
- } else {
180
- console.error('[LoadingModal] loading modal DOM not found');
181
- }
182
- }