Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 94 additions & 8 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,102 @@
<script setup>
</script>
<script>

<template>
<header>
import HomePage from './components/HomePage.vue'
import MyPolls from './components/MyPolls.vue'
import CreatePolls from './components/CreatePolls.vue'

const routes = {
'/': HomePage,
'/MyPolls': MyPolls,
'/CreatePolls': CreatePolls,
}

export default {
data() {
return {
currentPath: window.location.hash
}
},
computed: {
currentView() {
return routes[this.currentPath.slice(1) || '/']
}
},
mounted() {
window.addEventListener('hashchange', () => {
this.currentPath = window.location.hash
})
}
}

import axios from 'axios'

</header>
axios.get('/api/mydata')
.then(response => {
console.log(response.data)
})
.catch(error => {
console.log(error)
})

<main>

</main>
</script>

<template>
<div class="navbar">
<div class="navbar-container">
<div class="navbar-links">
<a href="#/">
<font-awesome-icon :icon="['fas', 'house']" />
</a>
<a href="#/MyPolls">My Polls</a>
<a href="#/CreatePolls">Create Polls</a>
</div>
</div>
</div>
<component :is="currentView" />
</template>

<style scoped>
<style>
body {
background: linear-gradient(to left, #4B0082, #000000);
}
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin-top: 50px; /* Hier den gewünschten Abstand in Pixeln eintragen */
text-align: center;
color: #fefefe;
}
/* Bei Hover nach unten verschieben */
.navbar a:hover {
transform: translateY(2px);
color: #060606;
}

/* Menüleiste position:fixed beim Scrollen */
.navbar {
background: linear-gradient(to right, #000000, #151515);
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 999;
}

.navbar-links a {
color: rgb(107, 107, 107); /* Ändere die Farbe des Links */
text-decoration: none; /* Entferne die Unterstreichung */
}

/* Trennung durch Kästchen */
.navbar a {
display: inline-block;
margin: 0 10px;
padding: 10px;
border: 3px solid #0f0f0f;
}
</style>
Binary file added frontend/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions frontend/src/components/CreatePolls.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<h1>Create Polls</h1>
<div class="create-poll">
<form>
<label for="question">Frage:</label>
<input type="text" id="question" v-model="question">
<label for="options">Antwortmöglichkeiten:</label>
<div v-for="(option, index) in options" :key="index">
<div class="option-container">
<input type="text" :id="'option-' + index" v-model="options[index]">
<button class="delete-option" @click="deleteOption(index)">
<font-awesome-icon :icon="['fas', 'trash']" />
</button>
</div>
</div>
<button @click.prevent="addOption">Weitere Antwortmöglichkeit hinzufügen</button>
<button @click.prevent="submit">Umfrage erstellen</button>
</form>
</div>
</template>
<script>

export default {
data() {
return {
question: '',
options: ['', '']
}
},
methods: {
addOption() {
this.options.push('');
},
deleteOption(index) {
this.options.splice(index, 1);
},
submit() {
// Hier muss der Code zum Speichern der Umfrage implementiert werden
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specifically: An Axios request to our endpoint.

}
}
}
</script>
<style scoped>
.create-poll {
max-width: 600px;
margin: 0 auto;
}
input[type="text"] {
display: block;
margin-bottom: 10px;
width: 100%;
padding: 10px;
font-size: 16px;
}
button {
display: block;
margin-top: 10px;
padding: 10px;
font-size: 16px;
background-color: #008CBA;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #00557e;
}
.option-container {
display: flex;
align-items: center;
}
.delete-option {
margin-left: 10px;
margin-bottom: 1.34em;
cursor: pointer;
background: linear-gradient(to right, #000000, #747474);
}
</style>
3 changes: 3 additions & 0 deletions frontend/src/components/HomePage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<h1>Pollock</h1>
</template>
32 changes: 32 additions & 0 deletions frontend/src/components/MyPolls.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<div>
<h1>My Polls</h1>
<ul>
<li v-for="poll in polls" :key="poll.id">{{ poll.title }}</li>
</ul>
</div>
</template>

<script>
import axios from 'axios';

export default {
data() {
return {
polls: [],
};
},
mounted() {
axios
.get('/polls') // Hier wird die GET-Anfrage an den Server gesendet
.then(response => {
this.polls = response.data; // Hier wird die Antwort in der Datenliste gespeichert
})
.catch(error => console.log(error));
Comment on lines +20 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better as async/await, otherwise a really good looking start!

},
};
</script>

<style scoped>

</style>
10 changes: 7 additions & 3 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import './assets/main.css'

import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#generated-frontend')
import { library } from '@fortawesome/fontawesome-svg-core'
import { faHome, faTrash} from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
Comment on lines +4 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in package.json and yarn.lock, just install it again with yarn add <package name>, and add those two files.


library.add(faHome, faTrash)

createApp(App).component('font-awesome-icon', FontAwesomeIcon).mount('#app')