mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Merge branch 'feature/customdocument26' into 'develop'
custom document backend implemented See merge request proj-wise2526-video2document/video2document!81
This commit is contained in:
@@ -58,6 +58,10 @@
|
|||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -92,19 +96,19 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Custom Document Generator</h1>
|
<h1>Manage document types</h1>
|
||||||
|
|
||||||
<label for="docName">Dokumentname:</label>
|
|
||||||
<input type="text" id="docName" placeholder="Gib hier den Dokumentnamen ein">
|
|
||||||
|
|
||||||
<label for="existingDocs">Vorhandene Dokumente auswählen (optional):</label>
|
<label for="existingDocs">Vorhandene Dokumente auswählen (optional):</label>
|
||||||
<select id="existingDocs">
|
<!--Drop Down-->
|
||||||
<option value="">-- Neues Dokument erstellen --</option>
|
<select name="existingDocs" id="existingDocs">
|
||||||
<option value="meeting_report_001">Meeting Report 001</option>
|
<option value="newDoc">-- Neues Dokument erstellen --</option>
|
||||||
<option value="summary_01">Summary 01</option>
|
|
||||||
<option value="project_plan_A">Project Plan A</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<div id="docNameWrapper">
|
||||||
|
<label for="docName">Dokumentname:</label>
|
||||||
|
<input type="text" id="docName" placeholder="Gib hier den Dokumentnamen ein">
|
||||||
|
</div>
|
||||||
|
|
||||||
<label for="prompt">Dein Prompt:</label>
|
<label for="prompt">Dein Prompt:</label>
|
||||||
<textarea id="prompt" placeholder="Schreibe hier den Prompt für dein Dokument..."></textarea>
|
<textarea id="prompt" placeholder="Schreibe hier den Prompt für dein Dokument..."></textarea>
|
||||||
|
|
||||||
@@ -118,6 +122,7 @@
|
|||||||
<div id="result"></div>
|
<div id="result"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="languages.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const goBackBtn = document.getElementById("goBackBtn");
|
const goBackBtn = document.getElementById("goBackBtn");
|
||||||
const generateBtn = document.getElementById("generateBtn");
|
const generateBtn = document.getElementById("generateBtn");
|
||||||
@@ -125,37 +130,81 @@
|
|||||||
const docNameInput = document.getElementById("docName");
|
const docNameInput = document.getElementById("docName");
|
||||||
const promptInput = document.getElementById("prompt");
|
const promptInput = document.getElementById("prompt");
|
||||||
const resultDiv = document.getElementById("result");
|
const resultDiv = document.getElementById("result");
|
||||||
|
const exampleText = "";
|
||||||
|
|
||||||
|
|
||||||
// Zurück zur Haupt-GUI
|
// Zurück zur Haupt-GUI
|
||||||
goBackBtn.addEventListener("click", () => {
|
goBackBtn.addEventListener("click", () => {
|
||||||
window.electronAPI.goBackToMain();
|
window.electronAPI.goBackToMain();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Generiere Dokument
|
// dokumente speichern
|
||||||
generateBtn.addEventListener("click", () => {
|
generateBtn.addEventListener("click", () => {
|
||||||
const prompt = promptInput.value.trim();
|
const name = docNameInput.value.trim();
|
||||||
let docName = docNameInput.value.trim();
|
const content = promptInput.value.trim();
|
||||||
const selectedExisting = existingDocs.value;
|
if (!name || !content) {
|
||||||
|
resultDiv.textContent = "Bitte Dokumentname und Prompt ausfüllen.";
|
||||||
|
setTimeout(() => {
|
||||||
|
resultDiv.textContent = "";
|
||||||
|
}, 3000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.api.saveTxtFile(name, content).then();
|
||||||
|
resultDiv.textContent = "Dokument erfolgreich gespeichert!";
|
||||||
|
setTimeout(() => {
|
||||||
|
resultDiv.textContent = "";
|
||||||
|
}, 3000);
|
||||||
|
reloadDocuments();
|
||||||
|
|
||||||
if (!prompt) {
|
|
||||||
alert("Bitte gib einen Prompt ein!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wenn ein vorhandenes Dokument ausgewählt wurde, hängt der Prompt daran
|
|
||||||
if (selectedExisting) {
|
|
||||||
docName = selectedExisting; // prompt wird an vorhandenes Dokument angehängt
|
|
||||||
} else if (!docName) {
|
|
||||||
alert("Bitte gib einen Dokumentnamen ein, wenn du ein neues Dokument erstellen möchtest!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Demo-Ausgabe im Result-Div
|
|
||||||
resultDiv.innerHTML = `<strong>Dokumentname:</strong> ${docName}<br><strong>Prompt:</strong> ${prompt}`;
|
|
||||||
|
|
||||||
// Hier kannst du den Prompt an dein LLM oder Module-Handler senden
|
|
||||||
// z.B. window.submit.submit({documentName: docName, prompt: prompt})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//function to load existingDoc options to the drop down list
|
||||||
|
const select = document.getElementById('existingDocs');
|
||||||
|
|
||||||
|
window.api.getTxtFiles().then(files => {
|
||||||
|
reloadDocuments();
|
||||||
|
});
|
||||||
|
|
||||||
|
//content anzeigen
|
||||||
|
const docNameWrapper = document.getElementById("docNameWrapper");
|
||||||
|
|
||||||
|
existingDocs.addEventListener("change", async () => {
|
||||||
|
const selected = existingDocs.value;
|
||||||
|
|
||||||
|
if (selected === "newDoc") {
|
||||||
|
docNameWrapper.classList.remove("hidden");
|
||||||
|
docNameInput.value = "";
|
||||||
|
promptInput.value = exampleText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
docNameWrapper.classList.add("hidden");
|
||||||
|
|
||||||
|
const content = await window.api.readTxtFile(selected);
|
||||||
|
promptInput.value = content;
|
||||||
|
docNameInput.value = selected.replace(".txt", "");
|
||||||
|
});
|
||||||
|
|
||||||
|
//reload drop down
|
||||||
|
function reloadDocuments() {
|
||||||
|
[...existingDocs.querySelectorAll('option:not([value="newDoc"])')]
|
||||||
|
.forEach(o => o.remove());
|
||||||
|
|
||||||
|
window.api.getTxtFiles().then(files => {
|
||||||
|
files.forEach(file => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = file;
|
||||||
|
option.textContent = file
|
||||||
|
.replace('.txt', '') // Endung entfernen
|
||||||
|
.replace(/_/g, ' ') // Leerzeichen ersetzen
|
||||||
|
.replace(/\b\w/g, c => c.toUpperCase()) // ersten Buchstaben groß
|
||||||
|
existingDocs.appendChild(option);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
<script src="./renderer.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<nav class="menu1">
|
<nav class="menu1">
|
||||||
<a href="custom_document.html" class="li1">Custom document</a>
|
<a href="custom_document.html" class="li1">Manage document types</a>
|
||||||
<a href="" class="li1">Help</a>
|
<a href="" class="li1">Help</a>
|
||||||
</nav>
|
</nav>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -30,6 +30,18 @@ try {
|
|||||||
file_download: () => {ipcRenderer.send("file_download")}
|
file_download: () => {ipcRenderer.send("file_download")}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//documenttypes
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('api', {
|
||||||
|
getTxtFiles: () => ipcRenderer.invoke('get-txt-files'),
|
||||||
|
saveTxtFile: (name, content) =>
|
||||||
|
ipcRenderer.invoke('save-txt-file', name, content),
|
||||||
|
readTxtFile: (fileName) =>
|
||||||
|
ipcRenderer.invoke('read-txt-file', fileName)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on("error", (event, err) => {alert(err)})
|
ipcRenderer.on("error", (event, err) => {alert(err)})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -262,4 +262,27 @@ let q1 = {
|
|||||||
{name:"abc", displayname:"ABC"},
|
{name:"abc", displayname:"ABC"},
|
||||||
{name:"qeg", displayname:"aqghegahu"}
|
{name:"qeg", displayname:"aqghegahu"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gibt Documentfiles an preload zurück
|
||||||
|
|
||||||
|
electron.ipcMain.handle('get-txt-files', () => {
|
||||||
|
const storagePath = `${mainDir}/storage/documentType`
|
||||||
|
|
||||||
|
return fs.readdirSync(storagePath)
|
||||||
|
.filter(f => f.endsWith('.txt'))
|
||||||
|
});
|
||||||
|
|
||||||
|
//speichern neuer document types
|
||||||
|
|
||||||
|
electron.ipcMain.handle('save-txt-file', (event, fileName, content) => {
|
||||||
|
const filePath = `${mainDir}/storage/documentType/${fileName}.txt`;
|
||||||
|
fs.writeFileSync(filePath, content, 'utf8');
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
electron.ipcMain.handle('read-txt-file', (event, fileName) => {
|
||||||
|
const filePath = `${mainDir}/storage/documentType/${fileName}`;
|
||||||
|
return fs.readFileSync(filePath, 'utf8');
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user