Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Permupop committed Nov 13, 2019
2 parents e9a58b9 + a1df2cd commit 5336361
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ public ResponseEntity verifyIfPrivilegeStatus(
return communityService.verifyIfPrivilegeStatus(token, organizeId);
}

// @GetMapping("/community/{organizeId}/privilege/status")
// public ResponseEntity verifyIfPrivilegeStatus(
// @RequestHeader(required = true, name = "Authorization") String token,
// @PathVariable String organizeId) {
// return communityService.verifyIfPrivilegeStatus(token, organizeId);
// }

@GetMapping("/communitys/user/{uid}")
@GetMapping("/communitys/admin/user/{uid}")
public ResponseEntity findAllCommunityOwnedByUser(
@PathVariable String uid,
@RequestParam(required = false, defaultValue = "0") int page,
@RequestParam(required = false, defaultValue = "10") int contentPerPage) {
return communityService.findAllCommunityOwnedByUser(uid, page, contentPerPage);
}

@GetMapping("/communitys/subscribe/user/{uid}")
public ResponseEntity findAllCommunityThatUserSubscribe(
@PathVariable String uid,
@RequestParam(required = false, defaultValue = "0") int page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class User {

private String role;

@Indexed
private String uid;

private String email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ public interface CommunityRepository extends MongoRepository<Community, String>{
public Page<Community> findByInterestTagsIsIn(String[] interestTags, PageRequest of);

public Optional<Community> findByCommunityId(String communityId);

public Page<Community> findByCommunityOwnerUid(String uid, PageRequest of);

}
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public ResponseEntity verifyIfPrivilegeStatus(String token, String communityId)
UserCommunity subscribedCommunity = userCommunityRepository.findByUidAndCommunityId(uid, communityId);
Community communityInDatabase = communityRepository.findByCommunityId(communityId).get();
if (uid.equals(communityInDatabase.getCommunityOwner().getUid())) {
response.put("isAdmin", true);
response.put("isOwner", true);
}
if (subscribedCommunity != null) {
response.put("isSubscribe", true);
Expand Down Expand Up @@ -339,4 +339,8 @@ public ResponseEntity updateCommunity(String token, String communityId, Communit
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response);
}

public ResponseEntity findAllCommunityOwnedByUser(String uid, int page, int contentPerPage) {
return new ResponseEntity(communityRepository.findByCommunityOwnerUid(uid, PageRequest.of(page, contentPerPage)), HttpStatus.OK);
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions nuxt-firebase-auth-master/components/communityCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
export default {
name: "CommunityCard",
props: {
communityPictureCover: String,
communityPictureCover: {
type: String,
default: require(`@/assets/default/community.png`)
},
communityName: String,
memberLists: Array
memberLists: Array,
}
};
</script>
Expand Down
50 changes: 41 additions & 9 deletions nuxt-firebase-auth-master/pages/community/_communityId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
</div>
</v-card>

<div v-for="(post ) in newPostList" :key="post.postId">
<div v-for="(post,postIndex ) in newPostList" :key="post.postId">
<v-card rounded outlined>
<br />
<div>
Expand All @@ -174,6 +174,11 @@
</v-avatar>
{{ getUser.displayName}}
</v-flex>
<v-flex v-if="post.uid=== getUser.uid" xs12 class="text-xs-right">
<v-btn text icon @click="removeNewPost(postIndex, post.postId)">
<v-icon>clear</v-icon>
</v-btn>
</v-flex>
</v-container>

</v-layout>
Expand Down Expand Up @@ -227,8 +232,8 @@
{{ post.displayName}}
</v-flex>
</v-container>
<v-flex xs12 class="text-xs-right">
<v-btn text icon @click="removePost(postIndex)">
<v-flex v-if="post.uid=== getUser.uid" xs12 class="text-xs-right">
<v-btn text icon @click="removePost(postIndex, post.postId)">
<v-icon>clear</v-icon>
</v-btn>
</v-flex>
Expand Down Expand Up @@ -406,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 @@ -645,9 +649,37 @@ export default {
});
}
},
removePost(todo) {
const postIndex = this.postList.indexOf(todo);
this.postList.splice(postIndex, 1);
removePost(index, postId) {
this.postList.splice(index, 1);
console.log("remove post work")
},
removeNewPost(index, postId) {
this.newPostList.splice(index, 1);
},
removePostFromDatabase(postId){
let loader = this.$loading.show();
axios
.post(
`${process.env.COMMUNITY_SERVICE}/community/${this.communityId}/unsubscribe`,
null,
{
headers: {
Authorization: `Bearer ${localStorage.getItem("jwtToken")}`
}
}
)
.then(joinCommunityResponse => {
this.isSubscribe = !this.isSubscribe;
loader.hide();
})
.catch(err => {
this.$swal({
type: "error",
title: "Failed to subscribe community !!!",
text: `${err.response.data.response}`
});
loader.hide();
});
},
addComment(postIndex) {
let value = this.comment && this.comment.trim();
Expand Down Expand Up @@ -698,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
69 changes: 61 additions & 8 deletions nuxt-firebase-auth-master/pages/community/myCommunity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +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 @@ -20,14 +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()
},
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 All @@ -51,7 +51,7 @@ export default {
let loader = this.$loading.show();
axios
.get(
`${process.env.COMMUNITY_SERVICE}/communitys/user/${this.getUser.uid}`
`${process.env.COMMUNITY_SERVICE}/communitys/subscribe/user/${this.getUser.uid}`
)
.then(subscribeCommunityResponse => {
this.communityList = subscribeCommunityResponse.data;
Expand Down

0 comments on commit 5336361

Please sign in to comment.