diff options
Diffstat (limited to 'static/api')
| -rw-r--r-- | static/api/images.js | 16 | ||||
| -rw-r--r-- | static/api/index.js | 1 | ||||
| -rw-r--r-- | static/api/profile.js | 1 |
3 files changed, 16 insertions, 2 deletions
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'; |