feat: add folder button to transcript modal
This commit is contained in:
+2
-2
@@ -210,10 +210,10 @@ async def put_config(body: dict, user: dict = Depends(current_user)):
|
|||||||
async def open_file(body: dict, user: dict = Depends(current_user)):
|
async def open_file(body: dict, user: dict = Depends(current_user)):
|
||||||
import subprocess
|
import subprocess
|
||||||
path = body.get("path", "")
|
path = body.get("path", "")
|
||||||
# Only allow opening files within the user's own output directory
|
|
||||||
user_dir = os.path.join(user["output_dir"], user["username"])
|
user_dir = os.path.join(user["output_dir"], user["username"])
|
||||||
if path and os.path.exists(path) and os.path.abspath(path).startswith(os.path.abspath(user_dir)):
|
if path and os.path.exists(path) and os.path.abspath(path).startswith(os.path.abspath(user_dir)):
|
||||||
subprocess.Popen(["xdg-open", path])
|
target = os.path.dirname(path) if body.get("folder") else path
|
||||||
|
subprocess.Popen(["xdg-open", target])
|
||||||
return {"ok": True}
|
return {"ok": True}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const logoutBtn = document.getElementById('logout-btn');
|
|||||||
const modal = document.getElementById('modal');
|
const modal = document.getElementById('modal');
|
||||||
const modalTitle = document.getElementById('modal-title');
|
const modalTitle = document.getElementById('modal-title');
|
||||||
const modalBody = document.getElementById('modal-body');
|
const modalBody = document.getElementById('modal-body');
|
||||||
|
const modalFolderBtn = document.getElementById('modal-folder-btn');
|
||||||
const modalOpenBtn = document.getElementById('modal-open-btn');
|
const modalOpenBtn = document.getElementById('modal-open-btn');
|
||||||
const modalCloseBtn = document.getElementById('modal-close-btn');
|
const modalCloseBtn = document.getElementById('modal-close-btn');
|
||||||
let _modalPath = null;
|
let _modalPath = null;
|
||||||
@@ -73,6 +74,9 @@ function closeModal() {
|
|||||||
modalCloseBtn.addEventListener('click', closeModal);
|
modalCloseBtn.addEventListener('click', closeModal);
|
||||||
modal.querySelector('.modal-backdrop').addEventListener('click', closeModal);
|
modal.querySelector('.modal-backdrop').addEventListener('click', closeModal);
|
||||||
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeModal(); });
|
document.addEventListener('keydown', e => { if (e.key === 'Escape') closeModal(); });
|
||||||
|
modalFolderBtn.addEventListener('click', () => {
|
||||||
|
if (_modalPath) apiFetch('/open', { method: 'POST', body: JSON.stringify({ path: _modalPath, folder: true }) });
|
||||||
|
});
|
||||||
modalOpenBtn.addEventListener('click', () => {
|
modalOpenBtn.addEventListener('click', () => {
|
||||||
if (_modalPath) apiFetch('/open', { method: 'POST', body: JSON.stringify({ path: _modalPath }) });
|
if (_modalPath) apiFetch('/open', { method: 'POST', body: JSON.stringify({ path: _modalPath }) });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -256,6 +256,11 @@
|
|||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<span id="modal-title" class="modal-title"></span>
|
<span id="modal-title" class="modal-title"></span>
|
||||||
<div class="modal-actions">
|
<div class="modal-actions">
|
||||||
|
<button id="modal-folder-btn" class="modal-btn" title="Verzeichnis öffnen">
|
||||||
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
||||||
|
<path d="M10 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
<button id="modal-open-btn" class="modal-btn" title="Im Editor öffnen">
|
<button id="modal-open-btn" class="modal-btn" title="Im Editor öffnen">
|
||||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
|
||||||
<path d="M14 3h7v7h-2V6.41l-9.29 9.3-1.42-1.42L17.59 5H14V3zm-1 2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8h-2v8H5V7h8V5z"/>
|
<path d="M14 3h7v7h-2V6.41l-9.29 9.3-1.42-1.42L17.59 5H14V3zm-1 2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8h-2v8H5V7h8V5z"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user