From 88189360c648403303bd9e261325f3c9b739e6f9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 27 Dec 2018 22:50:09 -0700 Subject: [PATCH] Update Settings view, fix avatar upload bug --- resources/views/settings/home.blade.php | 72 ++++++++----------------- 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/resources/views/settings/home.blade.php b/resources/views/settings/home.blade.php index aadee58d..adae0ae9 100644 --- a/resources/views/settings/home.blade.php +++ b/resources/views/settings/home.blade.php @@ -6,18 +6,30 @@

Account Settings


-
- @csrf -
-
- -
-
-

{{Auth::user()->username}}

-

Change Profile Photo

-

Max avatar size:

+
+
+ +
+
+

{{Auth::user()->username}}

+

+
+ + @csrf +
+
+ + +
+

Must be a jpeg or png. Max avatar size:

+

+
+
+
+
+ @csrf
@@ -118,45 +130,5 @@ }); $('#maxAvatarSize').text(filesize({{config('pixelfed.max_avatar_size') * 1024}}, {round: 0})); - - $(document).on('click', '.change-profile-photo', function(e) { - e.preventDefault(); - swal({ - title: 'Upload Photo', - content: { - element: 'input', - attributes: { - placeholder: 'Upload your photo.', - type: 'file', - name: 'photoUpload', - id: 'photoUploadInput' - } - }, - buttons: { - confirm: { - text: 'Upload' - } - } - }).then((res) => { - if(!res) { - return; - } - const input = $('#photoUploadInput')[0]; - const photo = input.files[0]; - const form = new FormData(); - form.append("upload", photo); - - axios.post('/api/v1/avatar/update', form, { - headers: { - 'Content-Type': 'multipart/form-data' - } - }).then((res) => { - swal('Success', 'Your photo has been successfully updated! It may take a few minutes to update across the site.', 'success'); - }).catch((res) => { - let msg = res.response.data.errors.upload[0]; - swal('Something went wrong', msg, 'error'); - }); - }); - }); @endpush