From 4c06eb64cbed3562e428ce59857d1763098638f3 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 19 Nov 2025 09:15:49 +0100 Subject: allow images to upload and sort if according to their datetime --- static/api/images.js | 16 ++++++++++++++-- static/api/index.js | 1 + static/api/profile.js | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 static/api/profile.js (limited to 'static/api') diff --git a/static/api/images.js b/static/api/images.js index 4bdac1f..aa783e9 100644 --- a/static/api/images.js +++ b/static/api/images.js @@ -52,15 +52,27 @@ export async function upload_to_timeline() { }) } -export async function upload_to_profile() { +export async function upload_to_profile(id) { const input = Input.new({ type: 'file', multiple: false, accept: 'image/jpeg', }) input.click(); + + return new Promise((resolve) => { + input.onchange = () => { + resolve(new FileUploader(`/api/profile/image/upload/${id}`, [...input.files])); + } + }) } export function list() { - return rest.get('/api/image/list').then(r => r.images); + return rest.get('/api/image/list') + .then(r => { + r.images.forEach(i => { + i.date = new Date(i.date * 1000) + }); + return r.images; + }); } diff --git a/static/api/index.js b/static/api/index.js index 3f2f483..cddd7bd 100644 --- a/static/api/index.js +++ b/static/api/index.js @@ -1,3 +1,4 @@ export * as images from './images.js'; export * as auth from './auth.js'; export * as session from './session.js'; +export * as profile from './profile.js'; diff --git a/static/api/profile.js b/static/api/profile.js new file mode 100644 index 0000000..a9ee591 --- /dev/null +++ b/static/api/profile.js @@ -0,0 +1 @@ +import * as rest from './rest.js'; -- cgit v1.2.3-70-g09d2