From 95ac7256d422283c6da8c0319318b2aa26025a5a Mon Sep 17 00:00:00 2001 From: MikeHughes-BIN Date: Tue, 16 Dec 2025 16:26:45 +0100 Subject: [PATCH] Fixed the Download button in main --- main.js | 124 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/main.js b/main.js index 9bd64be..4e9d673 100644 --- a/main.js +++ b/main.js @@ -1,12 +1,12 @@ // Loading required packages require("./requires.js") console.log(start); - - + + // Initialising map to be used to store the functionality later on for reloadability mapFunctions = new Map() - - + + // Loading the Function Map var path = `${mainDir}/services/modules` var folders = fs.readdirSync(path).filter(function (file) { @@ -20,9 +20,9 @@ folders.forEach(element => { mapFunctions.set(command.name, command); } }); - - - + + + // The startup information for the project, here you can add stuff that might be nice to see when the app starts mapFunctions.get("Startup_function").function() console.log("------------------------------------ Status ------------------------------------"); @@ -31,34 +31,34 @@ console.log(platform); console.log(`The Startup took ${new Date() - start}ms`) console.log(`${mapFunctions.size} Function modules loaded`); console.log("--------------------------------------------------------------------------------"); - - - - - - + + + + + + // --------------------------------------------------------- CLI COMMANDS --------------------------------------------------------- // - + const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); - - + + rl.on("line", data =>{ const args = data.trim().split(" "); const command = args.shift().toLowerCase(); mapFunctions.get("cliCommands").function(command, args) }) - - - - - + + + + + // ----------------------------------------------------------- ELECTRON ----------------------------------------------------------- // - + let mainWindow; - + function createWindow() { mainWindow = new electron.BrowserWindow({ width: 1200, @@ -69,21 +69,21 @@ function createWindow() { preload: `${mainDir}/electron/main/preload.js` } }); - + mainWindow.loadFile('./electron/main/index.html'); } - + electron.app.whenReady().then(createWindow); - - + + // electron.ipcMain.on("extract", (event, args) => { // mapFunctions.get("extraction-video-to-audio").function(args) // }) - + // setTimeout(() => { // mainWindow.webContents.send("fuck", "worked uwu") // }, 5000); - + electron.ipcMain.handle('get-module-names', async () => { let module_array = { "ai_modules":[], @@ -102,8 +102,8 @@ electron.ipcMain.handle('get-module-names', async () => { // console.log(module_array); return module_array }); - - + + // electron.ipcMain.on("get_modules", async (event, args) => { // let module_array = { // "ai_modules":[], @@ -120,12 +120,13 @@ electron.ipcMain.handle('get-module-names', async () => { // } // }) // console.log(module_array); - + // mainWindow.webContents.send("modules", module_array) // }) - - - + +var globalArgs = {} +var globalFinalHtmlPath = "" + electron.ipcMain.on("file_submit", async (event, args) => { try { globalArgs = args @@ -145,11 +146,11 @@ electron.ipcMain.on("file_submit", async (event, args) => { if (!templateFile) { throw new Error("Unknown document type: " + args.document.type); } - + console.log(args); let audiopath = "" let transcriptpath = "" - + console.log("\n\n Running the Video to Audio Extractor"); // This code handles the Video to Audio extraction module call await mapFunctions.get("module-handler").function(args.video.module, {inputVideoPath: args.video.inputVideoPath, outputType: mapFunctions.get(args.transcription.module).audioformat}).then(resp => { @@ -161,8 +162,8 @@ electron.ipcMain.on("file_submit", async (event, args) => { mainWindow.webContents.send("error", err) return }) - - + + console.log("\n\n Running the Audio to Transcription module"); // TODO implement transcription module // This code handles the Audio to Text transcription module call @@ -175,8 +176,8 @@ electron.ipcMain.on("file_submit", async (event, args) => { mainWindow.webContents.send("error", err) return }) - - + + console.log("\n\n Running the Transcription Summarizer module"); // This code summarises the transcript, so that it can be used by an llm // await mapFunctions.get("summarize-transcription").function('A:\\programing\\@projects\\video2document\\storage\\transcripts\\IMG_2978.json').then(resp => { @@ -189,24 +190,24 @@ electron.ipcMain.on("file_submit", async (event, args) => { mainWindow.webContents.send("error", err) return }) - + console.log("\n\n Running the LLM module"); // TODO implement documentation module // This code handles the Text to Document processing module call - + console.log(`\n\n Running the LLM for Document Style ${args.document.type}`); await mapFunctions.get("module-handler").function(args.document.module, { inputTranscriptPath: transcriptpath, documentTypePath: "./storage/documentType/" + templateFile, language: "en" }).then(resp => { - console.log(resp); - transcriptpath = resp - curstep++ - mainWindow.webContents.send("progress", { curstep: curstep, totalsteps: totalsteps }) - }).catch(err => { - mainWindow.webContents.send("error", err) - return - }) + console.log(resp); + globalFinalHtmlPath = resp + curstep++ + mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) + }).catch(err => { + mainWindow.webContents.send("error", err) + return + }) + - // TODO actually implement this functionality // Module to get the first few lines for each speaker to send to the frontend // await mapFunctions.get("speaker-getter-idfk").function(transcriptpath).then(resp => { @@ -214,7 +215,7 @@ electron.ipcMain.on("file_submit", async (event, args) => { // transcriptpath = resp // curstep++ // mainWindow.webContents.send("progress", {curstep:curstep, totalsteps:totalsteps}) - + // // { // // speakerA: {source: "Pfad zur Audio File"}, // // speakerB:..... @@ -224,15 +225,18 @@ electron.ipcMain.on("file_submit", async (event, args) => { // mainWindow.webContents.send("error", err) // return // }) - - + + } catch (error) { console.log(error); } }) - - - + +electron.ipcMain.on("file_download", async() => { + await mapFunctions.get("htmlDocumentConverter").convert({inputPath:globalFinalHtmlPath, format: globalArgs.document.outputType, showDialog: true}); +}) + + let q = { video: { @@ -252,8 +256,8 @@ let q = ] } } - - + + let q1 = { "ai_modules": [ {name:"abc", displayname:"ABC"},