Commit cde037db authored by raphael.peim's avatar raphael.peim

Update Profile.vue and fix bugs

parent 0f65bcd2
...@@ -20,10 +20,19 @@ ...@@ -20,10 +20,19 @@
return $this->createUser($post); return $this->createUser($post);
break; break;
case 'GET': case 'GET':
if (empty($this->request->getUriParameters())) if (empty($this->request->getUriParameters())) {
return $this->getAllUsers(); return $this->getAllUsers();
else }
return $this->getUserById($this->request->getUriParameters()[0]); else {
$parameters = $this->request->getUriParameters();
if (is_numeric($parameters[0])) {
return $this->getUserById($this->request->getUriParameters()[0]);
}
else {
return $this->getUserByLogin($this->request->getUriParameters()[0]);
}
}
break; break;
case 'PUT': case 'PUT':
$put = json_decode(file_get_contents("php://input")); $put = json_decode(file_get_contents("php://input"));
...@@ -78,6 +87,17 @@ ...@@ -78,6 +87,17 @@
return $response; return $response;
} }
protected function getUserByLogin($login) {
$user = User::getWithLogin($login);
if (!empty($user))
$response = Response::okResponse(json_encode($user));
else
$response = Response::notFoundResponse("Aucune réponse");
return $response;
}
protected function updateUser($put, $id) { protected function updateUser($put, $id) {
$user = User::getWithId($id); $user = User::getWithId($id);
......
frontend/src/assets/img/game.png

516 KB | W: | H:

frontend/src/assets/img/game.png

384 KB | W: | H:

frontend/src/assets/img/game.png
frontend/src/assets/img/game.png
frontend/src/assets/img/game.png
frontend/src/assets/img/game.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:type="information.type" :type="information.type"
:id="information.id" :id="information.id"
:placeholder="information.placeholder" :placeholder="information.placeholder"
:value="information.value"
autocomplete="off" autocomplete="off"
required> required>
<!-- :pattern="information.pattern" --> <!-- :pattern="information.pattern" -->
......
...@@ -7,6 +7,7 @@ import Rules from '../views/Rules' ...@@ -7,6 +7,7 @@ import Rules from '../views/Rules'
import GameChoice from '../views/GameChoice' import GameChoice from '../views/GameChoice'
import GameCreate from '../views/GameCreate' import GameCreate from '../views/GameCreate'
import GameJoin from '../views/GameJoin' import GameJoin from '../views/GameJoin'
import Waiting from '../views/Waiting'
import Game from '../views/Game' import Game from '../views/Game'
import Profile from '../views/Profile' import Profile from '../views/Profile'
...@@ -48,6 +49,11 @@ const routes = [ ...@@ -48,6 +49,11 @@ const routes = [
name: 'GameJoin', name: 'GameJoin',
component: GameJoin component: GameJoin
}, },
{
path: '/waiting',
name: 'Waiting',
component: Waiting
},
{ {
path: '/game', path: '/game',
name: 'Game', name: 'Game',
......
<template> <template>
<div class="body position-absolute h-100 w-100"> <div class="body position-absolute h-100 w-100">
<Navbar/> <Navbar/>
<div class="container h-75"> <div id="game" class="container h-75">
<div class="row h-100"> <div class="row h-100">
<div class="col-3 h-100" style="border: 1px solid black;"> <div id="chat" class="col-3 h-100" style="border: 1px solid black;">
<div id="chat" class="row h-75" style="border: 1px solid black;"> <div class="row h-75" style="border: 1px solid black;">
<div class="col w-100 h-100" style="border: 1px solid black;"> <div class="col w-100 h-100" style="border: 1px solid black;">
</div>
</div> </div>
<div id="form" class="row h-25 pt-4" style="border: 1px solid black;"> </div>
<div class="col w-100 h-75"> <div class="row h-25" style="border: 1px solid black;">
<form @submit="onSubmit"> <div class="col w-100 h-75 pt-4">
<Input :information="input" /> <form @submit="onSubmit">
</form> <Input :information="input" />
</div> </form>
</div> </div>
</div>
</div> </div>
<div id="game" class="col-9 h-100" style="border: 1px solid black;"> <div class="col-9 h-100" style="border: 1px solid black;">
</div> </div>
</div> </div>
</div> </div>
...@@ -48,14 +48,9 @@ ...@@ -48,14 +48,9 @@
<style> <style>
#chat { #chat {
background-image: url('../assets/img/chat.png'); background: linear-gradient(rgb(10, 50, 20), rgb(30, 120, 60), rgb(10, 50, 20));
}
#form {
background-image: url('../assets/img/form.jpg');
} }
#game { #game {
background-image: url('../assets/img/game.png'); background: linear-gradient(rgb(10, 50, 20), rgb(20, 85, 40), rgb(10, 50, 20));
background-repeat: no-repeat;
background-size: 100%;
} }
</style> </style>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">Créer une partie</h5> <h5 class="card-header text-primary">Créer une partie</h5>
<div class="card-body" style="width : 500px;"> <div class="card-body" style="width : 500px;">
<router-link to="/game"> <router-link to="/waiting">
<button type="button" class="btn btn-primary btn-block">Commencer</button> <button type="button" class="btn btn-primary btn-block">Commencer</button>
</router-link> </router-link>
</div> </div>
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
}); });
}, },
getToken(login, password) { getToken(login, password) {
return new Promise((resolve, reject) => { return new Promise((resolve) => {
fetch(this.$apiUrl + '/login', { fetch(this.$apiUrl + '/login', {
method: 'POST', method: 'POST',
body: JSON.stringify({ login: login, password: password }) body: JSON.stringify({ login: login, password: password })
...@@ -113,8 +113,7 @@ ...@@ -113,8 +113,7 @@
resolve(data.jwt_token) resolve(data.jwt_token)
}).catch(error => { }).catch(error => {
console.error(error) console.error(error)
console.error(reject) })
});
}) })
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="container d-flex justify-content-center"> <div class="container d-flex justify-content-center">
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">Vos informations</h5> <h5 class="card-header text-primary">Vos informations</h5>
<div class="card-body" style="width : 500px;"> <div id="body" class="card-body" style="width : 500px;">
</div> </div>
</div> </div>
...@@ -24,25 +24,41 @@ ...@@ -24,25 +24,41 @@
this.getData() this.getData()
}, },
methods: { methods: {
// Récupération des données du token // Récupération des données du user
getData() { getData() {
fetch(this.$apiUrl + '/validatetoken', { fetch(this.$apiUrl + '/user/' + localStorage.login, {
method: 'GET', method: 'GET'
headers: {
'Authorization' : 'Bearer ' + localStorage.token
}
}) })
.then(response => { .then(response => {
if (response.status === 200) { if (response.status === 200) {
console.log(response.json()) return response.json()
} }
// else { else {
// window.location.href = '/#/' throw new Error('Something went wrong on api server!')
// } }
})
.then(data => {
const body = document.querySelector('#body')
for (const [key, value] of Object.entries(data)) {
if (key != "id" && key != "password" && key != "role") {
let div = document.createElement('div')
let input = document.createElement('input')
div.className = 'form-group'
input.className = 'form-control form-control-user'
input.type = 'text'
input.id = key
input.value = value
input.autocomplete = 'off'
input.required = true
div.append(input)
body.append(div)
}
}
}) })
// .then(tokenData => {
// console.log(tokenData)
// })
} }
} }
} }
......
...@@ -5,9 +5,34 @@ ...@@ -5,9 +5,34 @@
<div class="card shadow mb-4"> <div class="card shadow mb-4">
<h5 class="card-header text-primary">En attente de joueurs</h5> <h5 class="card-header text-primary">En attente de joueurs</h5>
<div class="card-body" style="width : 500px;"> <div class="card-body" style="width : 500px;">
<table class="table table-striped table-primary">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Login</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>{{ login }}</td>
</tr>
<tr>
<th scope="row">2</th>
<td></td>
</tr>
<tr>
<th scope="row">3</th>
<td></td>
</tr>
<tr>
<th scope="row">4</th>
<td></td>
</tr>
</tbody>
</table>
<router-link to="/game"> <router-link to="/game">
<button type="button" class="btn btn-primary btn-block" style="margin-top: 20px;">Jouer</button> <button type="button" class="btn btn-primary btn-block">Jouer</button>
</router-link> </router-link>
</div> </div>
</div> </div>
...@@ -22,6 +47,11 @@ ...@@ -22,6 +47,11 @@
name: 'GameChoice', name: 'GameChoice',
components: { components: {
Navbar Navbar
},
data() {
return {
login: localStorage.login
}
} }
} }
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment