From c5fe6f218364ae08c518bbd721894283f884926e Mon Sep 17 00:00:00 2001 From: Shaalikaaa <59829348+Shaalikaaa@users.noreply.github.com> Date: Thu, 30 Jan 2020 15:23:27 +0530 Subject: [PATCH 1/4] landing questions fetched --- src/components/LandingQuestion.vue | 17 ++++++++++++----- src/components/OrganizationDescription.vue | 5 ++++- src/components/ProfileDescription.vue | 5 ++++- src/components/ProfileFeed.vue | 10 ++++++++-- src/components/UserHeader.vue | 7 ++++--- src/components/moderator/ModeratorNav.vue | 4 ++-- src/store/index.js | 6 ++++-- src/views/UserLanding.vue | 7 ++++--- src/views/UserProfile.vue | 10 +++++++++- src/views/moderator/Moderator.vue | 2 +- src/views/moderator/ModeratorApproveAnswer.vue | 8 +++++++- .../moderator/ModeratorApproveQuestion.vue | 9 ++++++++- src/views/moderator/ModeratorApproveUser.vue | 9 ++++++++- 13 files changed, 75 insertions(+), 24 deletions(-) diff --git a/src/components/LandingQuestion.vue b/src/components/LandingQuestion.vue index 38b9d4a..6a19a20 100644 --- a/src/components/LandingQuestion.vue +++ b/src/components/LandingQuestion.vue @@ -1,21 +1,25 @@ @@ -35,4 +39,7 @@ export default { margin-left: 300px; } +.view-button { + background-color: red; +} \ No newline at end of file diff --git a/src/components/OrganizationDescription.vue b/src/components/OrganizationDescription.vue index 692c132..56e93f8 100644 --- a/src/components/OrganizationDescription.vue +++ b/src/components/OrganizationDescription.vue @@ -1,6 +1,6 @@ \ No newline at end of file diff --git a/src/components/organizationProfileFeed.vue b/src/components/organizationProfileFeed.vue new file mode 100644 index 0000000..0904494 --- /dev/null +++ b/src/components/organizationProfileFeed.vue @@ -0,0 +1,51 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index 607dd60..7f6f773 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -42,7 +42,7 @@ const routes = [ }, { path: '/organizationProfile', - name: 'profile', + name: 'organizationprofile', component: () => import('../views/OrganizationProfile.vue') }, { diff --git a/src/store/index.js b/src/store/index.js index 53994a4..d1e9a23 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -7,16 +7,36 @@ Vue.use(Vuex) export default new Vuex.Store({ state: { landingQuestions: {}, - questionDetail: {} + questionDetail: {}, + userDetails: {}, + organizationDetails: {}, + approveUserDetails: {}, + approveQuestionDetails: {} }, mutations: { viewLandingQuestion(state,data) { state.landingQuestions=data; }, - + getQuestionDetails(state, data) { state.questionDetail=data; + }, + + getUserProfile(state, data) { + state.userDetails=data; + }, + + getOrganizationProfile(state, data) { + state.organizationDetails=data; + }, + + setApproveUserDetails(state, data) { + state.approveUserDetails=data; + }, + + setApproveQuestionDetails(state,data) { + state.approveQuestionDetails=data; } }, @@ -27,8 +47,8 @@ export default new Vuex.Store({ return new Promise((resolve, reject) => { Axios.get('http://172.16.20.107:8085/question/getLoginFeed/' + userId ) .then(response => { - window.console.log("the response",response.data.feed); - commit('viewLandingQuestion', response.data.feed) + window.console.log("the response",response); + commit('viewLandingQuestion', response) resolve(response) }) .catch(error => { @@ -47,17 +67,118 @@ export default new Vuex.Store({ .catch(error => { window.console.log(error) }) + }, + + getUserProfileDetails({commit}, userId) { + Axios.get('http://172.16.20.46:8086/user/viewUser/' + userId) + .then(response => { + window.console.log("userdetails",response) + commit('getUserProfile', response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + getOrganizationProfileDetails({commit}, organizationId) { + Axios.get('http://172.16.20.46:8086/organiaztion/viewOrganization/' + organizationId) + .then(response => { + window.console.log("organizationdetails",response) + commit('getOrganizationProfile', response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + approveUser({commit}, moderatorId) { + Axios.get('http://172.16.20.46:8086/moderator/approvaleList/' + moderatorId) + .then(response => { + window.console.log("getApproveUserDetails",response) + commit('setApproveUserDetails', response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + approveUserId(context, data) { + Axios.post('http://172.16.20.46:8086/moderator/approve/' + data.userId+ "/" +data.moderatorId) + .then(response => { + window.console.log("getApproveUserDetails",response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + disapproveUserId(context, data) { + Axios.post('http://172.16.20.46:8086/moderator/disapove/' +data.moderatorId) + .then(response => { + window.console.log("getApproveUserDetails",response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + approveQuestion({commit}, moderatorId) { + Axios.get('http://172.16.20.46:8086/' + moderatorId) + .then(response => { + window.console.log("getApproveUserDetails",response) + commit('setApproveQuestionDetails', response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + approveQuestionId(context, data) { + Axios.post('http://172.16.20.46:8086/' + data.questionId+ "/" +data.moderatorId) + .then(response => { + window.console.log("setApproveQuestionDetails",response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + disapproveQuestionId(context, data) { + Axios.post('http://172.16.20.46:8086/' +data.moderatorId) + .then(response => { + window.console.log("getApproveUserDetails",response) + }) + .catch(error => { + window.console.log(error) + }) } }, - getters: { + getters : { getLandingQuestion(state) { + window.console.log("getter from store",state.landingQuestions) return state.landingQuestions || {} }, questionDetails(state) { return state.questionDetail || {} + }, + + getUserDetails(state) { + return state.userDetails || {} + }, + + getOrganizationDetails(state) { + return state.organizationDetails || {} + }, + + getApproveUserDetails(state) { + return state.approveUserDetails || {} + }, + + getApproveQuestionDetails(state) { + return state.approveQuestionDetails || {} } } }) diff --git a/src/views/OrganizationProfile.vue b/src/views/OrganizationProfile.vue index 7b0fb3e..07bc878 100644 --- a/src/views/OrganizationProfile.vue +++ b/src/views/OrganizationProfile.vue @@ -1,24 +1,33 @@ diff --git a/src/views/UserLanding.vue b/src/views/UserLanding.vue index 317f629..9e93fac 100644 --- a/src/views/UserLanding.vue +++ b/src/views/UserLanding.vue @@ -1,13 +1,16 @@ @@ -18,25 +21,27 @@ import { mapGetters } from "vuex"; export default { components: { - LandingQuestion, - UserHeader + LandingQuestion, + UserHeader }, data() { - return { - dialog: false - } + return { + dialog: false + }; }, created() { - localStorage.setItem('userId','5e3140bb4c951a1723dc3f01') - this.$store.dispatch("viewLandingQuestion",this.userId) + localStorage.setItem("userId", "5e3140bb4c951a1723dc3f01"); + localStorage.setItem("organizationId", "5e3149d91edbf851280ccf51"); + localStorage.setItem("moderatorId", "5e314bc583f84b7add06ec37"); + this.$store.dispatch("viewLandingQuestion", this.userId); }, methods: { - dialogValue(){ - this.dialog = true; - }, - openProfile(){ - this.$router.push("/profile") - } + dialogValue() { + this.dialog = true; + }, + openProfile() { + this.$router.push("/profile"); + } }, computed: { @@ -66,7 +71,6 @@ export default { background-color: #111; overflow-x: hidden; padding-top: 20px; - } .footer { position: fixed; @@ -112,8 +116,7 @@ input { margin-left: 450px; } -.profile-button{ - margin-left:10px; +.profile-button { + margin-left: 10px; } - \ No newline at end of file diff --git a/src/views/UserProfile.vue b/src/views/UserProfile.vue index c12f0bb..5539ef7 100644 --- a/src/views/UserProfile.vue +++ b/src/views/UserProfile.vue @@ -1,9 +1,8 @@ @@ -11,15 +10,26 @@ import ProfileDescription from "@/components/ProfileDescription.vue"; import ProfileFeed from "@/components/ProfileFeed.vue"; import UserHeader from "@/components/UserHeader.vue"; -// import OrganizationDescription from "@/components/OrganizationDescription.vue"; +import { mapGetters } from 'vuex'; export default { + name: "Profile", - components: { + components: { ProfileDescription, ProfileFeed, UserHeader // OrganizationDescription + }, + mounted() { + + window.console.log('hello from mounted') + let userId=localStorage.getItem("userId"); + window.console.log("userId",userId) + this.$store.dispatch('getUserProfileDetails',userId); + }, + computed: { + ...mapGetters(["getUserDetails"]) } } From f55539b575d1d7309541795591cc7e544d2c3717 Mon Sep 17 00:00:00 2001 From: Shaalikaaa <59829348+Shaalikaaa@users.noreply.github.com> Date: Fri, 31 Jan 2020 16:40:47 +0530 Subject: [PATCH 4/4] before merge --- src/components/AddUserQuestion.vue | 135 +++++++++++++++++++++++++++++ src/components/Answer.vue | 3 +- src/components/Question.vue | 3 +- src/components/UserHeader.vue | 32 ++----- src/store/index.js | 33 ++++++- src/views/UserLanding.vue | 4 +- src/views/Viewquestion.vue | 14 +-- 7 files changed, 186 insertions(+), 38 deletions(-) create mode 100644 src/components/AddUserQuestion.vue diff --git a/src/components/AddUserQuestion.vue b/src/components/AddUserQuestion.vue new file mode 100644 index 0000000..190d8e0 --- /dev/null +++ b/src/components/AddUserQuestion.vue @@ -0,0 +1,135 @@ + + + \ No newline at end of file diff --git a/src/components/Answer.vue b/src/components/Answer.vue index 0754388..a8e29cf 100644 --- a/src/components/Answer.vue +++ b/src/components/Answer.vue @@ -26,7 +26,8 @@ \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index d1e9a23..e5109f9 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -11,7 +11,8 @@ export default new Vuex.Store({ userDetails: {}, organizationDetails: {}, approveUserDetails: {}, - approveQuestionDetails: {} + approveQuestionDetails: {}, + questionDetailsById: {} }, mutations: { @@ -37,6 +38,10 @@ export default new Vuex.Store({ setApproveQuestionDetails(state,data) { state.approveQuestionDetails=data; + }, + + setQuestionDetailsById(state,data) { + state.questionDetailsById=data } }, @@ -151,6 +156,28 @@ export default new Vuex.Store({ .catch(error => { window.console.log(error) }) + }, + + addQuestion(context, data) { + window.console.log("add question",data) + Axios.post('http://172.16.20.46:8085/question/add', data) + .then(response => { + window.console.log("response to add question",response) + }) + .catch(error => { + window.console.log(error) + }) + }, + + getQuestionDetailsById({commit}, questionId) { + Axios.gat('http://172.16.20.46:8085/question/', + questionId) + .then(response => { + window.console.log("response to get question details",response) + commit("setQuestionDetailsById",response) + }) + .catch(error => { + window.console.log(error) + }) } }, @@ -179,6 +206,10 @@ export default new Vuex.Store({ getApproveQuestionDetails(state) { return state.approveQuestionDetails || {} + }, + + getQuestionDetails(state) { + return state.questionDetailsById || {} } } }) diff --git a/src/views/UserLanding.vue b/src/views/UserLanding.vue index 9e93fac..ba07897 100644 --- a/src/views/UserLanding.vue +++ b/src/views/UserLanding.vue @@ -33,7 +33,7 @@ export default { localStorage.setItem("userId", "5e3140bb4c951a1723dc3f01"); localStorage.setItem("organizationId", "5e3149d91edbf851280ccf51"); localStorage.setItem("moderatorId", "5e314bc583f84b7add06ec37"); - this.$store.dispatch("viewLandingQuestion", this.userId); + this.$store.dispatch("viewLandingQuestion"); }, methods: { dialogValue() { @@ -61,7 +61,7 @@ export default { margin-left: 300px; } .sidenav { - height: 82%; + height: 100%; width: 160px; margin-top: 70px; z-index: 1; diff --git a/src/views/Viewquestion.vue b/src/views/Viewquestion.vue index 05c6eb2..f4e1af0 100644 --- a/src/views/Viewquestion.vue +++ b/src/views/Viewquestion.vue @@ -3,11 +3,10 @@


- +
- - +
@@ -16,11 +15,11 @@ import Question from "@/components/Question"; import Answer from "@/components/Answer"; import Enterans from "@/components/Enterans"; +import { mapGetters } from 'vuex'; export default { name: "viewquestion", - components: { Question, Answer, @@ -28,9 +27,10 @@ export default { }, mounted() { window.console.log("inside mounted", this.$route.params.questionId); - this.$store.dispatch("getQuestionDetails", { - questionId: this.$route.params.questionId - }); + this.$store.dispatch("getQuestionDetailsById",this.$route.params.questionId); + }, + computed: { + ...mapGetters(["getQuestionDetails"]) } };