@@ -13,7 +13,8 @@ createApp({
13
13
data ( ) {
14
14
return {
15
15
locationOrigin : `${ getLocationOrigin ( ) } ?ref=geophires-ui` ,
16
- locationHost : getLocationHost ( )
16
+ locationHost : getLocationHost ( ) ,
17
+ isCsvDownloading : ref ( false )
17
18
}
18
19
} ,
19
20
methods : {
@@ -26,21 +27,27 @@ createApp({
26
27
document . body . removeChild ( link )
27
28
} ,
28
29
downloadCsv : function ( event ) {
29
- fetch (
30
- document . querySelector ( '#geophires_param_form' ) . getAttribute ( 'action' ) ,
31
- {
32
- method : 'POST' ,
33
- body : JSON . stringify ( {
34
- geophires_input_parameters : JSON . parse ( event . target . dataset . geophires_input_parameters ) ,
35
- output_format : 'csv'
30
+ if ( ! this . isCsvDownloading ) {
31
+ this . isCsvDownloading = ref ( true )
32
+ fetch (
33
+ document . querySelector ( '#geophires_param_form' ) . getAttribute ( 'action' ) ,
34
+ {
35
+ method : 'POST' ,
36
+ body : JSON . stringify ( {
37
+ geophires_input_parameters : JSON . parse ( event . target . dataset . geophires_input_parameters ) ,
38
+ output_format : 'csv'
39
+ } )
40
+ }
41
+ )
42
+ . then ( response => {
43
+ this . isCsvDownloading = ref ( false )
44
+ console . debug ( 'CSV download got response:' , response )
45
+ return response . json ( )
36
46
} )
37
- }
38
- )
39
- . then ( response => response . json ( ) )
40
- . then ( data => {
41
- console . debug ( 'CSV download got data:' , data )
42
- this . downloadURI ( `data:text/csv,${ encodeURI ( data [ 'csv' ] ) } ` , 'geophires-result.csv' )
43
- } ) ;
47
+ . then ( data => {
48
+ this . downloadURI ( `data:text/csv,${ encodeURI ( data [ 'csv' ] ) } ` , 'geophires-result.csv' )
49
+ } ) ;
50
+ }
44
51
}
45
52
}
46
53
} ) . mount ( '#app' )
0 commit comments