Преглед изворни кода

: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,7 +30,7 @@ section.w-flex.column.pb5
30 30
                     p {{ tabContent[item].tab }}
31 31
                     SpiderChart(
32 32
                         :labels='aspects.map(label => label.name)'
33
-                        :profile-data='aspects.map(data => data.percentage * 10)'
33
+                        :profile-data='profileScore'
34 34
                         :target-data='targetScore'
35 35
                         profile-name='lucy'
36 36
                         v-if='isTab'
@@ -62,6 +62,7 @@ section.w-flex.column.pb5
62 62
 
63 63
 <script>
64 64
 import SpiderChart from './SpiderChart.vue'
65
+import { currentProfile } from '../services'
65 66
 
66 67
 export default {
67 68
     components: { SpiderChart },
@@ -86,10 +87,19 @@ export default {
86 87
         },
87 88
     },
88 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 103
     methods: {
94 104
         onTabChanged(tabs) {
95 105
             this.$emit('tab-change', tabs)

+ 12
- 3
frontend/src/entities/card/card.js Прегледај датотеку

@@ -46,7 +46,7 @@ class Aspect {
46 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 50
     new Aspect({
51 51
         name: 'creativity',
52 52
         labels: ['creative', 'methodical'],
@@ -73,6 +73,15 @@ const cardAspects = [
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 86
  * Class representing a profile card
78 87
  * NOT to be confused with a profile
@@ -126,10 +135,10 @@ const makeCardFromProfile = profile => {
126 135
 
127 136
 
128 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 139
     if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
131 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 142
             return a 
134 143
         })
135 144
     }

+ 1
- 1
frontend/src/services/survey.service.js Прегледај датотеку

@@ -46,7 +46,7 @@ const scoreSurveyByProfileId = async (profileId, maxDistance = 99) => {
46 46
 }
47 47
 
48 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 52
 export {

+ 0
- 2
frontend/src/views/HomeView.vue Прегледај датотеку

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

Loading…
Откажи
Сачувај