Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit ca698e1

Browse files
author
Nick Litwin
committed
Show new profile image upon upload
1 parent 7d5bc96 commit ca698e1

File tree

8 files changed

+24
-157
lines changed

8 files changed

+24
-157
lines changed

app/index.jade

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ html
236236
script(src="settings/preferences/preferences.controller.js")
237237
script(src="settings/settings.controller.js")
238238
script(src="settings/settings.routes.js")
239-
script(src="settings/update-password/update-password.controller.js")
240239
script(src="skill-picker/skill-picker.module.js")
241240
script(src="skill-picker/skill-picker.controller.js")
242241
script(src="skill-picker/skill-picker.routes.js")

app/services/image.service.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
angular.module('tc.services').factory('ImageService', ImageService);
55

6-
ImageService.$inject = ['CONSTANTS', 'ApiService', '$q', '$log', '$rootScope'];
6+
ImageService.$inject = ['CONSTANTS', 'ApiService', '$q', '$log', '$rootScope', 'toaster'];
77

8-
function ImageService(CONSTANTS, ApiService, $q, $log, $rootScope) {
8+
function ImageService(CONSTANTS, ApiService, $q, $log, $rootScope, toaster) {
99
var api = ApiService.restangularV3;
1010

1111
var service = {
@@ -17,15 +17,16 @@
1717

1818
function createFileRecord(S3Response) {
1919
return api.one('members', S3Response.userHandle).customPUT(S3Response.body, 'photo')
20-
.then(function() {
21-
// Show notification that upload was successful
20+
.then(function(newPhotoURL) {
2221
$rootScope.$broadcast(CONSTANTS.EVENT_PROFILE_UPDATED);
2322
$log.info('Successfully made file record');
24-
23+
toaster.pop('success', 'Success!', 'Your profile image has been updated.');
24+
return newPhotoURL;
2525
})
2626
.catch(function(err) {
2727
$log.info('Error in creating file record');
2828
$log.error(err);
29+
toaster.pop('error', 'Whoops!', 'There was an error uploading your profile image. Please try again later.');
2930
});
3031
}
3132

@@ -43,6 +44,7 @@
4344
})
4445
.catch(function(err) {
4546
$log.info('Error getting presigned url');
47+
toaster.pop('error', 'Whoops!', 'There was an error uploading your profile image. Please try again later.');
4648
deferred.reject(err);
4749
});
4850

@@ -70,12 +72,14 @@
7072
});
7173
} else if (status >= 400) {
7274
$log.error('Error uploading to S3 with status: ' + status);
75+
toaster.pop('error', 'Whoops!', 'There was an error uploading your profile image. Please try again later.');
7376
deferred.reject(err);
7477
}
7578
};
7679

7780
xhr.onerror = function(err) {
7881
$log.info('Error uploading to s3');
82+
toaster.pop('error', 'Whoops!', 'There was an error uploading your profile image. Please try again later.');
7983
deferred.reject(err);
8084
}
8185

app/settings/edit-profile/edit-profile.controller.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
vm.onFileChange = onFileChange;
1515
vm.updateProfile = updateProfile;
1616
vm.addSkill = addSkill;
17-
vm.ASSET_PREFIX = CONSTANTS.ASSET_PREFIX;
1817

1918
activate();
2019

@@ -95,7 +94,10 @@
9594
function onFileChange(file) {
9695
ImageService.getPresignedUrl(userHandle, file)
9796
.then(ImageService.uploadFileToS3)
98-
.then(ImageService.createFileRecord);
97+
.then(ImageService.createFileRecord)
98+
.then(function(newPhotoURL) {
99+
vm.userData.photoURL = newPhotoURL;
100+
});
99101
}
100102

101103
function updateProfile() {

app/settings/settings.jade

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
h1 Settings
44

55
.settings-container
6-
76
nav
87
ul
98
li

app/settings/update-password/update-password.controller.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

app/settings/update-password/update-password.jade

Lines changed: 0 additions & 26 deletions
This file was deleted.

app/settings/update-password/update-password.spec.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

assets/css/settings/settings.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,13 @@
3737

3838
.settings-container {
3939
@include module-l;
40+
margin: 30px auto 0;
4041
@media only screen and (min-width: 768px) {
4142
margin-top: 80px;
4243
padding-left: 30px;
4344
padding-right: 30px;
4445
}
45-
margin-left: auto;
46-
margin-right: auto;
47-
margin-top: 30px;
46+
4847
nav {
4948
display: flex;
5049
flex-direction: row;
@@ -54,12 +53,16 @@
5453
flex-direction: row;
5554
justify-content: center;
5655
}
56+
5757
li {
5858
display: inline-block;
5959
margin-right: 35px;
60-
@media only screen and (min-width: 768px) {
60+
61+
&:last-child {
62+
margin-right: 0;
6163
}
6264
}
65+
6366
a {
6467
@include sofia-pro-medium;
6568
font-size: 14px;
@@ -72,6 +75,7 @@
7275
}
7376
}
7477
}
78+
7579
.active-tab {
7680
padding: 0 5px 6px;
7781
border-bottom: 4px #0096FF solid;
@@ -80,13 +84,13 @@
8084

8185
hr {
8286
border-width: 1px 0 0 0;
87+
8388
&.nav-line {
8489
width: 95%;
85-
margin-top: 7px;
86-
margin-left: auto;
87-
margin-right: auto;
90+
margin: 7px auto 0;
8891
}
8992
}
93+
9094
// Common element stylings
9195
.button-l {
9296
@include button-l;

0 commit comments

Comments
 (0)