File tree Expand file tree Collapse file tree 4 files changed +29
-12
lines changed Expand file tree Collapse file tree 4 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,12 @@ a:not([href]) {
60
60
cursor : help;
61
61
}
62
62
63
- # params-deeplink {
63
+ # result-actions {
64
64
font-size : 0.5em ;
65
+ margin-left : 1em ;
65
66
}
66
67
67
- # download-csv , # download-csv : hover {
68
+ # result-actions a , # result-actions a : hover {
68
69
cursor : pointer;
70
+ color : # 2196F3 !important ;
69
71
}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ function setLoading(isLoading) {
3
3
if ( isLoading ) {
4
4
setVisible ( loader , true )
5
5
resetGenerationProfileGraphs ( )
6
- setVisible ( $ ( '#params-deeplink ' ) , false )
6
+ setVisible ( $ ( '#result-actions ' ) , false )
7
7
} else {
8
8
setVisible ( loader , false )
9
9
}
@@ -225,7 +225,7 @@ function submitForm(oFormElement) {
225
225
226
226
renderGenerationProfileGraphs ( resultsData )
227
227
228
- setVisible ( $ ( '#params-deeplink ' ) , true )
228
+ setVisible ( $ ( '#result-actions ' ) , true )
229
229
}
230
230
231
231
xhr . onerror = function ( ) {
Original file line number Diff line number Diff line change @@ -17,8 +17,15 @@ createApp({
17
17
}
18
18
} ,
19
19
methods : {
20
+ downloadURI : function ( uri , name ) {
21
+ let link = document . createElement ( 'a' )
22
+ link . download = name
23
+ link . href = uri
24
+ document . body . appendChild ( link )
25
+ link . click ( )
26
+ document . body . removeChild ( link )
27
+ } ,
20
28
downloadCsv : function ( event ) {
21
-
22
29
fetch (
23
30
document . querySelector ( '#geophires_param_form' ) . getAttribute ( 'action' ) ,
24
31
{
@@ -30,7 +37,10 @@ createApp({
30
37
}
31
38
)
32
39
. then ( response => response . json ( ) )
33
- . then ( data => alert ( data ) ) ;
40
+ . then ( data => {
41
+ console . debug ( 'CSV download got data:' , data )
42
+ this . downloadURI ( `data:text/csv,${ encodeURI ( data [ 'csv' ] ) } ` , 'geophires-result.csv' )
43
+ } ) ;
34
44
}
35
45
}
36
46
} ) . mount ( '#app' )
Original file line number Diff line number Diff line change @@ -150,15 +150,20 @@ <h3>
150
150
< h3 >
151
151
Result
152
152
153
+ < span id ="result-actions " class ="hidden ">
153
154
< a id ="params-deeplink "
154
- class ="hidden "
155
- title ="Right-click to copy a deeplink to the parameters for this result "
156
- > 🔗</ a >
157
-
155
+ title ="Right-click to copy a deeplink to the parameters for this result ">
156
+ <!--🔗-->
157
+ link
158
+ </ a >
159
+ ·
158
160
< a id ="download-csv "
159
161
title ="Download result as CSV "
160
- @click ="downloadCsv "
161
- > ⤓</ a >
162
+ @click ="downloadCsv ">
163
+ <!--⤓-->
164
+ csv
165
+ </ a >
166
+ </ span >
162
167
163
168
</ h3 >
164
169
< span id ="loading " class ="hidden loader "> Running...</ span >
You can’t perform that action at this time.
0 commit comments