imcp 0.0.13 → 0.0.15
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.
- package/dist/core/ConfigurationProvider.d.ts +1 -0
- package/dist/core/ConfigurationProvider.js +15 -0
- package/dist/core/InstallationService.js +2 -7
- package/dist/core/MCPManager.d.ts +11 -2
- package/dist/core/MCPManager.js +24 -1
- package/dist/core/RequirementService.js +2 -8
- package/dist/core/installers/clients/BaseClientInstaller.d.ts +51 -0
- package/dist/core/installers/clients/BaseClientInstaller.js +160 -0
- package/dist/core/installers/clients/ClientInstaller.d.ts +16 -8
- package/dist/core/installers/clients/ClientInstaller.js +77 -504
- package/dist/core/installers/clients/ClientInstallerFactory.d.ts +19 -0
- package/dist/core/installers/clients/ClientInstallerFactory.js +41 -0
- package/dist/core/installers/clients/ClineInstaller.d.ts +18 -0
- package/dist/core/installers/clients/ClineInstaller.js +124 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.d.ts +34 -0
- package/dist/core/installers/clients/GithubCopilotInstaller.js +162 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.d.ts +15 -0
- package/dist/core/installers/clients/MSRooCodeInstaller.js +122 -0
- package/dist/core/installers/requirements/BaseInstaller.d.ts +11 -34
- package/dist/core/installers/requirements/BaseInstaller.js +5 -116
- package/dist/core/installers/requirements/CommandInstaller.d.ts +6 -1
- package/dist/core/installers/requirements/CommandInstaller.js +7 -0
- package/dist/core/installers/requirements/GeneralInstaller.d.ts +6 -1
- package/dist/core/installers/requirements/GeneralInstaller.js +9 -4
- package/dist/core/installers/requirements/NpmInstaller.d.ts +46 -7
- package/dist/core/installers/requirements/NpmInstaller.js +150 -58
- package/dist/core/installers/requirements/PipInstaller.d.ts +9 -0
- package/dist/core/installers/requirements/PipInstaller.js +66 -28
- package/dist/core/onboard/FeedOnboardService.d.ts +72 -0
- package/dist/core/onboard/FeedOnboardService.js +312 -0
- package/dist/core/onboard/OnboardProcessor.d.ts +79 -0
- package/dist/core/onboard/OnboardProcessor.js +290 -0
- package/dist/core/onboard/OnboardStatus.d.ts +49 -0
- package/dist/core/onboard/OnboardStatus.js +10 -0
- package/dist/core/onboard/OnboardStatusManager.d.ts +57 -0
- package/dist/core/onboard/OnboardStatusManager.js +176 -0
- package/dist/core/types.d.ts +6 -6
- package/dist/core/validators/FeedValidator.d.ts +20 -0
- package/dist/core/validators/FeedValidator.js +80 -0
- package/dist/core/validators/IServerValidator.d.ts +19 -0
- package/dist/core/validators/IServerValidator.js +2 -0
- package/dist/core/validators/SSEServerValidator.d.ts +15 -0
- package/dist/core/validators/SSEServerValidator.js +39 -0
- package/dist/core/validators/ServerValidatorFactory.d.ts +24 -0
- package/dist/core/validators/ServerValidatorFactory.js +45 -0
- package/dist/core/validators/StdioServerValidator.d.ts +46 -0
- package/dist/core/validators/StdioServerValidator.js +229 -0
- package/dist/services/InstallRequestValidator.d.ts +1 -1
- package/dist/services/ServerService.d.ts +9 -6
- package/dist/services/ServerService.js +18 -7
- package/dist/utils/adoUtils.d.ts +29 -0
- package/dist/utils/adoUtils.js +252 -0
- package/dist/utils/clientUtils.d.ts +0 -7
- package/dist/utils/clientUtils.js +0 -42
- package/dist/utils/githubUtils.d.ts +10 -0
- package/dist/utils/githubUtils.js +22 -0
- package/dist/utils/macroExpressionUtils.d.ts +38 -0
- package/dist/utils/macroExpressionUtils.js +116 -0
- package/dist/utils/osUtils.d.ts +4 -20
- package/dist/utils/osUtils.js +78 -23
- package/dist/web/contract/serverContract.d.ts +66 -0
- package/dist/web/contract/serverContract.js +2 -0
- package/dist/web/public/css/notifications.css +48 -17
- package/dist/web/public/css/onboard.css +107 -0
- package/dist/web/public/index.html +90 -18
- package/dist/web/public/js/api.js +3 -6
- package/dist/web/public/js/flights/flights.js +127 -0
- package/dist/web/public/js/modal/index.js +58 -0
- package/dist/web/public/js/modal/installHandler.js +227 -0
- package/dist/web/public/js/modal/installModal.js +163 -0
- package/dist/web/public/js/modal/installation.js +281 -0
- package/dist/web/public/js/modal/loadingModal.js +52 -0
- package/dist/web/public/js/modal/loadingUI.js +74 -0
- package/dist/web/public/js/modal/messageQueue.js +112 -0
- package/dist/web/public/js/modal/modalSetup.js +513 -0
- package/dist/web/public/js/modal/modalUI.js +214 -0
- package/dist/web/public/js/modal/modalUtils.js +49 -0
- package/dist/web/public/js/modal/version.js +20 -0
- package/dist/web/public/js/modal/versionUtils.js +20 -0
- package/dist/web/public/js/modal.js +25 -1041
- package/dist/web/public/js/notifications.js +66 -27
- package/dist/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +338 -0
- package/dist/web/public/js/onboard/formProcessor.js +864 -0
- package/dist/web/public/js/onboard/index.js +374 -0
- package/dist/web/public/js/onboard/publishHandler.js +132 -0
- package/dist/web/public/js/onboard/state.js +76 -0
- package/dist/web/public/js/onboard/templates.js +343 -0
- package/dist/web/public/js/onboard/uiHandlers.js +758 -0
- package/dist/web/public/js/onboard/validationHandlers.js +378 -0
- package/dist/web/public/js/serverCategoryDetails.js +43 -17
- package/dist/web/public/js/serverCategoryList.js +15 -2
- package/dist/web/public/onboard.html +296 -0
- package/dist/web/public/styles.css +91 -1
- package/dist/web/server.d.ts +0 -10
- package/dist/web/server.js +131 -22
- package/package.json +2 -2
- package/src/core/ConfigurationProvider.ts +15 -0
- package/src/core/InstallationService.ts +2 -7
- package/src/core/MCPManager.ts +26 -1
- package/src/core/RequirementService.ts +2 -9
- package/src/core/installers/clients/BaseClientInstaller.ts +196 -0
- package/src/core/installers/clients/ClientInstaller.ts +97 -589
- package/src/core/installers/clients/ClientInstallerFactory.ts +46 -0
- package/src/core/installers/clients/ClineInstaller.ts +135 -0
- package/src/core/installers/clients/GithubCopilotInstaller.ts +179 -0
- package/src/core/installers/clients/MSRooCodeInstaller.ts +133 -0
- package/src/core/installers/requirements/BaseInstaller.ts +13 -136
- package/src/core/installers/requirements/CommandInstaller.ts +9 -1
- package/src/core/installers/requirements/GeneralInstaller.ts +11 -4
- package/src/core/installers/requirements/NpmInstaller.ts +178 -61
- package/src/core/installers/requirements/PipInstaller.ts +68 -29
- package/src/core/onboard/FeedOnboardService.ts +346 -0
- package/src/core/onboard/OnboardProcessor.ts +305 -0
- package/src/core/onboard/OnboardStatus.ts +55 -0
- package/src/core/onboard/OnboardStatusManager.ts +188 -0
- package/src/core/types.ts +6 -6
- package/src/core/validators/FeedValidator.ts +79 -0
- package/src/core/validators/IServerValidator.ts +21 -0
- package/src/core/validators/SSEServerValidator.ts +43 -0
- package/src/core/validators/ServerValidatorFactory.ts +51 -0
- package/src/core/validators/StdioServerValidator.ts +259 -0
- package/src/services/InstallRequestValidator.ts +1 -1
- package/src/services/ServerService.ts +22 -7
- package/src/utils/adoUtils.ts +291 -0
- package/src/utils/clientUtils.ts +0 -44
- package/src/utils/githubUtils.ts +24 -0
- package/src/utils/macroExpressionUtils.ts +121 -0
- package/src/utils/osUtils.ts +89 -24
- package/src/web/contract/serverContract.ts +74 -0
- package/src/web/public/css/notifications.css +48 -17
- package/src/web/public/css/onboard.css +107 -0
- package/src/web/public/index.html +90 -18
- package/src/web/public/js/api.js +3 -6
- package/src/web/public/js/flights/flights.js +127 -0
- package/src/web/public/js/modal/index.js +58 -0
- package/src/web/public/js/modal/installModal.js +163 -0
- package/src/web/public/js/modal/installation.js +281 -0
- package/src/web/public/js/modal/loadingModal.js +52 -0
- package/src/web/public/js/modal/messageQueue.js +112 -0
- package/src/web/public/js/modal/modalSetup.js +513 -0
- package/src/web/public/js/modal/modalUtils.js +49 -0
- package/src/web/public/js/modal/versionUtils.js +20 -0
- package/src/web/public/js/modal.js +25 -1041
- package/src/web/public/js/notifications.js +66 -27
- package/src/web/public/js/onboard/ONBOARDING_PAGE_DESIGN.md +338 -0
- package/src/web/public/js/onboard/formProcessor.js +864 -0
- package/src/web/public/js/onboard/index.js +374 -0
- package/src/web/public/js/onboard/publishHandler.js +132 -0
- package/src/web/public/js/onboard/state.js +76 -0
- package/src/web/public/js/onboard/templates.js +343 -0
- package/src/web/public/js/onboard/uiHandlers.js +758 -0
- package/src/web/public/js/onboard/validationHandlers.js +378 -0
- package/src/web/public/js/serverCategoryDetails.js +43 -17
- package/src/web/public/js/serverCategoryList.js +15 -2
- package/src/web/public/onboard.html +296 -0
- package/src/web/public/styles.css +91 -1
- package/src/web/server.ts +167 -58
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// HTML templates for onboarding form
|
|
2
|
+
// Global requirementTemplate is removed as requirements are now server-specific.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generates HTML for a server item.
|
|
6
|
+
* @param {number} serverIndex - The index of the server.
|
|
7
|
+
* @param {boolean} [isReadOnly=false] - If true, renders the server item as read-only.
|
|
8
|
+
* @param {object|null} [serverData=null] - Pre-existing server data (currently not used for pre-filling in template, handled by populateForm).
|
|
9
|
+
* @param {string} [serversListId='serversList'] - The ID of the servers list container this server belongs to.
|
|
10
|
+
* @returns {string} HTML string for the server item.
|
|
11
|
+
*/
|
|
12
|
+
export const serverTemplate = (serverIndex, isReadOnly = false, serverData = null, serversListId = 'serversList') => {
|
|
13
|
+
const disabledAttr = isReadOnly ? 'disabled' : '';
|
|
14
|
+
const readOnlyClasses = isReadOnly ? 'bg-gray-100 cursor-not-allowed opacity-70' : '';
|
|
15
|
+
const hideButtonClass = isReadOnly ? 'hidden' : ''; // Class to hide buttons
|
|
16
|
+
|
|
17
|
+
// Determine which serversListId this server belongs to by checking the active tab's form
|
|
18
|
+
// This is a bit of a hack; ideally, addServer in uiHandlers would pass this.
|
|
19
|
+
// For now, assume 'serversList' or 'existingCategoryServersList' based on context where addServer is called.
|
|
20
|
+
// The onclick handlers for removeServer, addServerRequirement, addEnvVariable will need to be updated
|
|
21
|
+
// in uiHandlers.js to correctly pass the serversListId if they are to be generic.
|
|
22
|
+
// For now, the template will use the serverIndex, and the global functions will need to know the context.
|
|
23
|
+
// Let's assume the global functions are called with context from index.js or uiHandlers.js.
|
|
24
|
+
// The onclicks in the template will call the global functions which are now context-aware.
|
|
25
|
+
// e.g. onclick="removeServer(${serverIndex}, 'serversList')" - this needs to be dynamic.
|
|
26
|
+
// For simplicity, let's assume the global functions in uiHandlers.js will determine the active list.
|
|
27
|
+
// Or, the functions like removeServer are already modified to accept serversListId.
|
|
28
|
+
// The `addServer` in `uiHandlers.js` is called with `serversListId`.
|
|
29
|
+
// The buttons here call global functions. These global functions (removeServer, addEnvVariable, etc.)
|
|
30
|
+
// will need to be aware of the active serversListId.
|
|
31
|
+
// This can be done by having uiHandlers.js set a global 'activeServersListId' or by modifying
|
|
32
|
+
// each function to accept it and ensuring the HTML onclicks pass it.
|
|
33
|
+
// The latter is cleaner. The `onclick` in HTML should be `removeServer(${serverIndex}, 'CURRENT_LIST_ID')`.
|
|
34
|
+
// This means `uiHandlers.addServer` needs to inject the correct `serversListId` into these onclicks.
|
|
35
|
+
|
|
36
|
+
// For now, let's keep the onclicks simple and assume uiHandlers.js functions will manage context.
|
|
37
|
+
// The `action-button-in-server` class is added to buttons that should be hidden in read-only mode.
|
|
38
|
+
|
|
39
|
+
return `
|
|
40
|
+
<div class="server-item p-4 border border-gray-300 rounded-lg mb-6 bg-white shadow" data-index="${serverIndex}">
|
|
41
|
+
<div id="${serversListId}-server-header-${serverIndex}" class="server-header-toggle flex justify-between items-center mb-3 cursor-pointer"
|
|
42
|
+
role="button" tabindex="0"
|
|
43
|
+
aria-expanded="false" aria-controls="${serversListId}-server-content-${serverIndex}"
|
|
44
|
+
onclick="window.toggleSectionContent('${serversListId}-server-content-${serverIndex}', this.querySelector('i.toggle-icon'), this)"
|
|
45
|
+
onkeydown="if(event.key==='Enter' || event.key===' ') { window.toggleSectionContent('${serversListId}-server-content-${serverIndex}', this.querySelector('i.toggle-icon'), this); event.preventDefault(); }">
|
|
46
|
+
<h3 id="${serversListId}-server-title-${serverIndex}" class="text-lg font-semibold text-gray-800">MCP Server #${serverIndex + 1} ${isReadOnly ? '(Read-only)' : ''}</h3>
|
|
47
|
+
<div class="flex items-center">
|
|
48
|
+
<button type="button" onclick="event.stopPropagation(); removeServer(${serverIndex}, '${serversListId}')"
|
|
49
|
+
class="action-button-in-server p-1.5 text-sm text-red-600 hover:text-red-800 hover:bg-red-50 rounded-md flex items-center mr-2 ${hideButtonClass}" title="Remove Server">
|
|
50
|
+
<i class='bx bx-trash text-lg'></i>
|
|
51
|
+
</button>
|
|
52
|
+
<i class='bx bxs-chevron-down text-xl toggle-icon'></i>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div id="${serversListId}-server-content-${serverIndex}" class="collapsible-content server-content-scrollable hidden" role="region" aria-labelledby="${serversListId}-server-title-${serverIndex}">
|
|
56
|
+
|
|
57
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
58
|
+
<div>
|
|
59
|
+
<label class="block text-sm font-medium text-gray-700 mb-1">Server Name*</label>
|
|
60
|
+
<input type="text" name="servers[${serverIndex}].name" required ${disabledAttr}
|
|
61
|
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
62
|
+
placeholder="e.g., ado-tools-server">
|
|
63
|
+
</div>
|
|
64
|
+
<div>
|
|
65
|
+
<label class="block text-sm font-medium text-gray-700 mb-1">Mode*</label>
|
|
66
|
+
<select name="servers[${serverIndex}].mode" required ${disabledAttr}
|
|
67
|
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}">
|
|
68
|
+
<option value="stdio">stdio</option>
|
|
69
|
+
<option value="sse">sse</option>
|
|
70
|
+
</select>
|
|
71
|
+
</div>
|
|
72
|
+
<div class="md:col-span-2">
|
|
73
|
+
<label class="block text-sm font-medium text-gray-700 mb-1">Description*</label>
|
|
74
|
+
<textarea name="servers[${serverIndex}].description" required rows="3" ${disabledAttr}
|
|
75
|
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
76
|
+
placeholder="Detailed description of the server's capabilities"></textarea>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="md:col-span-2 flex gap-x-4 items-end">
|
|
79
|
+
<div class="flex-grow">
|
|
80
|
+
<label class="block text-sm font-medium text-gray-700 mb-1">Schema File Path</label>
|
|
81
|
+
<input type="text" name="servers[${serverIndex}].schemas" id="schema-path-${serverIndex}" ${disabledAttr}
|
|
82
|
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
83
|
+
placeholder="e.g., ./schemas/my_server_schema.json">
|
|
84
|
+
</div>
|
|
85
|
+
<button type="button" onclick="browseLocalSchema(${serverIndex}, '${serversListId}')" ${disabledAttr}
|
|
86
|
+
class="action-button-in-server px-4 py-2 text-sm bg-gray-100 hover:bg-gray-200 border border-gray-300 rounded-lg whitespace-nowrap ${hideButtonClass} ${isReadOnly ? 'opacity-50 cursor-not-allowed' : ''}">
|
|
87
|
+
Browse Local
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="md:col-span-2">
|
|
91
|
+
<label class="block text-sm font-medium text-gray-700 mb-1">Repository URL</label>
|
|
92
|
+
<input type="url" name="servers[${serverIndex}].repository" ${disabledAttr}
|
|
93
|
+
class="w-full px-3 py-2 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
94
|
+
placeholder="e.g., https://github.com/org/repo">
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<!-- Package Dependencies -->
|
|
99
|
+
<div class="mt-4 p-3 bg-gray-50 rounded-lg border border-gray-200">
|
|
100
|
+
<h4 id="${serversListId}-deps-header-${serverIndex}" class="text-md font-semibold text-gray-700 mb-2 flex justify-between items-center cursor-pointer"
|
|
101
|
+
role="button" tabindex="0"
|
|
102
|
+
aria-expanded="false" aria-controls="${serversListId}-server-deps-content-${serverIndex}"
|
|
103
|
+
onclick="window.toggleSectionContent('${serversListId}-server-deps-content-${serverIndex}', this.querySelector('i'), this)"
|
|
104
|
+
onkeydown="if(event.key==='Enter' || event.key===' ') { window.toggleSectionContent('${serversListId}-server-deps-content-${serverIndex}', this.querySelector('i'), this); event.preventDefault(); }">
|
|
105
|
+
<span>Package Dependencies</span>
|
|
106
|
+
<i class='bx bxs-chevron-down text-xl'></i>
|
|
107
|
+
</h4>
|
|
108
|
+
<div id="${serversListId}-server-deps-content-${serverIndex}" class="collapsible-content mt-2 hidden" role="region" aria-labelledby="${serversListId}-deps-header-${serverIndex}">
|
|
109
|
+
<div id="server-requirements-list-${serverIndex}" class="space-y-4">
|
|
110
|
+
<!-- Server requirements will be populated here by serverRequirementTemplate -->
|
|
111
|
+
</div>
|
|
112
|
+
<button type="button" onclick="addServerRequirement(${serverIndex}, '${serversListId}', ${isReadOnly})"
|
|
113
|
+
class="action-button-in-server mt-3 px-3 py-1.5 text-sm border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 flex items-center ${hideButtonClass}">
|
|
114
|
+
<i class='bx bx-plus mr-1'></i> Add Dependency
|
|
115
|
+
</button>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<!-- Startup Configuration -->
|
|
120
|
+
<div class="mt-4 p-3 bg-gray-50 rounded-lg border border-gray-200">
|
|
121
|
+
<h4 id="${serversListId}-startup-header-${serverIndex}" class="text-md font-semibold text-gray-700 mb-2 flex justify-between items-center cursor-pointer"
|
|
122
|
+
role="button" tabindex="0"
|
|
123
|
+
aria-expanded="false" aria-controls="${serversListId}-installation-content-${serverIndex}"
|
|
124
|
+
onclick="window.toggleSectionContent('${serversListId}-installation-content-${serverIndex}', this.querySelector('i'), this)"
|
|
125
|
+
onkeydown="if(event.key==='Enter' || event.key===' ') { window.toggleSectionContent('${serversListId}-installation-content-${serverIndex}', this.querySelector('i'), this); event.preventDefault(); }">
|
|
126
|
+
<span>Startup Configuration</span>
|
|
127
|
+
<i class='bx bxs-chevron-down text-xl'></i>
|
|
128
|
+
</h4>
|
|
129
|
+
<div id="${serversListId}-installation-content-${serverIndex}" class="collapsible-content mt-2 hidden" role="region" aria-labelledby="${serversListId}-startup-header-${serverIndex}">
|
|
130
|
+
<div id="installation-config-${serverIndex}">
|
|
131
|
+
<!-- Installation fields will be rendered here based on mode by renderInstallationConfig -->
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<!-- Environment Variables -->
|
|
137
|
+
<div class="mt-4 p-3 bg-gray-50 rounded-lg border border-gray-200" id="env-vars-block-${serverIndex}">
|
|
138
|
+
<h4 id="${serversListId}-envars-header-${serverIndex}" class="text-md font-semibold text-gray-700 mb-2 flex justify-between items-center cursor-pointer"
|
|
139
|
+
role="button" tabindex="0"
|
|
140
|
+
aria-expanded="false" aria-controls="${serversListId}-env-vars-content-${serverIndex}"
|
|
141
|
+
onclick="window.toggleSectionContent('${serversListId}-env-vars-content-${serverIndex}', this.querySelector('i'), this)"
|
|
142
|
+
onkeydown="if(event.key==='Enter' || event.key===' ') { window.toggleSectionContent('${serversListId}-env-vars-content-${serverIndex}', this.querySelector('i'), this); event.preventDefault(); }">
|
|
143
|
+
<span>Environment Variables</span>
|
|
144
|
+
<i class='bx bxs-chevron-down text-xl'></i>
|
|
145
|
+
</h4>
|
|
146
|
+
<div id="${serversListId}-env-vars-content-${serverIndex}" class="collapsible-content mt-2 hidden" role="region" aria-labelledby="${serversListId}-envars-header-${serverIndex}">
|
|
147
|
+
<div id="envVarsContainer_${serverIndex}" class="space-y-3">
|
|
148
|
+
<!-- Environment variables will be added here by envVariableTemplate -->
|
|
149
|
+
</div>
|
|
150
|
+
<button type="button" onclick="addEnvVariable(${serverIndex}, '${serversListId}', ${isReadOnly})"
|
|
151
|
+
class="action-button-in-server mt-3 px-3 py-1.5 text-sm border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-100 flex items-center ${hideButtonClass}">
|
|
152
|
+
<i class='bx bx-plus mr-1'></i> Add Environment Variable
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</div><!-- Closing server-content-${serverIndex} -->
|
|
157
|
+
</div>
|
|
158
|
+
`;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Generates HTML for an environment variable item.
|
|
163
|
+
* @param {number} serverIndex - The index of the server.
|
|
164
|
+
* @param {number} envIndex - The index of the environment variable.
|
|
165
|
+
* @param {boolean} [isReadOnly=false] - If true, renders the item as read-only.
|
|
166
|
+
* @param {string} [serversListId='serversList'] - The ID of the servers list container.
|
|
167
|
+
* @returns {string} HTML string for the environment variable item.
|
|
168
|
+
*/
|
|
169
|
+
export const envVariableTemplate = (serverIndex, envIndex, isReadOnly = false, serversListId = 'serversList') => {
|
|
170
|
+
const disabledAttr = isReadOnly ? 'disabled' : '';
|
|
171
|
+
const readOnlyClasses = isReadOnly ? 'bg-gray-100 cursor-not-allowed opacity-70' : '';
|
|
172
|
+
const hideButtonClass = isReadOnly ? 'hidden' : '';
|
|
173
|
+
|
|
174
|
+
return `
|
|
175
|
+
<div class="env-var-item grid grid-cols-1 gap-2" data-env-index="${envIndex}">
|
|
176
|
+
<div class="grid grid-cols-3 gap-2 items-end">
|
|
177
|
+
<div>
|
|
178
|
+
<label class="block text-sm font-medium text-gray-700">Name*</label>
|
|
179
|
+
<input type="text" name="servers[${serverIndex}].installation.env[${envIndex}].name" required ${disabledAttr}
|
|
180
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
181
|
+
placeholder="ENV_VAR_NAME">
|
|
182
|
+
</div>
|
|
183
|
+
<div>
|
|
184
|
+
<label class="block text-sm font-medium text-gray-700">Default Value</label>
|
|
185
|
+
<input type="text" name="servers[${serverIndex}].installation.env[${envIndex}].default" ${disabledAttr}
|
|
186
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
187
|
+
placeholder="Default value">
|
|
188
|
+
</div>
|
|
189
|
+
<div class="flex items-center gap-2">
|
|
190
|
+
<label class="inline-flex items-center text-sm">
|
|
191
|
+
<input type="checkbox" name="servers[${serverIndex}].installation.env[${envIndex}].required" ${disabledAttr}
|
|
192
|
+
class="text-blue-600 focus:ring-blue-500 ${isReadOnly ? 'opacity-70 cursor-not-allowed' : ''}">
|
|
193
|
+
<span class="ml-1 ${isReadOnly ? 'text-gray-500' : ''}">Required</span>
|
|
194
|
+
</label>
|
|
195
|
+
<button type="button" onclick="removeEnvVariable(${serverIndex}, ${envIndex}, '${serversListId}')"
|
|
196
|
+
class="action-button-in-env px-2 py-1 text-red-600 hover:text-red-800 ${hideButtonClass}">
|
|
197
|
+
<i class='bx bx-trash'></i>
|
|
198
|
+
</button>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
<div>
|
|
202
|
+
<label class="block text-sm font-medium text-gray-700">Description</label>
|
|
203
|
+
<textarea name="servers[${serverIndex}].installation.env[${envIndex}].description" rows="2" ${disabledAttr}
|
|
204
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
205
|
+
placeholder="Environment variable description"></textarea>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
`;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Generates HTML for a server requirement item.
|
|
213
|
+
* @param {number} serverIndex - The index of the server.
|
|
214
|
+
* @param {number} reqIndex - The index of the requirement.
|
|
215
|
+
* @param {boolean} [isReadOnly=false] - If true, renders the item as read-only.
|
|
216
|
+
* @param {string} [serversListId='serversList'] - The ID of the servers list container.
|
|
217
|
+
* @returns {string} HTML string for the server requirement item.
|
|
218
|
+
*/
|
|
219
|
+
export const serverRequirementTemplate = (serverIndex, reqIndex, isReadOnly = false, serversListId = 'serversList') => {
|
|
220
|
+
const disabledAttr = isReadOnly ? 'disabled' : '';
|
|
221
|
+
const readOnlyClasses = isReadOnly ? 'bg-gray-100 cursor-not-allowed opacity-70' : '';
|
|
222
|
+
const hideButtonClass = isReadOnly ? 'hidden' : '';
|
|
223
|
+
|
|
224
|
+
return `
|
|
225
|
+
<div class="server-requirement-item p-3 border border-gray-200 rounded-lg mb-3" data-req-index="${reqIndex}">
|
|
226
|
+
<div class="grid grid-cols-2 gap-3">
|
|
227
|
+
<div>
|
|
228
|
+
<label class="block text-sm font-medium text-gray-700">Name*</label>
|
|
229
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].name" required ${disabledAttr}
|
|
230
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
231
|
+
placeholder="Package or command name">
|
|
232
|
+
</div>
|
|
233
|
+
<div>
|
|
234
|
+
<label class="block text-sm font-medium text-gray-700">Type*</label>
|
|
235
|
+
<select name="servers[${serverIndex}].requirements[${reqIndex}].type" required onchange="toggleServerAliasField(${serverIndex}, ${reqIndex}, '${serversListId}')" ${disabledAttr}
|
|
236
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}">
|
|
237
|
+
<option value="">Select Type</option>
|
|
238
|
+
<option value="npm">NPM Package</option>
|
|
239
|
+
<option value="pip">PIP Package</option>
|
|
240
|
+
<option value="command">Command</option>
|
|
241
|
+
</select>
|
|
242
|
+
</div>
|
|
243
|
+
<div>
|
|
244
|
+
<label class="block text-sm font-medium text-gray-700">Version*</label>
|
|
245
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].version" required ${disabledAttr}
|
|
246
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
247
|
+
placeholder="e.g., latest, v\${latest}, 1.0.0">
|
|
248
|
+
</div>
|
|
249
|
+
<div>
|
|
250
|
+
<label class="block text-sm font-medium text-gray-700">Order</label>
|
|
251
|
+
<input type="number" name="servers[${serverIndex}].requirements[${reqIndex}].order" min="0" ${disabledAttr}
|
|
252
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
253
|
+
placeholder="Installation order">
|
|
254
|
+
</div>
|
|
255
|
+
<div id="server-alias-field-${serverIndex}-${reqIndex}" class="hidden">
|
|
256
|
+
<label class="block text-sm font-medium text-gray-700">Alias</label>
|
|
257
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].alias" ${disabledAttr}
|
|
258
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
259
|
+
placeholder="Command alias">
|
|
260
|
+
</div>
|
|
261
|
+
<div class="col-span-2">
|
|
262
|
+
<label class="block text-sm font-medium text-gray-700">Registry*</label>
|
|
263
|
+
<select name="servers[${serverIndex}].requirements[${reqIndex}].registryType" onchange="toggleServerRegistryConfig(${serverIndex}, ${reqIndex}, '${serversListId}')" ${disabledAttr}
|
|
264
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}" required>
|
|
265
|
+
<option value="public" selected>Public Registry</option>
|
|
266
|
+
<option value="github">GitHub Release</option>
|
|
267
|
+
<option value="artifacts">Private Artifacts</option>
|
|
268
|
+
</select>
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
<div id="server-registry-config-${serverIndex}-${reqIndex}" class="col-span-2 registry-configs">
|
|
272
|
+
<!-- GitHub Registry Config -->
|
|
273
|
+
<div id="server-github-config-${serverIndex}-${reqIndex}" class="registry-config mt-3 p-2 bg-gray-50 rounded-lg hidden">
|
|
274
|
+
<h3 class="text-sm font-medium text-gray-900 mb-2">GitHub Registry Details</h3>
|
|
275
|
+
<div class="grid grid-cols-1 gap-3">
|
|
276
|
+
<div>
|
|
277
|
+
<label class="block text-sm font-medium text-gray-700">Repository*</label>
|
|
278
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.githubRelease.repository" ${disabledAttr}
|
|
279
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
280
|
+
placeholder="org/repo">
|
|
281
|
+
</div>
|
|
282
|
+
<div>
|
|
283
|
+
<label class="block text-sm font-medium text-gray-700">Assets Name Pattern</label>
|
|
284
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.githubRelease.assetsName" ${disabledAttr}
|
|
285
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
286
|
+
placeholder="package-\${latest}.zip (e.g. for multiple assets)">
|
|
287
|
+
</div>
|
|
288
|
+
<div>
|
|
289
|
+
<label class="block text-sm font-medium text-gray-700">Asset Name Pattern*</label>
|
|
290
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.githubRelease.assetName" ${disabledAttr}
|
|
291
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
292
|
+
placeholder="package-\${latest}.tgz (specific asset)">
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
|
|
297
|
+
<!-- Artifacts Registry Config -->
|
|
298
|
+
<div id="server-artifacts-config-${serverIndex}-${reqIndex}" class="registry-config mt-3 p-2 bg-gray-50 rounded-lg hidden">
|
|
299
|
+
<h3 class="text-sm font-medium text-gray-900 mb-2">Private Artifacts Registry Details</h3>
|
|
300
|
+
<div class="grid grid-cols-1 gap-3">
|
|
301
|
+
<div>
|
|
302
|
+
<label class="block text-sm font-medium text-gray-700">Registry Name*</label>
|
|
303
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.artifacts.registryName" ${disabledAttr}
|
|
304
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
305
|
+
placeholder="My-Artifacts-Registry">
|
|
306
|
+
</div>
|
|
307
|
+
<div>
|
|
308
|
+
<label class="block text-sm font-medium text-gray-700">Registry URL*</label>
|
|
309
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.artifacts.registryUrl" ${disabledAttr}
|
|
310
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
311
|
+
placeholder="https://artifacts.example.com">
|
|
312
|
+
</div>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<!-- Local Registry Config -->
|
|
317
|
+
<div id="server-local-config-${serverIndex}-${reqIndex}" class="registry-config mt-3 p-2 bg-gray-50 rounded-lg hidden">
|
|
318
|
+
<h3 class="text-sm font-medium text-gray-900 mb-2">Local Path Details</h3>
|
|
319
|
+
<div class="grid grid-cols-1 gap-3">
|
|
320
|
+
<div>
|
|
321
|
+
<label class="block text-sm font-medium text-gray-700">Local Path*</label>
|
|
322
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.local.localPath" ${disabledAttr}
|
|
323
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
324
|
+
placeholder="/path/to/local/registry_or_file">
|
|
325
|
+
</div>
|
|
326
|
+
<div>
|
|
327
|
+
<label class="block text-sm font-medium text-gray-700">Asset Name Pattern</label>
|
|
328
|
+
<input type="text" name="servers[${serverIndex}].requirements[${reqIndex}].registry.local.assetName" ${disabledAttr}
|
|
329
|
+
class="w-full px-2 py-1.5 text-sm border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${readOnlyClasses}"
|
|
330
|
+
placeholder="package-\${latest}.tgz (if localPath is a dir)">
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
</div>
|
|
336
|
+
<button type="button" onclick="removeServerRequirement(${serverIndex}, ${reqIndex}, '${serversListId}')"
|
|
337
|
+
class="action-button-in-req mt-2 px-2 py-1 text-red-600 hover:text-red-800 flex items-center text-sm ${hideButtonClass}">
|
|
338
|
+
<i class='bx bx-trash mr-1'></i>
|
|
339
|
+
Remove
|
|
340
|
+
</button>
|
|
341
|
+
</div>
|
|
342
|
+
`;
|
|
343
|
+
};
|