Переглянути джерело

:construction: Dynamic chart data pending a new backend route

tags/0.0.3^2
juancarbajal98 3 роки тому
джерело
коміт
f32f9f43bc

+ 15
- 5
frontend/src/components/SummaryBar.vue Переглянути файл

30
                     p {{ tabContent[item].tab }}
30
                     p {{ tabContent[item].tab }}
31
                     SpiderChart(
31
                     SpiderChart(
32
                         :labels='aspects.map(label => label.name)'
32
                         :labels='aspects.map(label => label.name)'
33
-                        :profile-data='aspects.map(data => data.percentage * 10)'
33
+                        :profile-data='profileScore'
34
                         :target-data='targetScore'
34
                         :target-data='targetScore'
35
                         profile-name='lucy'
35
                         profile-name='lucy'
36
                         v-if='isTab'
36
                         v-if='isTab'
62
 
62
 
63
 <script>
63
 <script>
64
 import SpiderChart from './SpiderChart.vue'
64
 import SpiderChart from './SpiderChart.vue'
65
+import { currentProfile } from '../services'
65
 
66
 
66
 export default {
67
 export default {
67
     components: { SpiderChart },
68
     components: { SpiderChart },
86
         },
87
         },
87
     },
88
     },
88
     emits: ['tab-change'],
89
     emits: ['tab-change'],
89
-    data: () => ({
90
-        // profileScore: [5.7, 5.2, 4.8, 5.2, 4.9, 4.9], // lucy 
91
-        targetScore: [5.3, 4.8, 5.7, 4.8, 5.6, 4.8], // Role
92
-    }),
90
+    // data: () => ({
91
+    //     profileScore: [5.7, 5.2, 4.8, 5.2, 4.9, 4.9], // lucy 
92
+    //     targetScore: [5.3, 4.8, 5.7, 4.8, 5.6, 4.8], // Role
93
+    // }),
94
+    computed: {
95
+        profileScore(){ // take from built up aspects object
96
+            return this.aspects.map(data => data.percentage * .1) 
97
+        },
98
+        targetScore(){ // take directly from currentUser profile
99
+            let aspectResponses = currentProfile.responses.filter(r => [1,2,3,4,5,6].indexOf(r.response_key_id) !== -1)
100
+            return aspectResponses.map(r => r.val * .1)
101
+        }
102
+    },
93
     methods: {
103
     methods: {
94
         onTabChanged(tabs) {
104
         onTabChanged(tabs) {
95
             this.$emit('tab-change', tabs)
105
             this.$emit('tab-change', tabs)

+ 12
- 3
frontend/src/entities/card/card.js Переглянути файл

46
         this.percentage = percentage
46
         this.percentage = percentage
47
     }
47
     }
48
 }
48
 }
49
-const cardAspects = [
49
+const cardAspects = [ // TODO these aspects don't align with response_keys DB table
50
     new Aspect({
50
     new Aspect({
51
         name: 'creativity',
51
         name: 'creativity',
52
         labels: ['creative', 'methodical'],
52
         labels: ['creative', 'methodical'],
73
     }),
73
     }),
74
 ]
74
 ]
75
 
75
 
76
+const responseKeyIdToAspectName = {
77
+    1: 'vision',
78
+    2: 'creativity',
79
+    3: 'dynamism',
80
+    4: 'precision',
81
+    5: 'focus',
82
+    6: 'attention',
83
+}
84
+
76
 /**
85
 /**
77
  * Class representing a profile card
86
  * Class representing a profile card
78
  * NOT to be confused with a profile
87
  * NOT to be confused with a profile
126
 
135
 
127
 
136
 
128
     console.log(`RESP: ${profile?.responses}`)
137
     console.log(`RESP: ${profile?.responses}`)
129
-    let aspectResponses = profile?.responses.filter(r => r.response_id == 'aspect')
138
+    let aspectResponses = profile?.responses.filter(r => [1,2,3,4,5,6].indexOf(r.response_key_id) !== -1)
130
     if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
139
     if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
131
         c.aspects.map(a => {
140
         c.aspects.map(a => {
132
-            a.percentage = aspectResponses.find(r => r.response_key_id == a.name).val // depends on DB structure
141
+            a.percentage = aspectResponses.find(r => responseKeyIdToAspectName[r.response_key_id] == a.name).val 
133
             return a 
142
             return a 
134
         })
143
         })
135
     }
144
     }

+ 1
- 1
frontend/src/services/survey.service.js Переглянути файл

46
 }
46
 }
47
 
47
 
48
 const fetchResponsesByProfileId = async profileId => {
48
 const fetchResponsesByProfileId = async profileId => {
49
-    return await db.get(`/profile/${profileId}/responses`)
49
+    return await db.get(`/profile/${profileId}/responses`) // TODO write on backend, does not exist
50
 }
50
 }
51
 
51
 
52
 export {
52
 export {

+ 0
- 2
frontend/src/views/HomeView.vue Переглянути файл

1
 <template lang="pug">
1
 <template lang="pug">
2
 main.view--home
2
 main.view--home
3
-    p {{cP._profile.user_name}}
4
     article.w-flex.column.align-center
3
     article.w-flex.column.align-center
5
         template(v-if='isLoading')
4
         template(v-if='isLoading')
6
             w-spinner(bounce)
5
             w-spinner(bounce)
62
     },
61
     },
63
     mixins: [mixins.profileMixin],
62
     mixins: [mixins.profileMixin],
64
     computed: {
63
     computed: {
65
-        cP() {return currentProfile},
66
         cards() {
64
         cards() {
67
             return currentProfile.queue.map(qProfile => convertToCard(qProfile))
65
             return currentProfile.queue.map(qProfile => convertToCard(qProfile))
68
         },
66
         },

Завантаження…
Відмінити
Зберегти