-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix import Event #1945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
abhinavk96
merged 4 commits into
fossasia:development
from
YogeshSharma0201:import_event
Mar 6, 2019
Merged
Fix import Event #1945
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bbc6331
Fix import Event
YogeshSharma0201 929271f
Merge branch 'development' of github.com:fossasia/open-event-frontend…
YogeshSharma0201 7cebd39
Merge branch 'development' of github.com:fossasia/open-event-frontend…
YogeshSharma0201 fd6411c
Merge branch 'development' into import_event
abhinavk96 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import Controller from '@ember/controller'; | ||
| import { run } from '@ember/runloop'; | ||
|
|
||
| export default Controller.extend({ | ||
| importStatus : '', | ||
| importError : '', | ||
| isImporting : false, | ||
| file : false, | ||
| fileName : '', | ||
| importTask(taskUrl) { | ||
| run.later(() => { | ||
| this.get('loader') | ||
| .load(taskUrl) | ||
| .then(data => { | ||
| if (data.state !== 'SUCCESS') { | ||
| this.set('importStatus', `Status: ${data.state}`); | ||
| this.importTask(taskUrl); | ||
| } else { | ||
| this.set('importStatus', `Status: ${data.state}`); | ||
| this.transitionToRoute('events.view', data.result.id); | ||
| } | ||
| }) | ||
| .catch(e => { | ||
| this.setProperties({ | ||
| 'importError' : e.message, | ||
| 'isImporting' : false, | ||
| 'file' : false | ||
| }); | ||
| }); | ||
| }, 3000); | ||
| }, | ||
| actions: { | ||
| uploadFile(files) { | ||
| let [file] = files; | ||
| var data = new FormData(); | ||
| var endpoint = 'import/json'; | ||
| var ext = file.name.split('.'); | ||
| ext = ext[ext.length - 1].toLowerCase(); | ||
| if (ext === 'xml') { | ||
| endpoint = 'import/pentabarf'; | ||
| } else if (ext === 'ics' || ext === 'ical') { | ||
| endpoint = 'import/ical'; | ||
| } else if (ext === 'xcal') { | ||
| endpoint = 'import/xcal'; | ||
| } | ||
| data.append('file', file); | ||
|
|
||
| this.setProperties({ | ||
| 'importStatus' : 'Uploading file.. Please don\'t close this window', | ||
| 'importError' : '', | ||
| 'isImporting' : true, | ||
| 'file' : true | ||
| }); | ||
|
|
||
| this.get('loader').post( | ||
| `/events/${endpoint}`, | ||
| data, | ||
| { isFile: true } | ||
| ).then(data => { | ||
| this.importTask(`tasks/${data.task_url.split('/')[3]}`); | ||
| }).catch(e => { | ||
| this.set('importError', e.message); | ||
| }); | ||
| } | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| {{events/event-import-section}} | ||
| {{events/event-import-section uploadFile=(action 'uploadFile') importStatus=importStatus importError=importError isImporting=isImporting file=file}} | ||
| <br><br> | ||
| {{events/imports-history-section}} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
.zip,.xcalcases ? The upload input accepts those tooThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niranjan94 actually only
.zipfiles can be successfully imported, its endpoint isimport/json. Other cases don't even have a valid endpoint, but eventyay had this code so i thought they can be implemented later on the server side. Should i only accept.zipthen?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YogeshSharma0201 add the .zip and .xcal cases, it's fine if server doesn't accept them for now.