Skip to content

added profile page and got query working on homepage #1

Merged
merged 1 commit into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions final/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about"><img class="navImg" src="./assets/prof-link-placeholder.png"></router-link> |
<router-link to="/profile">Profile</router-link> |
<router-link to="/login" v-if="!authenticated">Log in</router-link>
<a href="#" v-if="authenticated" @click="$store.dispatch('signOut')"><img class="navImg" src="./assets/logout-placeholder.png"></a>
<div id="navSidebar">
Expand All @@ -24,8 +25,6 @@

</template>

<script src="https://www.gstatic.com/firebasejs/7.14.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.2/firebase-firestore.js"></script>
<script>
export default {
Expand Down
18 changes: 9 additions & 9 deletions final/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ new Vue({
}
}).$mount('#app')

var posts = new Vue ({
el: '#postList',
data: {
posts: [
{ message: 'first' },
{ message: 'second' },
{ message: 'third' }],
},
});
// var posts = new Vue ({
// el: '#postList',
// data: {
// posts: [
// { message: 'first' },
// { message: 'second' },
// { message: 'third' }],
// },
// });
7 changes: 6 additions & 1 deletion final/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import store from './store';
import Home from './views/Home.vue'
import About from './views/About.vue'
import Login from './views/Login.vue'
import Profile from './views/Profile.vue'


Vue.use(Router)
Expand All @@ -27,11 +28,15 @@ const router = new Router({
name: 'home',
component: Home
},

{
path: '/about',
name: 'about',
component: About
},
{
path: '/profile',
name: 'profile',
component: Profile
}
]
});
Expand Down
33 changes: 30 additions & 3 deletions final/src/views/Home.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<div class="home">

<ul id="postList">
<li v-for="(post, name, index) in posts" :key=index>{{ post.message }}</li>
</ul>

<PlaceholderTweets msg="still works?"/>
<!-- <PlaceholderTweets msg="still works?"/> -->

</div>

Expand All @@ -10,15 +14,38 @@
<script>
// @ is an alias to /src
import PlaceholderTweets from '@/components/PlaceholderTweets.vue'
// import PlaceholderTweets from '@/components/PlaceholderTweets.vue'
export default {
name: 'home',
data: function(){
return {
posts: []
}
},
components: {
PlaceholderTweets
// PlaceholderTweets
},
methods: {
getPosts(){
db.collection("posts").get().then(querySnapshot => {
querySnapshot.forEach( doc => {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
this.posts.unshift(doc.data())
});
});
}
},
// This runs when the page loads
mounted() {
// console.log(db);
this.getPosts();
}
};
</script>
38 changes: 38 additions & 0 deletions final/src/views/Profile.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<template>
<div class="about">
<h1>This is the profile page</h1>
<div>
{{ $store.state.user }}

</div>
</div>

</template>


<script>
// @ is an alias to /src
export default {
name: 'profile',
data: function(){
return {
}
},
methods: {
},
// This runs when the page loads
mounted() {
// console.log(db);
console.log(this.$store.state.user)
}
};
</script>