2018-05-19 14:31:13 +03:00
|
|
|
<template>
|
2018-06-14 10:48:49 +03:00
|
|
|
<ui-card>
|
2018-11-08 20:44:35 +02:00
|
|
|
<div slot="title"><fa icon="user"/> {{ $t('title') }}</div>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<section class="fit-top">
|
|
|
|
<ui-form :disabled="saving">
|
|
|
|
<ui-input v-model="name" :max="30">
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('name') }}</span>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-input>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<ui-input v-model="username" readonly>
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('account') }}</span>
|
2018-09-05 07:47:26 +03:00
|
|
|
<span slot="prefix">@</span>
|
|
|
|
<span slot="suffix">@{{ host }}</span>
|
|
|
|
</ui-input>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<ui-input v-model="location">
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('location') }}</span>
|
2018-11-05 18:40:11 +02:00
|
|
|
<span slot="prefix"><fa icon="map-marker-alt"/></span>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-input>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<ui-input v-model="birthday" type="date">
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('birthday') }}</span>
|
2018-11-05 18:40:11 +02:00
|
|
|
<span slot="prefix"><fa icon="birthday-cake"/></span>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-input>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<ui-textarea v-model="description" :max="500">
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('description') }}</span>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-textarea>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<ui-input type="file" @change="onAvatarChange">
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('avatar') }}</span>
|
2018-11-05 18:40:11 +02:00
|
|
|
<span slot="icon"><fa icon="image"/></span>
|
2018-11-08 20:44:35 +02:00
|
|
|
<span slot="desc" v-if="avatarUploading">{{ $t('uploading') }}<mk-ellipsis/></span>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-input>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-09-05 07:47:26 +03:00
|
|
|
<ui-input type="file" @change="onBannerChange">
|
2018-11-08 20:44:35 +02:00
|
|
|
<span>{{ $t('banner') }}</span>
|
2018-11-05 18:40:11 +02:00
|
|
|
<span slot="icon"><fa icon="image"/></span>
|
2018-11-08 20:44:35 +02:00
|
|
|
<span slot="desc" v-if="bannerUploading">{{ $t('uploading') }}<mk-ellipsis/></span>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-input>
|
2018-06-14 08:52:37 +03:00
|
|
|
|
2018-11-08 20:44:35 +02:00
|
|
|
<ui-button @click="save(true)">{{ $t('save') }}</ui-button>
|
2018-09-05 07:47:26 +03:00
|
|
|
</ui-form>
|
|
|
|
</section>
|
2018-09-13 12:23:44 +03:00
|
|
|
|
|
|
|
<section>
|
2018-11-08 20:44:35 +02:00
|
|
|
<header>{{ $t('advanced') }}</header>
|
2018-09-13 12:23:44 +03:00
|
|
|
|
|
|
|
<div>
|
2018-11-08 20:44:35 +02:00
|
|
|
<ui-switch v-model="isCat" @change="save(false)">{{ $t('is-cat') }}</ui-switch>
|
|
|
|
<ui-switch v-model="isBot" @change="save(false)">{{ $t('is-bot') }}</ui-switch>
|
|
|
|
<ui-switch v-model="alwaysMarkNsfw">{{ $t('@.always-mark-nsfw') }}</ui-switch>
|
2018-09-13 12:23:44 +03:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
2018-11-08 20:44:35 +02:00
|
|
|
<header>{{ $t('privacy') }}</header>
|
2018-09-13 12:23:44 +03:00
|
|
|
|
|
|
|
<div>
|
2018-11-08 20:44:35 +02:00
|
|
|
<ui-switch v-model="isLocked" @change="save(false)">{{ $t('is-locked') }}</ui-switch>
|
|
|
|
<ui-switch v-model="carefulBot" @change="save(false)">{{ $t('careful-bot') }}</ui-switch>
|
2018-09-13 12:23:44 +03:00
|
|
|
</div>
|
|
|
|
</section>
|
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-11-08 20:44:35 +02:00
|
|
|
import i18n from '../../../i18n';
|
2018-10-19 00:18:33 +03:00
|
|
|
import { apiUrl, host } from '../../../config';
|
2018-05-19 14:31:13 +03:00
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 20:44:35 +02:00
|
|
|
i18n: i18n('common/views/components/profile-editor.vue'),
|
2018-05-19 14:31:13 +03:00
|
|
|
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
|
|
|
isCat: false,
|
2018-10-19 00:18:33 +03:00
|
|
|
isBot: false,
|
2018-09-13 12:23:44 +03:00
|
|
|
isLocked: false,
|
2018-10-13 14:11:00 +03:00
|
|
|
carefulBot: false,
|
2018-05-20 08:01:47 +03:00
|
|
|
saving: false,
|
2018-06-15 01:56:56 +03:00
|
|
|
avatarUploading: false,
|
|
|
|
bannerUploading: false
|
2018-05-19 14:31:13 +03:00
|
|
|
};
|
|
|
|
},
|
2018-05-20 03:04:48 +03:00
|
|
|
|
2018-09-14 14:11:01 +03:00
|
|
|
computed: {
|
|
|
|
alwaysMarkNsfw: {
|
|
|
|
get() { return this.$store.state.i.settings.alwaysMarkNsfw; },
|
2018-11-09 01:13:34 +02:00
|
|
|
set(value) { this.$root.api('i/update', { alwaysMarkNsfw: value }); }
|
2018-09-14 14:11:01 +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.isCat = this.$store.state.i.isCat;
|
2018-10-19 00:18:33 +03:00
|
|
|
this.isBot = this.$store.state.i.isBot;
|
2018-09-13 12:23:44 +03:00
|
|
|
this.isLocked = this.$store.state.i.isLocked;
|
2018-10-13 14:11:00 +03:00
|
|
|
this.carefulBot = this.$store.state.i.carefulBot;
|
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]) {
|
2018-06-15 01:56:56 +03:00
|
|
|
this.avatarUploading = true;
|
2018-05-20 08:01:47 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
})
|
2018-08-19 07:32:02 +03:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(f => {
|
|
|
|
this.avatarId = f.id;
|
|
|
|
this.avatarUploading = false;
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.avatarUploading = false;
|
|
|
|
alert('%18n:@upload-failed%');
|
|
|
|
});
|
2018-05-20 08:01:47 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
onBannerChange([file]) {
|
2018-06-15 01:56:56 +03:00
|
|
|
this.bannerUploading = true;
|
2018-05-20 08:01:47 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
})
|
2018-08-19 07:32:02 +03:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(f => {
|
|
|
|
this.bannerId = f.id;
|
|
|
|
this.bannerUploading = false;
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.bannerUploading = false;
|
|
|
|
alert('%18n:@upload-failed%');
|
|
|
|
});
|
2018-05-20 08:01:47 +03:00
|
|
|
},
|
|
|
|
|
2018-09-13 12:23:44 +03:00
|
|
|
save(notify) {
|
2018-05-19 14:31:13 +03:00
|
|
|
this.saving = true;
|
|
|
|
|
2018-11-09 01:13:34 +02:00
|
|
|
this.$root.api('i/update', {
|
2018-05-19 14:31:13 +03:00
|
|
|
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,
|
2018-11-09 01:41:06 +02:00
|
|
|
isCat: !!this.isCat,
|
|
|
|
isBot: !!this.isBot,
|
|
|
|
isLocked: !!this.isLocked,
|
|
|
|
carefulBot: !!this.carefulBot
|
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-09-13 12:23:44 +03:00
|
|
|
if (notify) {
|
2018-10-10 15:23:38 +03:00
|
|
|
this.$swal({
|
|
|
|
type: 'success',
|
2018-11-08 20:44:35 +02:00
|
|
|
text: this.$t('saved')
|
2018-10-10 15:23:38 +03:00
|
|
|
});
|
2018-09-13 12:23:44 +03:00
|
|
|
}
|
2018-05-19 14:31:13 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|