2018-05-19 14:31:13 +03:00
|
|
|
<template>
|
2018-05-20 03:04:48 +03:00
|
|
|
<md-card>
|
2018-05-19 14:31:13 +03:00
|
|
|
<md-card-header>
|
2018-05-20 03:04:48 +03:00
|
|
|
<div class="md-title">%fa:pencil-alt% %i18n:@title%</div>
|
2018-05-19 14:31:13 +03:00
|
|
|
</md-card-header>
|
|
|
|
|
|
|
|
<md-card-content>
|
|
|
|
<md-field>
|
|
|
|
<label>%i18n:@name%</label>
|
2018-05-20 11:45:06 +03:00
|
|
|
<md-input v-model="name" :disabled="saving" md-counter="30"/>
|
2018-05-19 14:31:13 +03:00
|
|
|
</md-field>
|
|
|
|
|
2018-05-20 11:37:30 +03:00
|
|
|
<md-field>
|
|
|
|
<label>%i18n:@account%</label>
|
|
|
|
<span class="md-prefix">@</span>
|
|
|
|
<md-input v-model="username" readonly></md-input>
|
|
|
|
<span class="md-suffix">@{{ host }}</span>
|
|
|
|
</md-field>
|
|
|
|
|
2018-05-19 14:31:13 +03:00
|
|
|
<md-field>
|
2018-05-20 03:04:48 +03:00
|
|
|
<md-icon>%fa:map-marker-alt%</md-icon>
|
|
|
|
<label>%i18n:@location%</label>
|
|
|
|
<md-input v-model="location" :disabled="saving"/>
|
2018-05-19 14:31:13 +03:00
|
|
|
</md-field>
|
|
|
|
|
|
|
|
<md-field>
|
2018-05-20 03:04:48 +03:00
|
|
|
<md-icon>%fa:birthday-cake%</md-icon>
|
2018-05-19 14:31:13 +03:00
|
|
|
<label>%i18n:@birthday%</label>
|
|
|
|
<md-input type="date" v-model="birthday" :disabled="saving"/>
|
|
|
|
</md-field>
|
|
|
|
|
2018-05-20 08:01:47 +03:00
|
|
|
<md-field>
|
|
|
|
<label>%i18n:@description%</label>
|
2018-05-20 11:45:06 +03:00
|
|
|
<md-textarea v-model="description" :disabled="saving" md-counter="500"/>
|
2018-05-20 08:01:47 +03:00
|
|
|
</md-field>
|
|
|
|
|
|
|
|
<md-field>
|
|
|
|
<label>%i18n:@avatar%</label>
|
|
|
|
<md-file @md-change="onAvatarChange"/>
|
|
|
|
</md-field>
|
|
|
|
|
|
|
|
<md-field>
|
|
|
|
<label>%i18n:@banner%</label>
|
|
|
|
<md-file @md-change="onBannerChange"/>
|
|
|
|
</md-field>
|
|
|
|
|
|
|
|
<md-dialog-alert
|
|
|
|
:md-active.sync="uploading"
|
|
|
|
md-content="%18n:!@uploading%"/>
|
|
|
|
|
2018-05-21 05:08:08 +03:00
|
|
|
<div>
|
|
|
|
<md-switch v-model="isCat">%i18n:@is-cat%</md-switch>
|
2018-05-19 14:31:13 +03:00
|
|
|
</div>
|
|
|
|
</md-card-content>
|
|
|
|
|
|
|
|
<md-card-actions>
|
|
|
|
<md-button class="md-primary" :disabled="saving" @click="save">%i18n:@save%</md-button>
|
|
|
|
</md-card-actions>
|
|
|
|
</md-card>
|
|
|
|
</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() {
|
|
|
|
this.name = (this as any).os.i.name || '';
|
2018-05-20 11:37:30 +03:00
|
|
|
this.username = (this as any).os.i.username;
|
2018-05-19 14:31:13 +03:00
|
|
|
this.location = (this as any).os.i.profile.location;
|
|
|
|
this.description = (this as any).os.i.description;
|
|
|
|
this.birthday = (this as any).os.i.profile.birthday;
|
2018-05-20 08:01:47 +03:00
|
|
|
this.avatarId = (this as any).os.i.avatarId;
|
|
|
|
this.bannerId = (this as any).os.i.bannerId;
|
2018-05-21 05:08:08 +03:00
|
|
|
this.isBot = (this as any).os.i.isBot;
|
|
|
|
this.isCat = (this as any).os.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);
|
|
|
|
data.append('i', (this as any).os.i.token);
|
|
|
|
|
|
|
|
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);
|
|
|
|
data.append('i', (this as any).os.i.token);
|
|
|
|
|
|
|
|
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-20 08:01:47 +03:00
|
|
|
(this as any).os.i.avatarId = i.avatarId;
|
|
|
|
(this as any).os.i.avatarUrl = i.avatarUrl;
|
|
|
|
(this as any).os.i.bannerId = i.bannerId;
|
|
|
|
(this as any).os.i.bannerUrl = i.bannerUrl;
|
|
|
|
|
2018-05-20 14:26:38 +03:00
|
|
|
alert('%i18n:@saved%');
|
2018-05-19 14:31:13 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|