From ffa4ec92099d7f072cfcfba455b73d80ee9567bd Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 18 Sep 2019 17:32:37 +0200 Subject: [PATCH] Work on dashboard Signed-off-by: Thomas Citharel --- js/public/index.html | 2 +- js/src/App.vue | 34 +-- js/src/components/Event/DateCalendarIcon.vue | 4 +- js/src/components/Event/DateTimePicker.vue | 17 +- js/src/components/Event/EventListCard.vue | 185 ++++++++++++++++ js/src/components/NavBar.vue | 14 +- js/src/graphql/actor.ts | 62 ++++-- js/src/i18n/en_US.json | 17 +- js/src/i18n/fr_FR.json | 17 +- js/src/mixins/actor.ts | 12 ++ js/src/mixins/event.ts | 61 ++++++ js/src/router/event.ts | 8 + js/src/types/actor/actor.model.ts | 2 + js/src/types/current-user.model.ts | 3 + js/src/types/event.model.ts | 15 ++ js/src/utils/auth.ts | 40 +++- .../views/Account/children/EditIdentity.vue | 1 + js/src/views/Event/Event.vue | 63 +----- js/src/views/Event/MyEvents.vue | 201 ++++++++++++++++++ js/src/views/Home.vue | 159 ++++++++++---- js/src/views/User/Login.vue | 3 +- js/src/views/User/PasswordReset.vue | 4 +- js/src/views/User/Register.vue | 4 +- js/src/vue-apollo.ts | 14 +- lib/mobilizon/events/events.ex | 60 ++++++ lib/mobilizon_web/resolvers/event.ex | 10 +- lib/mobilizon_web/resolvers/user.ex | 20 +- lib/mobilizon_web/schema/user.ex | 10 + lib/mobilizon_web/views/error_view.ex | 23 +- schema.graphql | 5 +- test/mobilizon/events/events_test.exs | 16 +- .../resolvers/event_resolver_test.exs | 46 ++-- test/mobilizon_web/views/error_view_test.exs | 3 +- 33 files changed, 931 insertions(+), 204 deletions(-) create mode 100644 js/src/components/Event/EventListCard.vue create mode 100644 js/src/mixins/actor.ts create mode 100644 js/src/mixins/event.ts create mode 100644 js/src/views/Event/MyEvents.vue diff --git a/js/public/index.html b/js/public/index.html index b7f91bf39..08101498c 100644 --- a/js/public/index.html +++ b/js/public/index.html @@ -6,7 +6,7 @@ - + mobilizon diff --git a/js/src/App.vue b/js/src/App.vue index c9fbf8be8..81b2635fa 100644 --- a/js/src/App.vue +++ b/js/src/App.vue @@ -24,7 +24,7 @@ import Footer from '@/components/Footer.vue'; import Logo from '@/components/Logo.vue'; import { CURRENT_ACTOR_CLIENT, IDENTITIES, UPDATE_CURRENT_ACTOR_CLIENT } from '@/graphql/actor'; import { IPerson } from '@/types/actor'; -import { changeIdentity, saveActorData } from '@/utils/auth'; +import { changeIdentity, initializeCurrentActor, saveActorData } from '@/utils/auth'; @Component({ apollo: { @@ -40,18 +40,19 @@ import { changeIdentity, saveActorData } from '@/utils/auth'; }) export default class App extends Vue { async created() { - await this.initializeCurrentUser(); - await this.initializeCurrentActor(); + if (await this.initializeCurrentUser()) { + await initializeCurrentActor(this.$apollo.provider.defaultClient); + } } - private initializeCurrentUser() { + private async initializeCurrentUser() { const userId = localStorage.getItem(AUTH_USER_ID); const userEmail = localStorage.getItem(AUTH_USER_EMAIL); const accessToken = localStorage.getItem(AUTH_ACCESS_TOKEN); const role = localStorage.getItem(AUTH_USER_ROLE); if (userId && userEmail && accessToken && role) { - return this.$apollo.mutate({ + return await this.$apollo.mutate({ mutation: UPDATE_CURRENT_USER_CLIENT, variables: { id: userId, @@ -61,26 +62,7 @@ export default class App extends Vue { }, }); } - } - - /** - * We fetch from localStorage the latest actor ID used, - * then fetch the current identities to set in cache - * the current identity used - */ - private async initializeCurrentActor() { - const actorId = localStorage.getItem(AUTH_USER_ACTOR_ID); - - const result = await this.$apollo.query({ - query: IDENTITIES, - }); - const identities = result.data.identities; - if (identities.length < 1) return; - const activeIdentity = identities.find(identity => identity.id === actorId) || identities[0] as IPerson; - - if (activeIdentity) { - return await changeIdentity(this.$apollo.provider.defaultClient, activeIdentity); - } + return false; } } @@ -107,6 +89,7 @@ export default class App extends Vue { @import "~bulma/sass/elements/icon.sass"; @import "~bulma/sass/elements/image.sass"; @import "~bulma/sass/elements/other.sass"; +@import "~bulma/sass/elements/progress.sass"; @import "~bulma/sass/elements/tag.sass"; @import "~bulma/sass/elements/title.sass"; @import "~bulma/sass/elements/notification"; @@ -122,6 +105,7 @@ export default class App extends Vue { @import "~buefy/src/scss/components/autocomplete"; @import "~buefy/src/scss/components/form"; @import "~buefy/src/scss/components/modal"; +@import "~buefy/src/scss/components/progress"; @import "~buefy/src/scss/components/tag"; @import "~buefy/src/scss/components/taginput"; @import "~buefy/src/scss/components/upload"; diff --git a/js/src/components/Event/DateCalendarIcon.vue b/js/src/components/Event/DateCalendarIcon.vue index 72baa994d..62f5b5cb5 100644 --- a/js/src/components/Event/DateCalendarIcon.vue +++ b/js/src/components/Event/DateCalendarIcon.vue @@ -1,5 +1,5 @@