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 'feature/ui-test'
delete button and function implemented See merge request proj-wise2526-video2document/video2document!84
This commit is contained in:
@@ -121,6 +121,7 @@
|
|||||||
<a href="index.html">
|
<a href="index.html">
|
||||||
<button id="goBackBtn">Abbrechen</button>
|
<button id="goBackBtn">Abbrechen</button>
|
||||||
</a>
|
</a>
|
||||||
|
<button id="deleteBtn">Dokument löschen</button>
|
||||||
<button id="generateBtn">Dokument speichern</button>
|
<button id="generateBtn">Dokument speichern</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -131,6 +132,7 @@
|
|||||||
<script>
|
<script>
|
||||||
const goBackBtn = document.getElementById("goBackBtn");
|
const goBackBtn = document.getElementById("goBackBtn");
|
||||||
const generateBtn = document.getElementById("generateBtn");
|
const generateBtn = document.getElementById("generateBtn");
|
||||||
|
const deleteBtn = document.getElementById("deleteBtn");
|
||||||
const existingDocs = document.getElementById("existingDocs");
|
const existingDocs = document.getElementById("existingDocs");
|
||||||
const docNameInput = document.getElementById("docName");
|
const docNameInput = document.getElementById("docName");
|
||||||
const promptInput = document.getElementById("prompt");
|
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
|
//function to load existingDoc options to the drop down list
|
||||||
const select = document.getElementById('existingDocs');
|
const select = document.getElementById('existingDocs');
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<nav class="menu1">
|
<nav class="menu1">
|
||||||
<a href="custom_document.html" class="li1">Manage document types</a>
|
<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>
|
||||||
</nav>
|
</nav>
|
||||||
</section>
|
</section>
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="checkbox-container">
|
<div class="checkbox-container">
|
||||||
<input type="checkbox" name="docFormat" id="docFormatCustom" value="custom">
|
<input type="checkbox" name="docFormat" id="docFormatCustom" value="custom">
|
||||||
<select name="costumDocumentType" id="costumDocumentType">
|
<select name="customDocumentTypes" id="customDocumentTypes">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+14
-15
@@ -5,10 +5,10 @@ try {
|
|||||||
onFileDrop: (file) => webUtils.getPathForFile(file)
|
onFileDrop: (file) => webUtils.getPathForFile(file)
|
||||||
})
|
})
|
||||||
contextBridge.exposeInMainWorld("submit", {
|
contextBridge.exposeInMainWorld("submit", {
|
||||||
submit: (meeting_specifications) => {ipcRenderer.send("file_submit", meeting_specifications)}
|
submit: (meeting_specifications) => { ipcRenderer.send("file_submit", meeting_specifications) }
|
||||||
})
|
})
|
||||||
contextBridge.exposeInMainWorld("electronAPI", {
|
contextBridge.exposeInMainWorld("electronAPI", {
|
||||||
getFilePath: (file) => {return webUtils.getPathForFile(file)}
|
getFilePath: (file) => { return webUtils.getPathForFile(file) }
|
||||||
})
|
})
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld("onStartup", {
|
contextBridge.exposeInMainWorld("onStartup", {
|
||||||
@@ -23,27 +23,26 @@ try {
|
|||||||
speakerAudios: (callback) => ipcRenderer.on('speakerAudios', callback)
|
speakerAudios: (callback) => ipcRenderer.on('speakerAudios', callback)
|
||||||
})
|
})
|
||||||
contextBridge.exposeInMainWorld("submitSpeaker", {
|
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", {
|
contextBridge.exposeInMainWorld("download", {
|
||||||
file_download: () => {ipcRenderer.send("file_download")}
|
file_download: () => { ipcRenderer.send("file_download") }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//documenttypes
|
//documenttypes
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('api', {
|
contextBridge.exposeInMainWorld('api', {
|
||||||
getTxtFiles: () => ipcRenderer.invoke('get-txt-files'),
|
getTxtFiles: () => ipcRenderer.invoke('get-txt-files'),
|
||||||
saveTxtFile: (name, content) =>
|
saveTxtFile: (name, content) =>
|
||||||
ipcRenderer.invoke('save-txt-file', name, content),
|
ipcRenderer.invoke('save-txt-file', name, content),
|
||||||
readTxtFile: (fileName) =>
|
readTxtFile: (fileName) =>
|
||||||
ipcRenderer.invoke('read-txt-file', 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) {
|
} catch (error) {
|
||||||
console.log("Error in preload.js");
|
console.log("Error in preload.js");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,8 +281,21 @@ electron.ipcMain.handle('save-txt-file', (event, fileName, content) => {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
//read file content
|
||||||
electron.ipcMain.handle('read-txt-file', (event, fileName) => {
|
electron.ipcMain.handle('read-txt-file', (event, fileName) => {
|
||||||
const filePath = `${mainDir}/storage/documentType/${fileName}`;
|
const filePath = `${mainDir}/storage/documentType/${fileName}`;
|
||||||
return fs.readFileSync(filePath, 'utf8');
|
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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user