Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mod4-wp-2023-2024-pokemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Service Desk
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
Morais Fonseca, Claudenir (UT-EEMCS)
mod4-wp-2023-2024-pokemon
Commits
e4eb33f6
Commit
e4eb33f6
authored
10 months ago
by
Gyunderov, I.A. (Ivan, Student B-TCS)
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3
solved
parent
6a3ddb4e
No related branches found
No related tags found
1 merge request
!102
Update trainer
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/webapp/js/requests.js
+43
-0
43 additions, 0 deletions
src/main/webapp/js/requests.js
src/main/webapp/trainers.html
+20
-3
20 additions, 3 deletions
src/main/webapp/trainers.html
with
63 additions
and
3 deletions
src/main/webapp/js/requests.js
+
43
−
0
View file @
e4eb33f6
...
@@ -148,4 +148,47 @@ function createTrainer() {
...
@@ -148,4 +148,47 @@ function createTrainer() {
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
error
(
'
Error:
'
,
error
);
console
.
error
(
'
Error:
'
,
error
);
});
});
}
function
updateTrainer
()
{
const
id
=
document
.
getElementById
(
'
updateTrainerId
'
).
value
;
const
name
=
document
.
getElementById
(
'
updateTrainerName
'
).
value
;
const
profileUrl
=
document
.
getElementById
(
'
updateTrainerProfileUrl
'
).
value
;
const
currentTrainer
=
pokemonTrainers
?.
data
?.
find
(
item
=>
item
.
id
==
id
);
const
creationDate
=
currentTrainer
.
created
;
const
trainer
=
{
id
:
id
,
name
:
name
,
profileUrl
:
profileUrl
,
created
:
creationDate
,
lastUpDate
:
new
Date
().
toLocaleDateString
()
};
fetch
(
`/pokemon/api/trainers/
${
id
}
`
,
{
method
:
'
PUT
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
body
:
JSON
.
stringify
(
trainer
),
})
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
console
.
log
(
'
Success:
'
,
data
);
// Refresh the trainers table
fetch
(
'
/pokemon/api/trainers
'
)
.
then
(
res
=>
res
.
json
())
.
then
(
data
=>
{
pokemonTrainers
=
data
;
createPokemonTrainersTable
();
})
.
catch
(
err
=>
{
console
.
error
(
`Unable to fetch Pokemon Trainers:
${
err
.
status
}
`
);
console
.
error
(
err
);
});
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Error:
'
,
error
);
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/webapp/trainers.html
+
20
−
3
View file @
e4eb33f6
...
@@ -39,8 +39,9 @@
...
@@ -39,8 +39,9 @@
<div
id=
"detailsDiv"
class=
"col-4"
>
No data
</div>
<div
id=
"detailsDiv"
class=
"col-4"
>
No data
</div>
</div>
</div>
</div>
</div>
</br>
<form
id=
"createTrainerForm"
onsubmit=
"event.preventDefault(); createTrainer();"
>
<h1>
Create Trainer
</h1>
<form
id=
"createTrainerForm"
onsubmit=
"createTrainer();"
>
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6"
>
<label
for=
"trainerName"
>
Name
</label>
<label
for=
"trainerName"
>
Name
</label>
<input
type=
"text"
class=
"form-control"
id=
"trainerName"
required
>
<input
type=
"text"
class=
"form-control"
id=
"trainerName"
required
>
...
@@ -51,6 +52,22 @@
...
@@ -51,6 +52,22 @@
</div>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Create Trainer
</button>
<button
type=
"submit"
class=
"btn btn-primary"
>
Create Trainer
</button>
</form>
</form>
</br>
<h1>
Update Trainer
</h1>
<form
id=
"updateTrainerForm"
onsubmit=
"updateTrainer();"
>
<div
class=
"form-group col-md-6"
>
<label
for=
"updateTrainerId"
>
ID
</label>
<input
type=
"text"
class=
"form-control"
id=
"updateTrainerId"
required
>
</div>
<div
class=
"form-group col-md-6"
>
<label
for=
"updateTrainerName"
>
Name
</label>
<input
type=
"text"
class=
"form-control"
id=
"updateTrainerName"
required
>
</div>
<div
class=
"form-group col-md-6"
>
<label
for=
"updateTrainerProfileUrl"
>
Profile URL (optional)
</label>
<input
type=
"text"
class=
"form-control"
id=
"updateTrainerProfileUrl"
>
</div>
<button
type=
"submit"
class=
"btn btn-primary"
>
Update Trainer
</button>
</form>
</body>
</body>
</html>
</html>
\ No newline at end of file
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