2019-03-02 11:25:10 +01:00
|
|
|
import AbstractModel from './abstractModel'
|
|
|
|
|
|
|
|
export default class UserModel extends AbstractModel {
|
2020-02-08 14:16:06 +01:00
|
|
|
constructor(data) {
|
|
|
|
super(data)
|
|
|
|
this.created = new Date(this.created)
|
|
|
|
this.updated = new Date(this.updated)
|
|
|
|
}
|
|
|
|
|
2019-03-02 11:25:10 +01:00
|
|
|
defaults() {
|
|
|
|
return {
|
|
|
|
id: 0,
|
|
|
|
email: '',
|
|
|
|
username: '',
|
2020-11-21 22:25:00 +01:00
|
|
|
name: '',
|
2020-02-08 14:16:06 +01:00
|
|
|
created: null,
|
|
|
|
updated: null,
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|
|
|
|
}
|
2020-02-09 13:28:33 +01:00
|
|
|
|
|
|
|
getAvatarUrl(size = 50) {
|
2020-12-18 23:11:23 +01:00
|
|
|
return `${window.API_URL}/avatar/${this.username}?size=${size}`
|
2020-02-09 13:28:33 +01:00
|
|
|
}
|
2020-11-21 22:25:00 +01:00
|
|
|
|
|
|
|
getDisplayName() {
|
|
|
|
if (this.name !== '') {
|
|
|
|
return this.name
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.username
|
|
|
|
}
|
2019-03-02 11:25:10 +01:00
|
|
|
}
|