Ver código fonte

:recycle: cleaning up some loading confusion | sprinkling in more organized logs | moving around some func calls and components

tags/0.0.3^2
j 3 anos atrás
pai
commit
a30af96ce3

+ 12
- 9
frontend/src/App.vue Ver arquivo

1
 <template lang="pug">
1
 <template lang="pug">
2
 w-app 
2
 w-app 
3
-    TopNav(@on-open="openDrawer = !openDrawer")
3
+    TopNav(@on-open='openDrawer = !openDrawer')
4
 
4
 
5
-    w-drawer(v-model="openDrawer")
6
-        SideBar(@updatePid="setPid" :pid="profile.id.value")
7
-        
8
-    RouterView(
9
-        @updatePid="setPid"
10
-    )
5
+    w-drawer(v-model='openDrawer')
6
+        SideBar(:pid='profile.id.value' @updatePid='setPid')
7
+
8
+    RouterView(@updatePid='setPid')
11
 </template>
9
 </template>
12
 
10
 
13
 <script>
11
 <script>
18
 import { currentProfile } from './services'
16
 import { currentProfile } from './services'
19
 import { surveyFactory } from './utils'
17
 import { surveyFactory } from './utils'
20
 
18
 
21
-// const DEV_MODE = import.meta.env.VITE_DEV == 'true'
22
-const DEV_MODE = false
19
+const DEV_MODE = import.meta.env.VITE_DEV == 'true'
23
 const DEV_PID = 45
20
 const DEV_PID = 45
24
 
21
 
25
 export default {
22
 export default {
43
          * using the login form
40
          * using the login form
44
          */
41
          */
45
         if (DEV_MODE) {
42
         if (DEV_MODE) {
43
+            console.info('===============================================')
44
+            console.info('-                   SIIMEE                    -')
45
+            console.info('-----------------------------------------------')
46
+            console.info('[Siimee App]: You are in development mode:', DEV_MODE)
47
+            console.info('[Siimee App]: Starting application...')
48
+            console.info('-----------------------------------------------')
46
             await this.setPid(DEV_PID)
49
             await this.setPid(DEV_PID)
47
         }
50
         }
48
     },
51
     },

+ 1
- 1
frontend/src/components/onboarding/Aspects.vue Ver arquivo

6
         | SUBMIT ANSWERS
6
         | SUBMIT ANSWERS
7
 </template>
7
 </template>
8
 <script>
8
 <script>
9
-import QuestionResponse from '../QuestionResponse.vue'
9
+import QuestionResponse from './QuestionResponse.vue'
10
 
10
 
11
 export default {
11
 export default {
12
     name: 'Aspects',
12
     name: 'Aspects',

frontend/src/components/QuestionResponse.vue → frontend/src/components/onboarding/QuestionResponse.vue Ver arquivo


+ 19
- 7
frontend/src/router/guards.js Ver arquivo

1
 import { currentProfile } from '../services'
1
 import { currentProfile } from '../services'
2
 
2
 
3
+const DEV_MODE = import.meta.env.VITE_DEV == 'true'
3
 
4
 
4
-const checkLoginStatus = (destination, nextCb) => {
5
-    if(!currentProfile.isLoggedIn || !currentProfile.isComplete) {
6
-        console.warn(`profile: ${currentProfile.id.value} | login: ${currentProfile.isLoggedIn} | completed: ${currentProfile.isComplete}`)
5
+async function log(to) {
6
+    if (DEV_MODE) {
7
+        if (!currentProfile.isLoggedIn || !currentProfile.isComplete) {
8
+            console.info(
9
+                `[Guard Status debug]: Profile: ${currentProfile.id.value} | Login: ${currentProfile.isLoggedIn} | Complete: ${currentProfile.isComplete}`,
10
+            )
11
+        }
12
+        console.info('[Guard Status debug]: being routed to:', to.fullPath)
7
     }
13
     }
8
-    if (
14
+}
15
+
16
+const checkLoginStatus = (destination, nextCb) => {
17
+    log(destination)
18
+    if (DEV_MODE) {
19
+        nextCb()
20
+    } else if (
9
         destination.meta.requiresCompleteProfile &&
21
         destination.meta.requiresCompleteProfile &&
10
         !currentProfile.isLoggedIn &&
22
         !currentProfile.isLoggedIn &&
11
-        !currentProfile.isComplete 
23
+        !currentProfile.isComplete
12
     ) {
24
     ) {
13
         nextCb('onboarding')
25
         nextCb('onboarding')
14
-    } else if(
26
+    } else if (
15
         destination.meta.requiresCompleteProfile &&
27
         destination.meta.requiresCompleteProfile &&
16
         destination.meta.requiresAuth &&
28
         destination.meta.requiresAuth &&
17
         !currentProfile.isLoggedIn
29
         !currentProfile.isLoggedIn
22
     }
34
     }
23
 }
35
 }
24
 
36
 
25
-export { checkLoginStatus }
37
+export { checkLoginStatus }

+ 12
- 0
frontend/src/router/index.js Ver arquivo

69
         name: `LoginView`,
69
         name: `LoginView`,
70
         meta: { requiresAuth: false, requiresCompleteProfile: false },
70
         meta: { requiresAuth: false, requiresCompleteProfile: false },
71
     },
71
     },
