2022-02-23 08:41:30 +01:00
|
|
|
<main class="layout-maxed ajouter-un-album" id="app">
|
|
|
|
<h1>Ajouter un album</h1>
|
2022-08-29 23:22:28 +02:00
|
|
|
<form @submit="search">
|
|
|
|
<div class="grid sm:grid-cols-2">
|
|
|
|
<div>
|
2022-02-23 11:33:57 +01:00
|
|
|
<label for="q">Nom de l'album ou code barre</label>
|
2022-02-18 16:53:54 +01:00
|
|
|
<div class="field has-addons">
|
2022-08-29 23:22:28 +02:00
|
|
|
<input type="text" name="q" id="q" v-model="q" placeholder="ex : Iron Maiden - Powerslave" autofocus>
|
2022-03-01 16:09:46 +01:00
|
|
|
<button class="button is-primary" :disabled="loading" aria-label="Chercher">
|
2022-02-23 08:41:30 +01:00
|
|
|
<i class="icon-search" v-if="!loading"></i>
|
|
|
|
<i class="icon-spin animate-spin" v-if="loading"></i>
|
2022-02-18 16:53:54 +01:00
|
|
|
</button>
|
|
|
|
</div>
|
2022-08-29 23:22:28 +02:00
|
|
|
<div class="grid sm:grid-cols-3 gap-5">
|
|
|
|
<div class="field">
|
2022-09-03 17:11:17 +02:00
|
|
|
<label for="format">Format</label>
|
2022-08-29 23:22:28 +02:00
|
|
|
<select id="format" v-model="format">
|
|
|
|
<option value="">Tous</option>
|
|
|
|
<option v-for="format in orderedItems(formats)" :value="format">{{format}}</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label for="year">Année</label>
|
|
|
|
<input type="number" name="year" v-model="year" id="year" placeholder="1984">
|
|
|
|
</div>
|
|
|
|
<div class="field">
|
|
|
|
<label for="country">Pays</label>
|
|
|
|
<input type="string" name="country" v-model="country" id="country" placeholder="France">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-02-18 16:53:54 +01:00
|
|
|
</div>
|
2022-08-29 23:22:28 +02:00
|
|
|
</form>
|
|
|
|
|
2022-03-01 16:09:46 +01:00
|
|
|
|
2022-03-07 16:58:02 +01:00
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 list hover">
|
2022-02-18 19:24:10 +01:00
|
|
|
<div class="item" v-if="!loading" v-for="item in items">
|
2022-02-18 16:53:54 +01:00
|
|
|
<a @click="loadDetails(item.id)" class="title">{{ item.artists_sort }} {{ item.title }}</a>
|
|
|
|
<div class="grid grid-cols-2 md:grid-cols-4">
|
|
|
|
<div>
|
2022-03-01 16:09:46 +01:00
|
|
|
<img :src="item.thumb" :alt="item.title" @click="loadDetails(item.id)"/>
|
2022-02-18 16:53:54 +01:00
|
|
|
</div>
|
|
|
|
<div class="md:col-span-3">
|
|
|
|
<span><strong>Année :</strong> {{ item.year }}</span>
|
|
|
|
<br />
|
|
|
|
<span><strong>Pays :</strong> {{ item.country }}</span>
|
|
|
|
<br />
|
2022-02-22 08:15:07 +01:00
|
|
|
<span>
|
|
|
|
<strong>Format : </strong>
|
|
|
|
<template v-for="(format, index) in item.format">
|
|
|
|
{{ format }}<template v-if="index < item.format.length - 1">, </template>
|
|
|
|
</template>
|
2022-02-18 16:53:54 +01:00
|
|
|
</span>
|
|
|
|
<br />
|
2022-02-22 08:15:07 +01:00
|
|
|
<span>
|
2022-03-01 16:09:46 +01:00
|
|
|
<strong>Genre : </strong>
|
2022-02-22 08:15:07 +01:00
|
|
|
<template v-for="(genre, index) in item.genre">
|
|
|
|
{{ genre }}<template v-if="index < item.genre.length - 1">, </template>
|
|
|
|
</template>
|
2022-02-18 16:53:54 +01:00
|
|
|
</span>
|
|
|
|
<br />
|
2022-02-22 08:15:07 +01:00
|
|
|
<span>
|
|
|
|
<strong>Style : </strong>
|
|
|
|
<template v-for="(style, index) in item.style">
|
|
|
|
{{ style }}<template v-if="index < item.style.length - 1">, </template>
|
|
|
|
</template>
|
2022-02-18 16:53:54 +01:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2022-03-03 17:03:18 +01:00
|
|
|
<div class="modal" :class="{'is-visible': modalIsVisible}">
|
2022-02-17 09:37:25 +01:00
|
|
|
<div class="modal-background"></div>
|
|
|
|
<div class="modal-card">
|
2022-02-18 11:05:10 +01:00
|
|
|
<header>
|
|
|
|
<div>{{details.artists_sort}} - {{details.title}}</div>
|
2022-03-03 17:03:18 +01:00
|
|
|
<button aria-label="Fermer" class="close" @click="toggleModal"></button>
|
2022-02-17 09:37:25 +01:00
|
|
|
</header>
|
2022-02-18 11:05:10 +01:00
|
|
|
<section>
|
|
|
|
<div class="grid grid-cols-2 gap-16">
|
|
|
|
<div>
|
|
|
|
<div class="text-center">
|
2022-02-23 10:39:17 +01:00
|
|
|
<img :src="details.thumb %>" :alt="`Miniature pour l'album ${details.title}`" />
|
2022-02-17 09:37:25 +01:00
|
|
|
<hr />
|
2022-02-23 10:39:17 +01:00
|
|
|
<img v-for="image in details.images" :src="image.uri150" :alt="`Miniature de type ${image.type}`" style="max-width: 60px;" />
|
2022-02-17 09:37:25 +01:00
|
|
|
<hr />
|
|
|
|
</div>
|
|
|
|
<ol class="ml-4">
|
|
|
|
<li v-for="track in details.tracklist">{{ track.title }} ({{track.duration}})</li>
|
|
|
|
</ol>
|
|
|
|
</div>
|
2022-02-18 11:05:10 +01:00
|
|
|
<div>
|
|
|
|
<div class="grid grid-cols-2 gap-10">
|
2022-02-22 08:15:07 +01:00
|
|
|
<div>
|
2022-02-18 11:05:10 +01:00
|
|
|
<strong>Genres</strong>
|
|
|
|
<br />
|
2022-02-22 08:15:07 +01:00
|
|
|
<template v-for="(genre, index) in details.genres">
|
|
|
|
{{genre}}<template v-if="index < details.genres.length - 1">, </template>
|
|
|
|
</template>
|
2022-02-18 11:05:10 +01:00
|
|
|
</div>
|
2022-02-22 08:15:07 +01:00
|
|
|
<div>
|
2022-02-18 11:05:10 +01:00
|
|
|
<strong>Styles</strong>
|
|
|
|
<br />
|
2022-02-22 08:15:07 +01:00
|
|
|
<span v-for="(style, index) in details.styles">
|
|
|
|
{{style}}<template v-if="index < details.styles.length - 1">, </template>
|
|
|
|
</span>
|
2022-02-18 11:05:10 +01:00
|
|
|
</div>
|
2022-02-18 19:24:10 +01:00
|
|
|
</div>
|
2022-02-18 11:05:10 +01:00
|
|
|
<hr />
|
|
|
|
<div class="grid grid-cols-3 gap-10">
|
|
|
|
<div>
|
|
|
|
<strong>Pays</strong>
|
|
|
|
<br />
|
|
|
|
<span>{{details.country}}</span>
|
2022-02-18 19:24:10 +01:00
|
|
|
</div>
|
2022-02-18 11:05:10 +01:00
|
|
|
<div>
|
|
|
|
<strong>Année</strong>
|
|
|
|
<br />
|
|
|
|
<span>{{details.year}}</span>
|
2022-02-17 09:37:25 +01:00
|
|
|
</div>
|
2022-02-18 11:05:10 +01:00
|
|
|
<div>
|
|
|
|
<strong>Date de sortie</strong>
|
|
|
|
<br />
|
|
|
|
<span>{{details.released}}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<div class="grid grid-cols-2 gap-10">
|
|
|
|
<div>
|
|
|
|
<strong>Format</strong>
|
|
|
|
<br />
|
2022-02-22 08:15:07 +01:00
|
|
|
<span v-for="(format, index) in details.formats">
|
|
|
|
{{format.name}}<template v-if="index < details.formats.length - 1">, </template>
|
|
|
|
</span>
|
2022-02-18 11:05:10 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<div class="grid grid-cols-2 gap-10">
|
|
|
|
<div>
|
|
|
|
<strong>Codes barres</strong>
|
|
|
|
<ol>
|
|
|
|
<li v-for="identifier in details.identifiers">
|
|
|
|
{{identifier.value}} ({{identifier.type}})
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<strong>Label</strong>
|
|
|
|
<ol>
|
|
|
|
<li v-for="label in details.labels">
|
|
|
|
{{label.name}}
|
|
|
|
</li>
|
|
|
|
</ol>
|
|
|
|
<strong>Société</strong>
|
|
|
|
<ol>
|
|
|
|
<li v-for="company in details.companie">
|
|
|
|
{{company.name}}
|
|
|
|
</li>
|
|
|
|
</ol>
|
2022-02-17 09:37:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2022-02-18 11:05:10 +01:00
|
|
|
<footer>
|
|
|
|
<button class="button is-primary" @click="add">Ajouter</button>
|
2022-02-17 09:37:25 +01:00
|
|
|
<button class="button" @click="toggleModal">Annuler</button>
|
2022-02-18 19:24:10 +01:00
|
|
|
</footer>
|
2022-02-17 09:37:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-02-23 08:41:30 +01:00
|
|
|
</main>
|
2022-02-18 11:05:10 +01:00
|
|
|
|
2022-02-15 11:03:20 +01:00
|
|
|
<script>
|
|
|
|
Vue.createApp({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
q: '',
|
2022-08-29 23:22:28 +02:00
|
|
|
year: '',
|
|
|
|
country: '',
|
|
|
|
format: '',
|
2022-02-15 16:45:14 +01:00
|
|
|
loading: false,
|
2022-02-15 11:03:20 +01:00
|
|
|
items: [],
|
2022-02-17 09:37:25 +01:00
|
|
|
details: {},
|
|
|
|
modalIsVisible: false,
|
2022-08-29 23:22:28 +02:00
|
|
|
formats: [
|
|
|
|
'Vinyl',
|
|
|
|
'Acetate',
|
|
|
|
'Flexi-disc',
|
|
|
|
'Lathe Cut',
|
|
|
|
'Mighty Tiny',
|
|
|
|
'Shellac',
|
|
|
|
'Sopic',
|
|
|
|
'Pathé Disc',
|
|
|
|
'Edison Disc',
|
|
|
|
'Cylinder',
|
|
|
|
'CD',
|
|
|
|
'CDr',
|
|
|
|
'CDV',
|
|
|
|
'DVD',
|
|
|
|
'DVDr',
|
|
|
|
'HD DVD',
|
|
|
|
'HD DVD-R',
|
|
|
|
'Blu-ray',
|
|
|
|
'Blu-ray-R',
|
|
|
|
'Ultra HD Blu-ray',
|
|
|
|
'SACD',
|
|
|
|
'4-Track Cartridge',
|
|
|
|
'8-Track Cartridge',
|
|
|
|
'Cassette',
|
|
|
|
'DC-International',
|
|
|
|
'Elcaset',
|
|
|
|
'PlayTape',
|
|
|
|
'RCA Tape Cartridge',
|
|
|
|
'DAT',
|
|
|
|
'DCC',
|
|
|
|
'Microcassette',
|
|
|
|
'NT Cassette',
|
|
|
|
'Pocket Rocker',
|
|
|
|
'Revere Magnetic Stereo Tape Ca',
|
|
|
|
'Tefifon',
|
|
|
|
'Reel-To-Reel',
|
|
|
|
'Sabamobil',
|
|
|
|
'Betacam',
|
|
|
|
'Betacam SP',
|
|
|
|
'Betamax',
|
|
|
|
'Cartrivision',
|
|
|
|
'MiniDV',
|
|
|
|
'Super VHS',
|
|
|
|
'U-matic',
|
|
|
|
'VHS',
|
|
|
|
'Video 2000',
|
|
|
|
'Video8',
|
|
|
|
'Film Reel',
|
|
|
|
'HitClips',
|
|
|
|
'Laserdisc',
|
|
|
|
'SelectaVision',
|
|
|
|
'VHD',
|
|
|
|
'Wire Recording',
|
|
|
|
'Minidisc',
|
|
|
|
'MVD',
|
|
|
|
'UMD',
|
|
|
|
'Floppy Disk',
|
|
|
|
'File',
|
|
|
|
'Memory Stick',
|
|
|
|
'Hybrid',
|
|
|
|
'All Media',
|
|
|
|
'Box Set',
|
|
|
|
]
|
2022-02-15 11:03:20 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
search(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
2022-02-15 16:45:14 +01:00
|
|
|
if ( this.loading ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = true;
|
2022-08-29 23:22:28 +02:00
|
|
|
let url = `/api/v1/search?q=${this.q}`;
|
|
|
|
|
|
|
|
if ( this.year ) {
|
|
|
|
url += `&year=${this.year}`;
|
|
|
|
}
|
|
|
|
if ( this.country ) {
|
|
|
|
url += `&country=${this.country}`;
|
|
|
|
}
|
|
|
|
if ( this.format ) {
|
|
|
|
url += `&format=${this.format}`;
|
|
|
|
}
|
2022-02-15 16:45:14 +01:00
|
|
|
|
2022-08-29 23:22:28 +02:00
|
|
|
axios.get(url)
|
2022-02-15 11:03:20 +01:00
|
|
|
.then( response => {
|
|
|
|
const {
|
|
|
|
results,
|
|
|
|
} = response.data;
|
|
|
|
let items = [];
|
|
|
|
|
|
|
|
for (let i = 0 ; i < results.length ; i += 1 ) {
|
|
|
|
const {
|
|
|
|
id,
|
|
|
|
title,
|
|
|
|
thumb,
|
|
|
|
year,
|
|
|
|
country,
|
|
|
|
format,
|
|
|
|
genre,
|
|
|
|
style,
|
|
|
|
} = results[i];
|
|
|
|
items.push({
|
|
|
|
id,
|
|
|
|
title,
|
|
|
|
thumb,
|
|
|
|
year,
|
|
|
|
country,
|
|
|
|
format,
|
|
|
|
genre,
|
|
|
|
style,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.items = items;
|
|
|
|
})
|
2022-02-15 16:45:14 +01:00
|
|
|
.catch((err) => {
|
|
|
|
showToastr(err.response?.data?.message || "Aucun résultat trouvé :/");
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.loading = false;
|
2022-02-15 11:03:20 +01:00
|
|
|
});
|
2022-02-17 09:37:25 +01:00
|
|
|
},
|
|
|
|
toggleModal() {
|
|
|
|
this.modalIsVisible = !this.modalIsVisible;
|
|
|
|
},
|
|
|
|
loadDetails(discogsId) {
|
|
|
|
axios.get(`/api/v1/search/${discogsId}`)
|
|
|
|
.then( response => {
|
|
|
|
const {
|
|
|
|
data,
|
|
|
|
} = response;
|
|
|
|
|
|
|
|
this.details = data;
|
|
|
|
this.toggleModal();
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
showToastr(err.response?.data?.message || "Impossible de charger les détails de cet album");
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
add() {
|
|
|
|
axios.post('/api/v1/albums', this.details)
|
|
|
|
.then(() => {
|
|
|
|
window.location.href = '/ma-collection';
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-04-10 15:27:51 +02:00
|
|
|
showToastr(err.response?.data?.message || "Impossible d'ajouter cet album pour le moment…");
|
2022-02-17 09:37:25 +01:00
|
|
|
});
|
|
|
|
},
|
2022-08-29 23:22:28 +02:00
|
|
|
orderedItems(items) {
|
|
|
|
return items.sort();
|
|
|
|
}
|
2022-02-15 11:03:20 +01:00
|
|
|
}
|
2022-03-03 17:03:18 +01:00
|
|
|
}).mount('#app');
|
2022-04-10 15:21:15 +02:00
|
|
|
</script>
|