Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Manish Kumar
webpoke
Commits
2a5dbf40
Commit
2a5dbf40
authored
Jun 21, 2020
by
Sofia Aicha Delijaj
Browse files
showing the leaderboard
parent
2eb678e4
Changes
11
Hide whitespace changes
Inline
Side-by-side
backend/app/controllers/joueur.controller.js
View file @
2a5dbf40
...
...
@@ -108,4 +108,15 @@ exports.refuse = (req, res) => {
else
res
.
send
(
data
);
});
}
};
exports
.
wins
=
(
req
,
res
)
=>
{
Joueur
.
wins
((
err
,
data
)
=>
{
if
(
err
)
res
.
status
(
500
).
send
({
message
:
err
.
message
||
"
Some error occurred while retrieving Pokemon.
"
});
else
res
.
send
(
data
);
});
};
\ No newline at end of file
backend/app/models/joueur.model.js
View file @
2a5dbf40
...
...
@@ -95,5 +95,16 @@ Joueur.refuse = (pseudo, ami, result) => {
});
};
Joueur
.
wins
=
(
result
)
=>
{
sql
.
query
(
"
SELECT pseudo, win from joueur ORDER BY win DESC
"
,
(
err
,
res
)
=>
{
if
(
err
)
{
console
.
log
(
"
error:
"
,
err
);
result
(
null
,
err
);
return
;
}
result
(
null
,
res
);
});
};
module
.
exports
=
Joueur
;
\ No newline at end of file
backend/app/routes/joueur.routes.js
View file @
2a5dbf40
...
...
@@ -25,4 +25,7 @@ module.exports = app => {
// Logout
app
.
get
(
"
/logout
"
,
joueur
.
desAuth
);
//get the descendent wins
app
.
get
(
"
/winners
"
,
joueur
.
wins
);
};
\ No newline at end of file
frontend/src/app/app-routing.module.ts
View file @
2a5dbf40
...
...
@@ -8,6 +8,7 @@ import { AccountMenuComponent } from './account-menu/account-menu.component';
import
{
ProfilComponent
}
from
'
./profil/profil.component
'
;
import
{
HomeComponent
}
from
'
./home/home.component
'
import
{
BattleComponent
}
from
"
./battle/battle.component
"
;
import
{
LeaderboardComponent
}
from
'
./leaderboard/leaderboard.component
'
;
const
routes
:
Routes
=
[
...
...
frontend/src/app/app.module.ts
View file @
2a5dbf40
...
...
@@ -22,6 +22,7 @@ import { OnlinePlayersComponent } from './sub-components/online-players/online-p
import
{
NotifierModule
}
from
"
angular-notifier
"
;
import
{
BattleComponent
}
from
'
./battle/battle.component
'
;
import
{
NgbModule
}
from
'
@ng-bootstrap/ng-bootstrap
'
;
import
{
LeaderboardComponent
}
from
'
./leaderboard/leaderboard.component
'
;
@
NgModule
({
...
...
@@ -37,7 +38,8 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
ProfilComponent
,
HomeComponent
,
OnlinePlayersComponent
,
BattleComponent
BattleComponent
,
LeaderboardComponent
],
imports
:
[
BrowserModule
,
...
...
frontend/src/app/header/header.component.html
View file @
2a5dbf40
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarSupportedContent"
aria-controls=
"navbarSupportedContent"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
...
...
frontend/src/app/home/home.component.html
View file @
2a5dbf40
<img
src=
"https://upload.wikimedia.org/wikipedia/commons/thumb/9/98/International_Pok%C3%A9mon_logo.svg/1200px-International_Pok%C3%A9mon_logo.svg.png"
alt=
"Paris"
class=
"center"
>
<div
class=
"container"
>
<app-online-players></app-online-players>
<app-
online-players></app-online-players
>
<app-
leaderboard></app-leaderboard
>
</div>
\ No newline at end of file
frontend/src/app/leaderboard/leaderboard.component.css
0 → 100644
View file @
2a5dbf40
frontend/src/app/leaderboard/leaderboard.component.html
0 → 100644
View file @
2a5dbf40
<h1>
Leaderboard
</h1>
<div>
<table
class=
"table"
>
<tr>
<th>
Pseudo
</th>
<th>
Nombre de victoire
</th>
</tr>
<tr
*ngFor=
"let i of resultat"
>
<th>
{{i.pseudo}}
</th>
<th>
{{i.win}}
</th>
</tr>
</table>
</div>
\ No newline at end of file
frontend/src/app/leaderboard/leaderboard.component.spec.ts
0 → 100644
View file @
2a5dbf40
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
LeaderboardComponent
}
from
'
./leaderboard.component
'
;
describe
(
'
LeaderboardComponent
'
,
()
=>
{
let
component
:
LeaderboardComponent
;
let
fixture
:
ComponentFixture
<
LeaderboardComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
LeaderboardComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
LeaderboardComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
frontend/src/app/leaderboard/leaderboard.component.ts
0 → 100644
View file @
2a5dbf40
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
HttpClient
}
from
'
@angular/common/http
'
;
@
Component
({
selector
:
'
app-leaderboard
'
,
templateUrl
:
'
./leaderboard.component.html
'
,
styleUrls
:
[
'
./leaderboard.component.css
'
]
})
export
class
LeaderboardComponent
implements
OnInit
{
constructor
(
private
httpClient
:
HttpClient
)
{
}
resultat
:
any
=
{};
ngOnInit
():
void
{
this
.
httpClient
.
get
(
'
http://localhost:3000/winners
'
,
{
responseType
:
'
json
'
,
withCredentials
:
true
}).
subscribe
(
res
=>
{
this
.
resultat
=
res
;
console
.
log
(
res
)})
}
}
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