File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
components/events/view/export
templates/components/events/view/export Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
import Component from '@ember/component' ;
2
+ import { action } from '@ember/object' ;
2
3
3
- export default Component . extend ( {
4
- } ) ;
4
+ export default class extends Component {
5
+ @action
6
+ async exportEventDownload ( eventDownloadUrl ) {
7
+ this . set ( 'isLoading' , true ) ;
8
+ try {
9
+ const res = await this . loader . downloadFile ( `${ eventDownloadUrl } ` ) ;
10
+ const anchor = document . createElement ( 'a' ) ;
11
+ anchor . style . display = 'none' ;
12
+ anchor . href = URL . createObjectURL ( new Blob ( [ res ] , { type : 'octet/stream' } ) ) ;
13
+ anchor . download = 'EventExport.zip' ;
14
+ anchor . click ( ) ;
15
+ this . notify . success ( this . l10n . t ( 'Exported Event Downloaded successfully.' ) ) ;
16
+ } catch ( e ) {
17
+ console . error ( e ) ;
18
+ this . notify . error ( this . l10n . t ( e ) ) ;
19
+ }
20
+ this . set ( 'isLoading' , false ) ;
21
+ }
22
+
23
+ }
Original file line number Diff line number Diff line change 25
25
<button class =" ui blue button" {{ action startGeneration }} >
26
26
{{ t ' Start' }}
27
27
</button >
28
- <a href =" {{ eventDownloadUrl }} " class =" ui button {{ if isDownloadDisabled ' disabled' ' ' }} " >
28
+ <a href =" # " class =" ui button {{ if isDownloadDisabled ' disabled' ' ' }} " {{ action exportEventDownload eventDownloadUrl }} >
29
29
{{ t ' Download' }}
30
30
</a >
31
31
<div class =" hidden divider" ></div >
You can’t perform that action at this time.
0 commit comments