Kaynağa Gözat

last save

tags/0.0.1
diaseu 4 yıl önce
ebeveyn
işleme
4ab6449cbe

+ 2
- 1
backend/db/data-generator/classes.js Dosyayı Görüntüle

@@ -3,7 +3,8 @@ class User {
3 3
         this.user_id = id
4 4
         this.user_name = ''
5 5
         this.user_email = ''
6
-        this.user_media = ''
6
+        // TODO: user_media
7
+        // this.user_media = ''
7 8
         this.is_admin = false
8 9
         this.is_poster = false
9 10
     }

+ 3
- 2
backend/db/data-generator/index.js Dosyayı Görüntüle

@@ -30,7 +30,7 @@ const write = async (batchNum, outputDataObject) => {
30 30
     await fs.writeFile(`${config.mockOutputPath}_${batchNum}.js`, '', () => {})
31 31
     fs.appendFile(
32 32
         `${config.mockOutputPath}_${batchNum}.js`,
33
-        config.header + 'export default ' + JSON.stringify(outputDataObject),
33
+        config.header + 'module.exports = ' + JSON.stringify(outputDataObject),
34 34
         err => {
35 35
             if (err) {
36 36
                 console.error(err)
@@ -72,7 +72,8 @@ const generateUsers = () => {
72 72
         for (let i=0; i < 3; i++) {
73 73
             mediaArray.push(random.media())
74 74
         }
75
-        user.user_media = mediaArray
75
+        // TODO: make this a table
76
+        // user.user_media = mediaArray
76 77
     })
77 78
     console.log('COMPLETED: Generated Users...')
78 79
     return users

+ 3
- 3
backend/knexfile.js Dosyayı Görüntüle

@@ -5,10 +5,10 @@ module.exports = {
5 5
         client: 'mysql',
6 6
         connection: {
7 7
             host: 'localhost',
8
-            port: 3306,
8
+            port: 3307,
9 9
             user: 'root',
10
-            password: 'root',
11
-            database: 'test',
10
+            password: 'potato',
11
+            database: 'potato',
12 12
         },
13 13
         pool: {
14 14
             min: 2,

+ 2
- 0
backend/lib/services/match.js Dosyayı Görüntüle

@@ -112,6 +112,8 @@ module.exports = class MatchService extends Schmervice.Service {
112 112
         // You only need to engage from one side
113 113
         engageEveryone(seekerPeople)
114 114
         engageEveryone(posterPeople)
115
+        // TODO: Test this, probably bug
116
+
115 117
         Object.values(peopleById).forEach(person => {
116 118
             if (person.fiance) {
117 119
                 person.fiance.fiance = null

+ 1
- 1
backend/lib/services/matchqueue.js Dosyayı Görüntüle

@@ -30,7 +30,7 @@ module.exports = class MatchQueueService extends Schmervice.Service {
30 30
             seeker: {},
31 31
         }
32 32
         queueEntries.forEach(entry => {
33
-            const type = entry.user.is_poster == 0 ? 'poster' : 'seeker'
33
+            const type = entry.user.is_poster == 1 ? 'poster' : 'seeker'
34 34
             if (!queueByProfileId[type][entry.profile_id]) {
35 35
                 queueByProfileId[type][entry.profile_id] = []
36 36
             }

+ 1
- 0
backend/server/manifest.js Dosyayı Görüntüle

@@ -80,6 +80,7 @@ module.exports = new Confidence.Store({
80 80
                                 user: process.env.DB_USER,
81 81
                                 password: process.env.DB_ROOT_PASSWORD,
82 82
                                 database: process.env.DB_NAME,
83
+                                port: 3307
83 84
                             },
84 85
                         },
85 86
                     },

+ 1
- 1
docker-compose.yml Dosyayı Görüntüle

@@ -10,7 +10,7 @@ services:
10 10
           MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
11 11
           MYSQL_DATABASE: "${DB_NAME}"
12 12
         ports:
13
-          - '3306:3306'
13
+          - '3307:3306'
14 14
 
15 15
 volumes:
16 16
     siimee_db:

+ 10
- 2
frontend/src/components/Messages.vue Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 <template lang="pug">
2 2
 .sidebar__messages
3
-  h4.message__title {{ title }}
3
+  h5.message__title {{ title }}
4 4
   router-link(
5 5
       :to="'/chats/' + user.uid" 
6 6
       v-for='user in users' 
@@ -38,6 +38,7 @@ export default {
38 38
     &__messages
39 39
         padding: 20px 10px
40 40
         /* overflow-y: scroll */
41
+        text-align: left
41 42
         a
42 43
             color: black
43 44
             text-decoration: none
@@ -55,13 +56,20 @@ export default {
55 56
             object-fit: cover
56 57
             width: 70px
57 58
             height: 70px
59
+            border-radius: 50%
58 60
 
59 61
 .message
60 62
     &__title
61 63
         color: #fd5068
64
+        text-transform: uppercase
62 65
         margin-bottom: 10px
63 66
     &__right
64 67
         margin-left: 10px
65 68
     &__name
66
-        margin-bottom: 10px
69
+        padding-top: 5px
70
+        font-weight: 600
71
+    &__content
72
+        padding-top: 10px
73
+        line-height: 1em
74
+        
67 75
 </style>

+ 12
- 2
frontend/src/components/Sidebar.vue Dosyayı Görüntüle

@@ -2,8 +2,9 @@
2 2
 
3 3
 aside.sidebar.p-1
4 4
     h3 Messages
5
-    input
6
-    label search
5
+    .search
6
+        input
7
+        label search
7 8
 
8 9
     messages(:title="title" :users="users")
9 10
 </template>
@@ -38,4 +39,13 @@ export default {
38 39
 aside.sidebar
39 40
     background-color: yellow
40 41
     height: 100vh
42
+    h3
43
+        padding: 2vh
44
+
45
+.search
46
+    display: flex
47
+    flex-direction: row
48
+    input
49
+        border: 0
50
+
41 51
 </style>

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

@@ -109,9 +109,14 @@ const isValid = step => {
109 109
 const next = e => {
110 110
     const validity = isValid(state.step - 1)
111 111
     if (validity.error) return console.error(validity.error)
112
-
112
+    // TODO: make steps work, 
113
+    // console.log('next', )
113 114
     // Save or next
114 115
     if (state.step === props.form.length) {
116
+        // TODO: call survey service
117
+        // TODO: in the survey service, create a save function
118
+        // call service from here, pass it profile id as argument
119
+        // profileId = answers['what-is-your-user-id']
115 120
         alert('saved...')
116 121
         resetAnswers()
117 122
         state.step = 1

+ 15
- 3
frontend/src/entities/survey/survey.js Dosyayı Görüntüle

@@ -3,14 +3,26 @@ import { _baseRecord } from '..'
3 3
 import { surveySchema } from './survey.schema'
4 4
 
5 5
 class Survey extends _baseRecord {
6
-    constructor(questionArray) {
6
+    constructor(questionSteps) {
7 7
         super()
8 8
 
9 9
         this.type = this.constructor.name.toLowerCase()
10 10
 
11 11
         /**  Fields */
12
-        this.steps = questionArray // ! required
13
-
12
+        this.steps = [
13
+            [
14
+                {
15
+                    id: 0,
16
+                    type: 'input-string',
17
+                    question: 'what is your user id',
18
+                    responses: null,
19
+                    description: null,
20
+                    category: null,
21
+                }
22
+            ],
23
+            ...Object.values(questionSteps),
24
+        ] // ! required
25
+        
14 26
         return this
15 27
     }
16 28
 

+ 78
- 45
frontend/src/services/survey.service.js Dosyayı Görüntüle

@@ -8,52 +8,85 @@ import { Survey } from '../entities/survey'
8 8
  * @param {number} profileId
9 9
  * @returns {array} instantiated Profile objects (see: /entites/profile)
10 10
  */
11
-const fetchSurveyByProfileId = profileId => {
12
-    // const surveyForProfileId = await db.get(`/user/${profileId}/profiles`)
13
-    const myquestions = [
14
-        [
15
-            {
16
-                id: 1,
17
-                type: 'input-string',
18
-                question: 'whats your favorite color',
19
-                responses: null,
20
-            },
21
-        ],
22
-        [
23
-            {
24
-                id: 2,
25
-                type: 'tag-cloud',
26
-                question: 'whats your favorite number',
27
-                responses: ['1', '2', '3'],
28
-            },
29
-        ],
30
-        [
31
-            {
32
-                id: 3,
33
-                type: 'checklist',
34
-                question: 'what is your current status',
35
-                responses: ['employed', 'unemployed', 'degenerate', 'alien'],
36
-            },
37
-        ],
38
-        [
39
-            {
40
-                id: 4,
41
-                type: 'slide',
42
-                question: 'choose a num',
43
-                responses: null,
44
-            },
45
-        ],
46
-        [
47
-            {
48
-                id: 5,
49
-                type: 'checklist',
50
-                question: 'pick a status',
51
-                responses: ['cry', 'sad', 'mad', 'numb'],
52
-            },
53
-        ],
54
-    ]
55
-    const mysurvey = new Survey(myquestions)
11
+const fetchSurveyByProfileId = async profileId => {
12
+    const myquestions = await db.get(`/survey/questions`)
13
+    // const myquestions = [
14
+    //     [
15
+    //         {
16
+    //             id: 1,
17
+    //             type: 'input-string',
18
+    //             question: 'whats your favorite color',
19
+    //             responses: null,
20
+    //         },
21
+    //     ],
22
+    // [
23
+    //     {
24
+    //     "response_key_id": 1,
25
+    //     "response_key_category": "grit",
26
+    //     "response_key_prompt": "what is your name",
27
+    //     "response_key_description": null
28
+    //     },
29
+    // ],
30
+    //     [
31
+    //         {
32
+    //             id: 2,
33
+    //             type: 'tag-cloud',
34
+    //             question: 'whats your favorite number',
35
+    //             responses: ['1', '2', '3'],
36
+    //         },
37
+    //     ],
38
+    //     [
39
+    //         {
40
+    //             id: 3,
41
+    //             type: 'checklist',
42
+    //             question: 'what is your current status',
43
+    //             responses: ['employed', 'unemployed', 'degenerate', 'alien'],
44
+    //         },
45
+    //     ],
46
+    //     [
47
+    //         {
48
+    //             id: 4,
49
+    //             type: 'slide',
50
+    //             question: 'choose a num',
51
+    //             responses: null,
52
+    //         },
53
+    //     ],
54
+    //     [
55
+    //         {
56
+    //             id: 5,
57
+    //             type: 'checklist',
58
+    //             question: 'pick a status',
59
+    //             responses: ['cry', 'sad', 'mad', 'numb'],
60
+    //         },
61
+    //     ],
62
+    // ]
63
+    const allsteps = { 'step-1': [], 'step-2': [], 'step-3': [], 'step-4': [] }
64
+    let counter = 0
65
+
66
+    for (let i = 0; i < myquestions.length; i++) {
67
+        const question = myquestions[i]
68
+        const reformatted = {
69
+            id: question.response_key_id,
70
+            type: 'input-string',
71
+            question: question.response_key_prompt,
72
+            responses: null,
73
+            description: question.response_key_description,
74
+            category: question.response_key_category,
75
+        }
76
+        counter = counter + 1
77
+        // TODO: check for step array before pushing
78
+        if (i < 4 * counter && i >= 4 * (counter - 1)) {
79
+            allsteps[`step-${counter}`].push(reformatted)
80
+        }
81
+    }
82
+    const mysurvey = new Survey(allsteps)
83
+
56 84
     return mysurvey
57 85
 }
58 86
 
87
+// TODO: saveSurveyByProfileID - needs await, db.post
88
+const saveSurveyByProfileID = async profileID => {
89
+    const myresponses = await db.post(`/${profileId}/respond`)
90
+}
91
+
59 92
 export { fetchSurveyByProfileId }

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

@@ -1,13 +1,18 @@
1 1
 <template lang="pug">
2
-article#profile
3
-    h1 Profile Page
2
+sidebar
3
+main.f-col.start.w-full
4
+    article#profile
5
+        h1 Profile Page
6
+    main-nav
4 7
 </template>
5 8
 
6 9
 <script>
7
-
10
+import sidebar from '../components/Sidebar.vue'
11
+import mainNav from '../components/MainNav.vue'
8 12
 
9 13
 export default {
10 14
     name: 'Profile',
15
+    components: { sidebar, mainNav },
11 16
     data() {
12 17
         return {
13 18
             requesting: false,

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

@@ -3,7 +3,7 @@ sidebar
3 3
 main.f-col.start.w-full
4 4
     article.match
5 5
         h1 Survey Page
6
-        siimeform(:form="validSurvey.steps")
6
+        siimeform(v-if="validSurvey && validSurvey.steps" :form="validSurvey.steps")
7 7
     mainNav
8 8
 </template>
9 9
 
@@ -15,8 +15,13 @@ import { fetchSurveyByProfileId } from '../services'
15 15
 
16 16
 export default {
17 17
     components: { siimeform, sidebar, mainNav },
18
-    computed: { 
19
-        validSurvey: () => fetchSurveyByProfileId(),
18
+    data() {
19
+        return { 
20
+            validSurvey: null,
21
+        }
22
+    },
23
+    async created() {
24
+        this.validSurvey = await fetchSurveyByProfileId()
20 25
     },
21 26
 }
22 27
 </script>

Loading…
İptal
Kaydet