Skip to content

Commit

Permalink
[REFACTOR] CommunityService ใช้ภาพ Default จาก Local ใน Assets และแสด…
Browse files Browse the repository at this point in the history
…ง My Owned Community
  • Loading branch information
wdrdres3qew5ts21 committed Nov 13, 2019
1 parent 901a86e commit a1df2cd
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ResponseEntity verifyIfPrivilegeStatus(
public ResponseEntity findAllCommunityOwnedByUser(
@PathVariable String uid,
@RequestParam(required = false, defaultValue = "0") int page,
@RequestParam(required = false, defaultValue = "20") int contentPerPage) {
@RequestParam(required = false, defaultValue = "10") int contentPerPage) {
return communityService.findAllCommunityOwnedByUser(uid, page, contentPerPage);
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions nuxt-firebase-auth-master/components/communityCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export default {
props: {
communityPictureCover: {
type: String,
default: "https://www.elegantthemes.com/blog/wp-content/uploads/2017/03/Facebook-Groups-for-Bloggers-shutterstock_555845587-ProStockStudio-FT.png"
default: require(`@/assets/default/community.png`)
},
communityName: String,
memberLists: Array
memberLists: Array,
}
};
</script>
Expand Down
5 changes: 2 additions & 3 deletions nuxt-firebase-auth-master/pages/community/_communityId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ export default {
imagePost: null,
postPictureListsUrl: [],
postPictureLists: null,
defaultImage:
"https://www.elegantthemes.com/blog/wp-content/uploads/2017/03/Facebook-Groups-for-Bloggers-shutterstock_555845587-ProStockStudio-FT.png",
defaultImage: require(`@/assets/default/community.png`),
remove: ["remove"],
post: "",
newPost: "",
Expand Down Expand Up @@ -731,7 +730,7 @@ export default {
`${process.env.COMMUNITY_SERVICE}/community/${this.communityId}/posts?page=${this.page}`
)
.then(postListResponse => {
if (postListResponse.data.content.length > 1) {
if (postListResponse.data.content.length > 0) {
postListResponse.data.content.forEach(post =>
this.postList.push(post)
);
Expand Down
4 changes: 2 additions & 2 deletions nuxt-firebase-auth-master/pages/community/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default {
communityName: "",
interestTags: [],
categoryList: [],
defaultImage: "https://www.elegantthemes.com/blog/wp-content/uploads/2017/03/Facebook-Groups-for-Bloggers-shutterstock_555845587-ProStockStudio-FT.png"
defaultImage: require(`@/assets/default/community.png`)
};
},
watch: {
Expand Down Expand Up @@ -182,7 +182,7 @@ export default {
`${process.env.COMMUNITY_SERVICE}/communitys?communityName=${this.communityName}${interestTags}&page=${this.page}`
)
.then(response => {
if (response.data.length > 1) {
if (response.data.length > 0) {
response.data.forEach(community =>
this.communityList.push(community)
);
Expand Down
80 changes: 59 additions & 21 deletions nuxt-firebase-auth-master/pages/community/myCommunity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
<div>
<br />
<h2>My Community</h2>
<community-card
v-for="(community, index) in communityList"
:key="index"
:communityPictureCover="community.communityPictureCover"
:communityName="community.communityName"
></community-card>
<div v-if="communityList.length>0">
<community-card
v-for="(community, index) in communityList"
:key="index"
:communityPictureCover="community.communityPictureCover==undefined?defaultImage: community.communityPictureCover"
:communityName="community.communityName"
></community-card>
<client-only>
<infinite-loading spinner="spiral" @infinite="infiniteScroll">
<!-- <div slot="no-results">
<v-btn color="primary" block>Go to Top</v-btn>
</div>-->
</infinite-loading>
</client-only>
</div>
</div>
</template>
<script>
import CommunityCard from "@/components/communityCard";
import axios from "axios";
import { mapGetters } from "vuex";
import {
mockCarouselsPhoto,
mockCommunityList,
Expand All @@ -21,28 +31,56 @@ import {
export default {
data() {
return {
communityList: []
communityList: [],
page: 0,
defaultImage: require(`@/assets/default/community.png`)
};
},
components: {
CommunityCard
},
computed: {
...mapGetters(["getUser"])
},
mounted() {
this.communityList = mockCommunityList;
// this.communityList = mockCommunityList;
this.loadMyOwnedCommunity()
},
loadMyOwnedCommunity() {
axios
.get(
`${process.env.COMMUNITY_SERVICE}/community/${this.communityId}/privilege/status`
)
.then(subscribeCommunityResponse => {
this.isSubscribe = subscribeCommunityResponse.data.isSubscribe;
this.isOwner = subscribeCommunityResponse.data.isOwner;
loader.hide();
})
.catch(err => {
loader.hide();
});
methods: {
loadMyOwnedCommunity() {
axios
.get(
`${process.env.COMMUNITY_SERVICE}/communitys/admin/user/${this.getUser.uid}`
)
.then(ownedCommunityList => {
this.communityList = ownedCommunityList.data.content
console.log(ownedCommunityList.data)
})
.catch(err => {
});
},
infiniteScroll($state) {
setTimeout(() => {
this.page++;
axios
.get(
`${process.env.COMMUNITY_SERVICE}/communitys/admin/user/${this.getUser.uid}?page=${this.page}`
)
.then(ownedCommunityList => {
if (ownedCommunityList.data.content.length > 0) {
ownedCommunityList.data.content.forEach(community =>
this.communityList.push(community)
);
$state.loaded();
} else {
$state.complete();
}
})
.catch(err => {
console.log(err);
});
}, 500);
}
}
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
{
communityDetail: [
{
communityPictureCover: "",
communityPictureCover: require(`@/assets/default/community.png`),
communityName: ""
}
]
Expand Down

0 comments on commit a1df2cd

Please sign in to comment.