-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,31 @@ | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { dropTask } from 'ember-concurrency'; | ||
|
||
export default class ProjectDetailedComponent extends Component { | ||
@service notification; | ||
@service store; | ||
@service fetch; | ||
|
||
syncProject = dropTask(async () => { | ||
try { | ||
// post request to the api endpoint to sync the project | ||
const request = await this.fetch.fetch( | ||
`/api/projects/${this.args.project.id}/sync`, | ||
{ | ||
method: 'POST', | ||
} | ||
); | ||
if (request.ok) { | ||
this.notification.success('Project synced successfully'); | ||
} else if (request.status === 404) { | ||
this.notification.danger('Project not found'); | ||
} else if (request.status === 500) { | ||
this.notification.danger('An error occurred while syncing the project'); | ||
} | ||
} catch (e) { | ||
this.notification.danger(e); | ||
} | ||
this.store.findRecord('project', this.args.project.id); | ||
}); | ||
} |
This file contains 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