-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
18 changed files
with
166 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ ignore = W191 | |
exclude = | ||
.git, | ||
__pycache__, | ||
backend/migrations, | ||
api/migrations, | ||
site-packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,4 +90,3 @@ class Meta: | |
include_resource_linkage=True, | ||
type_='User' | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import DS from 'ember-data'; | ||
import ENV from '../config/environment'; | ||
|
||
const { JSONAPIAdapter } = DS; | ||
const { APP } = ENV; | ||
|
||
export default JSONAPIAdapter.extend({ | ||
host : APP.backLink, | ||
pathForType : () => { | ||
return 'update/profileImage'; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,26 @@ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({ | ||
init() { | ||
this._super(...arguments); | ||
}, | ||
actions: { | ||
updateProfileImage() { | ||
document.getElementById('profileImageSelector').click(); | ||
}, | ||
|
||
profileImageSelected(event) { | ||
const reader = new FileReader(); | ||
const { target } = event; | ||
const { files } = target; | ||
const [file] = files; | ||
const _this = this; | ||
|
||
reader.onload = () => { | ||
_this.get('sendProfileImage')(reader.result, file.type.split('/')[1]); | ||
}; | ||
|
||
reader.readAsDataURL(file); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Controller.extend({ | ||
routing : service('-routing'), | ||
uid : '', | ||
actions : { | ||
updateProfileImage(profileImageData, extension) { | ||
const _this = this; | ||
const user = this.get('store').peekAll('user'); | ||
user.forEach(user_ => { | ||
_this.set('uid', user_.get('id')); | ||
}); | ||
let profileImage = _this.get('store').createRecord('profile-image', { | ||
image : profileImageData, | ||
uid : _this.uid, | ||
extension : '.' + extension | ||
}); | ||
profileImage.save() | ||
.then(record => { | ||
user.forEach(user_ => { | ||
user_.set('photoURL', record.photoURL); | ||
}); | ||
}) | ||
.catch(err => { | ||
let userErrors = profileImage.get('errors.user'); | ||
if (userErrors !== undefined) { | ||
_this.set('userError', userErrors); | ||
} | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import DS from 'ember-data'; | ||
|
||
const { Model, attr } = DS; | ||
|
||
export default Model.extend({ | ||
uid : attr('string'), | ||
image : attr('string'), | ||
extension : attr('string'), | ||
photoURL : attr('string') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
import Ember from 'ember'; | ||
import Route from '@ember/routing/route'; | ||
|
||
const { RSVP, set } = Ember; | ||
|
||
export default Route.extend({ | ||
model() { | ||
return RSVP.hash({ | ||
user: this.get('store').peekAll('user').slice(0, 1)[0] | ||
}); | ||
}, | ||
|
||
setupController(controller, model) { | ||
this._super(...arguments); | ||
set(controller, 'user', model.user); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
@import "footer"; | ||
@import "overrides"; | ||
@import "notifications"; | ||
@import "profile"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.profile-image:hover { | ||
.profile-change { | ||
opacity: 1; | ||
} | ||
|
||
img { | ||
opacity: 0.3; | ||
} | ||
} | ||
|
||
|
||
.profile-change { | ||
bottom: 0; | ||
margin-left: auto; | ||
margin-right: auto; | ||
opacity: 0; | ||
padding-top: 50%; | ||
position: absolute; | ||
text-align: center; | ||
top: 0; | ||
transition: 0.5s ease; | ||
width: 100%; | ||
} |
6 changes: 4 additions & 2 deletions
6
frontend/app/templates/components/user-component/my-profile.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{user-component/my-profile}} | ||
{{user-component/my-profile user=user sendProfileImage=(action 'updateProfileImage')}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Adapter | profile image', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let adapter = this.owner.lookup('adapter:profile-image'); | ||
assert.ok(adapter); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Unit | Controller | my-profile', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let controller = this.owner.lookup('controller:my-profile'); | ||
assert.ok(controller); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { run } from '@ember/runloop'; | ||
|
||
module('Unit | Model | profile image', function(hooks) { | ||
setupTest(hooks); | ||
|
||
// Replace this with your real tests. | ||
test('it exists', function(assert) { | ||
let store = this.owner.lookup('service:store'); | ||
let model = run(() => store.createRecord('profile-image', {})); | ||
assert.ok(model); | ||
}); | ||
}); |