Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ehasa-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
WIMMA Lab 2019
Overflow
ehasa-frontend
Commits
b2dc9886
Commit
b2dc9886
authored
5 years ago
by
Joni Laukka
Browse files
Options
Downloads
Patches
Plain Diff
game info view added. game edit button now needs game state 'CREATED'
parent
35eb3767
No related branches found
No related tags found
3 merge requests
!46
Development to testing
,
!41
Notifications + small updates
,
!39
Notification view
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/GameInfoView.js
+70
-0
70 additions, 0 deletions
src/components/GameInfoView.js
src/components/GameView.js
+19
-8
19 additions, 8 deletions
src/components/GameView.js
with
89 additions
and
8 deletions
src/components/GameInfoView.js
0 → 100644
+
70
−
0
View file @
b2dc9886
import
React
from
"
react
"
;
import
{
Map
,
TileLayer
}
from
"
react-leaflet
"
;
export
default
class
GameInfoView
extends
React
.
Component
{
componentDidMount
()
{
document
.
addEventListener
(
"
keyup
"
,
this
.
handleEsc
);
}
componentWillUnmount
()
{
document
.
removeEventListener
(
"
keyup
"
,
this
.
handleEsc
);
}
handleEsc
=
e
=>
{
if
(
e
.
keyCode
===
27
)
{
this
.
props
.
toggleView
();
}
};
render
()
{
if
(
this
.
props
.
gameInfo
===
undefined
)
{
return
false
;
}
return
(
<
div
className
=
"
fade-main
"
>
<
div
className
=
"
sticky
"
>
<
span
id
=
"
closeEditGameFormX
"
className
=
"
close
"
onClick
=
{
this
.
props
.
toggleView
}
>
×
<
/span
>
<
/div
>
<
div
className
=
""
>
<
h1
>
Game
Info
<
/h1
>
<
p
>
Game
name
:
{
this
.
props
.
gameInfo
.
name
}
<
/p
>
<
p
>
Description
:
{
this
.
props
.
gameInfo
.
desc
}
<
/p
>
<
p
>
Start
date
:
{
this
.
props
.
gameInfo
.
startdate
}
<
/p
>
<
p
>
End
date
:
{
this
.
props
.
gameInfo
.
enddate
}
<
/p
>
<
h2
>
Factions
<
/h2
>
<
div
>
{
this
.
props
.
gameInfo
.
factions
.
map
(
faction
=>
(
<
p
key
=
{
faction
.
factionId
}
style
=
{{
color
:
faction
.
colour
}}
>
{
faction
.
factionName
}
<
/p
>
))}
<
/div
>
<
div
>
<
Map
id
=
"
gameInfoCenterMap
"
className
=
""
center
=
{[
this
.
props
.
gameInfo
.
center
.
lat
,
this
.
props
.
gameInfo
.
center
.
lng
]}
zoom
=
"
13
"
maxZoom
=
"
13
"
style
=
{{
height
:
"
400px
"
,
width
:
"
400px
"
}}
>
<
TileLayer
attribution
=
"
Maanmittauslaitoksen kartta
"
url
=
"
https://tiles.kartat.kapsi.fi/taustakartta/{z}/{x}/{y}.jpg
"
/>
<
/Map
>
<
/div
>
<
/div
>
<
/div
>
);
}
}
This diff is collapsed.
Click to expand it.
src/components/GameView.js
+
19
−
8
View file @
b2dc9886
...
@@ -9,6 +9,7 @@ import NotificationView from "./NotificationView";
...
@@ -9,6 +9,7 @@ import NotificationView from "./NotificationView";
import
GameStateButtons
from
"
./GameStateButtons
"
;
import
GameStateButtons
from
"
./GameStateButtons
"
;
import
ClientSocket
from
"
./Socket
"
;
import
ClientSocket
from
"
./Socket
"
;
import
NotificationPopup
from
"
./NotificationPopup
"
;
import
NotificationPopup
from
"
./NotificationPopup
"
;
import
GameInfoView
from
"
./GameInfoView
"
;
export
default
class
GameView
extends
React
.
Component
{
export
default
class
GameView
extends
React
.
Component
{
state
=
{
state
=
{
...
@@ -133,14 +134,18 @@ export default class GameView extends React.Component {
...
@@ -133,14 +134,18 @@ export default class GameView extends React.Component {
{this.state.role !== "" && (
{this.state.role !== "" && (
<div>Your role in this game: {this.state.role}</div>
<div>Your role in this game: {this.state.role}</div>
)}
)}
{this.state.role === "admin" && (
{this.state.role === "admin" &&
<button
this.state.gameInfo.state === "CREATED" && (
id="editGameButton"
<button
onClick={() => this.setState({ form: "edit" })}
id="editGameButton"
>
onClick={() => this.setState({ form: "edit" })}
Edit
>
</button>
Edit
)}
</button>
)}
<button onClick={() => this.setState({ form: "info" })}>
Game Info
</button>
{this.state.role === "" && (
{this.state.role === "" && (
<button
<button
id="joinGameButton"
id="joinGameButton"
...
@@ -225,6 +230,12 @@ export default class GameView extends React.Component {
...
@@ -225,6 +230,12 @@ export default class GameView extends React.Component {
}
}
/>
/>
)}
)}
{this.state.form === "info" && (
<GameInfoView
gameInfo={this.state.gameInfo}
toggleView={() => this.setState({ form: "" })}
/>
)}
</div>
</div>
)}
)}
</div>
</div>
...
...
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