@@ -16,7 +16,7 @@ import { spawn } from 'child_process';
1616import { fileURLToPath } from 'url' ;
1717import { setupMenu } from './menu.js' ;
1818import contextMenu from 'electron-context-menu' ;
19- import { CancelError , download } from 'electron-dl ' ;
19+ import { setupProgressInfo } from './progress.js ' ;
2020
2121const configStore = new Store ( {
2222 defaults : {
@@ -35,6 +35,7 @@ let configureWindow = null,
3535 viewLogWindow = null ;
3636
3737let serverPort = 5050 ;
38+ let baseUrl = `http://127.0.0.1:${ serverPort } ` ;
3839let appStartTime = ( new Date ( ) ) . getTime ( ) ;
3940const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
4041
@@ -153,28 +154,6 @@ function reloadApp() {
153154 currWin . webContents . reload ( ) ;
154155}
155156
156- async function desktopFileDownload ( payload ) {
157- const currWin = BrowserWindow . getFocusedWindow ( ) ;
158- try {
159- await download ( currWin , payload . downloadUrl , {
160- filename : payload . fileName ,
161- saveAs : payload . prompt_for_download_location ,
162- onProgress : ( progress ) => {
163- currWin . webContents . send ( 'download-progress' , progress ) ;
164- } ,
165- onCompleted : ( item ) => {
166- currWin . webContents . send ( 'download-complete' , item ) ;
167- if ( payload . automatically_open_downloaded_file )
168- shell . openPath ( item . path ) ;
169- } ,
170- } ) ;
171- } catch ( error ) {
172- if ( ! ( error instanceof CancelError ) ) {
173- misc . writeServerLog ( error ) ;
174- }
175- }
176- }
177-
178157// This functions is used to start the pgAdmin4 server by spawning a
179158// separate process.
180159function startDesktopMode ( ) {
@@ -192,8 +171,9 @@ function startDesktopMode() {
192171 process . env . PGADMIN_SERVER_MODE = 'OFF' ;
193172
194173 // Start Page URL
195- startPageUrl = 'http://127.0.0.1:' + serverPort + '/?key=' + UUID ;
196- serverCheckUrl = 'http://127.0.0.1:' + serverPort + '/misc/ping?key=' + UUID ;
174+ baseUrl = `http://127.0.0.1:${ serverPort } ` ;
175+ startPageUrl = baseUrl + '/?key=' + UUID ;
176+ serverCheckUrl = baseUrl + '/misc/ping?key=' + UUID ;
197177
198178 // Write Python Path, pgAdmin file path and command in log file.
199179 misc . writeServerLog ( 'pgAdmin Runtime Environment' ) ;
@@ -356,6 +336,8 @@ function launchPgAdminWindow() {
356336 'reloadApp' : reloadApp ,
357337 } ) ;
358338
339+ setupProgressInfo ( pgAdminMainScreen ) ;
340+
359341 pgAdminMainScreen . loadURL ( startPageUrl ) ;
360342
361343 const bounds = configStore . get ( 'bounds' ) ;
@@ -429,7 +411,6 @@ ipcMain.on('log', (text) => ()=>{
429411 misc . writeServerLog ( text ) ;
430412} ) ;
431413ipcMain . on ( 'reloadApp' , reloadApp ) ;
432- ipcMain . on ( 'onFileDownload' , ( _ , payload ) => desktopFileDownload ( payload ) ) ;
433414ipcMain . handle ( 'checkPortAvailable' , async ( _e , fixedPort ) => {
434415 try {
435416 await misc . getAvailablePort ( fixedPort ) ;
0 commit comments