diff --git a/app/app.js b/app/app.js index ff8860dd638af1e9608f72eb1eec87874c151cc8..1a4c6ef859abeba5a187cf3f83ec9ea7ff29c9dd 100644 --- a/app/app.js +++ b/app/app.js @@ -100,3 +100,27 @@ $.ajax( { $( '#version' ).text( " - " + d.data ); } } ); + +var check_is_done = function() +{ + $.ajax( { + url: baseurl + '/done/' + uuid, + type: "GET", + dataType: 'json', + + success: function( d ) + { + if( d.error == false ) + toastr.success( 'Processing done' ); + else + setTimeout( check_is_done, 500 ); + }, + error: function( d ) + { + setTimeout( check_is_done, 500 ); + } + } ); +} + +toastr.info( "Processing file" ); +setTimeout( check_is_done, 2000 ); diff --git a/functions.py b/functions.py index 36d171d6d3ce0af668438e7dfa72732c252e72e4..7ada4a82c558556550dffe34f8a2cdd3ea2a5588 100644 --- a/functions.py +++ b/functions.py @@ -119,3 +119,9 @@ def process( infile, wd, filename ): wd + "/" + h + "/tenprint_card_back.png", dpi = ( res, res ) ) + + ############################################################################ + # Write to the end file + + with open( wd + "/" + h + "/done.txt", "w+" ) as fp: + fp.write( "done" ) diff --git a/module.py b/module.py index 5abfd8cac7f7349c46f492895334b3738e825494..fd7c92ba24109b790c1b93fc41f1c983d4e009c6 100644 --- a/module.py +++ b/module.py @@ -222,6 +222,20 @@ def get_archive( uuid ): return send_file( io, attachment_filename = filename + ".zip", as_attachment = True ) + +@api.route( baseurl + '/done/' ) +def is_done( uuid ): + iphash = hashlib.md5( get_ip()[ 1 ] ).hexdigest() + try: + return jsonify( { + 'error': False, + 'isdone': os.path.isfile( UPLOAD_FOLDER + "/" + iphash + "/" + uuid + "/done.txt" ) + } ) + except: + return jsonify( { + 'error': True + } ) + @api.route( baseurl + "/ip" ) def getip(): c, ip = get_ip() diff --git a/templates/ui.html b/templates/ui.html index c7b6426e397f151a42bfc58ae436a91d236f01f4..ff3dacce85ce64af8c7524ab16bda55eba9407ea 100644 --- a/templates/ui.html +++ b/templates/ui.html @@ -1,8 +1,9 @@ - + +