Skip to content
Snippets Groups Projects
Commit cd80ba4f authored by Ömer Kinik's avatar Ömer Kinik
Browse files

Upload New File

parent f31d415d
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vote results</title>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<!-- import for vuetify-->
<link href="https://cdn.jsdelivr.net/npm/vuetify@latest/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vuetify@latest"></script>
<style>
.progress-container {
background-color: #e0e0e0;
margin-bottom: 20px;
padding: 5px;
box-sizing: border-box;
}
.progress-bar {
max-width: 90%;
height: 24px;
background-color: #4caf50;
color: white;
}
</style>
</head>
<body>
<div id="app">
<v-app>
<v-card melevation="1" max-width="1200" style="margin-top: 35px; margin-left: 50px;">
<v-card-title class="py-5 font-weight-black" style="font-size: 35px;">
Vote results
</v-card-title>
<div class="progress-container" v-for="person in persons">
{{ person.person.firstName }} {{ person.person.lastName }} - {{ getPercentage(person.Stimmzahl) }}%
<div class="progress-bar" :style="{width: getPercentage(person.Stimmzahl) + '%'}">
</div>
</div>
</v-card>
<v-container>
<v-bottom-navigation grow>
<v-btn @click="goToPage('index.html')">
Create a person
</v-btn>
<v-btn @click="goToPage('vote.html')">
Vote
</v-btn>
<v-btn @click="goToPage('vote_results.html')">
Vote results
</v-btn>
</v-bottom-navigation>
</v-container>
</v-app>
</div>
<script>
const vuetify = Vuetify.createVuetify();
let app = Vue.createApp({
data() {
return {
persons: [],
voteLimit: 0
}
},
methods: {
async getVoteLimit() {
const response = await axios.get('http://127.0.0.1:8000/vote')
const data = response.data
let sum = 0
for (person of data) {
sum += person.Stimmzahl
}
this.voteLimit = sum
},
async getPersons() {
const response = await axios.get('http://127.0.0.1:8000/vote')
this.persons = response.data
},
getPercentage(stimmzahl) {
return ((stimmzahl / this.voteLimit) * 100).toFixed(1)
},
goToPage(page) {
window.location.href = page;
}
},
mounted() {
this.getVoteLimit()
this.getPersons()
}
})
app.use(vuetify);
app.mount('#app')
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment