100 lines
3.1 KiB
JavaScript
100 lines
3.1 KiB
JavaScript
// frontend/static/js/workdir_config.js
|
|
|
|
async function getWorkDirConfig() {
|
|
if (!currentProfile?.work_dir) {
|
|
showError('No work directory selected');
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
return await apiRequest(`/workdir-config/${encodeURIComponent(currentProfile.work_dir)}`);
|
|
} catch (error) {
|
|
showError('Failed to load work directory configuration');
|
|
return null;
|
|
}
|
|
}
|
|
|
|
async function getGroupConfig(groupId) {
|
|
if (!currentProfile?.work_dir) {
|
|
showError('No work directory selected');
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
return await apiRequest(
|
|
`/workdir-config/${encodeURIComponent(currentProfile.work_dir)}/group/${groupId}`
|
|
);
|
|
} catch (error) {
|
|
showError('Failed to load group configuration');
|
|
return null;
|
|
}
|
|
}
|
|
|
|
async function updateGroupConfig(groupId, settings) {
|
|
if (!currentProfile?.work_dir) {
|
|
showError('No work directory selected');
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
await apiRequest(
|
|
`/workdir-config/${encodeURIComponent(currentProfile.work_dir)}/group/${groupId}`,
|
|
{
|
|
method: 'PUT',
|
|
body: JSON.stringify(settings)
|
|
}
|
|
);
|
|
showSuccess('Group configuration updated successfully');
|
|
return true;
|
|
} catch (error) {
|
|
showError('Failed to update group configuration');
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// static/js/workdir_config.js
|
|
async function showWorkDirConfig() {
|
|
if (!currentProfile?.work_dir) {
|
|
showError('No work directory selected');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const config = await getWorkDirConfig();
|
|
|
|
const content = `
|
|
<div class="space-y-4">
|
|
<div>
|
|
<h4 class="text-sm font-medium text-gray-900">Directory</h4>
|
|
<p class="mt-1 text-sm text-gray-500">${currentProfile.work_dir}</p>
|
|
</div>
|
|
<div>
|
|
<h4 class="text-sm font-medium text-gray-900">Version</h4>
|
|
<p class="mt-1 text-sm text-gray-500">${config.version}</p>
|
|
</div>
|
|
<div>
|
|
<h4 class="text-sm font-medium text-gray-900">Group Configurations</h4>
|
|
<div class="mt-2 space-y-3">
|
|
${Object.entries(config.group_settings || {}).map(([groupId, settings]) => `
|
|
<div class="rounded-md bg-gray-50 p-3">
|
|
<h5 class="text-sm font-medium text-gray-900">${groupId}</h5>
|
|
<pre class="mt-2 text-xs text-gray-500">${JSON.stringify(settings, null, 2)}</pre>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
createModal('Work Directory Configuration', content);
|
|
} catch (error) {
|
|
showError('Failed to load work directory configuration');
|
|
}
|
|
}
|
|
|
|
function closeModal(button) {
|
|
const modal = button.closest('.modal');
|
|
if (modal) {
|
|
modal.remove();
|
|
}
|
|
} |