diff --git a/javascripts/collection.js b/javascripts/collection.js index 4daf055..b548e2f 100644 --- a/javascripts/collection.js +++ b/javascripts/collection.js @@ -7,8 +7,8 @@ Vue.createApp({ total: 0, // eslint-disable-next-line no-undef page: query.page || 1, + limit: 16, totalPages: 1, - limit: 24, artist: "", format: "", year: "", @@ -69,7 +69,7 @@ Vue.createApp({ 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) { url += `&artist=${this.formatParams(this.artist)}`; } @@ -94,6 +94,7 @@ Vue.createApp({ .get(url) .then((response) => { this.items = response.data.rows; + this.limit = response.data.limit; this.total = response.data.count || 0; this.totalPages = parseInt(response.data.count / this.limit, 10) + diff --git a/javascripts/mon-compte/index.js b/javascripts/mon-compte/index.js index 6faa615..3546884 100644 --- a/javascripts/mon-compte/index.js +++ b/javascripts/mon-compte/index.js @@ -11,6 +11,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") { password: "", passwordConfirm: "", // eslint-disable-next-line no-undef + pagination, + // eslint-disable-next-line no-undef mastodon: mastodon || { publish: false, url: "", @@ -56,7 +58,7 @@ if (typeof email !== "undefined" && typeof username !== "undefined") { // eslint-disable-next-line no-unused-vars async updateProfil() { this.errors = []; - const { oldPassword, password, passwordConfirm, mastodon } = + const { oldPassword, password, passwordConfirm, mastodon, pagination } = this.formData; if (password && !oldPassword) { @@ -82,6 +84,8 @@ if (typeof email !== "undefined" && typeof username !== "undefined") { data.oldPassword = oldPassword; } + data.pagination = pagination; + try { await axios.patch(`/api/v1/me`, data); diff --git a/sass/box.scss b/sass/box.scss index 95c138e..1ab13ad 100644 --- a/sass/box.scss +++ b/sass/box.scss @@ -5,15 +5,19 @@ color: var(--font-color); display: block; padding: 1.25rem; - width: calc(100% - 2rem); - margin: auto; + @include transition() {} - @include respond-to("small-up") { - width: 65%; - } - @include respond-to("medium-up") { - width: 35%; + &.mini { + margin: auto; + width: calc(100% - 2rem); + + @include respond-to("small-up") { + width: 65%; + } + @include respond-to("medium-up") { + width: 35%; + } } h1 { diff --git a/src/middleware/Albums.js b/src/middleware/Albums.js index 749de9a..c9be824 100644 --- a/src/middleware/Albums.js +++ b/src/middleware/Albums.js @@ -192,7 +192,6 @@ Publié automatiquement via #musictopus`; async getAll() { const { page, - limit, exportFormat = "json", sort = "artists_sort", order = "asc", @@ -206,6 +205,8 @@ Publié automatiquement via #musictopus`; discogsId, } = this.req.query; + const limit = this.req.user?.pagination || 16; + let userId = this.req.user?._id; const where = {}; @@ -303,6 +304,7 @@ Publié automatiquement via #musictopus`; default: return { rows, + limit, count, }; } diff --git a/src/middleware/Me.js b/src/middleware/Me.js index edf40db..5dd6e3e 100644 --- a/src/middleware/Me.js +++ b/src/middleware/Me.js @@ -16,6 +16,7 @@ class Me extends Pages { const { _id } = this.req.user; const schema = Joi.object({ + pagination: Joi.number(), isPublicCollection: Joi.boolean(), oldPassword: Joi.string(), password: Joi.string(), @@ -45,6 +46,10 @@ class Me extends Pages { user.salt = value.password; } + if (value.pagination) { + user.pagination = value.pagination; + } + if (value.isPublicCollection !== undefined) { user.isPublicCollection = value.isPublicCollection; } diff --git a/src/models/users.js b/src/models/users.js index b8a047a..0b17802 100644 --- a/src/models/users.js +++ b/src/models/users.js @@ -25,6 +25,10 @@ const UserSchema = new mongoose.Schema( }, hash: String, salt: String, + pagination: { + type: Number, + default: 16, + }, isPublicCollection: { type: Boolean, default: false, diff --git a/views/pages/composants.ejs b/views/pages/composants.ejs index f5a9cce..ff8ef81 100644 --- a/views/pages/composants.ejs +++ b/views/pages/composants.ejs @@ -238,7 +238,7 @@

Les boites

-
+

Connexion diff --git a/views/pages/connexion.ejs b/views/pages/connexion.ejs index 2e86f72..e78533c 100644 --- a/views/pages/connexion.ejs +++ b/views/pages/connexion.ejs @@ -1,4 +1,4 @@ -
+

Connexion diff --git a/views/pages/inscription/index.ejs b/views/pages/inscription/index.ejs index 877b471..449ace3 100644 --- a/views/pages/inscription/index.ejs +++ b/views/pages/inscription/index.ejs @@ -1,4 +1,4 @@ -
+

Inscription diff --git a/views/pages/mon-compte/index.ejs b/views/pages/mon-compte/index.ejs index fbab634..187d5b2 100644 --- a/views/pages/mon-compte/index.ejs +++ b/views/pages/mon-compte/index.ejs @@ -5,7 +5,7 @@
-
+

Mes données personnelles

@@ -68,7 +68,7 @@
-
+

Mon activité

@@ -126,6 +126,22 @@
+
+

Mes préférences

+
+
+ + +
+
+
+ +