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

profiles from generated batch; generator updated to include user_media

tags/0.0.1
diaseu пре 4 година
родитељ
комит
abc1ed1401

+ 1
- 0
backend/db/data-generator/classes.js Прегледај датотеку

3
         this.user_id = id
3
         this.user_id = id
4
         this.user_name = ''
4
         this.user_name = ''
5
         this.user_email = ''
5
         this.user_email = ''
6
+        this.user_media = ''
6
         this.is_admin = false
7
         this.is_admin = false
7
         this.is_poster = false
8
         this.is_poster = false
8
     }
9
     }

+ 2
- 2
backend/db/data-generator/config.js Прегледај датотеку

2
 const magic = 1000
2
 const magic = 1000
3
 
3
 
4
 // Insert here how many users you would like to generate:
4
 // Insert here how many users you would like to generate:
5
-const total = 20
6
-const batchSize = 10
5
+const total = 100
6
+const batchSize = 20
7
 
7
 
8
 // Amount of responses for a complete survey
8
 // Amount of responses for a complete survey
9
 const questions = 13
9
 const questions = 13

+ 8
- 1
backend/db/data-generator/index.js Прегледај датотеку

30
     await fs.writeFile(`${config.mockOutputPath}_${batchNum}.js`, '', () => {})
30
     await fs.writeFile(`${config.mockOutputPath}_${batchNum}.js`, '', () => {})
31
     fs.appendFile(
31
     fs.appendFile(
32
         `${config.mockOutputPath}_${batchNum}.js`,
32
         `${config.mockOutputPath}_${batchNum}.js`,
33
-        config.header + 'module.exports = ' + JSON.stringify(outputDataObject),
33
+        config.header + 'export default ' + JSON.stringify(outputDataObject),
34
         err => {
34
         err => {
35
             if (err) {
35
             if (err) {
36
                 console.error(err)
36
                 console.error(err)
67
         }
67
         }
68
         user.user_name = random.name() + ' ' + random.name()
68
         user.user_name = random.name() + ' ' + random.name()
69
         user.user_email = random.email()
69
         user.user_email = random.email()
70
+
71
+        var mediaArray = []
72
+        for (let i=0; i < 3; i++) {
73
+            
74
+        }
75
+
76
+        user.user_media = random.media()
70
     })
77
     })
71
     console.log('COMPLETED: Generated Users...')
78
     console.log('COMPLETED: Generated Users...')
72
     return users
79
     return users

+ 15
- 0
backend/db/data-generator/random.js Прегледај датотеку

30
     }
30
     }
31
     return str
31
     return str
32
 }
32
 }
33
+const randomMedia = max => {
34
+    const stockimg = [
35
+        'https://i.imgur.com/a4wirDS.png',
36
+        'https://i.imgur.com/F6GxGXG.jpeg',
37
+        'https://i.imgur.com/ekrkdNt.jpeg',
38
+        'https://i.imgur.com/VtMTfDg.jpeg',
39
+        'https://i.imgur.com/9Fwouqm.jpeg',
40
+        'https://i.imgur.com/rOjRCgo.jpeg',
41
+        'https://i.imgur.com/FwSdQww.jpeg',
42
+        'https://i.imgur.com/JjZyzXL.jpeg',
43
+
44
+    ]
45
+    return randomValFrom(stockimg)
46
+}
33
 
47
 
34
 module.exports = {
48
 module.exports = {
35
     number: randomNumber,
49
     number: randomNumber,
36
     valFrom: randomValFrom,
50
     valFrom: randomValFrom,
37
     email: randomEmail,
51
     email: randomEmail,
38
     name: randomName,
52
     name: randomName,
53
+    media: randomMedia
39
 }
54
 }

+ 22
- 16
frontend/src/components/ProfileCardList.vue Прегледај датотеку

3
     .profile_card_list_container.w-full
3
     .profile_card_list_container.w-full
4
         .swipe(
4
         .swipe(
5
             :config='config'
5
             :config='config'
6
-            :key='user.id'
7
-            @throwout='swipped(user)'
8
-            v-for='user in users'
6
+            :key='profile.profile_id'
7
+            @throwout='swipped(profile)'
8
+            v-for='profile in profiles'
9
         )
9
         )
10
             .card.b-solid.rounded.p-0.bg-cover(
10
             .card.b-solid.rounded.p-0.bg-cover(
11
-                :style='{ "background-image": `url(${user.avatar})` }'
11
+                :style='{ "background-image": `url(${profile.user.user_media})` }'
12
+                
12
             )
13
             )
13
                 .card__content
14
                 .card__content
14
-                    h3.p-1.mv-0.b-solid.rounded {{ user.name }}
15
+                    h3.p-1.mv-0.b-solid.rounded {{ profile.user.user_name }}
15
 
16
 
16
 </template>
17
 </template>
17
 
18
 
18
 <script>
19
 <script>
