diff options
Diffstat (limited to 'resources/assets')
-rw-r--r-- | resources/assets/js/app.js | 1 | ||||
-rw-r--r-- | resources/assets/js/profile.js | 26 | ||||
-rw-r--r-- | resources/assets/js/setup.js | 5 | ||||
-rw-r--r-- | resources/assets/sass/app.scss | 4 |
4 files changed, 36 insertions, 0 deletions
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 16d3a12..f50f805 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -7,5 +7,6 @@ window.openpgp = require('openpgp'); window.Vue = require('vue'); require('./bootstrap'); +require('./setup'); require('./profile'); require('./chat'); diff --git a/resources/assets/js/profile.js b/resources/assets/js/profile.js index bce94da..d834542 100644 --- a/resources/assets/js/profile.js +++ b/resources/assets/js/profile.js @@ -10,4 +10,30 @@ $("#avatarFile").on("change", () => { if (file) { reader.readAsDataURL(file); } +}); + +$("#avatarForm").submit(function (e) { + var url = "/avatar"; + var data = new FormData(); + $.each(jQuery('#avatarFile')[0].files, (i, file) => { + data.append('avatar', file); + }); + + e.preventDefault(); + $.ajax({ + url: url, + data: data, + cache: false, + contentType: false, + processData: false, + method: 'POST', + type: 'POST', + success: (data) => { + $("#avatarUploadSucceededAlert").show(); + $("#avatarUploadSucceededMessage").text(data.success); + }, + error: () => { + $("#avatarUploadFailedAlert").show(); + } + }); });
\ No newline at end of file diff --git a/resources/assets/js/setup.js b/resources/assets/js/setup.js new file mode 100644 index 0000000..880bf91 --- /dev/null +++ b/resources/assets/js/setup.js @@ -0,0 +1,5 @@ +$.ajaxSetup({ + headers: { + 'X-CSRF-Token': $('input[name="_token"]').val() + } +});
\ No newline at end of file diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss index ce64b3f..bd5e1a5 100644 --- a/resources/assets/sass/app.scss +++ b/resources/assets/sass/app.scss @@ -13,4 +13,8 @@ .navbar-laravel { background-color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04); +} + +.alert { + display: none; }
\ No newline at end of file |