-
Notifications
You must be signed in to change notification settings - Fork 0
Exercise 7 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RespectableRuessel
wants to merge
11
commits into
main
Choose a base branch
from
exercise-7
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Exercise 7 #9
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d85155
Started apollo client
6be44cf
Started implementing Vuex in Nuxt
87ac7b9
Merge branch 'exercise-7' of github.com:Systems-Development-and-Frame…
7b91123
Added apolloHelpers and some queries
6f6a62f
Completed linking the backend with the frontend
7a3c300
Fixed NewsList test
fb2dc28
Fixed linting errors
6e1420c
Updated readme
RespectableRuessel 3239dea
Added tests for login feature and login-form
TheKilljoy 3f9a2e5
Fixed linter error
TheKilljoy f42aab3
new credentials for test server
TheKilljoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| .idea | ||
| node_modules | ||
| lib | ||
| .env | ||
| dev.env | ||
|
|
||
| dev.env | ||
| dev.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| TOKEN_SECRET=TEST123456 | ||
| NEO4J_URI=bolt://34.239.207.33:32848 | ||
| NEO4J_URI=bolt://100.26.212.97:32898 | ||
| NEO4J_USER=neo4j | ||
| NEO4J_PASSWORD=discriminations-beginners-tubes | ||
| NEO4J_PASSWORD=journals-knives-employee | ||
| NEO4J_DATABASE= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,3 +88,6 @@ sw.* | |
|
|
||
| # Vim swap files | ||
| *.swp | ||
|
|
||
| .nuxt-storybook | ||
| storybook-static | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,36 @@ | ||
| # no-nuxt-pls | ||
|
|
||
| ## Build Setup | ||
|
|
||
| ```bash | ||
| # install dependencies | ||
| $ npm install | ||
|
|
||
| # serve with hot reload at localhost:3000 | ||
| $ npm run dev | ||
| ## Installation | ||
| Run | ||
| ``` | ||
| npm install | ||
| ``` | ||
| to install all depedencies. But be warned it will install ~3200 packages | ||
| that are able to break you project without you beeing able to find the issues | ||
| easily. Your file manager will love it. | ||
|
|
||
| # build for production and launch server | ||
| $ npm run build | ||
| $ npm run start | ||
| ## Run Developer Mode | ||
| You can start a dev server with hot reload by running: | ||
| ``` | ||
| npm run dev | ||
| ``` | ||
|
|
||
| # generate static project | ||
| $ npm run generate | ||
| ## Build and Deploy | ||
| To build the project for deployment run: | ||
| ``` | ||
| npm run build | ||
| ``` | ||
| in your project directory. | ||
| If you have not generated the static project before run: | ||
| ``` | ||
| npm run generate | ||
| ``` | ||
| but be careful it takes 100 hours to generate for a simple hello world site. | ||
| That's called efficency and good design. | ||
| Finally you can start the project with: | ||
| ``` | ||
| npm run start | ||
| ``` | ||
|
|
||
| ## Details | ||
| For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| <template> | ||
| <form class="login-form" @submit.prevent="submitLogin"> | ||
| <fieldset> | ||
| <legend> | ||
| Login | ||
| </legend> | ||
| <div> | ||
| <label for="email">E-Mail:</label> | ||
| <input | ||
| id="email" | ||
| v-model="email" | ||
| type="email" | ||
| name="email" | ||
| size="25" | ||
| /> | ||
| </div> | ||
| <div> | ||
| <label for="password">Password:</label> | ||
| <input | ||
| id="password" | ||
| v-model="password" | ||
| type="password" | ||
| name="password" | ||
| size="25" | ||
| /> | ||
| </div> | ||
| <div v-if="error" class="error"> | ||
| {{ error.message }} | ||
| </div> | ||
| <div> | ||
| <button type="submit">Login</button> | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
| </template> | ||
|
|
||
| <script> | ||
| import gql from 'graphql-tag'; | ||
| import { mapActions } from 'vuex'; | ||
|
|
||
| const LOGIN_MUTATION = gql`mutation ($email: String!, $password: String!){ login(email: $email, password: $password) }`; | ||
|
|
||
| export default { | ||
| data() { | ||
| return { | ||
| error: null, | ||
| email: '', | ||
| password: '', | ||
| } | ||
| }, | ||
|
|
||
| methods: { | ||
| ...mapActions('auth', ['login']), | ||
| async submitLogin() { | ||
| const { email, password } = this; | ||
| const { data } = await this.$apollo.mutate({mutation: LOGIN_MUTATION, variables: { email, password }}); | ||
| if (data.login) { | ||
| await this.$apolloHelpers.onLogin(data.login); | ||
| await this.$router.push('/'); | ||
| } else { | ||
| this.error = { message: 'Oops! Something went wrong.' }; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| @Component | ||
| export default class LoginForm extends Vue { | ||
| @Prop() public token: string = this.$store.state.auth.token; | ||
| public email: string = ''; | ||
| public password: string = ''; | ||
|
|
||
|
|
||
| @Action('auth') | ||
| async submitLogin(): Promise<void> { | ||
| const { login } = await this.$a | ||
| const res = await this.$apollo.mutate({mutation: gql`mutation ($email: String!, $password: String!){ | ||
| login(email: $email, password: $password) | ||
| }`, variables: {email: this.email, password: this.password}}).then((data: any) => data.login as string); | ||
| await this.$app.$apolloHelpers.onLogin(res); | ||
| this.$store.commit('login', { email: this.email, password: this.password }); | ||
| } | ||
| }; */ | ||
| </script> | ||
|
|
||
| <style scoped> | ||
|
|
||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| <template> | ||
| <nav class="nav-bar"> | ||
| <div> | ||
| <nuxt-link to="/Login">Login</nuxt-link> | ||
| </div> | ||
| <div> | ||
| <template v-if="token"> | ||
| <button @click="logout">Logout</button> | ||
| </template> | ||
| <template v-else> You are not logged in. </template> | ||
| </div> | ||
| </nav> | ||
| </template> | ||
|
|
||
| <script> | ||
|
|
||
| export default { | ||
| data() { | ||
| return { | ||
| token: '' | ||
| } | ||
| }, | ||
|
|
||
| mounted() { | ||
| this.setupMenu(); | ||
| }, | ||
|
|
||
| methods: { | ||
| setupMenu(){ | ||
| this.token = this.$apolloHelpers.getToken(); | ||
| }, | ||
| logout() { | ||
| this.token = null; | ||
| this.$apolloHelpers.onLogout(); | ||
| window.location.reload(false); | ||
| }, | ||
| }, | ||
| }; | ||
| </script> | ||
|
|
||
| <style> | ||
| .nav-bar { | ||
| top: 0; | ||
| position: fixed; | ||
| width: 100%; | ||
| height: 6rem; | ||
| padding: 2rem; | ||
| border-bottom: 1px solid black; | ||
| display: flex; | ||
| justify-content: space-between; | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,32 @@ | |
| <div> | ||
| <h2>{{news.title}} ({{news.votes}})</h2> | ||
| <br> | ||
| <button @click="updateNews(1)">Upvote</button> | ||
| <button @click="updateNews(-1)">Downvote</button> | ||
| <button @click="deleteNews">Remove</button> | ||
| <button v-if="token" @click="updateNews(1)">Upvote</button> | ||
| <button v-if="token" @click="updateNews(-1)">Downvote</button> | ||
| <button v-if="authorId === news.author.id" @click="deleteNews">Delete</button> | ||
| <button v-if="authorId === news.author.id">Edit</button> | ||
|
Comment on lines
+7
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. star For a delete and edit button that is only visible to the author of the post. |
||
| </div> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| <script> | ||
|
|
||
| export default { | ||
| props: { | ||
| news: Object, | ||
| token: String, | ||
| authorId: String, | ||
| }, | ||
|
|
||
| methods: { | ||
| updateNews(value) { | ||
| this.$emit('update', this.news); | ||
| }, | ||
| deleteNews() { | ||
| this.$emit('remove', this.news); | ||
| } | ||
| } | ||
| } | ||
| /* | ||
| import { Vue, Component, Prop, Emit } from 'nuxt-property-decorator'; | ||
| import { Item } from '@/interface/item'; | ||
|
|
||
|
|
@@ -27,6 +46,7 @@ export default class NewsItem extends Vue { | |
| } | ||
|
|
||
| } | ||
| */ | ||
| </script> | ||
|
|
||
| <style scoped> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
star For an upvote button that behaves according to the authentication state of your user