forked from dbroqua/MusicTopus
Some changes in structure + add album
This commit is contained in:
parent
3ebdc9c06a
commit
f08e70eb7c
36 changed files with 883 additions and 165 deletions
11
views/error.ejs
Normal file
11
views/error.ejs
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div class="container">
|
||||
<section class="px-md-5 mx-md-5 dark-grey-text mb-4">
|
||||
<h1><%= page.title %></h1>
|
||||
<% if ( errorCode && errorCode === 404 ) { %>
|
||||
<img src="/img/404.svg" alt="Erreur 404" style="max-height: 400px;" />
|
||||
<% } %>
|
||||
<pre>
|
||||
<%= page.error %>
|
||||
</pre>
|
||||
</section>
|
||||
</div>
|
37
views/index.ejs
Normal file
37
views/index.ejs
Normal file
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<%- include('partials/head'); %>
|
||||
<body>
|
||||
<header>
|
||||
<%- include('partials/header'); %>
|
||||
</header>
|
||||
|
||||
|
||||
<div id="toastr"></div>
|
||||
|
||||
<main class="mt-4 mb-5">
|
||||
|
||||
<% if ( page.failureFlash ) {%>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<%= page.failureFlash %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<%
|
||||
if (error && error.length > 0) {
|
||||
for( let i = 0 ; i < error.length ; i += 1 ) {
|
||||
%>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<%= error %>
|
||||
</div>
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
<%- include(viewname) %>
|
||||
</main>
|
||||
<footer class="bg-light text-lg-start">
|
||||
<%- include('partials/footer'); %>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
144
views/pages/ajouter-un-album/form.ejs
Normal file
144
views/pages/ajouter-un-album/form.ejs
Normal file
|
@ -0,0 +1,144 @@
|
|||
<div class="container-fluid" id="app">
|
||||
<form class="bg-white rounded shadow-5-strong p-5" method="POST" @submit="add">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-3 p-2 text-center">
|
||||
<img src="<%= page.values.thumb %>" alt="Miniature" />
|
||||
<hr />
|
||||
<img v-for="image in album.images" :src="image.uri150" alt="Miniature" style="max-width: 60px;" />
|
||||
<hr />
|
||||
<ol>
|
||||
<li v-for="track in album.tracklist">{{ track.title }} ({{track.duration}})</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="col-12 col-sm-9 p-2">
|
||||
<div class="row">
|
||||
<div class="col-12 p-2">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="title" name="title" class="form-control" v-model="album.title" disabled />
|
||||
<label class="form-label" for="artists">Titre</label>
|
||||
</div>
|
||||
|
||||
<div class="form-outline mb-4" v-for="artist in album.artists">
|
||||
<input type="text" id="artists" name="artists" class="form-control" v-model="artist.name" disabled />
|
||||
<label class="form-label" for="artists">Artiste</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2" v-for="genre in album.genres">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="genres" name="genres" class="form-control" v-model="genre" disabled />
|
||||
<label class="form-label" for="company">Genre</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 p-2" v-for="style in album.styles">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="style" name="style" class="form-control" v-model="style" disabled />
|
||||
<label class="form-label" for="company">Style</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="year" name="year" class="form-control" v-model="album.year" disabled />
|
||||
<label class="form-label" for="year">Année</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 p-2">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="released" name="released" class="form-control" v-model="album.released" disabled />
|
||||
<label class="form-label" for="released">Date de sortie</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="country" name="country" class="form-control" v-model="album.country" disabled />
|
||||
<label class="form-label" for="country">Pays</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2">
|
||||
<ol>
|
||||
<li v-for="identifier in album.identifiers">
|
||||
{{identifier.value}} ({{identifier.type}})
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 p-2">
|
||||
<div class="form-outline mb-4">
|
||||
<textarea id="notes" id="notes" name="notes" class="form-control" v-model="album.notes" disabled></textarea>
|
||||
<label class="form-label" for="country">Notes</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2" v-for="format in album.formats">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="format" name="format" class="form-control" v-model="format.name" disabled />
|
||||
<label class="form-label" for="format">Format</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2" v-for="label in album.labels">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="label" name="label" class="form-control" v-model="label.name" disabled />
|
||||
<label class="form-label" for="label">Label</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2" v-for="company in album.companies">
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="company" name="company" class="form-control" v-model="company.name" disabled />
|
||||
<label class="form-label" for="company">Société</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2">
|
||||
<ol>
|
||||
<li v-for="video in album.videos">
|
||||
<a :href="video.uri" target="_blank">{{video.title}}</a>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12 col-sm-6 p-2">
|
||||
<ol>
|
||||
<li v-for="extraartist in album.extraartists">
|
||||
{{extraartist.name}} ({{extraartist.role}})
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">Ajouter</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
const defaultValues = <%- JSON.stringify(page.values) %>;
|
||||
|
||||
Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
album: defaultValues,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add(event) {
|
||||
event.preventDefault();
|
||||
|
||||
axios.post('/api/v1/albums', this.album)
|
||||
.then(() => {
|
||||
window.location.href = '/ma-collection';
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('ERR:', err.response);
|
||||
showToastr(err.response?.data?.message || "Impossible d'ajouter ce album pour le moment…");
|
||||
});
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
|
105
views/pages/ajouter-un-album/search.ejs
Normal file
105
views/pages/ajouter-un-album/search.ejs
Normal file
|
@ -0,0 +1,105 @@
|
|||
<div class="container-fluid" id="app">
|
||||
<form @submit="search">
|
||||
<div class="input-group mb-3">
|
||||
<div class="form-outline">
|
||||
<input v-model="q" type="search" id="q" class="form-control" />
|
||||
<label class="form-label" for="q">Nom de l'album ou code barre</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<table class="table table-striped table-hover table-sm align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pochette</th>
|
||||
<th>Titre</th>
|
||||
<th>Pays</th>
|
||||
<th>Année</th>
|
||||
<th>Format</th>
|
||||
<th>Genres</th>
|
||||
<th>Styles</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in items">
|
||||
<td>
|
||||
<img :src="item.thumb" :alt="item.title" style="max-width: 120px;"/>
|
||||
</td>
|
||||
<td>
|
||||
<a :href="'/ajouter-un-album/' + item.id">{{ item.title }}</a>
|
||||
</td>
|
||||
<td>{{ item.year }}</td>
|
||||
<td>{{ item.country }}</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li v-for="format in item.format">{{ format }}</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li v-for="genre in item.genre">{{ genre }}</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li v-for="style in item.style">{{ style }}</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
q: '',
|
||||
items: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search(event) {
|
||||
event.preventDefault();
|
||||
|
||||
axios.get(`/api/v1/search?q=${this.q}`)
|
||||
.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;
|
||||
})
|
||||
.catch( err => {
|
||||
console.log('err:', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
|
30
views/pages/connexion.ejs
Normal file
30
views/pages/connexion.ejs
Normal file
|
@ -0,0 +1,30 @@
|
|||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-xl-5 col-md-8">
|
||||
<form class="bg-white rounded shadow-5-strong p-5" method="POST">
|
||||
<div class="text-center">
|
||||
<img class="mb-4" src="/img/logo.png" alt="DarKou">
|
||||
</div>
|
||||
<h4>Connexion</h4>
|
||||
|
||||
<div class="form-outline mb-4">
|
||||
<input type="email" id="email" name="email" class="form-control" />
|
||||
<label class="form-label" for="email">Adresse e-mail</label>
|
||||
</div>
|
||||
|
||||
<div class="form-outline mb-4">
|
||||
<input type="password" id="password" name="password" class="form-control" />
|
||||
<label class="form-label" for="password">Mot de passe</label>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col text-end">
|
||||
<p>Pas encore inscrit ? <a href="/inscription">Inscrivez-vous</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-block">Connexion</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
35
views/pages/inscription.ejs
Normal file
35
views/pages/inscription.ejs
Normal file
|
@ -0,0 +1,35 @@
|
|||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-xl-5 col-md-8">
|
||||
<form class="bg-white rounded shadow-5-strong p-5" method="POST">
|
||||
<div class="text-center">
|
||||
<img class="mb-4" src="/img/logo.png" alt="DarKou">
|
||||
</div>
|
||||
<h4>Inscription</h4>
|
||||
|
||||
<div class="form-outline mb-4">
|
||||
<input type="text" id="username" name="username" class="form-control" />
|
||||
<label class="form-label" for="username">Nom d'utilisateur</label>
|
||||
</div>
|
||||
|
||||
<div class="form-outline mb-4">
|
||||
<input type="email" id="email" name="email" class="form-control" />
|
||||
<label class="form-label" for="email">Adresse e-mail</label>
|
||||
</div>
|
||||
|
||||
<div class="form-outline mb-4">
|
||||
<input type="password" id="password" name="password" class="form-control" />
|
||||
<label class="form-label" for="password">Mot de passe</label>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col text-end">
|
||||
<p>Déjà inscrit ? <a href="/connexion">Connectez-vous</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary btn-block">Inscription</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
2
views/partials/footer.ejs
Normal file
2
views/partials/footer.ejs
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
<script type="text/javascript" src="/libs/mdb-ui-kit/js/mdb.min.js"></script>
|
39
views/partials/head.ejs
Normal file
39
views/partials/head.ejs
Normal file
|
@ -0,0 +1,39 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title><% if (page.title) { %><%= page.title %> <% } else { %> DarKou - Ma CDThèque <% } %></title>
|
||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||
|
||||
<link
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
href="/libs/mdb-ui-kit/css/mdb.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<link href="/css/main.css" rel="stylesheet" />
|
||||
|
||||
<script type="text/javascript" src="/libs/jquery/jquery.min.js"></script>
|
||||
|
||||
<script src="/libs/axios/axios.min.js"></script>
|
||||
<script src="/libs/vue/vue.global.prod.js"></script>
|
||||
|
||||
<script>
|
||||
function showToastr(message) {
|
||||
var x = document.getElementById("toastr");
|
||||
if ( message ) {
|
||||
x.innerHTML = message;
|
||||
}
|
||||
|
||||
x.className = "show";
|
||||
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
|
||||
};
|
||||
</script>
|
||||
</head>
|
49
views/partials/header.ejs
Normal file
49
views/partials/header.ejs
Normal file
|
@ -0,0 +1,49 @@
|
|||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<button
|
||||
class="navbar-toggler"
|
||||
type="button"
|
||||
data-mdb-toggle="collapse"
|
||||
data-mdb-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false"
|
||||
aria-label="Toggle navigation"
|
||||
>
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<a class="navbar-brand mt-2 mt-lg-0" href="/">
|
||||
Ma CDThèque
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<% if ( user ) { %>
|
||||
<div class="d-flex align-items-center">
|
||||
<a class="text-reset me-3" href="/ajouter-un-album">
|
||||
Ajouter un album
|
||||
</a>
|
||||
<div class="dropdown">
|
||||
<a
|
||||
class="dropdown-toggle d-flex align-items-center hidden-arrow"
|
||||
href="#"
|
||||
id="navbarDropdownMenuAvatar"
|
||||
role="button"
|
||||
data-mdb-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
>
|
||||
Mon compte
|
||||
</a>
|
||||
<ul
|
||||
class="dropdown-menu dropdown-menu-end"
|
||||
aria-labelledby="navbarDropdownMenuAvatar"
|
||||
>
|
||||
<li><a class="dropdown-item" href="/ma-collection">Ma collection</a></li>
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
<li><a class="dropdown-item" href="/se-deconnecter">Déconnexion</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</nav>
|
Loading…
Add table
Add a link
Reference in a new issue