Skip to content

Commit

Permalink
Connect api (#76)
Browse files Browse the repository at this point in the history
* search page done

* view seminar and event

* Fix query string construction

* displayed dates and follow/attend both events/seminars

* scroll fix and my events

* manage events done

* suggestions done and scroll 2.0

* helper functions and big fixes
  • Loading branch information
bhavanthy authored Nov 10, 2018
1 parent be9fe85 commit 14f0733
Show file tree
Hide file tree
Showing 11 changed files with 573 additions and 976 deletions.
1 change: 0 additions & 1 deletion frontend/src/assets/data/flights.json

This file was deleted.

13 changes: 0 additions & 13 deletions frontend/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Vue from 'vue'
import Router from 'vue-router'

//apps
import Dashboard from '../views/apps/Dashboard.vue'
import Calendar from '../views/apps/Calendar.vue'
import Contacts from '../views/apps/Contacts.vue'
import Gallery from '../views/apps/Gallery.vue'
Expand All @@ -14,7 +13,6 @@ import Register from '../views/pages/authentication/Register.vue'
import ForgotPassword from '../views/pages/authentication/ForgotPassword.vue'
import Profile from '../views/pages/Profile.vue'
import NotFound from '../views/pages/NotFound.vue'
import Invoice from '../views/pages/Invoice.vue'
import SearchPage from '../views/pages/Search.vue'
import EventPage from '../views/pages/Event.vue'
import SeminarPage from '../views/pages/Seminar.vue'
Expand Down Expand Up @@ -246,17 +244,6 @@ const router = new Router({
tags: ["pages"]
}
},
{
path: "/invoice",
name: "invoice",
component: Invoice,
meta: {
auth: true,
layout: layouts.navLeft,
searchable: true,
tags: ["pages"]
}
},
{
path: "/login",
name: "login",
Expand Down
63 changes: 61 additions & 2 deletions frontend/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,60 @@ export default new Vuex.Store({
},
setSeminar(state, payload){
state.seminar = payload
}
},
addToAttend(state, payload){
state.user.attend.push(payload)
if (payload.__typename === 'Event') {
state.event.attend = true
} else if (payload.__typename === 'Seminar'){
state.seminar.attend = true
}
},
removeFromAttend(state, payload){
if (payload.__typename === 'Event') {
state.event.attend = false
} else if (payload.__typename === 'Seminar'){
state.seminar.attend = false
}
state.user.attend = state.user.attend.filter(item => item.id !== payload.id && item.__typename !== payload.__typename)
},
addToFollow(state, payload){
state.user.follow.push(payload)
if (payload.__typename === 'Event') {
state.event.follow = true
} else if (payload.__typename === 'Seminar'){
state.seminar.follow = true
}
},
removeFromFollow(state, payload){
if (payload.__typename === 'Event') {
state.event.follow = false
} else if (payload.__typename === 'Seminar'){
state.seminar.follow = false
}
state.user.follow = state.user.follow.filter(item => item.id !== payload.id && item.__typename !== payload.__typename)
},
addToManage(state, payload){
state.user.manage.push(payload)
if (payload.__typename === 'Event') {
state.event.manage = true
} else if (payload.__typename === 'Seminar'){
state.seminar.manage = true
}
},
removeFromManage(state, payload){
if (payload.__typename === 'Event') {
state.event.manage = false
} else if (payload.__typename === 'Seminar'){
state.seminar.manage = false
}
state.user.manage = state.user.manage.filter(item => item.id !== payload.id && item.__typename !== payload.__typename)
},
},
actions: {

setUser(user){
this.state.user = user
},
},
getters: {
layout(state, getters) {
Expand Down Expand Up @@ -91,6 +141,15 @@ export default new Vuex.Store({
},
splashScreen(state, getters) {
return state.splashScreen
},
getUser(state){
return state.user
},
getEvent(state){
return state.event
},
getSeminar(state){
return state.seminar
}
},
plugins: [createPersistedState({paths: ['layout']})],
Expand Down
156 changes: 48 additions & 108 deletions frontend/src/views/pages/Event.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<h1 style="margin:10px; margin-top:20px;text-align:center;">{{info.name}} </h1>
<el-row type="flex" class="row-bg">
<el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="text-align:right;margin-right:10px">
<el-button v-if="followInfo.status" @click="unfollow" type="primary" plain title="Unfollow">{{followInfo.following}}</el-button>
<el-button v-if="manageInfo.status" title="Edit" type="primary"> {{manageInfo.edit}} Event </el-button>
<el-button v-else-if="followInfo.status" @click="unfollow" type="primary" plain title="Unfollow">{{followInfo.following}}</el-button>
<el-button v-else @click="follow" type="primary" title="Follow">{{followInfo.follow}}</el-button>
</el-col>
<el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="margin-left:10px">
<el-button v-if="attendInfo.status" @click="unattend" type="primary" plain title="Unattend">{{attendInfo.attending}}</el-button>
<el-button v-if="manageInfo.status" title="Announcement" type="primary"> {{manageInfo.announcement}} </el-button>
<el-button v-else-if="attendInfo.status" @click="unattend" type="primary" plain title="Unattend">{{attendInfo.attending}}</el-button>
<el-button v-else @click="attend" type="primary" title="Attend">{{attendInfo.attend}}</el-button>
</el-col>
</el-row>
Expand All @@ -17,7 +19,8 @@
Location: {{info.location}}
</el-col>
<el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" style="text-align:right;margin:10px;">
Date: {{info.start_time}} - {{info.end_time}}
<p>Start Date: {{info.start_time}}</p>
<p>End Date: {{info.end_time}}</p>
</el-col>
</el-row>
<hr>
Expand Down Expand Up @@ -51,7 +54,8 @@
<p>Location: {{seminar.location}}</p>
</el-col>
<el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
<p>Date: {{seminar.start_time}} - {{seminar.end_time}} </p>
<p>Start Date: {{seminar.start_time}} </p>
<p>End Date: {{seminar.end_time}} </p>
</el-col>
</el-row>
</div>
Expand All @@ -70,6 +74,7 @@
<script>
import { createApolloFetch } from "apollo-fetch"
import * as moment from 'moment'
import {followAndAttend, unfollowAndUnattend, loadSeminars} from './helper'
const fetch = createApolloFetch({ uri: "http://localhost:4000/graphql" });
export default {
Expand All @@ -85,129 +90,64 @@ export default {
status: this.$store.state.event.attend,
attend: "Attend",
attending: "Attending"
},
manageInfo: {
status: this.$store.state.event.manage,
edit: "Edit",
announcement: "Announcment"
},
activeName: "news",
info:this.$store.state.event,
userid:this.$store.state.user.id
user:this.$store.state.user
};
},
methods: {
follow() {
console.log(this.userid,this.info.id)
fetch({query: `mutation addUserToEvent($newUser: EventParticipationInput!) {
addUserToEvent(EventParticipation: $newUser)
}`,
variables: {
newUser: {
userid: this.userid,
eventid: this.info.id,
participationType: "FOLLOWING"
}
}
})
.then(res =>{
if(res.data){
this.followInfo.status = !this.followInfo.status
} else {
console.log("not following")
followAndAttend('Event', 'FOLLOWING').then(function(result) {
if (result){
this.followInfo.status = true
} else{
this.followInfo.status = false
}
})
.catch(err =>{
console.log(err)
})
}.bind(this))
},
attend() {
fetch({query: `mutation addUserToEvent($newUser: EventParticipationInput!) {
addUserToEvent(EventParticipation: $newUser)
}`,
variables: {
newUser: {
userid: this.userid,
eventid: this.info.id,
participationType: "ATTENDING"
}
}
})
.then(res =>{
if(res.data){
this.attendInfo.status = !this.attendInfo.status;
followAndAttend('Event', 'ATTENDING').then(function(result) {
if (result){
this.attendInfo.status = true
} else{
this.attendInfo.status = false
}
})
}.bind(this))
},
loadSeminar(id) {
fetch({
query: `{
getSeminarByID(id:${id}){
announcements{
date_modified
message
}
id
name
event_id
description
start_time
end_time
location
organizers{
id
first_name
middle_name
last_name
}
}
}`
})
.then(res => {
if(res.data){
var seminarInfo = res.data.getSeminarByID
seminarInfo.event_id = this.info.name
seminarInfo.id=id
seminarInfo.start_time = moment(parseInt(seminarInfo.start_time,10)).format("MMMM Do YYYY, h:mm a")
seminarInfo.end_time = moment(parseInt(seminarInfo.end_time,10)).format("MMMM Do YYYY, h:mm a")
seminarInfo.announcements.forEach(seminar => {
seminar.date_modified = moment(parseInt(seminar.date_modified,10)).format("MMMM Do YYYY, h:mm a")
});
this.$store.commit("setSeminar",seminarInfo)
this.$router.push("seminar")
}
})
loadSeminars(id).then(function(result) {
console.log(result)
if (result){
this.$router.push("seminar")
} else{
console.log("something went wrong")
}
}.bind(this))
},
unfollow(){
fetch({query: `mutation removeUserFromEvent($newUser: EventParticipationInput!) {
removeUserFromEvent(EventParticipation: $newUser)
}`,
variables: {
newUser: {
userid: this.userid,
eventid: this.info.id,
participationType: "FOLLOWING"
}
}
})
.then(res =>{
if(res.data){
this.followInfo.status = !this.followInfo.status
unfollowAndUnattend('Event', 'FOLLOWING').then(function(result) {
if (result){
this.followInfo.status = false
} else{
this.followInfo.status = true
}
})
}.bind(this))
},
unattend(){
fetch({query: `mutation removeUserFromEvent($newUser: EventParticipationInput!) {
removeUserFromEvent(EventParticipation: $newUser)
}`,
variables: {
newUser: {
userid: this.userid,
eventid: this.info.id,
participationType: "ATTENDING"
}
}
})
.then(res =>{
if(res.data){
this.attendInfo.status = !this.attendInfo.status;
console.log(this.user.attend)
unfollowAndUnattend('Event', 'ATTENDING').then(function(result) {
if (result){
this.attendInfo.status = false
} else{
this.attendInfo.status = true
}
})
}.bind(this))
}
},
components: {}
Expand Down
Loading

0 comments on commit 14f0733

Please sign in to comment.