Add fullscreen file editor for email templates, project docs and agent files
This commit is contained in:
parent
7844e82c95
commit
5c75ad575d
3 changed files with 274 additions and 66 deletions
|
|
@ -103,8 +103,7 @@
|
|||
<div class="file-actions">
|
||||
<button class="btn btn-sm btn-secondary"
|
||||
onclick="viewEmailFile(event, '{{ file.name }}')" title="Anzeigen">👁</button>
|
||||
<button class="btn btn-sm btn-primary"
|
||||
onclick="editEmailFile('{{ file.name }}')" title="Bearbeiten">✎</button>
|
||||
<a href="/files/editor?type=email&name={{ file.name|urlencode }}" class="btn btn-sm btn-primary" title="Bearbeiten">✎</a>
|
||||
<a href="/files/email/delete/{{ file.name }}" class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('Email-Vorlage löschen?')" title="Löschen">✕</a>
|
||||
</div>
|
||||
|
|
@ -137,7 +136,11 @@
|
|||
<div class="file-actions">
|
||||
<button class="btn btn-sm btn-secondary"
|
||||
onclick="viewProjectFile(event, '{{ file.name }}')" title="Anzeigen">👁</button>
|
||||
{% if file.name.lower().endswith(('.md', '.txt')) %}
|
||||
<a href="/files/editor?type=project&name={{ file.name|urlencode }}" class="btn btn-sm btn-primary" title="Bearbeiten">✎</a>
|
||||
{% else %}
|
||||
<a href="/files/project/{{ file.name }}?download=1" class="btn btn-sm btn-primary" title="Herunterladen" download>↓</a>
|
||||
{% endif %}
|
||||
<a href="/files/project/delete/{{ file.name }}" class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('Projektdokument löschen?')" title="Löschen">✕</a>
|
||||
</div>
|
||||
|
|
@ -170,7 +173,11 @@
|
|||
<div class="file-actions">
|
||||
<button class="btn btn-sm btn-secondary"
|
||||
onclick="viewAgentFile(event, '{{ agent_key }}', '{{ file.name }}')" title="Anzeigen">👁</button>
|
||||
{% if file.name.lower().endswith(('.md', '.txt', '.json', '.csv')) %}
|
||||
<a href="/files/editor?type=agent&agent={{ agent_key|urlencode }}&name={{ file.name|urlencode }}" class="btn btn-sm btn-primary" title="Bearbeiten">✎</a>
|
||||
{% else %}
|
||||
<a href="/files/agent/{{ agent_key }}/{{ file.name }}?download=1" class="btn btn-sm btn-primary" title="Herunterladen" download>↓</a>
|
||||
{% endif %}
|
||||
<a href="/files/agent/{{ agent_key }}/delete/{{ file.name }}" class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('Agent-Datei löschen?')" title="Löschen">✕</a>
|
||||
</div>
|
||||
|
|
@ -205,31 +212,11 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Email Editor Modal -->
|
||||
<div class="modal fade" id="editModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">✎ Bearbeiten: <span id="editModalFilename"></span></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<textarea id="editModalContent" class="inline-editor" spellcheck="false"></textarea>
|
||||
<div id="editSaveStatus" style="font-size:.8rem;color:var(--text-muted);margin-top:.5rem;height:1.2em;"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-primary" onclick="saveEmailFile()">💾 Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
let currentEditFile = null;
|
||||
|
||||
function openFileModal(title, url) {
|
||||
document.getElementById('fileModalTitle').textContent = title;
|
||||
const content = document.getElementById('fileModalContent');
|
||||
|
|
@ -257,48 +244,5 @@ function viewAgentFile(event, agentKey, name) {
|
|||
openFileModal(`${agentKey}/${name}`, `/files/agent/${agentKey}/view/${encodeURIComponent(name)}?json=1`);
|
||||
}
|
||||
|
||||
function editEmailFile(name) {
|
||||
currentEditFile = name;
|
||||
document.getElementById('editModalFilename').textContent = name;
|
||||
const textarea = document.getElementById('editModalContent');
|
||||
const status = document.getElementById('editSaveStatus');
|
||||
textarea.value = 'Wird geladen…';
|
||||
status.textContent = '';
|
||||
const modal = new bootstrap.Modal(document.getElementById('editModal'));
|
||||
modal.show();
|
||||
fetch('/files/email/view/' + encodeURIComponent(name) + '?json=1')
|
||||
.then(r => r.json())
|
||||
.then(d => { textarea.value = d.content || d.error || ''; })
|
||||
.catch(e => { textarea.value = 'Fehler: ' + e.message; });
|
||||
}
|
||||
|
||||
function saveEmailFile() {
|
||||
if (!currentEditFile) return;
|
||||
const content = document.getElementById('editModalContent').value;
|
||||
const status = document.getElementById('editSaveStatus');
|
||||
status.style.color = 'var(--text-muted)';
|
||||
status.textContent = 'Speichern…';
|
||||
|
||||
fetch('/files/email/save/' + encodeURIComponent(currentEditFile), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ content })
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(d => {
|
||||
if (d.ok) {
|
||||
status.style.color = 'var(--success)';
|
||||
status.textContent = '✓ Gespeichert';
|
||||
setTimeout(() => { status.textContent = ''; }, 3000);
|
||||
} else {
|
||||
status.style.color = 'var(--danger)';
|
||||
status.textContent = '✗ Fehler: ' + (d.error || 'Unbekannt');
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
status.style.color = 'var(--danger)';
|
||||
status.textContent = '✗ ' + e.message;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue