Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
AstroProject
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin VAN DE MERGHEL
AstroProject
Commits
9860067d
"content/slides/cri/ansible.html" did not exist on "797ff74416de55e4992d240a6da3fc60f317379f"
Commit
9860067d
authored
9 months ago
by
ForkBench
Browse files
Options
Downloads
Patches
Plain Diff
Adding flags to registrations
parent
59e82294
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/Util.ts
+22
-1
22 additions, 1 deletion
frontend/src/Util.ts
frontend/src/components/Registrations/Registrations.svelte
+37
-20
37 additions, 20 deletions
frontend/src/components/Registrations/Registrations.svelte
with
59 additions
and
21 deletions
frontend/src/Util.ts
+
22
−
1
View file @
9860067d
import
type
{
Nation
}
from
"
../bindings/changeme/astro/services/models
"
;
export
function
randomColor
(
brightness
:
number
):
string
{
export
function
randomColor
(
brightness
:
number
):
string
{
function
randomChannel
(
brightness
:
number
):
string
{
function
randomChannel
(
brightness
:
number
):
string
{
var
r
=
255
-
brightness
;
var
r
=
255
-
brightness
;
...
@@ -8,4 +10,23 @@ export function randomColor(brightness: number): string {
...
@@ -8,4 +10,23 @@ export function randomColor(brightness: number): string {
return
'
#
'
+
randomChannel
(
brightness
)
+
randomChannel
(
brightness
)
+
randomChannel
(
brightness
);
return
'
#
'
+
randomChannel
(
brightness
)
+
randomChannel
(
brightness
)
+
randomChannel
(
brightness
);
}
}
export
const
rightBrighness
=
240
;
export
const
rightBrighness
=
240
;
\ No newline at end of file
export
function
getNationFlag
(
nation
:
Nation
|
null
):
string
{
if
(
!
nation
)
{
return
"
https://flagsapi.com/FR/flat/64.png
"
;
}
console
.
log
(
`"
${
nation
.
nation_code
}
"`
);
return
`https://flagsapi.com/
${
nation
.
nation_code
}
/flat/64.png`
}
export
function
getNationFlatAlt
(
nation
:
Nation
|
null
):
string
{
if
(
!
nation
)
{
return
"
FR
"
;
}
return
nation
.
nation_code
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/components/Registrations/Registrations.svelte
+
37
−
20
View file @
9860067d
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
import
{
SelectedCompetition
}
from
"
../../store
"
;
import
{
SelectedCompetition
}
from
"
../../store
"
;
import
{
GenerateRandomPlayer
}
from
"
../../../bindings/changeme/astro/services/player
"
;
import
{
GenerateRandomPlayer
}
from
"
../../../bindings/changeme/astro/services/player
"
;
import
swal
from
"
sweetalert
"
;
import
swal
from
"
sweetalert
"
;
import
{
getNationFlag
,
getNationFlatAlt
}
from
"
../../Util
"
;
// Variables that will be used in the component
// Variables that will be used in the component
let
players
:
(
Models
.
Player
|
null
)[]
=
[];
let
players
:
(
Models
.
Player
|
null
)[]
=
[];
...
@@ -124,23 +125,23 @@
...
@@ -124,23 +125,23 @@
key
:
"
PlayerInitialRank
"
,
key
:
"
PlayerInitialRank
"
,
asc
:
!
sortBy
.
asc
,
asc
:
!
sortBy
.
asc
,
}
;
}
;
}}
>
Initial
Rank
</th
}}
>
Rank
</th
>
>
<th
<th
on:click=
{
()
=>
{
on:click=
{
()
=>
{
sortBy
=
{
sortBy
=
{
key
:
"
Player
Fir
stname
"
,
key
:
"
Player
La
stname
"
,
asc
:
!
sortBy
.
asc
,
asc
:
!
sortBy
.
asc
,
}
;
}
;
}}
>
Fir
stname
</th
}}
>
La
stname
</th
>
>
<th
<th
on:click=
{
()
=>
{
on:click=
{
()
=>
{
sortBy
=
{
sortBy
=
{
key
:
"
Player
La
stname
"
,
key
:
"
Player
Fir
stname
"
,
asc
:
!
sortBy
.
asc
,
asc
:
!
sortBy
.
asc
,
}
;
}
;
}}
>
La
stname
</th
}}
>
Fir
stname
</th
>
>
<th
<th
on:click=
{
()
=>
{
on:click=
{
()
=>
{
...
@@ -213,12 +214,12 @@
...
@@ -213,12 +214,12 @@
>
>
<td
<td
on:dblclick=
{
async
()
=>
{
on:dblclick=
{
async
()
=>
{
// Show a prompt to the user to change the
fir
stname
// Show a prompt to the user to change the
la
stname
let
new
Fir
stname
=
await
swal
(
{
let
new
La
stname
=
await
swal
(
{
content
:
{
content
:
{
element
:
"
input
"
,
element
:
"
input
"
,
attributes
:
{
attributes
:
{
placeholder
:
"
New
fir
stname
"
,
placeholder
:
"
New
la
stname
"
,
}
,
}
,
},
},
buttons:
{
buttons:
{
...
@@ -228,8 +229,8 @@
...
@@ -228,8 +229,8 @@
});
});
//
Check
if
the
user
confirmed
the
prompt
//
Check
if
the
user
confirmed
the
prompt
if
(
new
Fir
stname
)
{
if
(
new
La
stname
)
{
player.Player
Fir
stname =
new
Fir
stname;
player.Player
La
stname =
new
La
stname;
if
(
competition
!=
undefined
)
if
(
competition
!=
undefined
)
await
Session.UpdateCompetitionPlayer
(
await
Session.UpdateCompetitionPlayer
(
competition.CompetitionID
,
competition.CompetitionID
,
...
@@ -238,16 +239,17 @@
...
@@ -238,16 +239,17 @@
loadPlayers
();
loadPlayers
();
}
);
}
);
}
}
}}
>
{
player
.
PlayerFirstname
}
</td
}}
>
{
player
.
PlayerLastname
.
toLocaleUpperCase
()
}
</td
>
>
<td
<td
on:dblclick=
{
async
()
=>
{
on:dblclick=
{
async
()
=>
{
// Show a prompt to the user to change the
la
stname
// Show a prompt to the user to change the
fir
stname
let
new
La
stname
=
await
swal
(
{
let
new
Fir
stname
=
await
swal
(
{
content
:
{
content
:
{
element
:
"
input
"
,
element
:
"
input
"
,
attributes
:
{
attributes
:
{
placeholder
:
"
New
la
stname
"
,
placeholder
:
"
New
fir
stname
"
,
}
,
}
,
},
},
buttons:
{
buttons:
{
...
@@ -257,8 +259,8 @@
...
@@ -257,8 +259,8 @@
});
});
//
Check
if
the
user
confirmed
the
prompt
//
Check
if
the
user
confirmed
the
prompt
if
(
new
La
stname
)
{
if
(
new
Fir
stname
)
{
player.Player
La
stname =
new
La
stname;
player.Player
Fir
stname =
new
Fir
stname;
if
(
competition
!=
undefined
)
if
(
competition
!=
undefined
)
await
Session.UpdateCompetitionPlayer
(
await
Session.UpdateCompetitionPlayer
(
competition.CompetitionID
,
competition.CompetitionID
,
...
@@ -267,7 +269,7 @@
...
@@ -267,7 +269,7 @@
loadPlayers
();
loadPlayers
();
}
);
}
);
}
}
}}
>
{
player
.
Player
La
stname
}
</td
}}
>
{
player
.
Player
Fir
stname
}
</td
>
>
<td
<td
>
{
#if
player
.
PlayerClub
}{
player
.
PlayerClub
>
{
#if
player
.
PlayerClub
}{
player
.
PlayerClub
...
@@ -277,9 +279,14 @@
...
@@ -277,9 +279,14 @@
>
{
#if
player
.
PlayerRegion
}{
player
.
PlayerRegion
>
{
#if
player
.
PlayerRegion
}{
player
.
PlayerRegion
.
region_name
}{
:
else
}
Sans Nom
{
/if
}
</td
.
region_name
}{
:
else
}
Sans Nom
{
/if
}
</td
>
>
<td
<td
class=
"flag-container"
>
{
#if
player
.
PlayerNation
}{
player
.
PlayerNation
><img
.
nation_name
}{
:
else
}
Sans Nom
{
/if
}
</td
src=
{
getNationFlag
(
player
.
PlayerNation
)
}
alt=
"Player's flag : {getNationFlatAlt(
player.PlayerNation
)}"
class=
"flag"
/></td
>
>
</tr>
</tr>
{
/if
}
{
/if
}
...
@@ -348,4 +355,14 @@
...
@@ -348,4 +355,14 @@
color
:
red
;
color
:
red
;
text-align
:
center
;
text-align
:
center
;
}
}
.flag-container
{
text-align
:
left
;
}
.flag
{
width
:
20px
;
height
:
20px
;
vertical-align
:
middle
;
}
</style>
</style>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment