Implemented first version of the json object that should be send back to the main. as well as fixed some bugs

This commit is contained in:
2025-11-18 12:59:08 +01:00
parent 5f14d633e3
commit abd72c9b54
3 changed files with 75 additions and 8 deletions
+7 -2
View File
@@ -16,8 +16,13 @@
</div> </div>
<div class="dropdownMenus" id="dropdownMenus"> <div class="dropdownMenus" id="dropdownMenus">
<select name="ai_type" id="ai_type"> <select name="ai_type" id="ai_type">
<option value="ai">ai</option>
</select> </select>
<select name="transkript_type" id="transkript_type"> <select name="transkript_type" id="transkript_type">
<option value="transkripty">transkripty</option>
</select>
<select name="output_type" id="output_type">
<option value="mp4">mp4</option>
</select> </select>
<select name="language_option" id="language_option"> <select name="language_option" id="language_option">
</select> </select>
@@ -40,12 +45,12 @@
<div class="checkbox-group"> <div class="checkbox-group">
<label id="checkbox_group" for="checkbox-group">Choose prefered document style:</label> <label id="checkbox_group" for="checkbox-group">Choose prefered document style:</label>
<div class="checkbox-container"> <div class="checkbox-container">
<input type="checkbox" name ="docFormat" id="docFormat"> <input type="checkbox" name ="docFormat" id="docFormat" value="Meeting report">
<label id="label_format" for="docFormat">Meeting report</label> <label id="label_format" for="docFormat">Meeting report</label>
</div> </div>
<div class="checkbox-container"> <div class="checkbox-container">
<input type="checkbox" name="docFormat" id="docFormatSummary"> <input type="checkbox" name="docFormat" id="docFormatSummary" value="Summary with timestamps">
<label id="label_summary" for="docFormatSummary">Summary with timestamps</label> <label id="label_summary" for="docFormatSummary">Summary with timestamps</label>
</div> </div>
</div> </div>
+6 -2
View File
@@ -16,10 +16,14 @@ uploadContainer.addEventListener("drop", (e) => {
e.preventDefault() e.preventDefault()
const files = e.dataTransfer.files const files = e.dataTransfer.files
const filePath = window.explorer.onFileDrop(files[0]) const filePath = window.explorer.onFileDrop(files[0])
var holdy = filePath + ""; const testEndings = [".mp4", ".mov", ".avi", ".mkv"];
if(holdy.endsWith(".mp4") || holdy.endsWith(".mov") || holdy.endsWith(".avi") || holdy.endsWith( ".mkv")){ var pathToLower = filePath.toLowerCase();
if(testEndings.some(e => pathToLower.endsWith(e))){
document.getElementById("progressbar").style.visibility = "visible";
const files1 = e.dataTransfer.files; const files1 = e.dataTransfer.files;
handleFiles(files1); handleFiles(files1);
}else{
alert('The given file is not compatible. These are the available types: [".mp4", ".mov", ".avi", ".mkv"].');
} }
} catch (error) { } catch (error) {
+62 -4
View File
@@ -4,10 +4,11 @@ function checkBoxes() {
try { try {
const checkboxes = document.querySelectorAll('input[name="docFormat"]'); const checkboxes = document.querySelectorAll('input[name="docFormat"]');
let isChecked = false; let isChecked = false;
var checkedCounter = 0;
checkboxes.forEach(function(checkbox){ checkboxes.forEach(function(checkbox){
if(checkbox.checked){ if(checkbox.checked){
isChecked = true; isChecked = true;
checkedCounter++;
} }
}); });
@@ -19,11 +20,48 @@ function checkBoxes() {
selectedCheckboxes[checkbox.nextElementSibling.textContent] = ""; selectedCheckboxes[checkbox.nextElementSibling.textContent] = "";
} }
}); });
console.log(selectedCheckboxes);
const testEndings = [".mp4", ".mov", ".avi", ".mkv"];
var pathTest = window.electronAPI.getFilePath(videoUpload.files[0]); var pathTest = window.electronAPI.getFilePath(videoUpload.files[0]);
if(pathTest.endsWith(".mp4") || pathTest.endsWith(".mov") || pathTest.endsWith(".avi") || pathTest.endsWith( ".mkv")){ var pathToLower = pathTest.toLowerCase();
if(testEndings.some(e => pathToLower.endsWith(e))){
document.getElementById("progressbar").style.visibility = "visible"; document.getElementById("progressbar").style.visibility = "visible";
//assembly of the json for the main
const selectedStyles = [checkedCounter];
var iter = 0;
checkboxes.forEach(function(checkbox){
if(checkbox.checked){
console.log(checkbox.value);
selectedStyles[iter] = {iter: checkbox.value};
iter++;
}
});
console.log(selectedCheckboxes);
const outputType = document.getElementById("output_type");
const transcriptionType = document.getElementById("transkript_type");
const aiType = document.getElementById("ai_type");
const sendingPackage = {
"video": {
"module":"extraction-video-toaudio",
"inputVideoPath": pathTest,
"outputType": outputType.value
},
"transcription": {
"module": transcriptionType.value
},
"document": {
"module":aiType.value,
"style": selectedStyles
}
};
console.log(sendingPackage);
//window.extractor.extract({inputVideoPath: pathTest, outputType:"wav"}); //window.extractor.extract({inputVideoPath: pathTest, outputType:"wav"});
}else{
alert('The given file is not compatible. These are the available types: [".mp4", ".mov", ".avi", ".mkv"].');
} }
} else { } else {
//language only english at the moment //language only english at the moment
@@ -68,6 +106,7 @@ function handleFiles(files) {
videoUpload.files = files; videoUpload.files = files;
fileName.textContent = `Chosen video: ${file.name}`; fileName.textContent = `Chosen video: ${file.name}`;
generateThumbnail(filePath); generateThumbnail(filePath);
activateSubmitBtn(true);
} }
} }
} catch (error) { } catch (error) {
@@ -96,7 +135,7 @@ function loadAiOptions(options){
var menu = document.getElementById('ai_type'); var menu = document.getElementById('ai_type');
var object_holdy; var object_holdy;
var choice ; var choice ;
object_holdy = Object.keys(languageOptions); object_holdy = Object.keys(options);
for(i = 0; i < options.length; i++){ for(i = 0; i < options.length; i++){
choice = document.createElement('option'); choice = document.createElement('option');
choice.textContent = object_holdy[i]; choice.textContent = object_holdy[i];
@@ -109,6 +148,25 @@ function loadAiOptions(options){
} }
} }
//function to load transcription options to the drop down list
function loadTranscriptionOptions(options){
try {
var menu = document.getElementById('transkript_type');
var object_holdy;
var choice ;
object_holdy = Object.keys(options);
for(i = 0; i < options.length; i++){
choice = document.createElement('option');
choice.textContent = object_holdy[i];
choice.value = object_holdy[i];
menu.appendChild(choice);
}
} catch (error) {
console.log("Error in script.js function loadTranscriptionOptions");
console.log(error);
}
}
//function to load language options to the drop down list //function to load language options to the drop down list
function loadLanguageOptions(){ function loadLanguageOptions(){
try { try {