fin projet

This commit is contained in:
2025-04-03 14:38:06 +02:00
parent 83fa675ddf
commit 25156c612f
4 changed files with 75 additions and 25 deletions

View File

@@ -6,13 +6,16 @@
<p if="{this.props.Type === 'master'}">{state.release.year}</p>
<p if="{this.props.Type === 'master'}">{state.release.name}</p>
<a if="{this.props.Type !== 'artist' && state.release.artists?.[0]}" href={"#/release-details/artist/" + state.release.artists[0].id}>{state.release.artists[0].name}</p>
<div class="container">
<img class="cover" if="{this.props.Type === 'master'}" src="{state.release.image?.[0]?.resource_url}" alt="{state.release.title}" />
<img class="cover" if="{this.props.Type !== 'master'}" src="{state.release.thumb}" alt="{state.release.title}" />
<div class="details-right" if="{this.props.Type !== 'artist'}">
<b>Track list</b>
<b if="{this.props.Type === 'master' && state.release.profile}">Track list</b>
<div if="{this.props.Type === 'master' && !state.release.profile}">
<h4>{state.release.message}</h4>
</div>
<ul>
<li each="{track in state.release.tracklist}">
{track.position} - {track.title} - {track.duration}
@@ -24,18 +27,22 @@
</div>
</div>
<div if="{this.props.Type === 'artist'}">
<h3>{state.release.name}</h3>
<h4>Biographie</h4>
{state.release.profile}
<strong if="{!state.release.profile || state.release.profile.trim() === ''}">Pas de profil</strong>
</div>
<!-- Liste des extra-artists avec liens -->
<div class="credits" if="{this.props.Type === 'release'}">
<b>Crédits :</b>
<ul>
<li each="{artist in state.resource.extraartists}">
<a href={"#/release-details/" + "artist" + "/" + artist.id }>{artist.name} - {artist.role}</a>
{console.log(state.resource)}
</li>
</ul>
<select onchange="{goToArtist}">
<option disabled selected>-- Sélectionnez un artiste --</option>
<option each="{artist in state.resource.extraartists}" value={"#/release-details/artist/" + artist.id}>
{artist.name} - {artist.role}
</option>
</select>
</div>
<a if={this.props.Type === "release"} href={"#/release-details/master/" + state.release.master_id}><button>master</button></a>
</div>
</div>
@@ -48,23 +55,38 @@
resource: []
},
async onMounted() {
const id = this.props.Id
if(this.props.Type === "release"){
this.state.release = await window.getReleaseDetails(id);
previousId: null,
previousType: "",
// Récupérer les extra-artists depuis leur URL
const response = await fetch(this.state.release.resource_url);
this.state.resource = await response.json();
async onMounted() {
await this.loadData()
},
async onBeforeUpdate() {
if (this.props.Id !== this.previousId || this.props.Type !== this.previousType) {
await this.loadData()
}
else if (this.props.Type === "master"){
this.state.release = await window.getMasterDetails(id)
},
async loadData() {
this.previousId = this.props.Id
this.previousType = this.props.Type
if (this.props.Type === "release") {
this.state.release = await window.getReleaseDetails(this.props.Id)
const response = await fetch(this.state.release.resource_url)
this.state.resource = await response.json()
} else if (this.props.Type === "master") {
this.state.release = await window.getMasterDetails(this.props.Id)
} else if (this.props.Type === "artist") {
this.state.release = await window.getArtistDetails(this.props.Id)
}
else{
this.state.release = await window.getArtistDetails(id)
}
console.log(this.state.release)
this.update()
},
goToArtist(e) {
const url = e.target.value;
if (url) window.location.hash = url;
}
}
</script>
@@ -188,5 +210,6 @@
.credits a:hover {
text-decoration: underline;
}
</style>
</release-details>