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
79114c98
Commit
79114c98
authored
5 years ago
by
Joni Laukka
Browse files
Options
Downloads
Patches
Plain Diff
Confirmations to notification form, game state buttons and edit game leaving
parent
faaef841
No related branches found
Branches containing commit
No related tags found
3 merge requests
!46
Development to testing
,
!41
Notifications + small updates
,
!39
Notification view
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/EditGameForm.js
+22
-7
22 additions, 7 deletions
src/components/EditGameForm.js
src/components/GameStateButtons.js
+35
-32
35 additions, 32 deletions
src/components/GameStateButtons.js
src/components/NotificationView.js
+4
-1
4 additions, 1 deletion
src/components/NotificationView.js
with
61 additions
and
40 deletions
src/components/EditGameForm.js
+
22
−
7
View file @
79114c98
...
@@ -30,7 +30,8 @@ export default class EditGameForm extends React.Component {
...
@@ -30,7 +30,8 @@ export default class EditGameForm extends React.Component {
objectivePoints
:
[],
objectivePoints
:
[],
capture_time
:
300
,
capture_time
:
300
,
confirmation_time
:
60
,
confirmation_time
:
60
,
displayColorPicker
:
false
displayColorPicker
:
false
,
saved
:
false
};
};
this
.
handleMapDrag
=
this
.
handleMapDrag
.
bind
(
this
);
this
.
handleMapDrag
=
this
.
handleMapDrag
.
bind
(
this
);
...
@@ -185,7 +186,12 @@ export default class EditGameForm extends React.Component {
...
@@ -185,7 +186,12 @@ export default class EditGameForm extends React.Component {
// show/hide this form
// show/hide this form
handleView
=
e
=>
{
handleView
=
e
=>
{
this
.
props
.
toggleView
(
this
.
props
.
view
);
if
(
this
.
state
.
saved
||
window
.
confirm
(
"
Are you sure you want to leave without saving?
"
)
)
{
this
.
props
.
toggleView
(
this
.
props
.
view
);
}
};
};
// remove view with ESC
// remove view with ESC
...
@@ -248,6 +254,7 @@ export default class EditGameForm extends React.Component {
...
@@ -248,6 +254,7 @@ export default class EditGameForm extends React.Component {
}
}
let
token
=
sessionStorage
.
getItem
(
"
token
"
);
let
token
=
sessionStorage
.
getItem
(
"
token
"
);
let
error
=
false
;
// Send Game info to the server
// Send Game info to the server
fetch
(
`
${
process
.
env
.
REACT_APP_API_URL
}
/game/edit/
${
this
.
props
.
gameId
}
`
,
{
fetch
(
`
${
process
.
env
.
REACT_APP_API_URL
}
/game/edit/
${
this
.
props
.
gameId
}
`
,
{
...
@@ -261,15 +268,23 @@ export default class EditGameForm extends React.Component {
...
@@ -261,15 +268,23 @@ export default class EditGameForm extends React.Component {
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
if
(
!
res
.
ok
)
{
if
(
!
res
.
ok
)
{
throw
Error
(
res
.
statusMessage
);
error
=
true
;
}
else
{
return
res
.
json
();
}
}
return
res
.
json
();
})
})
.
then
(
result
=>
{
.
then
(
result
=>
{
alert
(
result
.
message
);
alert
(
result
.
message
);
this
.
props
.
onEditSave
();
if
(
!
error
)
{
this
.
handleView
();
this
.
setState
(
{
saved
:
true
},
()
=>
{
this
.
handleView
();
this
.
props
.
onEditSave
();
}
);
}
})
})
.
catch
(
error
=>
console
.
log
(
"
Error:
"
,
error
));
.
catch
(
error
=>
console
.
log
(
"
Error:
"
,
error
));
};
};
...
...
This diff is collapsed.
Click to expand it.
src/components/GameStateButtons.js
+
35
−
32
View file @
79114c98
...
@@ -6,39 +6,42 @@ export default class GameStateButtons extends React.Component {
...
@@ -6,39 +6,42 @@ export default class GameStateButtons extends React.Component {
};
};
setGameState
(
state
)
{
setGameState
(
state
)
{
console
.
log
(
state
);
if
(
let
token
=
sessionStorage
.
getItem
(
"
token
"
);
window
.
confirm
(
`Are you sure you want to change game state to
${
state
}
?`
)
let
error
=
false
;
)
{
fetch
(
let
token
=
sessionStorage
.
getItem
(
"
token
"
);
`
${
process
.
env
.
REACT_APP_API_URL
}
/game/edit-state/
${
this
.
props
.
gameId
}
`
,
let
error
=
false
;
{
fetch
(
method
:
"
PUT
"
,
`
${
process
.
env
.
REACT_APP_API_URL
}
/game/edit-state/
${
this
.
props
.
gameId
}
`
,
headers
:
{
{
Authorization
:
"
Bearer
"
+
token
,
method
:
"
PUT
"
,
Accept
:
"
application/json
"
,
headers
:
{
"
Content-Type
"
:
"
application/json
"
Authorization
:
"
Bearer
"
+
token
,
},
Accept
:
"
application/json
"
,
body
:
JSON
.
stringify
({
"
Content-Type
"
:
"
application/json
"
id
:
this
.
props
.
gameId
,
},
state
:
state
body
:
JSON
.
stringify
({
})
id
:
this
.
props
.
gameId
,
}
state
:
state
)
})
.
then
(
res
=>
{
if
(
!
res
.
ok
)
{
error
=
true
;
}
return
res
.
json
();
})
.
then
(
res
=>
{
if
(
error
)
{
console
.
log
(
res
);
}
else
{
alert
(
`Game state changed to
${
state
}
`
);
this
.
setState
({
gameState
:
state
});
}
}
})
)
.
catch
(
error
=>
console
.
log
(
error
));
.
then
(
res
=>
{
if
(
!
res
.
ok
)
{
error
=
true
;
}
return
res
.
json
();
})
.
then
(
res
=>
{
if
(
error
)
{
console
.
log
(
res
);
}
else
{
alert
(
`Game state changed to
${
state
}
`
);
this
.
setState
({
gameState
:
state
});
}
})
.
catch
(
error
=>
console
.
log
(
error
));
}
}
}
render
()
{
render
()
{
...
...
This diff is collapsed.
Click to expand it.
src/components/NotificationView.js
+
4
−
1
View file @
79114c98
...
@@ -30,12 +30,15 @@ export default class NotificationView extends React.Component {
...
@@ -30,12 +30,15 @@ export default class NotificationView extends React.Component {
if
(
this
.
state
.
notificationInput
===
""
)
{
if
(
this
.
state
.
notificationInput
===
""
)
{
alert
(
"
notification message can't be empty
"
);
alert
(
"
notification message can't be empty
"
);
}
else
{
}
else
if
(
window
.
confirm
(
"
Are you sure you want to send the notification
"
)
)
{
this
.
props
.
socket
.
emit
(
"
game-info
"
,
{
this
.
props
.
socket
.
emit
(
"
game-info
"
,
{
type
:
this
.
state
.
notificationTypeInput
,
type
:
this
.
state
.
notificationTypeInput
,
message
:
this
.
state
.
notificationInput
,
message
:
this
.
state
.
notificationInput
,
game
:
this
.
props
.
gameId
game
:
this
.
props
.
gameId
});
});
alert
(
"
Notification sent
"
);
this
.
getNotifications
(
this
.
props
.
gameId
);
this
.
getNotifications
(
this
.
props
.
gameId
);
this
.
setState
({
notificationInput
:
""
});
this
.
setState
({
notificationInput
:
""
});
}
}
...
...
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