Merge branch 'feature/customdocument26' into 'feature/ui-test'

delete button and function implemented

See merge request proj-wise2526-video2document/video2document!84
This commit is contained in:
Heyne, Stefan Norbert Robert
2026-01-10 14:41:13 +01:00
4 changed files with 67 additions and 18 deletions
+37
View File
@@ -121,6 +121,7 @@
<a href="index.html">
<button id="goBackBtn">Abbrechen</button>
</a>
<button id="deleteBtn">Dokument löschen</button>
<button id="generateBtn">Dokument speichern</button>
</div>
@@ -131,6 +132,7 @@
<script>
const goBackBtn = document.getElementById("goBackBtn");
const generateBtn = document.getElementById("generateBtn");
const deleteBtn = document.getElementById("deleteBtn");
const existingDocs = document.getElementById("existingDocs");
const docNameInput = document.getElementById("docName");
const promptInput = document.getElementById("prompt");
@@ -157,6 +159,41 @@
});
// dokumente löschen
deleteBtn.addEventListener("click", () => {
const name = docNameInput.value.trim();
if (!name) {
resultDiv.textContent = "Bitte Dokumentname angeben.";
setTimeout(() => {
resultDiv.textContent = "";
}, 3000);
return;
}
const confirmDelete = confirm(
`Möchtest du das Dokument "${name}" wirklich löschen?`
);
if (!confirmDelete) return;
window.api.deleteTxtFile(name).then((success) => {
if (success) {
resultDiv.textContent = "Dokument erfolgreich gelöscht!";
reloadDocuments();
existingDocs.value = "newDoc";
existingDocs.dispatchEvent(new Event("change"));
} else {
resultDiv.textContent = "Dokument konnte nicht gelöscht werden.";
}
setTimeout(() => {
resultDiv.textContent = "";
}, 3000);
});
});
//function to load existingDoc options to the drop down list
const select = document.getElementById('existingDocs');
+2 -2
View File
@@ -21,7 +21,7 @@
<nav class="menu1">
<a href="custom_document.html" class="li1">Manage document types</a>
<a href="" class="li1">Help</a>
<a href="help_page.html" class="li1">Help</a>
</nav>
</nav>
</section>
@@ -120,7 +120,7 @@
</div>
<div class="checkbox-container">
<input type="checkbox" name="docFormat" id="docFormatCustom" value="custom">
<select name="costumDocumentType" id="costumDocumentType">
<select name="customDocumentTypes" id="customDocumentTypes">
</select>
</div>
</div>
+14 -15
View File
@@ -5,10 +5,10 @@ try {
onFileDrop: (file) => webUtils.getPathForFile(file)
})
contextBridge.exposeInMainWorld("submit", {
submit: (meeting_specifications) => {ipcRenderer.send("file_submit", meeting_specifications)}
submit: (meeting_specifications) => { ipcRenderer.send("file_submit", meeting_specifications) }
})
contextBridge.exposeInMainWorld("electronAPI", {
getFilePath: (file) => {return webUtils.getPathForFile(file)}
getFilePath: (file) => { return webUtils.getPathForFile(file) }
})
contextBridge.exposeInMainWorld("onStartup", {
@@ -23,27 +23,26 @@ try {
speakerAudios: (callback) => ipcRenderer.on('speakerAudios', callback)
})
contextBridge.exposeInMainWorld("submitSpeaker", {
speaker_submit: (speaker_names) => {ipcRenderer.send("speaker_submit", speaker_names)}
speaker_submit: (speaker_names) => { ipcRenderer.send("speaker_submit", speaker_names) }
})
contextBridge.exposeInMainWorld("download", {
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)
getTxtFiles: () => ipcRenderer.invoke('get-txt-files'),
saveTxtFile: (name, content) =>
ipcRenderer.invoke('save-txt-file', name, content),
readTxtFile: (fileName) =>
ipcRenderer.invoke('read-txt-file', fileName),
deleteTxtFile: (fileName) =>
ipcRenderer.invoke('delete-txt-file', fileName)
});
ipcRenderer.on("error", (event, err) => {alert(err)})
ipcRenderer.on("error", (event, err) => { alert(err) })
} catch (error) {
console.log("Error in preload.js");
}
+14 -1
View File
@@ -281,8 +281,21 @@ electron.ipcMain.handle('save-txt-file', (event, fileName, content) => {
return true;
});
//
//read file content
electron.ipcMain.handle('read-txt-file', (event, fileName) => {
const filePath = `${mainDir}/storage/documentType/${fileName}`;
return fs.readFileSync(filePath, 'utf8');
});
//delete documentfiles
electron.ipcMain.handle('delete-txt-file', (event, fileName) => {
const filePath = `${mainDir}/storage/documentType/${fileName}.txt`;
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath);
return true;
} else {
return false;
}
});