File tree 5 files changed +84
-0
lines changed
components/user-tag-graph
tests/integration/pods/components/user-tag-graph
5 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ import Ember from 'ember' ;
2
+ import DS from 'ember-data' ;
3
+ const { Model } = DS ;
4
+
5
+ export default Model . extend ( {
6
+ tag : DS . attr ( ) ,
7
+ rating : DS . attr ( )
8
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import Component from '@ember/component' ;
2
+ import { inject as service } from '@ember/service' ;
3
+ import { computed } from '@ember/object' ;
4
+ import { task } from 'ember-concurrency-decorators' ;
5
+ import { alias } from '@ember/object/computed' ;
6
+
7
+ export default class UserTagComponent extends Component {
8
+ @service store
9
+
10
+ @alias ( 'fetchUserTagsTask.lastSuccessful.value' ) userTags
11
+
12
+
13
+ get chartData ( ) {
14
+ const userTags = this . get ( 'userTags' )
15
+ if ( userTags ) {
16
+ return userTags . map ( ut => {
17
+ return {
18
+ x : ut . get ( 'tag.name' ) ,
19
+ y : Math . round ( ut . get ( 'rating' ) )
20
+ }
21
+ } )
22
+ } else {
23
+ return [ ]
24
+ }
25
+ }
26
+
27
+ didReceiveAttrs ( ) {
28
+ this . fetchUserTagsTask . perform ( )
29
+ }
30
+
31
+ @task fetchUserTagsTask = function * ( ) {
32
+ return yield this . store . query ( 'user-tag' , {
33
+ filter : {
34
+ user_id : this . userId
35
+ } ,
36
+ page : {
37
+ limit : 200
38
+ }
39
+ } )
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ <div class =" border-card" >
2
+ <h4 class =" t-align-c mb-4" >Topic-Vise Performance</h4 >
3
+
4
+ {{ #if chartData }}
5
+ <BarChart @data ={{ chartData }} />
6
+ {{ /if }}
7
+ </div >
Original file line number Diff line number Diff line change 12
12
@setOffset ={{ action ' setOffset' }} >
13
13
</SubmissionsHeatMapView >
14
14
15
+ <UserTagGraph class =" mb-5" @userId =" {{ user.id }} " />
16
+
15
17
<ProfileBadges
16
18
@userId ={{ user.id }} />
17
19
Original file line number Diff line number Diff line change
1
+ import { module , test } from 'qunit' ;
2
+ import { setupRenderingTest } from 'ember-qunit' ;
3
+ import { render } from '@ember/test-helpers' ;
4
+ import hbs from 'htmlbars-inline-precompile' ;
5
+
6
+ module ( 'Integration | Component | user-tag-graph' , function ( hooks ) {
7
+ setupRenderingTest ( hooks ) ;
8
+
9
+ test ( 'it renders' , async function ( assert ) {
10
+ // Set any properties with this.set('myProperty', 'value');
11
+ // Handle any actions with this.set('myAction', function(val) { ... });
12
+
13
+ await render ( hbs `<UserTagGraph />` ) ;
14
+
15
+ assert . equal ( this . element . textContent . trim ( ) , '' ) ;
16
+
17
+ // Template block usage:
18
+ await render ( hbs `
19
+ <UserTagGraph>
20
+ template block text
21
+ </UserTagGraph>
22
+ ` ) ;
23
+
24
+ assert . equal ( this . element . textContent . trim ( ) , 'template block text' ) ;
25
+ } ) ;
26
+ } ) ;
You can’t perform that action at this time.
0 commit comments