99 lines
3.0 KiB
JavaScript
99 lines
3.0 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;
|
|
}
|
|
}
|
|
|
|
async function showWorkDirConfig() {
|
|
if (!currentProfile?.work_dir) {
|
|
showError('No work directory selected');
|
|
return;
|
|
}
|
|
|
|
const config = await getWorkDirConfig();
|
|
if (config) {
|
|
const modal = document.createElement('div');
|
|
modal.className = 'modal active';
|
|
|
|
modal.innerHTML = `
|
|
<div class="modal-content">
|
|
<h2>Work Directory Configuration</h2>
|
|
<div class="config-info">
|
|
<p><strong>Directory:</strong> ${currentProfile.work_dir}</p>
|
|
<p><strong>Version:</strong> ${config.version}</p>
|
|
<p><strong>Created:</strong> ${new Date(config.created_at).toLocaleString()}</p>
|
|
<p><strong>Updated:</strong> ${new Date(config.updated_at).toLocaleString()}</p>
|
|
</div>
|
|
<div class="group-configs">
|
|
<h3>Group Configurations</h3>
|
|
${Object.entries(config.group_settings || {}).map(([groupId, settings]) => `
|
|
<div class="group-config">
|
|
<h4>${groupId}</h4>
|
|
<pre>${JSON.stringify(settings, null, 2)}</pre>
|
|
</div>
|
|
`).join('')}
|
|
</div>
|
|
<div class="button-group">
|
|
<button onclick="closeModal(this)">Close</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
document.body.appendChild(modal);
|
|
}
|
|
}
|
|
|
|
function closeModal(button) {
|
|
const modal = button.closest('.modal');
|
|
if (modal) {
|
|
modal.remove();
|
|
}
|
|
} |