misc_pterodactyl-panel/resources/assets/scripts/models/user.js

49 lines
975 B
JavaScript
Raw Normal View History

import { Collection, Model } from 'vue-mc';
2018-05-28 19:48:42 +00:00
import JwtDecode from 'jwt-decode';
export class User extends Model {
static defaults() {
return {
id: null,
uuid: '',
username: '',
email: '',
name_first: '',
name_last: '',
language: 'en',
root_admin: false,
}
}
2018-05-28 19:48:42 +00:00
static mutations() {
return {
id: Number,
uuid: String,
username: String,
email: String,
name_first: String,
name_last: String,
language: String,
root_admin: Boolean,
}
}
2018-05-28 19:48:42 +00:00
static fromJWT(token) {
return new User(JwtDecode(token).user || {});
}
}
2018-05-28 19:48:42 +00:00
export class UserCollection extends Collection {
static model() {
return User;
}
2018-05-28 19:48:42 +00:00
get todo() {
return this.sum('done');
}
get done() {
return this.todo === 0;
}
}