1 | <html> |
---|
2 | <head> |
---|
3 | <meta name="layout" content="main" /> |
---|
4 | <title>Processing files | Metagenomics | dbNP</title> |
---|
5 | |
---|
6 | <script type="text/javascript"> |
---|
7 | $(function() { |
---|
8 | $( "#wait_dialog" ).dialog({ |
---|
9 | height: 140, |
---|
10 | width: 400, |
---|
11 | title: 'Please wait while processing files', |
---|
12 | modal: true, |
---|
13 | autoOpen: true, |
---|
14 | buttons: {}, |
---|
15 | closeOnEscape: false, |
---|
16 | open: function(event, ui) { $(".ui-dialog-titlebar-close" ).hide(); }, |
---|
17 | resizable: false |
---|
18 | }); |
---|
19 | |
---|
20 | // Show the progressbar and update the value every second |
---|
21 | $( "#progressbar" ).progressbar({ |
---|
22 | value: 0 |
---|
23 | }); |
---|
24 | |
---|
25 | var progressInterval = setInterval(updateProgress, 250); |
---|
26 | |
---|
27 | // Call processing URL |
---|
28 | $.ajax({ |
---|
29 | type: 'POST', |
---|
30 | url: "<g:createLink controller="fasta" action="process" id="${entityId}" />", |
---|
31 | data: "entityType=${entityType}", |
---|
32 | success: function(data) { |
---|
33 | |
---|
34 | // Stop update progress bar |
---|
35 | clearInterval( progressInterval ); |
---|
36 | |
---|
37 | window.location.replace( "${url.encodeAsJavaScript()}" ); |
---|
38 | }, |
---|
39 | error: function(xhr, textStatus, errorThrown) { |
---|
40 | |
---|
41 | // Stop update progress bar (but update it for the last time) |
---|
42 | updateProgress() |
---|
43 | clearInterval( progressInterval ); |
---|
44 | |
---|
45 | alert( "Error " + xhr.getStatus() + ": " + xhr.getStatusText() ); |
---|
46 | //window.location.replace( "<g:createLink controller="${entityType}" action="show" id="${entityId}" />" ); |
---|
47 | } |
---|
48 | }); |
---|
49 | }); |
---|
50 | |
---|
51 | function updateProgress() { |
---|
52 | $.ajax({ |
---|
53 | type: "GET", |
---|
54 | url: "<g:createLink controller="fasta" action="getProgress" />", |
---|
55 | dataType: "json", |
---|
56 | success: function(progress) { |
---|
57 | $("#progressbar").progressbar("value", progress.bytesProcessed / progress.numBytes * 100 ); |
---|
58 | } |
---|
59 | }); |
---|
60 | } |
---|
61 | </script> |
---|
62 | <style type="text/css"> |
---|
63 | #wait_dialog { |
---|
64 | padding: 20px; |
---|
65 | text-align: center; |
---|
66 | } |
---|
67 | |
---|
68 | #progressbar { margin-top: 10px; } |
---|
69 | </style> |
---|
70 | </head> |
---|
71 | <body> |
---|
72 | <div id="wait_dialog"> |
---|
73 | |
---|
74 | <span class="spinner" style="display: inline-block; zoom: 1; *display: inline;"></span> |
---|
75 | Please wait while processing your files. |
---|
76 | |
---|
77 | <div id="progressbar"></div> |
---|
78 | |
---|
79 | </div> |
---|
80 | </body> |
---|
81 | </html> |
---|