From 509995908249e9df8af009960b0bbda8ed1eb64d Mon Sep 17 00:00:00 2001 From: janis Date: Wed, 31 May 2023 14:06:04 +0200 Subject: [PATCH] fix error, remove stuff, add stuff --- .desktop | 7 --- frontend/src/app.js | 21 +++++++ frontend/src/background.js | 56 +----------------- frontend/src/views/SettingsView.vue | 4 +- package/usr/share/applications/.desktop | 7 --- .../scalable/apps/fsrimageupscaler.png | Bin 44230 -> 0 bytes 6 files changed, 23 insertions(+), 72 deletions(-) delete mode 100755 .desktop create mode 100644 frontend/src/app.js delete mode 100755 package/usr/share/applications/.desktop delete mode 100755 package/usr/share/icons/hicolor/scalable/apps/fsrimageupscaler.png diff --git a/.desktop b/.desktop deleted file mode 100755 index d30d8bb..0000000 --- a/.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Type=Application -Name=Image & Video Upscaler -Comment=Upscale your videos and images with different upscalers -Path=/opt/imagevideoupscaler -Exec=/opt/imagevideoupscaler/imagevideoupscaler -Icon=imagevideoupscaler diff --git a/frontend/src/app.js b/frontend/src/app.js new file mode 100644 index 0000000..09d2e66 --- /dev/null +++ b/frontend/src/app.js @@ -0,0 +1,21 @@ +const express = require( 'express' ); +let app = express(); +const path = require( 'path' ); +const fs = require( 'fs' ); +const bodyParser = require( 'body-parser' ); +const exec = require( 'child_process' ).exec; + +app.use( bodyParser.urlencoded( { extended: false } ) ); +app.use( bodyParser.json() ); + +function execute(command, callback){ + exec(command, function(error, stdout, stderr){ callback(stdout); }); +}; + +app.get( '/api/getEngines', ( request, response ) => { + execute( 'ImageVideoUpscaler-cli -p', out => { + response.send( out ); + } ); +} ); + +app.listen( 8081 ); \ No newline at end of file diff --git a/frontend/src/background.js b/frontend/src/background.js index e3fb34f..6feec96 100644 --- a/frontend/src/background.js +++ b/frontend/src/background.js @@ -3,63 +3,9 @@ import { app, protocol, BrowserWindow } from 'electron'; import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'; import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer'; -const electron = require( 'electron' ); -const child_process = require( 'child_process' ); -const dialog = electron.dialog; const isDevelopment = process.env.NODE_ENV !== 'production'; - -// Src for run_script function: https://stackoverflow.com/a/57058495 - -// This function will output the lines from the script -// and will return the full combined output -// as well as exit code when it's done (using the callback). -function run_script(command, args, callback) { - var child = child_process.spawn(command, args, { - encoding: 'utf8', - shell: true - }); - // You can also use a variable to save the output for when the script closes later - child.on('error', (error) => { - dialog.showMessageBox({ - title: 'Title', - type: 'warning', - message: 'Error occured.\r\n' + error - }); - }); - - child.stdout.setEncoding('utf8'); - child.stdout.on('data', (data) => { - //Here is the output - data=data.toString(); - console.log(data); - }); - - child.stderr.setEncoding('utf8'); - child.stderr.on('data', (data) => { - // Return some data to the renderer process with the mainprocess-response ID - mainWindow.webContents.send('mainprocess-response', data); - //Here is the output from the command - console.log(data); - }); - - child.on('close', (code) => { - //Here you can get the exit code of the script - switch (code) { - case 0: - dialog.showMessageBox({ - title: 'Title', - type: 'info', - message: 'End process.\r\n' - }); - break; - } - - }); - if (typeof callback === 'function') - callback(); -} - +require( './app.js' ) // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ diff --git a/frontend/src/views/SettingsView.vue b/frontend/src/views/SettingsView.vue index 4f11939..503181a 100644 --- a/frontend/src/views/SettingsView.vue +++ b/frontend/src/views/SettingsView.vue @@ -6,12 +6,10 @@