Skip to content

Commit 45b588d

Browse files
mrsaicharan1abhinavk96
authored andcommitted
fix: Fix export events module(URL fetch logic) (#3294)
* Fix export events module(URL fetch logic) * used async/await
1 parent 121cc55 commit 45b588d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
import Component from '@ember/component';
2+
import { action } from '@ember/object';
23

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+
}

app/templates/components/events/view/export/download-zip.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<button class="ui blue button" {{action startGeneration}}>
2626
{{t 'Start'}}
2727
</button>
28-
<a href="{{eventDownloadUrl}}" class="ui button {{if isDownloadDisabled 'disabled' ''}}">
28+
<a href="#" class="ui button {{if isDownloadDisabled 'disabled' ''}}" {{action exportEventDownload eventDownloadUrl }}>
2929
{{t 'Download'}}
3030
</a>
3131
<div class="hidden divider"></div>

0 commit comments

Comments
 (0)