-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix Event Imports #1788
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 7 commits into
fossasia:development
from
YogeshSharma0201:fix_import_event
May 15, 2019
Merged
Fix Event Imports #1788
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ebca357
fix_import_event
YogeshSharma0201 c25909e
Merge branch 'development' of github.com:fossasia/open-event-frontend…
YogeshSharma0201 2b9b442
Merge branch 'development' into fix_import_event
YogeshSharma0201 9cd3ffc
remove usage of jquery
YogeshSharma0201 77c3d31
Merge developement and resolve conflicts
YogeshSharma0201 05aa31a
Merge branch 'development' into fix_import_event
mariobehling 839aa6c
Merge branch 'development' into fix_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,65 @@ | ||
| import Controller from '@ember/controller'; | ||
| import { run } from '@ember/runloop'; | ||
| import ENV from 'open-event-frontend/config/environment'; | ||
|
|
||
| export default Controller.extend({ | ||
| importStatus : 'Importing', | ||
| importError : 'Import Error', | ||
| btnImportEvent : false, | ||
| file : false, | ||
| fileName : '', | ||
| importTask(taskUrl) { | ||
| let _this = this; | ||
| 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}`); | ||
| document.location = `/events/${ data.result.id}`; | ||
| } | ||
| }) | ||
| .catch(e => { | ||
| this.set(''); | ||
| this.set('importError', e.message); | ||
| this.set('btnImportEvent', false); | ||
| this.set('file', false); | ||
| }); | ||
| }, 3000); | ||
| }, | ||
| actions: { | ||
| uploadFile(files) { | ||
| let _this = this; | ||
| 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 === 'ical') { | ||
| endpoint = 'import/ical'; | ||
| } | ||
| data.append('file', file); | ||
|
|
||
| this.set('importStatus', 'Uploading file.. Please don\'t close this window'); | ||
| this.set('importError', ''); | ||
| this.set('btnImportEvent', true); | ||
| this.set('file', true); | ||
|
|
||
| this.get('loader').post( | ||
| `${`${ENV.APP.apiHost}/${ENV.APP.apiNamespace}/events/`}${endpoint}`, | ||
| data, | ||
| { isExternal: true, isFile: true } | ||
| ).then(data => { | ||
| _this.importTask(`tasks/${data.task_url.split('/')[3]}`); | ||
| }).catch(e => { | ||
| this.set(''); | ||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import attr from 'ember-data/attr'; | ||
| import ModelBase from 'open-event-frontend/models/base'; | ||
|
|
||
| export default ModelBase.extend({ | ||
| resultStatus : attr('string'), | ||
| result : attr('string'), | ||
| task : attr('string'), | ||
| startsAt : attr('moment', { readOnly: true }) | ||
| }); |
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
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 btnImportEvent=btnImportEvent file=file}} | ||
| <br><br> | ||
| {{events/imports-history-section}} | ||
| {{events/imports-history-section data=model.data}} |
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.
This is not a valid query. There is no importJob model, please try importing the event yourself, and request a review when it works.
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.
I have implemented the importJob model both in backend and fronted. Please check fossasia/open-event-server#5514.
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.
I have tested it locally, it works.
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 Oh okay will check on the server.