Added pagination size
This commit is contained in:
parent
d4e6d23459
commit
bf2e9be3b7
11 changed files with 54 additions and 17 deletions
|
@ -7,8 +7,8 @@ Vue.createApp({
|
||||||
total: 0,
|
total: 0,
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
page: query.page || 1,
|
page: query.page || 1,
|
||||||
|
limit: 16,
|
||||||
totalPages: 1,
|
totalPages: 1,
|
||||||
limit: 24,
|
|
||||||
artist: "",
|
artist: "",
|
||||||
format: "",
|
format: "",
|
||||||
year: "",
|
year: "",
|
||||||
|
@ -69,7 +69,7 @@ Vue.createApp({
|
||||||
|
|
||||||
this.sortOrder = `${sortOrder.sort}-${sortOrder.order}`;
|
this.sortOrder = `${sortOrder.sort}-${sortOrder.order}`;
|
||||||
|
|
||||||
let url = `/api/v1/albums?page=${this.page}&limit=${this.limit}&sort=${this.sort}&order=${this.order}`;
|
let url = `/api/v1/albums?page=${this.page}&sort=${this.sort}&order=${this.order}`;
|
||||||
if (this.artist) {
|
if (this.artist) {
|
||||||
url += `&artist=${this.formatParams(this.artist)}`;
|
url += `&artist=${this.formatParams(this.artist)}`;
|
||||||
}
|
}
|
||||||
|
@ -94,6 +94,7 @@ Vue.createApp({
|
||||||
.get(url)
|
.get(url)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.items = response.data.rows;
|
this.items = response.data.rows;
|
||||||
|
this.limit = response.data.limit;
|
||||||
this.total = response.data.count || 0;
|
this.total = response.data.count || 0;
|
||||||
this.totalPages =
|
this.totalPages =
|
||||||
parseInt(response.data.count / this.limit, 10) +
|
parseInt(response.data.count / this.limit, 10) +
|
||||||
|
|
|
@ -11,6 +11,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
|
||||||
password: "",
|
password: "",
|
||||||
passwordConfirm: "",
|
passwordConfirm: "",
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
|
pagination,
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
mastodon: mastodon || {
|
mastodon: mastodon || {
|
||||||
publish: false,
|
publish: false,
|
||||||
url: "",
|
url: "",
|
||||||
|
@ -56,7 +58,7 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
async updateProfil() {
|
async updateProfil() {
|
||||||
this.errors = [];
|
this.errors = [];
|
||||||
const { oldPassword, password, passwordConfirm, mastodon } =
|
const { oldPassword, password, passwordConfirm, mastodon, pagination } =
|
||||||
this.formData;
|
this.formData;
|
||||||
|
|
||||||
if (password && !oldPassword) {
|
if (password && !oldPassword) {
|
||||||
|
@ -82,6 +84,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") {
|
||||||
data.oldPassword = oldPassword;
|
data.oldPassword = oldPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.pagination = pagination;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.patch(`/api/v1/me`, data);
|
await axios.patch(`/api/v1/me`, data);
|
||||||
|
|
||||||
|
|
|
@ -5,15 +5,19 @@
|
||||||
color: var(--font-color);
|
color: var(--font-color);
|
||||||
display: block;
|
display: block;
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
width: calc(100% - 2rem);
|
|
||||||
margin: auto;
|
|
||||||
@include transition() {}
|
@include transition() {}
|
||||||
|
|
||||||
@include respond-to("small-up") {
|
&.mini {
|
||||||
width: 65%;
|
margin: auto;
|
||||||
}
|
width: calc(100% - 2rem);
|
||||||
@include respond-to("medium-up") {
|
|
||||||
width: 35%;
|
@include respond-to("small-up") {
|
||||||
|
width: 65%;
|
||||||
|
}
|
||||||
|
@include respond-to("medium-up") {
|
||||||
|
width: 35%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
|
|
@ -192,7 +192,6 @@ Publié automatiquement via #musictopus`;
|
||||||
async getAll() {
|
async getAll() {
|
||||||
const {
|
const {
|
||||||
page,
|
page,
|
||||||
limit,
|
|
||||||
exportFormat = "json",
|
exportFormat = "json",
|
||||||
sort = "artists_sort",
|
sort = "artists_sort",
|
||||||
order = "asc",
|
order = "asc",
|
||||||
|
@ -206,6 +205,8 @@ Publié automatiquement via #musictopus`;
|
||||||
discogsId,
|
discogsId,
|
||||||
} = this.req.query;
|
} = this.req.query;
|
||||||
|
|
||||||
|
const limit = this.req.user?.pagination || 16;
|
||||||
|
|
||||||
let userId = this.req.user?._id;
|
let userId = this.req.user?._id;
|
||||||
|
|
||||||
const where = {};
|
const where = {};
|
||||||
|
@ -303,6 +304,7 @@ Publié automatiquement via #musictopus`;
|
||||||
default:
|
default:
|
||||||
return {
|
return {
|
||||||
rows,
|
rows,
|
||||||
|
limit,
|
||||||
count,
|
count,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Me extends Pages {
|
||||||
const { _id } = this.req.user;
|
const { _id } = this.req.user;
|
||||||
|
|
||||||
const schema = Joi.object({
|
const schema = Joi.object({
|
||||||
|
pagination: Joi.number(),
|
||||||
isPublicCollection: Joi.boolean(),
|
isPublicCollection: Joi.boolean(),
|
||||||
oldPassword: Joi.string(),
|
oldPassword: Joi.string(),
|
||||||
password: Joi.string(),
|
password: Joi.string(),
|
||||||
|
@ -45,6 +46,10 @@ class Me extends Pages {
|
||||||
user.salt = value.password;
|
user.salt = value.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value.pagination) {
|
||||||
|
user.pagination = value.pagination;
|
||||||
|
}
|
||||||
|
|
||||||
if (value.isPublicCollection !== undefined) {
|
if (value.isPublicCollection !== undefined) {
|
||||||
user.isPublicCollection = value.isPublicCollection;
|
user.isPublicCollection = value.isPublicCollection;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,10 @@ const UserSchema = new mongoose.Schema(
|
||||||
},
|
},
|
||||||
hash: String,
|
hash: String,
|
||||||
salt: String,
|
salt: String,
|
||||||
|
pagination: {
|
||||||
|
type: Number,
|
||||||
|
default: 16,
|
||||||
|
},
|
||||||
isPublicCollection: {
|
isPublicCollection: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -238,7 +238,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 id="boites">Les boites</h2>
|
<h2 id="boites">Les boites</h2>
|
||||||
<div class="box">
|
<div class="box mini">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<h1>
|
<h1>
|
||||||
Connexion
|
Connexion
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="box">
|
<div class="box mini">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<h1>
|
<h1>
|
||||||
Connexion
|
Connexion
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="box">
|
<div class="box mini">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<h1>
|
<h1>
|
||||||
Inscription
|
Inscription
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<form method="POST" @submit.prevent="updateProfil">
|
<form method="POST" @submit.prevent="updateProfil">
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-10">
|
||||||
<div>
|
<div class="box">
|
||||||
<h2>Mes données personnelles</h2>
|
<h2>Mes données personnelles</h2>
|
||||||
<div>
|
<div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="box">
|
||||||
<h2>Mon activité</h2>
|
<h2>Mon activité</h2>
|
||||||
<div>
|
<div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -126,6 +126,22 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="box">
|
||||||
|
<h2>Mes préférences</h2>
|
||||||
|
<div>
|
||||||
|
<div class="field">
|
||||||
|
<label for="pagination">Pagination</label>
|
||||||
|
<select id="pagination" v-model="formData.pagination">
|
||||||
|
<option value="16">16 albums/page</option>
|
||||||
|
<option value="24">24 albums/page</option>
|
||||||
|
<option value="32">32 albums/page</option>
|
||||||
|
<option value="48">48 albums/page</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div></div>
|
||||||
|
|
||||||
<button type="submit" class="button is-primary mt-10" :disabled="loading">
|
<button type="submit" class="button is-primary mt-10" :disabled="loading">
|
||||||
<span v-if="!loading">Mettre à jour</span>
|
<span v-if="!loading">Mettre à jour</span>
|
||||||
|
@ -139,5 +155,6 @@
|
||||||
<script>
|
<script>
|
||||||
const email = '<%= user.email %>';
|
const email = '<%= user.email %>';
|
||||||
const username = '<%= user.username %>';
|
const username = '<%= user.username %>';
|
||||||
|
const pagination = "<%= user.pagination || 16 %>";
|
||||||
const mastodon = <%- JSON.stringify(user.mastodon || {publish: false, url: '', token: '', message: ''}) %>;
|
const mastodon = <%- JSON.stringify(user.mastodon || {publish: false, url: '', token: '', message: ''}) %>;
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<section class="box" id="contact">
|
<section class="box mini" id="contact">
|
||||||
<h1>Nous contacter</h1>
|
<h1>Nous contacter</h1>
|
||||||
<form @submit="send" <% if (config.mailMethod === 'formspree' ) { %> id="contact" method="POST" action="https://formspree.io/f/<%= config.formspreeId %>" <% } %>>
|
<form @submit="send" <% if (config.mailMethod === 'formspree' ) { %> id="contact" method="POST" action="https://formspree.io/f/<%= config.formspreeId %>" <% } %>>
|
||||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16">
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-16">
|
||||||
|
|
Loading…
Reference in a new issue