2025-02-07 19:08:39 -03:00
|
|
|
// frontend/static/js/scripts.js
|
|
|
|
|
|
|
|
async function loadScriptGroups() {
|
|
|
|
try {
|
2025-02-07 19:35:59 -03:00
|
|
|
const groups = await apiRequest('/script-groups');
|
|
|
|
const select = document.getElementById('groupSelect');
|
2025-02-08 11:23:14 -03:00
|
|
|
const lastGroupId = localStorage.getItem('lastGroupId');
|
2025-02-08 15:17:08 -03:00
|
|
|
|
2025-02-08 11:23:14 -03:00
|
|
|
// Remover event listener anterior si existe
|
2025-02-08 15:17:08 -03:00
|
|
|
const oldHandler = select.onchange;
|
|
|
|
if (oldHandler) {
|
|
|
|
select.removeEventListener('change', oldHandler);
|
|
|
|
}
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
// Actualizar opciones
|
2025-02-07 19:35:59 -03:00
|
|
|
select.innerHTML = `
|
2025-02-08 15:17:08 -03:00
|
|
|
<option value="">Select group...</option>
|
2025-02-07 19:35:59 -03:00
|
|
|
${groups.map(group => `
|
2025-02-08 11:23:14 -03:00
|
|
|
<option value="${group.id}" ${group.id === lastGroupId ? 'selected' : ''}>
|
|
|
|
${group.name}
|
|
|
|
</option>
|
2025-02-07 19:35:59 -03:00
|
|
|
`).join('')}
|
|
|
|
`;
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
// Agregar nuevo event listener
|
2025-02-08 11:23:14 -03:00
|
|
|
select.addEventListener('change', handleGroupChange);
|
|
|
|
|
|
|
|
// Si hay un grupo guardado, cargarlo
|
2025-02-08 15:17:08 -03:00
|
|
|
if (lastGroupId && groups.some(g => g.id === lastGroupId)) {
|
|
|
|
await selectGroup(lastGroupId);
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
2025-02-07 19:08:39 -03:00
|
|
|
} catch (error) {
|
2025-02-08 15:17:08 -03:00
|
|
|
console.error('Error loading script groups:', error);
|
|
|
|
showError('Error loading script groups');
|
2025-02-07 19:08:39 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 11:23:14 -03:00
|
|
|
async function handleGroupChange(event) {
|
|
|
|
const groupId = event.target.value;
|
|
|
|
if (groupId) {
|
|
|
|
localStorage.setItem('lastGroupId', groupId);
|
2025-02-08 15:17:08 -03:00
|
|
|
await selectGroup(groupId);
|
2025-02-08 11:23:14 -03:00
|
|
|
} else {
|
|
|
|
localStorage.removeItem('lastGroupId');
|
2025-02-08 15:17:08 -03:00
|
|
|
updateGroupDisplay(null);
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
async function selectGroup(groupId) {
|
|
|
|
try {
|
|
|
|
// Cargar configuración del grupo
|
|
|
|
const config = await apiRequest(`/script-groups/${groupId}/config`);
|
|
|
|
currentGroup = { id: groupId, ...config };
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
// Actualizar displays
|
|
|
|
updateGroupDisplay(currentGroup);
|
|
|
|
|
|
|
|
// Cargar scripts si hay un directorio de trabajo configurado
|
|
|
|
if (currentGroup.work_dir) {
|
|
|
|
await loadGroupScripts(groupId);
|
|
|
|
// Cargar configuración del directorio de trabajo
|
|
|
|
const workDirConfig = await apiRequest(`/workdir-config/${groupId}`);
|
|
|
|
updateWorkDirConfig(workDirConfig);
|
|
|
|
} else {
|
|
|
|
document.getElementById('scriptList').innerHTML = `
|
|
|
|
<div class="bg-yellow-50 border-l-4 border-yellow-400 p-4">
|
|
|
|
<div class="flex">
|
|
|
|
<div class="ml-3">
|
|
|
|
<p class="text-sm text-yellow-700">
|
|
|
|
Please configure a work directory for this group first
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
2025-02-08 15:17:08 -03:00
|
|
|
} catch (error) {
|
|
|
|
console.error('Error selecting group:', error);
|
|
|
|
showError('Error loading group configuration');
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-07 19:35:59 -03:00
|
|
|
async function loadGroupScripts(groupId) {
|
2025-02-08 15:17:08 -03:00
|
|
|
if (!currentGroup?.work_dir) {
|
2025-02-08 11:23:14 -03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-02-07 19:35:59 -03:00
|
|
|
try {
|
2025-02-08 15:17:08 -03:00
|
|
|
// Cargar scripts y esquema
|
|
|
|
const [scripts, schema] = await Promise.all([
|
|
|
|
apiRequest(`/script-groups/${groupId}/scripts`),
|
|
|
|
apiRequest(`/script-groups/${groupId}/schema`)
|
|
|
|
]);
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
const scriptList = document.getElementById('scriptList');
|
2025-02-08 11:23:14 -03:00
|
|
|
scriptList.innerHTML = `
|
|
|
|
<div class="space-y-4">
|
2025-02-08 15:17:08 -03:00
|
|
|
${scripts.map(script => `
|
|
|
|
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
|
|
|
|
<div class="px-4 py-5 sm:p-6">
|
|
|
|
<div class="flex justify-between items-start">
|
|
|
|
<div>
|
|
|
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
|
|
|
${script.name}
|
|
|
|
</h3>
|
|
|
|
<p class="mt-1 max-w-2xl text-sm text-gray-500">
|
|
|
|
${script.description || 'No description available'}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<button onclick="runScript('${script.id}')"
|
|
|
|
class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
|
|
Run
|
|
|
|
</button>
|
2025-02-08 11:23:14 -03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`).join('')}
|
2025-02-08 15:17:08 -03:00
|
|
|
</div>
|
|
|
|
`;
|
2025-02-07 19:35:59 -03:00
|
|
|
} catch (error) {
|
2025-02-08 15:17:08 -03:00
|
|
|
console.error('Error loading group scripts:', error);
|
|
|
|
showError('Error loading scripts');
|
2025-02-07 19:35:59 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
async function runScript(scriptId) {
|
|
|
|
if (!currentGroup?.work_dir) {
|
|
|
|
showError('No work directory configured');
|
2025-02-07 19:08:39 -03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2025-02-08 15:17:08 -03:00
|
|
|
const result = await apiRequest(`/script-groups/${currentGroup.id}/scripts/${scriptId}/run`, {
|
2025-02-07 19:08:39 -03:00
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify({
|
2025-02-08 15:17:08 -03:00
|
|
|
work_dir: currentGroup.work_dir,
|
2025-02-07 19:08:39 -03:00
|
|
|
profile: currentProfile
|
|
|
|
})
|
|
|
|
});
|
2025-02-08 15:17:08 -03:00
|
|
|
|
|
|
|
if (result.error) {
|
2025-02-07 19:08:39 -03:00
|
|
|
showError(result.error);
|
|
|
|
} else {
|
2025-02-08 15:17:08 -03:00
|
|
|
showSuccess('Script executed successfully');
|
2025-02-07 19:08:39 -03:00
|
|
|
if (result.output) {
|
2025-02-08 15:17:08 -03:00
|
|
|
const outputArea = document.getElementById('outputArea');
|
|
|
|
const timestamp = new Date().toLocaleTimeString();
|
|
|
|
outputArea.innerHTML += `\n[${timestamp}] ${result.output}`;
|
|
|
|
outputArea.scrollTop = outputArea.scrollHeight;
|
2025-02-07 19:08:39 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (error) {
|
2025-02-08 15:17:08 -03:00
|
|
|
showError('Error executing script');
|
2025-02-07 19:08:39 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
async function editGroupConfig() {
|
|
|
|
if (!currentGroup) return;
|
2025-02-07 19:08:39 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
try {
|
|
|
|
const schema = await apiRequest(`/script-groups/${currentGroup.id}/schema`);
|
|
|
|
const content = `
|
|
|
|
<form id="groupConfigForm" class="space-y-4">
|
|
|
|
${Object.entries(schema.config_schema).map(([key, field]) => `
|
|
|
|
<div>
|
|
|
|
<label class="block text-sm font-medium text-gray-700">
|
|
|
|
${field.description || key}
|
|
|
|
</label>
|
|
|
|
${generateFormField(key, field, currentGroup[key])}
|
|
|
|
</div>
|
|
|
|
`).join('')}
|
2025-02-07 19:08:39 -03:00
|
|
|
</form>
|
2025-02-08 15:17:08 -03:00
|
|
|
`;
|
2025-02-07 19:08:39 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
const modal = createModal('Edit Group Configuration', content, true);
|
|
|
|
modal.querySelector('[onclick="saveModal(this)"]').onclick = () => saveGroupConfig(modal);
|
|
|
|
} catch (error) {
|
|
|
|
showError('Error loading group configuration');
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
async function saveGroupConfig(modal) {
|
|
|
|
if (!currentGroup) return;
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
const form = modal.querySelector('#groupConfigForm');
|
|
|
|
const formData = new FormData(form);
|
|
|
|
const config = {};
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
formData.forEach((value, key) => {
|
|
|
|
if (value === 'true') value = true;
|
|
|
|
else if (value === 'false') value = false;
|
|
|
|
else if (!isNaN(value) && value !== '') value = Number(value);
|
|
|
|
config[key] = value;
|
|
|
|
});
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
try {
|
|
|
|
await apiRequest(`/script-groups/${currentGroup.id}/config`, {
|
|
|
|
method: 'PUT',
|
|
|
|
body: JSON.stringify(config)
|
2025-02-08 11:23:14 -03:00
|
|
|
});
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
closeModal(modal);
|
|
|
|
showSuccess('Group configuration updated');
|
|
|
|
await selectGroup(currentGroup.id);
|
2025-02-08 11:23:14 -03:00
|
|
|
} catch (error) {
|
2025-02-08 15:17:08 -03:00
|
|
|
showError('Error saving group configuration');
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
async function editGroupSchema() {
|
|
|
|
if (!currentGroup) return;
|
|
|
|
|
2025-02-08 11:23:14 -03:00
|
|
|
try {
|
2025-02-08 15:17:08 -03:00
|
|
|
const schema = await apiRequest(`/script-groups/${currentGroup.id}/schema`);
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
const content = `
|
|
|
|
<div class="space-y-4">
|
|
|
|
<div class="grid grid-cols-2 gap-4">
|
2025-02-08 11:23:14 -03:00
|
|
|
<div>
|
2025-02-08 15:17:08 -03:00
|
|
|
<label class="block text-sm font-medium text-gray-700">Group Name</label>
|
|
|
|
<input type="text" name="group_name" value="${schema.group_name || ''}"
|
2025-02-08 13:20:05 -03:00
|
|
|
class="${STYLES.editableInput}">
|
2025-02-08 11:23:14 -03:00
|
|
|
</div>
|
2025-02-08 15:17:08 -03:00
|
|
|
<div>
|
|
|
|
<div class="flex justify-end">
|
|
|
|
<button type="button" onclick="addSchemaField()"
|
|
|
|
class="mt-6 rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white hover:bg-indigo-500">
|
|
|
|
Add Field
|
|
|
|
</button>
|
2025-02-08 11:23:14 -03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2025-02-08 15:17:08 -03:00
|
|
|
<div>
|
|
|
|
<label class="block text-sm font-medium text-gray-700">Description</label>
|
|
|
|
<input type="text" name="description" value="${schema.description || ''}"
|
|
|
|
class="${STYLES.editableInput}">
|
|
|
|
</div>
|
|
|
|
<div id="schemaFields" class="space-y-4">
|
|
|
|
${Object.entries(schema.config_schema || {}).map(([key, field]) =>
|
|
|
|
generateSchemaField(key, field)).join('')}
|
|
|
|
</div>
|
2025-02-08 11:23:14 -03:00
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
const modal = createModal('Edit Group Schema', content, true);
|
|
|
|
modal.querySelector('[onclick="saveModal(this)"]').onclick = () => saveGroupSchema(modal);
|
2025-02-08 11:23:14 -03:00
|
|
|
} catch (error) {
|
2025-02-08 15:17:08 -03:00
|
|
|
showError('Error loading group schema');
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
async function saveGroupSchema(modal) {
|
2025-02-08 11:23:14 -03:00
|
|
|
const schema = {
|
2025-02-08 15:17:08 -03:00
|
|
|
group_name: modal.querySelector('[name="group_name"]').value,
|
|
|
|
description: modal.querySelector('[name="description"]').value,
|
2025-02-08 11:23:14 -03:00
|
|
|
config_schema: {}
|
|
|
|
};
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
// Recopilar definiciones de campos
|
|
|
|
modal.querySelectorAll('.schema-field').forEach(field => {
|
|
|
|
const key = field.querySelector('[name="field_name"]').value;
|
|
|
|
const type = field.querySelector('[name="field_type"]').value;
|
2025-02-08 11:23:14 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
if (!key) return; // Ignorar campos sin nombre
|
|
|
|
|
|
|
|
const fieldSchema = {
|
2025-02-08 11:23:14 -03:00
|
|
|
type,
|
2025-02-08 15:17:08 -03:00
|
|
|
description: field.querySelector('[name="field_description"]').value,
|
|
|
|
required: field.querySelector('[name="field_required"]').value === 'true'
|
2025-02-08 11:23:14 -03:00
|
|
|
};
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
// Procesar valor por defecto según el tipo
|
|
|
|
const defaultValue = field.querySelector('[name="field_default"]').value;
|
|
|
|
if (defaultValue) {
|
|
|
|
if (type === 'number') {
|
|
|
|
fieldSchema.default = Number(defaultValue);
|
|
|
|
} else if (type === 'boolean') {
|
|
|
|
fieldSchema.default = defaultValue === 'true';
|
|
|
|
} else {
|
|
|
|
fieldSchema.default = defaultValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Procesar opciones para campos tipo select
|
2025-02-08 11:23:14 -03:00
|
|
|
if (type === 'select') {
|
2025-02-08 15:17:08 -03:00
|
|
|
const optionsStr = field.querySelector('[name="field_options"]').value;
|
|
|
|
fieldSchema.options = optionsStr.split(',').map(opt => opt.trim()).filter(Boolean);
|
2025-02-08 11:23:14 -03:00
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
schema.config_schema[key] = fieldSchema;
|
2025-02-08 11:23:14 -03:00
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
2025-02-08 15:17:08 -03:00
|
|
|
await apiRequest(`/script-groups/${currentGroup.id}/schema`, {
|
2025-02-08 11:23:14 -03:00
|
|
|
method: 'PUT',
|
|
|
|
body: JSON.stringify(schema)
|
|
|
|
});
|
2025-02-07 19:08:39 -03:00
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
closeModal(modal);
|
|
|
|
showSuccess('Group schema updated');
|
|
|
|
|
|
|
|
// Recargar configuración del grupo
|
|
|
|
await editGroupConfig();
|
2025-02-07 19:08:39 -03:00
|
|
|
} catch (error) {
|
2025-02-08 15:17:08 -03:00
|
|
|
showError('Error saving group schema');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateScriptList(scripts) {
|
|
|
|
const scriptList = document.getElementById('scriptList');
|
|
|
|
if (!scriptList) return;
|
|
|
|
|
|
|
|
if (!scripts || !scripts.length) {
|
|
|
|
scriptList.innerHTML = `
|
|
|
|
<div class="text-center text-gray-500 p-4">
|
|
|
|
No scripts available
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
scriptList.innerHTML = `
|
|
|
|
<div class="space-y-4">
|
|
|
|
${scripts.map(script => `
|
|
|
|
<div class="bg-white shadow sm:rounded-lg">
|
|
|
|
<div class="px-4 py-5 sm:p-6">
|
|
|
|
<div class="flex justify-between items-start">
|
|
|
|
<div>
|
|
|
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
|
|
|
${script.name}
|
|
|
|
</h3>
|
|
|
|
<p class="mt-1 max-w-2xl text-sm text-gray-500">
|
|
|
|
${script.description || 'No description available'}
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<button onclick="runScript('${script.id}')"
|
|
|
|
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
|
|
|
|
Run
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`).join('')}
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function restoreScriptGroup() {
|
|
|
|
const lastGroupId = localStorage.getItem('lastGroupId');
|
|
|
|
if (lastGroupId) {
|
|
|
|
const select = document.getElementById('groupSelect');
|
|
|
|
if (select) {
|
|
|
|
select.value = lastGroupId;
|
|
|
|
if (select.value === lastGroupId) { // Verifica que el grupo aún existe
|
|
|
|
await selectGroup(lastGroupId);
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem('lastGroupId');
|
|
|
|
}
|
|
|
|
}
|
2025-02-07 19:08:39 -03:00
|
|
|
}
|
2025-02-08 13:20:05 -03:00
|
|
|
}
|
|
|
|
|
2025-02-08 15:17:08 -03:00
|
|
|
function updateGroupDisplay(group) {
|
|
|
|
const configContainer = document.getElementById('groupConfig');
|
|
|
|
if (!configContainer) return;
|
|
|
|
|
|
|
|
if (!group) {
|
|
|
|
configContainer.innerHTML = '';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
configContainer.innerHTML = `
|
|
|
|
<div class="space-y-4">
|
|
|
|
<div class="flex justify-between items-center">
|
|
|
|
<div>
|
|
|
|
<h3 class="text-lg font-medium">${group.name || 'Unnamed Group'}</h3>
|
|
|
|
<p class="text-sm text-gray-500">${group.description || 'No description'}</p>
|
2025-02-08 13:20:05 -03:00
|
|
|
</div>
|
2025-02-08 15:17:08 -03:00
|
|
|
<div class="flex space-x-2">
|
|
|
|
<button onclick="editGroupConfig()"
|
|
|
|
class="px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
|
|
|
|
Edit Config
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="bg-gray-50 p-4 rounded-md">
|
|
|
|
<div class="flex justify-between items-center">
|
|
|
|
<div class="flex-grow">
|
|
|
|
<label class="block text-sm font-medium text-gray-700">Working Directory</label>
|
|
|
|
<div class="mt-1 flex items-center space-x-2">
|
|
|
|
<span class="text-gray-600">${group.work_dir || 'Not configured'}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button onclick="selectGroupWorkDir()"
|
|
|
|
class="px-3 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
|
|
|
|
${group.work_dir ? 'Change' : 'Select'} Directory
|
|
|
|
</button>
|
2025-02-08 13:20:05 -03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
2025-02-08 15:17:08 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function selectGroupWorkDir() {
|
|
|
|
if (!currentGroup) {
|
|
|
|
showError('No group selected');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await apiRequest('/select-directory');
|
|
|
|
if (response.path) {
|
|
|
|
const updatedConfig = {
|
|
|
|
...currentGroup,
|
|
|
|
work_dir: response.path
|
|
|
|
};
|
|
|
|
|
|
|
|
await apiRequest(`/script-groups/${currentGroup.id}/config`, {
|
|
|
|
method: 'PUT',
|
|
|
|
body: JSON.stringify(updatedConfig)
|
|
|
|
});
|
|
|
|
|
|
|
|
currentGroup = updatedConfig;
|
|
|
|
updateGroupDisplay(currentGroup);
|
|
|
|
showSuccess('Work directory updated successfully');
|
|
|
|
|
|
|
|
// Recargar scripts si hay
|
|
|
|
await loadGroupScripts(currentGroup.id);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
showError('Failed to update work directory');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inicializar cuando la página carga
|
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
|
|
await loadScriptGroups();
|
|
|
|
await restoreScriptGroup();
|
|
|
|
});
|