-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
<!-- Add the issue number that is fixed by this PR (In the form Fixes #123) --> Fixes #952 #### Checklist - [x] I have read the [Contribution & Best practices Guide](https://blog.fossasia.org/open-source-developer-guide-and-best-practices-at-fossasia) and my PR follows them. - [x] My branch is up-to-date with the Upstream `development` branch. - [ ] I have added necessary documentation (if appropriate) ### Preview Link - **Replace XXX with your PR no** - Link to live demo: http://pr-XXX-fossasia-badgeyay.surge.sh #### Changes proposed in this pull request: - Adds my-badges component to frontend - User can now view the badges he/she has generated - Badges can be downloaded from the my-badges portal as well Cheers!
- Loading branch information
Showing
17 changed files
with
192 additions
and
3 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
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
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,12 @@ | ||
import ApplicationAdapter from './application'; | ||
import ENV from '../config/environment'; | ||
|
||
const { APP } = ENV; | ||
|
||
export default ApplicationAdapter.extend({ | ||
host: APP.backLink, | ||
pathForType() { | ||
const user = this.get('session.currentUser'); | ||
return 'api/get_badges?uid=' + user.uid; | ||
} | ||
}); |
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,4 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
}); |
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,11 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { Model, attr } = DS; | ||
|
||
export default Model.extend({ | ||
badge_size : attr('string'), | ||
csv : attr('string'), | ||
download_link : attr('string'), | ||
image : attr('string'), | ||
text_color : attr('string') | ||
}); |
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
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,7 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
model() { | ||
return this.get('store').findAll('my-badges'); | ||
} | ||
}); |
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,12 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { JSONAPISerializer } = DS; | ||
|
||
export default JSONAPISerializer.extend({ | ||
|
||
normalizeResponse(store, primaryModelClass, payload, id, requestType) { | ||
console.log(payload); | ||
return payload; | ||
} | ||
|
||
}); |
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
47 changes: 47 additions & 0 deletions
47
frontend/app/templates/components/user-component/my-badges.hbs
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,47 @@ | ||
<div class="ui hidden divider"></div> | ||
|
||
{{#each model as |badge|}} | ||
|
||
<div class="ui card"> | ||
<div class="content"> | ||
<div class="header">Badge</div> | ||
</div> | ||
<div class="content"> | ||
<h4 class="ui sub header">Badge Details</h4> | ||
<div class="ui small feed"> | ||
<div class="event"> | ||
<div class="content"> | ||
<div class="summary"> | ||
Image : {{badge.image}} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="event"> | ||
<div class="content"> | ||
<div class="summary"> | ||
CSV : {{badge.csv}} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="event"> | ||
<div class="content"> | ||
<div class="summary"> | ||
Badge Size : {{badge.badge_size}} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="event"> | ||
<div class="content"> | ||
<div class="summary"> | ||
Text Color : {{badge.text_color}} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="extra content"> | ||
<a href="{{badge.download_link}}" class="ui button">Download Badge</a> | ||
</div> | ||
</div> | ||
|
||
{{/each}} |
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 @@ | ||
{{user-component/my-badges model=model}} |
26 changes: 26 additions & 0 deletions
26
frontend/tests/integration/components/user-component/my-badges-test.js
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,26 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { render } from '@ember/test-helpers'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
module('Integration | Component | user-component/my-badges', function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test('it renders', async function(assert) { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.set('myAction', function(val) { ... }); | ||
|
||
await render(hbs`{{user-component/my-badges}}`); | ||
|
||
assert.equal(this.element.textContent.trim(), ''); | ||
|
||
// Template block usage: | ||
await render(hbs` | ||
{{#user-component/my-badges}} | ||
template block text | ||
{{/user-component/my-badges}} | ||
`); | ||
|
||
assert.equal(this.element.textContent.trim(), ''); | ||
}); | ||
}); |
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,12 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Adapter | my badges', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let adapter = this.owner.lookup('adapter:my-badges'); | ||
assert.ok(adapter); | ||
}); | ||
}); |
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,14 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('Unit | Model | my badges', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = run(() => store.createRecord('my-badges', {})); | ||
assert.ok(model); | ||
}); | ||
}); |
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,11 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Route | my-badges', function(hooks) { | ||
setupTest(hooks); | ||
|
||
test('it exists', function(assert) { | ||
let route = this.owner.lookup('route:my-badges'); | ||
assert.ok(route); | ||
}); | ||
}); |
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,24 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('Unit | Serializer | my badges', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let serializer = store.serializerFor('my-badges'); | ||
|
||
assert.ok(serializer); | ||
}); | ||
|
||
test('it serializes records', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let record = run(() => store.createRecord('my-badges', {})); | ||
|
||
let serializedRecord = record.serialize(); | ||
|
||
assert.ok(serializedRecord); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.