2022-10-28 22:40:02 +02:00
|
|
|
Vue.createApp({
|
|
|
|
data() {
|
|
|
|
return {
|
2022-10-28 22:56:04 +02:00
|
|
|
q: "",
|
|
|
|
year: "",
|
|
|
|
country: "",
|
|
|
|
format: "",
|
2022-10-28 22:40:02 +02:00
|
|
|
loading: false,
|
|
|
|
items: [],
|
|
|
|
details: {},
|
|
|
|
modalIsVisible: false,
|
|
|
|
formats: [
|
2022-10-28 22:56:04 +02:00
|
|
|
"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-10-28 22:40:02 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
search(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
2022-10-28 22:56:04 +02:00
|
|
|
if (this.loading) {
|
2022-10-28 22:40:02 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.loading = true;
|
|
|
|
let url = `/api/v1/search?q=${this.q}`;
|
|
|
|
|
2022-10-28 22:56:04 +02:00
|
|
|
if (this.year) {
|
2022-10-28 22:40:02 +02:00
|
|
|
url += `&year=${this.year}`;
|
|
|
|
}
|
2022-10-28 22:56:04 +02:00
|
|
|
if (this.country) {
|
2022-10-28 22:40:02 +02:00
|
|
|
url += `&country=${this.country}`;
|
|
|
|
}
|
2022-10-28 22:56:04 +02:00
|
|
|
if (this.format) {
|
2022-10-28 22:40:02 +02:00
|
|
|
url += `&format=${this.format}`;
|
|
|
|
}
|
|
|
|
|
2022-10-28 22:56:04 +02:00
|
|
|
return axios
|
|
|
|
.get(url)
|
|
|
|
.then((response) => {
|
|
|
|
const { results } = response.data;
|
|
|
|
const items = [];
|
2022-10-28 22:40:02 +02:00
|
|
|
|
2022-10-28 22:56:04 +02:00
|
|
|
for (let i = 0; i < results.length; i += 1) {
|
2022-10-28 22:40:02 +02:00
|
|
|
const {
|
|
|
|
id,
|
|
|
|
title,
|
|
|
|
thumb,
|
|
|
|
year,
|
|
|
|
country,
|
|
|
|
format,
|
|
|
|
genre,
|
|
|
|
style,
|
|
|
|
} = results[i];
|
|
|
|
items.push({
|
|
|
|
id,
|
|
|
|
title,
|
|
|
|
thumb,
|
|
|
|
year,
|
|
|
|
country,
|
|
|
|
format,
|
|
|
|
genre,
|
|
|
|
style,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
this.items = items;
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-10-28 22:56:04 +02:00
|
|
|
showToastr(
|
|
|
|
err.response?.data?.message ||
|
|
|
|
"Aucun résultat trouvé :/"
|
|
|
|
);
|
2022-10-28 22:40:02 +02:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
toggleModal() {
|
|
|
|
this.modalIsVisible = !this.modalIsVisible;
|
|
|
|
},
|
|
|
|
loadDetails(discogsId) {
|
2022-10-28 22:56:04 +02:00
|
|
|
axios
|
|
|
|
.get(`/api/v1/search/${discogsId}`)
|
|
|
|
.then((response) => {
|
|
|
|
const { data } = response;
|
2022-10-28 22:40:02 +02:00
|
|
|
|
|
|
|
this.details = data;
|
|
|
|
this.toggleModal();
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-10-28 22:56:04 +02:00
|
|
|
showToastr(
|
|
|
|
err.response?.data?.message ||
|
|
|
|
"Impossible de charger les détails de cet album"
|
|
|
|
);
|
2022-10-28 22:40:02 +02:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
add() {
|
2022-10-28 22:56:04 +02:00
|
|
|
axios
|
|
|
|
.post("/api/v1/albums", this.details)
|
2022-10-28 22:40:02 +02:00
|
|
|
.then(() => {
|
2022-10-28 22:56:04 +02:00
|
|
|
window.location.href = "/ma-collection";
|
2022-10-28 22:40:02 +02:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-10-28 22:56:04 +02:00
|
|
|
showToastr(
|
|
|
|
err.response?.data?.message ||
|
|
|
|
"Impossible d'ajouter cet album pour le moment…"
|
|
|
|
);
|
2022-10-28 22:40:02 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
orderedItems(items) {
|
|
|
|
return items.sort();
|
2022-10-28 22:56:04 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}).mount("#ajouter-album");
|