Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-cdaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Quentin Vrel
projet-cdaw
Commits
5ee521d2
Commit
5ee521d2
authored
Dec 03, 2020
by
quentin.vrel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lobby handles actual data
parent
c45159f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
16 deletions
+37
-16
Lobby.vue
frontend/src/views/Lobby.vue
+37
-16
No files found.
frontend/src/views/Lobby.vue
View file @
5ee521d2
<
template
>
<div
class=
"lobby"
>
<user-ribbon
class=
"lobby-ribbon"
username=
"Josie Péritel
"
/>
<user-ribbon
class=
"lobby-ribbon"
:username=
"this.user.login"
:pathToImage=
"this.user.avatar
"
/>
<div
class=
"lobby-content"
>
<div
class=
"lobby-column"
>
<page-title
pagetitle=
"Parties"
/>
...
...
@@ -33,7 +33,7 @@ import UserRibbon from '@/components/UserRibbon.vue'
import
PageTitle
from
'@/components/PageTitle.vue'
import
ButtonText
from
'@/components/ButtonText.vue'
import
TextInput
from
'@/components/form/TextInput.vue'
import
User
from
'@/model/user.js'
export
default
{
name
:
'lobby'
,
...
...
@@ -44,12 +44,24 @@ export default {
TextInput
},
methods
:
{
getUserInfo
:
async
function
(){
let
userJson
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
));
let
user
=
new
User
(
userJson
.
id_user
,
userJson
.
id_role
,
userJson
.
login
,
userJson
.
avatar
,
userJson
.
lastname
,
userJson
.
firstname
,
userJson
.
mail
);
let
token
=
userJson
.
jwt_token
;
this
.
user
=
user
;
this
.
token
=
token
;
},
updateGames
:
async
function
(){
let
response
=
await
fetch
(
this
.
$apiRoot
+
'/game/public'
,
{
method
:
'GET'
});
if
(
response
.
ok
){
let
json
=
await
response
.
json
();
this
.
games
=
json
;
}
const
head
=
new
Headers
();
head
.
append
(
'Authorization'
,
'bearer '
+
this
.
token
);
await
fetch
(
this
.
$apiRoot
+
'/game/public'
,
{
method
:
'GET'
,
headers
:
head
})
.
then
(
response
=>
response
.
json
())
.
then
(
json
=>
this
.
games
=
json
)
.
catch
(()
=>
{
alert
(
"Votre session a expiré"
);
this
.
$router
.
push
(
"/"
);
});
},
/*
* using the id of the hovered button, highlight (id>0) or set back to default style (id=0) the relevant button
...
...
@@ -75,7 +87,7 @@ export default {
onSubmitMenu
:
function
(){
if
(
event
.
submitter
.
id
==
'profile'
)
{
this
.
$router
.
push
(
'profile
'
);
this
.
$router
.
push
(
'profile
/'
+
this
.
user
.
id_user
);
}
if
(
event
.
submitter
.
id
==
'new'
)
{
this
.
$router
.
push
(
'new'
);
...
...
@@ -92,19 +104,28 @@ export default {
},
data
()
{
return
{
games
:
[
{
"ID_GAME"
:
"2"
,
"NB_PLAYER"
:
"1"
,
"LOGIN"
:
"admin"
}
]
user
:
[],
token
:
''
,
games
:
[]
}
},
mounted
()
{
beforeCreate
()
{
if
(
localStorage
.
getItem
(
'user'
)
==
null
)
{
alert
(
'Vous devez être connecté'
);
this
.
$router
.
push
(
'/'
);
}
},
created
()
{
this
.
getUserInfo
();
this
.
handle
=
setInterval
(
this
.
updateGames
,
1000
)
},
destroyed
()
{
clearInterval
(
this
.
handle
);
}
}
</
script
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment