Kaynağa Gözat

: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 yıl önce
ebeveyn
işleme
a30af96ce3

+ 12
- 9
frontend/src/App.vue Dosyayı Görüntüle

@@ -1,13 +1,11 @@
1 1
 <template lang="pug">
2 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 9
 </template>
12 10
 
13 11
 <script>
@@ -18,8 +16,7 @@ import TopNav from './components/TopNav.vue'
18 16
 import { currentProfile } from './services'
19 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 20
 const DEV_PID = 45
24 21
 
25 22
 export default {
@@ -43,6 +40,12 @@ export default {
43 40
          * using the login form
44 41
          */
45 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 49
             await this.setPid(DEV_PID)
47 50
         }
48 51
     },

+ 1
- 1
frontend/src/components/onboarding/Aspects.vue Dosyayı Görüntüle

@@ -6,7 +6,7 @@ form(@submit.prevent="this.$emit('handle-submit')").questionnaire
6 6
         | SUBMIT ANSWERS
7 7
 </template>
8 8
 <script>
9
-import QuestionResponse from '../QuestionResponse.vue'
9
+import QuestionResponse from './QuestionResponse.vue'
10 10
 
11 11
 export default {
12 12
     name: 'Aspects',

frontend/src/components/QuestionResponse.vue → frontend/src/components/onboarding/QuestionResponse.vue Dosyayı Görüntüle


+ 19
- 7
frontend/src/router/guards.js Dosyayı Görüntüle

@@ -1,17 +1,29 @@
1 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 21
         destination.meta.requiresCompleteProfile &&
10 22
         !currentProfile.isLoggedIn &&
11
-        !currentProfile.isComplete 
23
+        !currentProfile.isComplete
12 24
     ) {
13 25
         nextCb('onboarding')
14
-    } else if(
26
+    } else if (
15 27
         destination.meta.requiresCompleteProfile &&
16 28
         destination.meta.requiresAuth &&
17 29
         !currentProfile.isLoggedIn
@@ -22,4 +34,4 @@ const checkLoginStatus = (destination, nextCb) => {
22 34
     }
23 35
 }
24 36
 
25
-export { checkLoginStatus }
37
+export { checkLoginStatus }

+ 12
- 0
frontend/src/router/index.js Dosyayı Görüntüle

