2018-05-19 14:31:13 +03:00
|
|
|
<template>
|
2018-06-14 10:48:49 +03:00
|
|
|
<ui-card>
|
|
|
|
<div slot="title">%fa:user% %i18n:@title%</div>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
|
|
|
<ui-form :disabled="saving">
|
|
|
|
<ui-input v-model="name" :max="30">
|
|
|
|
<span>%i18n:@name%</span>
|
|
|
|
</ui-input>
|
|
|
|
|
|
|
|
<ui-input v-model="username" readonly>
|
|
|
|
<span>%i18n:@account%</span>
|
|
|
|
<span slot="prefix">@</span>
|
|
|
|
<span slot="suffix">@{{ host }}</span>
|
|
|
|
</ui-input>
|
|
|
|
|
|
|
|
<ui-input v-model="location">
|
|
|
|
<span>%i18n:@location%</span>
|
|
|
|
<span slot="prefix">%fa:map-marker-alt%</span>
|
|
|
|
</ui-input>
|
|
|
|
|
|
|
|
<ui-input v-model="birthday" type="date">
|
|
|
|
<span>%i18n:@birthday%</span>
|
|
|
|
<span slot="prefix">%fa:birthday-cake%</span>
|
|
|
|
</ui-input>
|
|
|
|
|
|
|
|
<ui-textarea v-model="description" :max="500">
|
|
|
|
<span>%i18n:@description%</span>
|
|
|
|
</ui-textarea>
|
|
|
|
|
|
|
|
<ui-input type="file" @change="onAvatarChange">
|
|
|
|
<span>%i18n:@avatar%</span>
|
|
|
|
<span slot="prefix">%fa:picture-o%</span>
|
|
|
|
</ui-input>
|
|
|
|
|
|
|
|
<ui-input type="file" @change="onBannerChange">
|
|
|
|
<span>%i18n:@banner%</span>
|
|
|
|
<span slot="prefix">%fa:picture-o%</span>
|
|
|
|
</ui-input>
|
|
|
|
|
|
|
|
<ui-switch v-model="isCat">%i18n:@is-cat%</ui-switch>
|
|
|
|
|
|
|
|
<ui-button @click="save">%i18n:@save%</ui-button>
|
|
|
|
</ui-form>
|
2018-06-14 10:48:49 +03:00
|
|
|
</ui-card>
|
2018-05-19 14:31:13 +03:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-05-20 11:37:30 +03:00
|
|
|
import { apiUrl, host } from '../../../../config';
|
2018-05-19 14:31:13 +03:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
2018-05-20 11:37:30 +03:00
|
|
|
host,
|
2018-05-19 14:31:13 +03:00
|
|
|
name: null,
|
2018-05-20 11:37:30 +03:00
|
|
|
username: null,
|
2018-05-19 14:31:13 +03:00
|
|
|
location: null,
|
|
|
|
description: null,
|
|
|
|
birthday: null,
|
2018-05-20 08:01:47 +03:00
|
|
|
avatarId: null,
|
|
|
|
bannerId: null,
|
2018-05-21 05:08:08 +03:00
|
|
|
isBot: false,
|
|
|
|
isCat: false,
|
2018-05-20 08:01:47 +03:00
|
|
|
saving: false,
|
|
|
|
uploading: false
|
2018-05-19 14:31:13 +03:00
|
|
|
};
|
|
|
|
},
|
2018-05-20 03:04:48 +03:00
|
|
|
|
2018-05-19 14:31:13 +03:00
|
|
|
created() {
|
2018-05-27 07:49:09 +03:00
|
|
|
this.name = this.$store.state.i.name || '';
|
|
|
|
this.username = this.$store.state.i.username;
|
|
|
|
this.location = this.$store.state.i.profile.location;
|
|
|
|
this.description = this.$store.state.i.description;
|
|
|
|
this.birthday = this.$store.state.i.profile.birthday;
|
|
|
|
this.avatarId = this.$store.state.i.avatarId;
|
|
|
|
this.bannerId = this.$store.state.i.bannerId;
|
|
|
|
this.isBot = this.$store.state.i.isBot;
|
|
|
|
this.isCat = this.$store.state.i.isCat;
|
2018-05-19 14:31:13 +03:00
|
|
|
},
|
|
|
|
|
2018-05-20 03:04:48 +03:00
|
|
|
methods: {
|
2018-05-20 08:01:47 +03:00
|
|
|
onAvatarChange([file]) {
|
|
|
|
this.uploading = true;
|
|
|
|
|
|
|
|
const data = new FormData();
|
|
|
|
data.append('file', file);
|
2018-05-27 07:49:09 +03:00
|
|
|
data.append('i', this.$store.state.i.token);
|
2018-05-20 08:01:47 +03:00
|
|
|
|
|
|
|
fetch(apiUrl + '/drive/files/create', {
|
|
|
|
method: 'POST',
|
|
|
|
body: data
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(f => {
|
|
|
|
this.avatarId = f.id;
|
|
|
|
this.uploading = false;
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.uploading = false;
|
|
|
|
alert('%18n:!@upload-failed%');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onBannerChange([file]) {
|
|
|
|
this.uploading = true;
|
|
|
|
|
|
|
|
const data = new FormData();
|
|
|
|
data.append('file', file);
|
2018-05-27 07:49:09 +03:00
|
|
|
data.append('i', this.$store.state.i.token);
|
2018-05-20 08:01:47 +03:00
|
|
|
|
|
|
|
fetch(apiUrl + '/drive/files/create', {
|
|
|
|
method: 'POST',
|
|
|
|
body: data
|
|
|
|
})
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(f => {
|
|
|
|
this.bannerId = f.id;
|
|
|
|
this.uploading = false;
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.uploading = false;
|
|
|
|
alert('%18n:!@upload-failed%');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-05-19 14:31:13 +03:00
|
|
|
save() {
|
|
|
|
this.saving = true;
|
|
|
|
|
|
|
|
(this as any).api('i/update', {
|
|
|
|
name: this.name || null,
|
|
|
|
location: this.location || null,
|
|
|
|
description: this.description || null,
|
2018-05-20 08:01:47 +03:00
|
|
|
birthday: this.birthday || null,
|
|
|
|
avatarId: this.avatarId,
|
2018-05-21 05:08:08 +03:00
|
|
|
bannerId: this.bannerId,
|
|
|
|
isBot: this.isBot,
|
|
|
|
isCat: this.isCat
|
2018-05-20 08:01:47 +03:00
|
|
|
}).then(i => {
|
2018-05-19 14:31:13 +03:00
|
|
|
this.saving = false;
|
2018-05-27 07:49:09 +03:00
|
|
|
this.$store.state.i.avatarId = i.avatarId;
|
|
|
|
this.$store.state.i.avatarUrl = i.avatarUrl;
|
|
|
|
this.$store.state.i.bannerId = i.bannerId;
|
|
|
|
this.$store.state.i.bannerUrl = i.bannerUrl;
|
2018-05-20 08:01:47 +03:00
|
|
|
|
2018-05-20 14:26:38 +03:00
|
|
|
alert('%i18n:@saved%');
|
2018-05-19 14:31:13 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|