72
+    {
73
+        path: `/settings`,
74
+        component: HomeView,
75
+        name: `SettingsView`,
76
+        meta: { requiresAuth: false, requiresCompleteProfile: false },
77
+    },
78
+    {
79
+        path: `/search`,
80
+        component: HomeView,
81
+        name: `SearchView`,
82
+        meta: { requiresAuth: false, requiresCompleteProfile: false },
83
+    },
72
 ]
84
 ]
73
 
85
 
74
 const router = createRouter({
86
 const router = createRouter({

+ 7
- 4
frontend/src/services/login.service.js Ver arquivo

73
     async login(profileId, cb) {
73
     async login(profileId, cb) {
74
         this._loading.value = true
74
         this._loading.value = true
75
 
75
 
76
-        console.warn('logging in:', profileId)
76
+        console.warn('[Login Service warn]: Logging in:', profileId)
77
         this.id.value = parseInt(profileId)
77
         this.id.value = parseInt(profileId)
78
 
78
 
79
         await this.getGroupings()
79
         await this.getGroupings()
82
         this.setupToaster(cb)
82
         this.setupToaster(cb)
83
 
83
 
84
         this._loading.value = false
84
         this._loading.value = false
85
-        console.warn('logged in:', this.isLoggedIn)
86
-        console.warn('subscribed to:', this.chatter.subscriptions)
85
+        console.warn('[Login Service warn]: Login SUCCESSFUL')
86
+        console.warn(
87
+            `[Login Service warn]: ${profileId} subscribed to:`,
88
+            this.chatter.subscriptions,
89
+        )
87
         return this.id.value
90
         return this.id.value
88
     }
91
     }
89
     logout() {
92
     logout() {
90
-        console.warn('logging out:', this.id.value)
93
+        console.warn('[Login Service warn]: Logging out:', this.id.value)
91
         this.id.value = null
94
         this.id.value = null
92
         if (this.toaster) {
95
         if (this.toaster) {
93
             this.toaster.stop()
96
             this.toaster.stop()

+ 1
- 1
frontend/src/services/queue.service.js Ver arquivo

12
     try {
12
     try {
13
         queue = await db.get(`/profile/${profileId}/queue?include_profile=true`)
13
         queue = await db.get(`/profile/${profileId}/queue?include_profile=true`)
14
         if (!queue?.length) {
14
         if (!queue?.length) {
15
-            throw 'Could not retrieve match queue. Please take the survey and rescore.'
15
+            throw '[Queue Service]: Could not retrieve match queue. Please take the survey and rescore.'
16
         }
16
         }
17
     } catch (err) {
17
     } catch (err) {
18
         console.error(err)
18
         console.error(err)

+ 0
- 3
frontend/src/utils/mixins.js Ver arquivo

20
             this.getCards()
20
             this.getCards()
21
         },
21
         },
22
     },
22
     },
23
-    async created() {
24
-        await this.getCards()
25
-    },
26
     methods: {
23
     methods: {
27
         _reformat(data, mapCb) {
24
         _reformat(data, mapCb) {
28
             return data.map(mapCb)
25
             return data.map(mapCb)

+ 16
- 18
frontend/src/views/HomeView.vue Ver arquivo

1
 <template lang="pug">
1
 <template lang="pug">
2
 main.view--home
2
 main.view--home
3
     article(v-if='cards.length && !loading')
3
     article(v-if='cards.length && !loading')
4
-        ProfileCardList(:pid='pid' :cards='cards' @reload='getCards')
4
+        ProfileCardList(:cards='cards' :pid='pid' @reload='getCards')
5
 
5
 
6
     p(v-else-if='cards.length === 0') No profiles in match_queue.
6
     p(v-else-if='cards.length === 0') No profiles in match_queue.
7
-    w-spinner(v-else bounce)
7
+    w-spinner(bounce v-else)
8
 
8
 
9
     MainNav
9
     MainNav
10
 </template>
10
 </template>
20
 import { Card } from '../entities'
20
 import { Card } from '../entities'
21
 
21
 
22
 import {
22
 import {
23
+    currentProfile,
23
     fetchQueueByProfileId,
24
     fetchQueueByProfileId,
24
     fetchMembershipsByProfileId,
25
     fetchMembershipsByProfileId,
25
-    currentProfile,
26
 } from '../services'
26
 } from '../services'
27
 import { mixins } from '../utils'
27
 import { mixins } from '../utils'
28
 
28
 
41
     })
41
     })
42
 }
42
 }
43
 
43
 
44
-const converGroupingToCard = grouping => {
44
+const convertGroupingToCard = grouping => {
45
     if (grouping.type !== 'grouping') {
45
     if (grouping.type !== 'grouping') {
46
         console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
46
         console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
47
     }
47
     }
64
         SummaryBar,
64
         SummaryBar,
65
         PairingButton,
65
         PairingButton,
66
     },
66
     },
67
-    mixins: [mixins.pidMixin, mixins.cardMixin],
67
+    mixins: [mixins.cardMixin],
68
     methods: {
68
     methods: {
69
         /** Gets called from cardMixin */
69
         /** Gets called from cardMixin */
70
         async getCards() {
70
         async getCards() {
71
+            if (!currentProfile.isLoggedIn) {
72
+                console.error(
73
+                    '[Home View]: Profile not logged in or has problem loading',
74
+                )
75
+                console.error('[Home View]: Profile error:', currentProfile)
76
+                return
77
+            }
71
             this.loading = true
78
             this.loading = true
79
+            const pid = currentProfile.id
72
             try {
80
             try {
73
-                const queueList = await fetchQueueByProfileId(this.pid)
81
+                const queueList = await fetchQueueByProfileId(pid)
74
                 this.cards = this._reformat(queueList, convertToCard)
82
                 this.cards = this._reformat(queueList, convertToCard)
75
-                const matchList = await fetchMembershipsByProfileId(this.pid)
76
-                this.matches = this._reformat(matchList, converGroupingToCard)
83
+                const matchList = await fetchMembershipsByProfileId(pid)
84
+                this.matches = this._reformat(matchList, convertGroupingToCard)
77
             } catch (err) {
85
             } catch (err) {
78
                 console.error(err)
86
                 console.error(err)
79
             }
87
             }
80
             this.loading = false
88
             this.loading = false
81
         },
89
         },
82
         // this can be placed in utils/notification.js
90
         // this can be placed in utils/notification.js
83
-
84
         notify(payload) {
91
         notify(payload) {
85
             this.$waveui.notify({
92
             this.$waveui.notify({
86
                 message: payload,
93
                 message: payload,
94
                 icon: 'wi-star',
101
                 icon: 'wi-star',
95
             })
102
             })
96
         },
103
         },
97
-        //  a way to send a message to a user for development purposes and testing
98
-        async chat() {
99
-            const chatter = currentProfile.chatter
100
-            const res = await chatter.publish(chatter.subscriptions[0], {
101
-                title: 'New Message',
102
-                description: 'This is a new message',
103
-            })
104
-            this.notify(res)
105
-        },
106
     },
104
     },
107
 }
105
 }
108
 </script>
106
 </script>

+ 13
- 20
frontend/src/views/OnboardingView.vue Ver arquivo

1
 <template lang="pug">
1
 <template lang="pug">
2
 main.view--onboarding
2
 main.view--onboarding
3
-    article(style="display: flex;flex-direction: column;align-items: center;")
3
+    article(style='display: flex; flex-direction: column; align-items: center')
4
         component(
4
         component(
5
-            :is="onboardingStep.component"
6
-            :currentStep="currentStep"
7
-            :aspectQuestions="onboardingStep.component == 'Aspects'? aspectQuestions : null"
8
-            @go-to-step="goToStep"
9
-            @handle-submit="onboardingStep.component == 'Aspects'? onSubmit : null"
5
+            :aspectQuestions='onboardingStep.component == "Aspects" ? aspectQuestions : null'
6
+            :currentStep='currentStep'
7
+            :is='onboardingStep.component'
8
+            @go-to-step='goToStep'
9
+            @handle-submit='onboardingStep.component == "Aspects" ? onSubmit : null'
10
         )
10
         )
11
-        //- form(@submit.prevent="onSubmit").questionnaire
12
-        //-     QuestionResponse(v-for="question in questions" :question="question" @updated="onUpdate")
13
-        //-     w-button.ma1.grow(type="submit" bg-color="success")
14
-        //-         w-icon.mr1 wi-check
15
-        //-         | SUBMIT ANSWERS
16
     //- MainNav
11
     //- MainNav
17
 </template>
12
 </template>
18
 
13
 
22
 import stepViews from '@/components/onboarding'
17
 import stepViews from '@/components/onboarding'
23
 import OnboardingStepComponents from '../utils/onboardingStepComponents'
18
 import OnboardingStepComponents from '../utils/onboardingStepComponents'
24
 
19
 
25
-// import QuestionResponse from '../components/QuestionResponse.vue'
26
 const SCORED = [1, 2, 3, 4, 5, 6] // consider expanding + modifying DB table
20
 const SCORED = [1, 2, 3, 4, 5, 6] // consider expanding + modifying DB table
27
 const _isScored = id => SCORED.includes(id)
21
 const _isScored = id => SCORED.includes(id)
28
 
22
 
52
 // paginate to save every steps answers
46
 // paginate to save every steps answers
53
 export default {
47
 export default {
54
     name: 'OnboardingView',
48
     name: 'OnboardingView',
55
-    components: { 
49
+    components: {
56
         ...stepViews,
50
         ...stepViews,
57
-        // QuestionResponse 
58
-        },
51
+    },
59
     data: () => {
52
     data: () => {
60
         return {
53
         return {
61
             answered: {},
54
             answered: {},
65
             validSurvey: null,
58
             validSurvey: null,
66
         }
59
         }
67
     },
60
     },
68
-    computed : {
69
-        onboardingStep(){
70
-            if(!this.onboardingStepComponents.length) return []
61
+    computed: {
62
+        onboardingStep() {
63
+            if (!this.onboardingStepComponents.length) return []
71
             return this.onboardingStepComponents[this.currentStep]
64
             return this.onboardingStepComponents[this.currentStep]
72
-        }
65
+        },
73
     },
66
     },
74
     async created() {
67
     async created() {
75
         const survey = await surveyFactory.createSurvey(
68
         const survey = await surveyFactory.createSurvey(
89
                 console.log(ans.question, ans.answer),
82
                 console.log(ans.question, ans.answer),
90
             )
83
             )
91
         },
84
         },
92
-        goToStep(num){
85
+        goToStep(num) {
93
             this.currentStep = num
86
             this.currentStep = num
94
         },
87
         },
95
     },
88
     },

+ 7
- 8
frontend/src/views/PairsView.vue Ver arquivo

78
     width: 100%
78
     width: 100%
79
     margin: 0 auto
79
     margin: 0 auto
80
     background-color: #1F2024
80
     background-color: #1F2024
81
-    .w-tabs__bar-item
82
-        height: 50px
83
-        font-family: 'Century Gothic'
84
-        color: #FFFFFF
85
-        &.w-tabs__bar-item--active
86
-        &.primary
87
-            color: #F2CD5C
81
+    .w-tabs
82
+        &__bar-item
83
+            height: 50px
84
+            font-family: 'Century Gothic'
85
+            color: #FFFFFF
86
+            &.primary
87
+                color: #F2CD5C
88
     .select--matches
88
     .select--matches
89
         display: flex
89
         display: flex
90
         justify-content: space-between
90
         justify-content: space-between
97
     .active
97
     .active
98
         border-bottom: 3px solid #f2cd5c
98
         border-bottom: 3px solid #f2cd5c
99
         color: #f2cd5c
99
         color: #f2cd5c
100
-
101
     .idle
100
     .idle
102
         color: #bcc5d3
101
         color: #bcc5d3
103
 </style>
102
 </style>

Carregando…
Cancelar
Salvar