20
+
21
+
19
 export default {
22
 export default {
20
     name: 'ProfileCardList',
23
     name: 'ProfileCardList',
21
     props: {
24
     props: {
22
-        users: {
25
+        profiles: {
23
             type: [Object, Array],
26
             type: [Object, Array],
24
             default: () => [
27
             default: () => [
25
                 {
28
                 {
31
             ],
34
             ],
32
         },
35
         },
33
         uid: {
36
         uid: {
34
-            type: String,
35
-            default: '9999',
37
+            type: Number,
38
+            default: 1,
36
         },
39
         },
37
     },
40
     },
38
     data: () => ({
41
     data: () => ({
46
     }),
49
     }),
47
     computed: {
50
     computed: {
48
         currentCard() {
51
         currentCard() {
49
-            return this.users[this.users.length - 1]
52
+            return this.profiles[this.profiles.length - 1]
50
         },
53
         },
51
     },
54
     },
52
     created() {
55
     created() {
53
-        this.getUser()
56
+        this.getProfile()
54
     },
57
     },
55
     methods: {
58
     methods: {
56
         logOut() {},
59
         logOut() {},
57
         reject() {
60
         reject() {
58
             this.swipped(this.currentCard)
61
             this.swipped(this.currentCard)
59
         },
62
         },
60
-        swipped(user) {
61
-            const index = this.users.findIndex(u => u.uid == user.uid)
62
-            this.users.splice(index, 1)
63
-            user.id = Date.now() + (Math.random() * 100000).toFixed()
64
-            this.users.unshift({ ...user })
63
+        swipped(profile) {
64
+            const index = this.profiles.findIndex(u => u.uid == profile.uid)
65
+            this.profiles.splice(index, 1)
66
+            profile.id = Date.now() + (Math.random() * 100000).toFixed()
67
+            this.profiles.unshift({ ...profile })
65
         },
68
         },
66
-        getUser() {
69
+        getProfile() {
67
             return
70
             return
68
         },
71
         },
69
         onRequest() {
72
         onRequest() {
89
     max-width: 85vw
92
     max-width: 85vw
90
     height: 50vh
93
     height: 50vh
91
     background-position: center
94
     background-position: center
95
+    border-radius: 3vh
96
+    border: 1px solid #fff
92
     &_content
97
     &_content
93
         width: 100%
98
         width: 100%
94
         height: 100%
99
         height: 100%
95
     h3
100
     h3
96
         position: absolute
101
         position: absolute
97
         bottom: 0
102
         bottom: 0
103
+        color: #fff
98
 
104
 
99
 </style>
105
 </style>

+ 1
- 0
frontend/src/components/Sidebar.vue Прегледај датотеку

1
 <template lang="pug">
1
 <template lang="pug">
2
+
2
 aside.sidebar.p-1
3
 aside.sidebar.p-1
3
     h3 Messages
4
     h3 Messages
4
     input
5
     input

+ 56
- 20
frontend/src/views/home.vue Прегледај датотеку

1
 <template lang="pug">
1
 <template lang="pug">
2
 article#home
2
 article#home
3
-    profile-card-list(:uid='uid' :users='swipables')
3
+    h1(v-if="user") {{ user.user_name }}
4
+    profile-card-list(:uid='mypid' :profiles='swipables')
5
+    
6
+
4
 </template>
7
 </template>
5
 
8
 
6
 <script>
9
 <script>
7
 import profileCardList from '../components/ProfileCardList.vue'
10
 import profileCardList from '../components/ProfileCardList.vue'
11
+import batch20 from '../../../backend/db/generated/_batch_20.js'
8
 
12
 
9
 export default {
13
 export default {
10
     name: 'HomeView',
14
     name: 'HomeView',
11
     components: { profileCardList },
15
     components: { profileCardList },
12
     data: () => ({
16
     data: () => ({
13
-        swipables: [],
14
-        uid: null,
17
+        swipables: [   
18
+            // { 
19
+            //     user_id: 1, 
20
+            //     user: {
21
+            //         user_id: 20,
22
+            //         user_name: 'wravu pdjak',
23
+            //         user_email: '3vypx3qyj@aol.com',
24
+            //         is_admin: false,
25
+            //         is_poster: 1,
26
+            //     }, 
27
+            //     profile_id: 1 
28
+            // },
29
+        ],
30
+        user: null,
31
+        mypid: null,
15
     }),
32
     }),
16
     created() {
33
     created() {
17
-        // this.uid = auth.currentUser?.uid || "99999";
18
-        this.uid = '99999'
19
-        this.getUsers()
34
+        // this.mypid = auth.currentUser?.mypid || "99999";
35
+        this.mypid = 21
36
+        this.getBatch()
37
+        const myProfile = this.getProfilesfor(this.mypid)
38
+        this.user = this.getUserfromProfile(myProfile)
39
+        console.log('this.user', this.user)
20
     },
40
     },
21
     methods: {
41
     methods: {
22
-        getUsers() {
23
-            const users = [
24
-                {
25
-                    name: 'bob',
26
-                    id: 1234,
27
-                    metadata: { age: '21', rawMetadata: 'Some Text Here!' },
28
-                },
29
-                {
30
-                    name: 'rob',
31
-                    id: 1235,
32
-                    metadata: { age: '21', rawMetadata: 'Some Text Here!' },
33
-                },
34
-            ]
35
-            this.swipables = users
42
+        getBatch() {
43
+            const profiles = batch20.profiles
44
+            // .map is more readable
45
+            this.swipables = profiles.map((profile) => {
46
+                profile.user = this.getUserfromProfile(profile)
47
+                return profile
48
+            })
49
+            // for loop is faster
50
+            // const myList = []
51
+            // for (let profile in profiles) {
52
+            //     profile.user = this.getUserfromProfile(profile)
53
+            //     myList.push(profile)
54
+            // }
55
+            // this.swipables = myList
56
+            // before you store in 31, save user info per profile
57
+        },
58
+        getProfilesfor(pid) {
59
+            const profilesfromBatch = batch20.profiles
60
+            const profiles = profilesfromBatch.filter((profile) => {
61
+                return profile.profile_id === pid
62
+            })
63
+            return profiles[0]
36
         },
64
         },
65
+        getUserfromProfile(profile) {
66
+            const users = batch20.users
67
+            const usersProfile = users.filter((user) => {
68
+                return user.user_id === profile.user_id
69
+            })
70
+            return usersProfile[0]
71
+        }
72
+
37
     },
73
     },
38
 }
74
 }
39
 </script>
75
 </script>

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