@@ -69,6 +69,18 @@ const routes = [
69 69
         name: `LoginView`,
70 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 86
 const router = createRouter({

+ 7
- 4
frontend/src/services/login.service.js Dosyayı Görüntüle

@@ -73,7 +73,7 @@ class Login {
73 73
     async login(profileId, cb) {
74 74
         this._loading.value = true
75 75
 
76
-        console.warn('logging in:', profileId)
76
+        console.warn('[Login Service warn]: Logging in:', profileId)
77 77
         this.id.value = parseInt(profileId)
78 78
 
79 79
         await this.getGroupings()
@@ -82,12 +82,15 @@ class Login {
82 82
         this.setupToaster(cb)
83 83
 
84 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 90
         return this.id.value
88 91
     }
89 92
     logout() {
90
-        console.warn('logging out:', this.id.value)
93
+        console.warn('[Login Service warn]: Logging out:', this.id.value)
91 94
         this.id.value = null
92 95
         if (this.toaster) {
93 96
             this.toaster.stop()

+ 1
- 1
frontend/src/services/queue.service.js Dosyayı Görüntüle

@@ -12,7 +12,7 @@ const fetchQueueByProfileId = async profileId => {
12 12
     try {
13 13
         queue = await db.get(`/profile/${profileId}/queue?include_profile=true`)
14 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 17
     } catch (err) {
18 18
         console.error(err)

+ 0
- 3
frontend/src/utils/mixins.js Dosyayı Görüntüle

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

+ 16
- 18
frontend/src/views/HomeView.vue Dosyayı Görüntüle

@@ -1,10 +1,10 @@
1 1
 <template lang="pug">
2 2
 main.view--home
3 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 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 9
     MainNav
10 10
 </template>
@@ -20,9 +20,9 @@ import PairingButton from '../components/PairingButton.vue'
20 20
 import { Card } from '../entities'
21 21
 
22 22
 import {
23
+    currentProfile,
23 24
     fetchQueueByProfileId,
24 25
     fetchMembershipsByProfileId,
25
-    currentProfile,
26 26
 } from '../services'
27 27
 import { mixins } from '../utils'
28 28
 
@@ -41,7 +41,7 @@ const convertToCard = profile => {
41 41
     })
42 42
 }
43 43
 
44
-const converGroupingToCard = grouping => {
44
+const convertGroupingToCard = grouping => {
45 45
     if (grouping.type !== 'grouping') {
46 46
         console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
47 47
     }
@@ -64,23 +64,30 @@ export default {
64 64
         SummaryBar,
65 65
         PairingButton,
66 66
     },
67
-    mixins: [mixins.pidMixin, mixins.cardMixin],
67
+    mixins: [mixins.cardMixin],
68 68
     methods: {
69 69
         /** Gets called from cardMixin */
70 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 78
             this.loading = true
79
+            const pid = currentProfile.id
72 80
             try {
73
-                const queueList = await fetchQueueByProfileId(this.pid)
81
+                const queueList = await fetchQueueByProfileId(pid)
74 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 85
             } catch (err) {
78 86
                 console.error(err)
79 87
             }
80 88
             this.loading = false
81 89
         },
82 90
         // this can be placed in utils/notification.js
83
-
84 91
         notify(payload) {
85 92
             this.$waveui.notify({
86 93
                 message: payload,
@@ -94,15 +101,6 @@ export default {
94 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 106
 </script>

+ 13
- 20
frontend/src/views/OnboardingView.vue Dosyayı Görüntüle

@@ -1,18 +1,13 @@
1 1
 <template lang="pug">
2 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 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 11
     //- MainNav
17 12
 </template>
18 13
 
@@ -22,7 +17,6 @@ import { allSteps, possible } from '@/utils/lang'
22 17
 import stepViews from '@/components/onboarding'
23 18
 import OnboardingStepComponents from '../utils/onboardingStepComponents'
24 19
 
25
-// import QuestionResponse from '../components/QuestionResponse.vue'
26 20
 const SCORED = [1, 2, 3, 4, 5, 6] // consider expanding + modifying DB table
27 21
 const _isScored = id => SCORED.includes(id)
28 22
 
@@ -52,10 +46,9 @@ const _formatAspectQuestions = steps => {
52 46
 // paginate to save every steps answers
53 47
 export default {
54 48
     name: 'OnboardingView',
55
-    components: { 
49
+    components: {
56 50
         ...stepViews,
57
-        // QuestionResponse 
58
-        },
51
+    },
59 52
     data: () => {
60 53
         return {
61 54
             answered: {},
@@ -65,11 +58,11 @@ export default {
65 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 64
             return this.onboardingStepComponents[this.currentStep]
72
-        }
65
+        },
73 66
     },
74 67
     async created() {
75 68
         const survey = await surveyFactory.createSurvey(
@@ -89,7 +82,7 @@ export default {
89 82
                 console.log(ans.question, ans.answer),
90 83
             )
91 84
         },
92
-        goToStep(num){
85
+        goToStep(num) {
93 86
             this.currentStep = num
94 87
         },
95 88
     },

+ 7
- 8
frontend/src/views/PairsView.vue Dosyayı Görüntüle

@@ -78,13 +78,13 @@ export default {
78 78
     width: 100%
79 79
     margin: 0 auto
80 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 88
     .select--matches
89 89
         display: flex
90 90
         justify-content: space-between
@@ -97,7 +97,6 @@ export default {
97 97
     .active
98 98
         border-bottom: 3px solid #f2cd5c
99 99
         color: #f2cd5c
100
-
101 100
     .idle
102 101
         color: #bcc5d3
103 102
 </style>

Loading…
İptal
Kaydet