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
Merge requests
!149
Issue#8
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue#8
s3190285/mod4-wp-2023-2024-pokemon:issue#8
into
main
Overview
0
Commits
10
Pipelines
0
Changes
4
Open
s3190285
requested to merge
s3190285/mod4-wp-2023-2024-pokemon:issue#8
into
main
10 months ago
Overview
0
Commits
10
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
main
main (HEAD)
and
latest version
latest version
53e07700
10 commits,
10 months ago
4 files
+
373
−
2
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
src/main/webapp/js/requests.js
+
87
−
2
Options
@@ -18,7 +18,6 @@ function updateDetails(pokemonTypeId) {
<h5 class="card-title">
${
pt
.
name
}
#
${
pt
.
pokedexNumber
}
</h5>
<p class="card-text">
Japanese name:
${
pt
.
japaneseName
}
</br>
Classification:
${
pt
.
classification
}
</br>
Abilities:
${
pt
.
abilities
?.
join
(
"
,
"
)
||
"
none
"
}
</br>
Type:
${
pt
.
primaryType
}${
pt
.
secondaryType
?
"
,
"
+
pt
.
secondaryType
:
""
}
</p>
@@ -60,4 +59,90 @@ function createPokemonTypesTable() {
</tbody>
</table>
`
}
\ No newline at end of file
}
function
updatePokemonTypesTable
()
{
fetch
(
'
/pokemon/api/pokemonTypes
'
)
.
then
(
res
=>
res
.
json
())
.
then
(
data
=>
{
pokemonTypes
=
data
;
})
.
catch
(
err
=>
{
console
.
error
(
`Unable to fetch Pokemon types
${
err
.
status
}
`
);
console
.
error
(
err
);
});
}
function
createPokemonType
()
{
let
time
=
new
Date
();
const
name
=
document
.
getElementById
(
'
pokemonName
'
).
value
;
const
imgUrl
=
document
.
getElementById
(
'
imgUrl
'
).
value
;
// const japaneseName = document.getElementById('japaneseName').value;
const
pokedexNumber
=
document
.
getElementById
(
'
pokedexNumber
'
).
value
;
// const abilities = document.getElementById('abilities').value;
// const baseAttack = document.getElementById('baseAttack').value;
// const captureRate = document.getElementById('captureRate').value;
// const classification = document.getElementById('classification').value;
// const baseDefense = document.getElementById('baseDefense').value;
// const baseHeight = document.getElementById('baseHeight').value;
// const baseHp = document.getElementById('baseHp').value;
// const baseSpAttack = document.getElementById('baseSpAttack').value;
// const baseSpDefense = document.getElementById('baseSpDefense').value;
// const baseSpeed = document.getElementById('baseSpeed').value;
const
primaryType
=
document
.
getElementById
(
'
primaryType
'
).
value
;
const
secondaryType
=
document
.
getElementById
(
'
secondaryType
'
).
value
;
// const baseWeight = document.getElementById('baseWeight').value;
// const generation = document.getElementById('generation').value;
// const isLegendary = document.getElementById('isLegendary').value;
const
data
=
{
id
:
0
,
created
:
time
,
lastUpDate
:
time
,
imgUrl
:
imgUrl
,
name
:
name
,
japaneseName
:
0
,
pokedexNumber
:
pokedexNumber
,
abilities
:
null
,
baseAttack
:
0
,
captureRate
:
0
,
classification
:
0
,
baseDefense
:
0
,
baseHeight
:
0
,
baseHp
:
0
,
baseSpAttack
:
0
,
baseSpDefense
:
0
,
baseSpeed
:
0
,
primaryType
:
primaryType
,
secondaryType
:
secondaryType
,
baseWeight
:
0
,
generation
:
0
,
isLegendary
:
0
}
fetch
(
'
/pokemon/api/pokemonTypes
'
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
(
data
)
}).
then
(
response
=>
updatePokemonTypesTable
())
}
function
deletePokemonType
()
{
let
idPokemon
=
document
.
getElementById
(
"
pokemonId
"
).
value
;
fetch
(
`/pokemon/api/pokemonTypes/
${
idPokemon
}
`
,
{
method
:
'
DELETE
'
})
.
then
(
response
=>
{
if
(
response
.
ok
)
{
// Trainer deleted successfully, update UI
updatePokemonTypesTable
();
// Reload trainer table
updateDetails
(
''
);
// Clear details panel
}
else
{
console
.
error
(
'
Failed to delete Pokemon type:
'
,
response
.
status
);
}
})
.
catch
(
error
=>
{
console
.
error
(
'
Error deleting Pokemon type:
'
,
error
);
});
}
Loading