From 8cb53ceba279cc8d53c75dea2a6f98164b6ea2b1 Mon Sep 17 00:00:00 2001 From: Kenneth SOARES Date: Mon, 17 Feb 2025 14:57:00 +0100 Subject: [PATCH 01/12] download button for user pictures and albums --- core/static/bundled/user/pictures-index.js | 15 ++++++++++++--- core/templates/core/download_pictures.jinja | 13 +++++++++++++ core/templates/core/user_pictures.jinja | 17 ++++------------- sas/templates/sas/album.jinja | 11 +++++++++-- 4 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 core/templates/core/download_pictures.jinja diff --git a/core/static/bundled/user/pictures-index.js b/core/static/bundled/user/pictures-index.js index 68f08d25..5ee95b90 100644 --- a/core/static/bundled/user/pictures-index.js +++ b/core/static/bundled/user/pictures-index.js @@ -30,7 +30,8 @@ import { picturesFetchPictures } from "#openapi"; /** * @typedef PicturePageConfig - * @property {number} userId Id of the user to get the pictures from + * @property {number} userId Id of the user to get the pictures from (optional if albumId defined) + * @property {number} albumId Id of the album to get the pictures from (optinal if userId defined) **/ /** @@ -46,9 +47,17 @@ window.loadPicturePage = (config) => { albums: {}, async init() { - this.pictures = await paginated(picturesFetchPictures, { + let query = {}; + + if (config.userId) { // biome-ignore lint/style/useNamingConvention: api is in snake_case - query: { users_identified: [config.userId] }, + query = { users_identified: [config.userId] }; + } else { + // biome-ignore lint/style/useNamingConvention: api is in snake_case + query = { album_id: config.albumId }; + } + this.pictures = await paginated(picturesFetchPictures, { + query, }); this.albums = this.pictures.reduce((acc, picture) => { if (!acc[picture.album]) { diff --git a/core/templates/core/download_pictures.jinja b/core/templates/core/download_pictures.jinja new file mode 100644 index 00000000..d66c0063 --- /dev/null +++ b/core/templates/core/download_pictures.jinja @@ -0,0 +1,13 @@ +{% macro download_button() %} +
+ + +
+{% endmacro %} diff --git a/core/templates/core/user_pictures.jinja b/core/templates/core/user_pictures.jinja index a06ea757..2cd17b93 100644 --- a/core/templates/core/user_pictures.jinja +++ b/core/templates/core/user_pictures.jinja @@ -1,4 +1,5 @@ {% extends "core/base.jinja" %} +{% from "core/download_pictures.jinja" import download_button %} {%- block additional_css -%} @@ -14,19 +15,9 @@ {% block content %}
- {% if user.id == object.id %} -
- - -
- {% endif %} + {% if user.id == object.id %} + {{ download_button() }} + {% endif %}