iceshrimp-legacy/src/client/app/common/views/components/settings/profile.vue

443 lines
13 KiB
Vue
Raw Normal View History

2018-05-19 13:31:13 +02:00
<template>
2018-06-14 09:48:49 +02:00
<ui-card>
2019-02-18 03:13:56 +01:00
<template #title><fa icon="user"/> {{ $t('title') }}</template>
2018-06-14 07:52:37 +02:00
2018-11-09 10:32:09 +01:00
<section class="esokaraujimuwfttfzgocmutcihewscl">
<div class="header" :style="bannerStyle">
<mk-avatar class="avatar" :user="$store.state.i" :disable-preview="true" :disable-link="true"/>
</div>
2018-09-05 06:47:26 +02:00
<ui-form :disabled="saving">
<ui-input v-model="name" :max="30">
<span>{{ $t('name') }}</span>
2018-09-05 06:47:26 +02:00
</ui-input>
2018-06-14 07:52:37 +02:00
2018-09-05 06:47:26 +02:00
<ui-input v-model="username" readonly>
<span>{{ $t('account') }}</span>
2019-02-18 03:13:56 +01:00
<template #prefix>@</template>
<template #suffix>@{{ host }}</template>
2018-09-05 06:47:26 +02:00
</ui-input>
2018-06-14 07:52:37 +02:00
2018-09-05 06:47:26 +02:00
<ui-input v-model="location">
<span>{{ $t('location') }}</span>
2019-02-18 03:13:56 +01:00
<template #prefix><fa icon="map-marker-alt"/></template>
2018-09-05 06:47:26 +02:00
</ui-input>
2018-06-14 07:52:37 +02:00
2018-09-05 06:47:26 +02:00
<ui-input v-model="birthday" type="date">
2019-02-18 03:13:56 +01:00
<template #title>{{ $t('birthday') }}</template>
<template #prefix><fa icon="birthday-cake"/></template>
2018-09-05 06:47:26 +02:00
</ui-input>
2018-06-14 07:52:37 +02:00
2018-09-05 06:47:26 +02:00
<ui-textarea v-model="description" :max="500">
<span>{{ $t('description') }}</span>
2019-02-18 03:13:56 +01:00
<template #desc>{{ $t('you-can-include-hashtags') }}</template>
2018-09-05 06:47:26 +02:00
</ui-textarea>
2018-06-14 07:52:37 +02:00
2018-12-03 12:08:18 +01:00
<ui-select v-model="lang">
2019-02-18 03:13:56 +01:00
<template #label>{{ $t('language') }}</template>
<template #icon><fa icon="language"/></template>
2018-12-03 12:08:18 +01:00
<option v-for="lang in unique(Object.values(langmap).map(x => x.nativeName)).map(name => Object.keys(langmap).find(k => langmap[k].nativeName == name))" :value="lang" :key="lang">{{ langmap[lang].nativeName }}</option>
</ui-select>
2018-09-05 06:47:26 +02:00
<ui-input type="file" @change="onAvatarChange">
<span>{{ $t('avatar') }}</span>
2019-02-18 03:13:56 +01:00
<template #icon><fa icon="image"/></template>
<template #desc v-if="avatarUploading">{{ $t('uploading') }}<mk-ellipsis/></template>
2018-09-05 06:47:26 +02:00
</ui-input>
2018-06-14 07:52:37 +02:00
2018-09-05 06:47:26 +02:00
<ui-input type="file" @change="onBannerChange">
<span>{{ $t('banner') }}</span>
2019-02-18 03:13:56 +01:00
<template #icon><fa icon="image"/></template>
<template #desc v-if="bannerUploading">{{ $t('uploading') }}<mk-ellipsis/></template>
2018-09-05 06:47:26 +02:00
</ui-input>
2018-06-14 07:52:37 +02:00
<div class="fields">
<header>{{ $t('profile-metadata') }}</header>
<ui-horizon-group>
<ui-input v-model="fieldName0">{{ $t('metadata-label') }}</ui-input>
<ui-input v-model="fieldValue0">{{ $t('metadata-content') }}</ui-input>
</ui-horizon-group>
<ui-horizon-group>
<ui-input v-model="fieldName1">{{ $t('metadata-label') }}</ui-input>
<ui-input v-model="fieldValue1">{{ $t('metadata-content') }}</ui-input>
</ui-horizon-group>
<ui-horizon-group>
<ui-input v-model="fieldName2">{{ $t('metadata-label') }}</ui-input>
<ui-input v-model="fieldValue2">{{ $t('metadata-content') }}</ui-input>
</ui-horizon-group>
<ui-horizon-group>
<ui-input v-model="fieldName3">{{ $t('metadata-label') }}</ui-input>
<ui-input v-model="fieldValue3">{{ $t('metadata-content') }}</ui-input>
</ui-horizon-group>
</div>
2019-03-11 12:07:27 +01:00
<ui-button @click="save(true)"><fa :icon="faSave"/> {{ $t('save') }}</ui-button>
2018-09-05 06:47:26 +02:00
</ui-form>
</section>
2018-09-13 11:23:44 +02:00
<section>
2019-03-11 12:12:44 +01:00
<header><fa :icon="faCogs"/> {{ $t('advanced') }}</header>
2018-09-13 11:23:44 +02:00
<div>
<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('@._settings.always-mark-nsfw') }}</ui-switch>
2018-09-13 11:23:44 +02:00
</div>
</section>
<section>
2019-03-11 12:12:44 +01:00
<header><fa :icon="faUnlockAlt"/> {{ $t('privacy') }}</header>
2018-09-13 11:23:44 +02:00
<div>
<ui-switch v-model="isLocked" @change="save(false)">{{ $t('is-locked') }}</ui-switch>
2018-12-28 19:12:22 +01:00
<ui-switch v-model="carefulBot" :disabled="isLocked" @change="save(false)">{{ $t('careful-bot') }}</ui-switch>
<ui-switch v-model="autoAcceptFollowed" :disabled="!isLocked && !carefulBot" @change="save(false)">{{ $t('auto-accept-followed') }}</ui-switch>
2018-09-13 11:23:44 +02:00
</div>
</section>
2018-11-29 08:23:45 +01:00
<section v-if="enableEmail">
2019-03-11 12:12:44 +01:00
<header><fa :icon="faEnvelope"/> {{ $t('email') }}</header>
2018-11-29 08:23:45 +01:00
<div>
<template v-if="$store.state.i.email != null">
<ui-info v-if="$store.state.i.emailVerified">{{ $t('email-verified') }}</ui-info>
<ui-info v-else warn>{{ $t('email-not-verified') }}</ui-info>
</template>
<ui-input v-model="email" type="email"><span>{{ $t('email-address') }}</span></ui-input>
2019-04-16 06:05:47 +02:00
<ui-button @click="updateEmail()" :disabled="email === $store.state.i.email"><fa :icon="faSave"/> {{ $t('save') }}</ui-button>
2018-11-29 08:23:45 +01:00
</div>
</section>
<section>
2019-03-11 12:12:44 +01:00
<header><fa :icon="faBoxes"/> {{ $t('export-and-import') }}</header>
<div>
2019-02-06 12:56:48 +01:00
<ui-select v-model="exportTarget">
<option value="notes">{{ $t('export-targets.all-notes') }}</option>
<option value="following">{{ $t('export-targets.following-list') }}</option>
<option value="mute">{{ $t('export-targets.mute-list') }}</option>
<option value="blocking">{{ $t('export-targets.blocking-list') }}</option>
<option value="user-lists">{{ $t('export-targets.user-lists') }}</option>
2019-02-06 12:56:48 +01:00
</ui-select>
2019-03-11 11:43:58 +01:00
<ui-horizon-group class="fit-bottom">
<ui-button @click="doExport()"><fa :icon="faDownload"/> {{ $t('export') }}</ui-button>
2019-03-11 16:34:19 +01:00
<ui-button @click="doImport()" :disabled="!['following', 'user-lists'].includes(exportTarget)"><fa :icon="faUpload"/> {{ $t('import') }}</ui-button>
2019-03-11 11:43:58 +01:00
</ui-horizon-group>
</div>
</section>
2019-02-20 17:30:21 +01:00
<section>
<details>
<summary>{{ $t('danger-zone') }}</summary>
<ui-button @click="deleteAccount()">{{ $t('delete-account') }}</ui-button>
</details>
</section>
2018-06-14 09:48:49 +02:00
</ui-card>
2018-05-19 13:31:13 +02:00
</template>
<script lang="ts">
import Vue from 'vue';
import i18n from '../../../../i18n';
import { apiUrl, host } from '../../../../config';
2018-11-11 04:35:30 +01:00
import { toUnicode } from 'punycode';
2018-12-03 12:08:18 +01:00
import langmap from 'langmap';
import { unique } from '../../../../../../prelude/array';
2019-03-11 12:12:44 +01:00
import { faDownload, faUpload, faUnlockAlt, faBoxes, faCogs } from '@fortawesome/free-solid-svg-icons';
import { faSave, faEnvelope } from '@fortawesome/free-regular-svg-icons';
2018-05-19 13:31:13 +02:00
export default Vue.extend({
i18n: i18n('common/views/components/profile-editor.vue'),
2018-11-29 08:23:45 +01:00
2018-05-19 13:31:13 +02:00
data() {
return {
2018-12-03 12:08:18 +01:00
unique,
langmap,
2018-11-11 04:35:30 +01:00
host: toUnicode(host),
enableEmail: false,
2018-11-29 08:23:45 +01:00
email: null,
2018-05-19 13:31:13 +02:00
name: null,
2018-05-20 10:37:30 +02:00
username: null,
2018-05-19 13:31:13 +02:00
location: null,
description: null,
2019-07-28 03:31:16 +02:00
fieldName0: null,
fieldValue0: null,
fieldName1: null,
fieldValue1: null,
fieldName2: null,
fieldValue2: null,
fieldName3: null,
fieldValue3: null,
2018-12-03 12:08:18 +01:00
lang: null,
2018-05-19 13:31:13 +02:00
birthday: null,
2018-05-20 07:01:47 +02:00
avatarId: null,
bannerId: null,
2018-05-21 04:08:08 +02:00
isCat: false,
isBot: false,
2018-09-13 11:23:44 +02:00
isLocked: false,
2018-10-13 13:11:00 +02:00
carefulBot: false,
autoAcceptFollowed: false,
2018-05-20 07:01:47 +02:00
saving: false,
2018-06-15 00:56:56 +02:00
avatarUploading: false,
2019-02-06 09:10:40 +01:00
bannerUploading: false,
2019-02-06 12:56:48 +01:00
exportTarget: 'notes',
2019-03-11 12:12:44 +01:00
faDownload, faUpload, faSave, faEnvelope, faUnlockAlt, faBoxes, faCogs
2018-05-19 13:31:13 +02:00
};
},
2018-05-20 02:04:48 +02:00
computed: {
alwaysMarkNsfw: {
Use PostgreSQL instead of MongoDB (#4572) * wip * Update note.ts * Update timeline.ts * Update core.ts * wip * Update generate-visibility-query.ts * wip * wip * wip * wip * wip * Update global-timeline.ts * wip * wip * wip * Update vote.ts * wip * wip * Update create.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update files.ts * wip * wip * Update CONTRIBUTING.md * wip * wip * wip * wip * wip * wip * wip * wip * Update read-notification.ts * wip * wip * wip * wip * wip * wip * wip * Update cancel.ts * wip * wip * wip * Update show.ts * wip * wip * Update gen-id.ts * Update create.ts * Update id.ts * wip * wip * wip * wip * wip * wip * wip * Docker: Update files about Docker (#4599) * Docker: Use cache if files used by `yarn install` was not updated This patch reduces the number of times to installing node_modules. For example, `yarn install` step will be skipped when only ".config/default.yml" is updated. * Docker: Migrate MongoDB to Postgresql Misskey uses Postgresql as a database instead of Mongodb since version 11. * Docker: Uncomment about data persistence This patch will save a lot of databases. * wip * wip * wip * Update activitypub.ts * wip * wip * wip * Update logs.ts * wip * Update drive-file.ts * Update register.ts * wip * wip * Update mentions.ts * wip * wip * wip * Update recommendation.ts * wip * Update index.ts * wip * Update recommendation.ts * Doc: Update docker.ja.md and docker.en.md (#1) (#4608) Update how to set up misskey. * wip * :v: * wip * Update note.ts * Update postgre.ts * wip * wip * wip * wip * Update add-file.ts * wip * wip * wip * Clean up * Update logs.ts * wip * :pizza: * wip * Ad notes * wip * Update api-visibility.ts * Update note.ts * Update add-file.ts * tests * tests * Update postgre.ts * Update utils.ts * wip * wip * Refactor * wip * Refactor * wip * wip * Update show-users.ts * Update update-instance.ts * wip * Update feed.ts * Update outbox.ts * Update outbox.ts * Update user.ts * wip * Update list.ts * Update update-hashtag.ts * wip * Update update-hashtag.ts * Refactor * Update update.ts * wip * wip * :v: * clean up * docs * Update push.ts * wip * Update api.ts * wip * :v: * Update make-pagination-query.ts * :v: * Delete hashtags.ts * Update instances.ts * Update instances.ts * Update create.ts * Update search.ts * Update reversi-game.ts * Update signup.ts * Update user.ts * id * Update example.yml * :art: * objectid * fix * reversi * reversi * Fix bug of chart engine * Add test of chart engine * Improve test * Better testing * Improve chart engine * Refactor * Add test of chart engine * Refactor * Add chart test * Fix bug * コミットし忘れ * Refactoring * :v: * Add tests * Add test * Extarct note tests * Refactor * 存在しないユーザーにメンションできなくなっていた問題を修正 * Fix bug * Update update-meta.ts * Fix bug * Update mention.vue * Fix bug * Update meta.ts * Update CONTRIBUTING.md * Fix bug * Fix bug * Fix bug * Clean up * Clean up * Update notification.ts * Clean up * Add mute tests * Add test * Refactor * Add test * Fix test * Refactor * Refactor * Add tests * Update utils.ts * Update utils.ts * Fix test * Update package.json * Update update.ts * Update manifest.ts * Fix bug * Fix bug * Add test * :art: * Update endpoint permissions * Updaye permisison * Update person.ts #4299 * データベースと同期しないように * Fix bug * Fix bug * Update reversi-game.ts * Use a feature of Node v11.7.0 to extract a public key (#4644) * wip * wip * :v: * Refactoring #1540 * test * test * test * test * test * test * test * Fix bug * Fix test * :sushi: * wip * #4471 * Add test for #4335 * Refactor * Fix test * Add tests * :clock4: * Fix bug * Add test * Add test * rename * Fix bug
2019-04-07 14:50:36 +02:00
get() { return this.$store.state.i.alwaysMarkNsfw; },
2018-11-09 00:13:34 +01:00
set(value) { this.$root.api('i/update', { alwaysMarkNsfw: value }); }
},
2018-11-09 10:32:09 +01:00
bannerStyle(): any {
if (this.$store.state.i.bannerUrl == null) return {};
return {
2019-04-08 12:56:42 +02:00
backgroundColor: this.$store.state.i.bannerColor,
2018-11-09 10:32:09 +01:00
backgroundImage: `url(${ this.$store.state.i.bannerUrl })`
};
},
},
2018-05-19 13:31:13 +02:00
created() {
this.$root.getMeta().then(meta => {
this.enableEmail = meta.enableEmail;
});
2018-11-29 08:23:45 +01:00
this.email = this.$store.state.i.email;
this.name = this.$store.state.i.name;
2018-05-27 06:49:09 +02:00
this.username = this.$store.state.i.username;
Use PostgreSQL instead of MongoDB (#4572) * wip * Update note.ts * Update timeline.ts * Update core.ts * wip * Update generate-visibility-query.ts * wip * wip * wip * wip * wip * Update global-timeline.ts * wip * wip * wip * Update vote.ts * wip * wip * Update create.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update files.ts * wip * wip * Update CONTRIBUTING.md * wip * wip * wip * wip * wip * wip * wip * wip * Update read-notification.ts * wip * wip * wip * wip * wip * wip * wip * Update cancel.ts * wip * wip * wip * Update show.ts * wip * wip * Update gen-id.ts * Update create.ts * Update id.ts * wip * wip * wip * wip * wip * wip * wip * Docker: Update files about Docker (#4599) * Docker: Use cache if files used by `yarn install` was not updated This patch reduces the number of times to installing node_modules. For example, `yarn install` step will be skipped when only ".config/default.yml" is updated. * Docker: Migrate MongoDB to Postgresql Misskey uses Postgresql as a database instead of Mongodb since version 11. * Docker: Uncomment about data persistence This patch will save a lot of databases. * wip * wip * wip * Update activitypub.ts * wip * wip * wip * Update logs.ts * wip * Update drive-file.ts * Update register.ts * wip * wip * Update mentions.ts * wip * wip * wip * Update recommendation.ts * wip * Update index.ts * wip * Update recommendation.ts * Doc: Update docker.ja.md and docker.en.md (#1) (#4608) Update how to set up misskey. * wip * :v: * wip * Update note.ts * Update postgre.ts * wip * wip * wip * wip * Update add-file.ts * wip * wip * wip * Clean up * Update logs.ts * wip * :pizza: * wip * Ad notes * wip * Update api-visibility.ts * Update note.ts * Update add-file.ts * tests * tests * Update postgre.ts * Update utils.ts * wip * wip * Refactor * wip * Refactor * wip * wip * Update show-users.ts * Update update-instance.ts * wip * Update feed.ts * Update outbox.ts * Update outbox.ts * Update user.ts * wip * Update list.ts * Update update-hashtag.ts * wip * Update update-hashtag.ts * Refactor * Update update.ts * wip * wip * :v: * clean up * docs * Update push.ts * wip * Update api.ts * wip * :v: * Update make-pagination-query.ts * :v: * Delete hashtags.ts * Update instances.ts * Update instances.ts * Update create.ts * Update search.ts * Update reversi-game.ts * Update signup.ts * Update user.ts * id * Update example.yml * :art: * objectid * fix * reversi * reversi * Fix bug of chart engine * Add test of chart engine * Improve test * Better testing * Improve chart engine * Refactor * Add test of chart engine * Refactor * Add chart test * Fix bug * コミットし忘れ * Refactoring * :v: * Add tests * Add test * Extarct note tests * Refactor * 存在しないユーザーにメンションできなくなっていた問題を修正 * Fix bug * Update update-meta.ts * Fix bug * Update mention.vue * Fix bug * Update meta.ts * Update CONTRIBUTING.md * Fix bug * Fix bug * Fix bug * Clean up * Clean up * Update notification.ts * Clean up * Add mute tests * Add test * Refactor * Add test * Fix test * Refactor * Refactor * Add tests * Update utils.ts * Update utils.ts * Fix test * Update package.json * Update update.ts * Update manifest.ts * Fix bug * Fix bug * Add test * :art: * Update endpoint permissions * Updaye permisison * Update person.ts #4299 * データベースと同期しないように * Fix bug * Fix bug * Update reversi-game.ts * Use a feature of Node v11.7.0 to extract a public key (#4644) * wip * wip * :v: * Refactoring #1540 * test * test * test * test * test * test * test * Fix bug * Fix test * :sushi: * wip * #4471 * Add test for #4335 * Refactor * Fix test * Add tests * :clock4: * Fix bug * Add test * Add test * rename * Fix bug
2019-04-07 14:50:36 +02:00
this.location = this.$store.state.i.location;
2018-05-27 06:49:09 +02:00
this.description = this.$store.state.i.description;
2018-12-03 12:08:18 +01:00
this.lang = this.$store.state.i.lang;
Use PostgreSQL instead of MongoDB (#4572) * wip * Update note.ts * Update timeline.ts * Update core.ts * wip * Update generate-visibility-query.ts * wip * wip * wip * wip * wip * Update global-timeline.ts * wip * wip * wip * Update vote.ts * wip * wip * Update create.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update files.ts * wip * wip * Update CONTRIBUTING.md * wip * wip * wip * wip * wip * wip * wip * wip * Update read-notification.ts * wip * wip * wip * wip * wip * wip * wip * Update cancel.ts * wip * wip * wip * Update show.ts * wip * wip * Update gen-id.ts * Update create.ts * Update id.ts * wip * wip * wip * wip * wip * wip * wip * Docker: Update files about Docker (#4599) * Docker: Use cache if files used by `yarn install` was not updated This patch reduces the number of times to installing node_modules. For example, `yarn install` step will be skipped when only ".config/default.yml" is updated. * Docker: Migrate MongoDB to Postgresql Misskey uses Postgresql as a database instead of Mongodb since version 11. * Docker: Uncomment about data persistence This patch will save a lot of databases. * wip * wip * wip * Update activitypub.ts * wip * wip * wip * Update logs.ts * wip * Update drive-file.ts * Update register.ts * wip * wip * Update mentions.ts * wip * wip * wip * Update recommendation.ts * wip * Update index.ts * wip * Update recommendation.ts * Doc: Update docker.ja.md and docker.en.md (#1) (#4608) Update how to set up misskey. * wip * :v: * wip * Update note.ts * Update postgre.ts * wip * wip * wip * wip * Update add-file.ts * wip * wip * wip * Clean up * Update logs.ts * wip * :pizza: * wip * Ad notes * wip * Update api-visibility.ts * Update note.ts * Update add-file.ts * tests * tests * Update postgre.ts * Update utils.ts * wip * wip * Refactor * wip * Refactor * wip * wip * Update show-users.ts * Update update-instance.ts * wip * Update feed.ts * Update outbox.ts * Update outbox.ts * Update user.ts * wip * Update list.ts * Update update-hashtag.ts * wip * Update update-hashtag.ts * Refactor * Update update.ts * wip * wip * :v: * clean up * docs * Update push.ts * wip * Update api.ts * wip * :v: * Update make-pagination-query.ts * :v: * Delete hashtags.ts * Update instances.ts * Update instances.ts * Update create.ts * Update search.ts * Update reversi-game.ts * Update signup.ts * Update user.ts * id * Update example.yml * :art: * objectid * fix * reversi * reversi * Fix bug of chart engine * Add test of chart engine * Improve test * Better testing * Improve chart engine * Refactor * Add test of chart engine * Refactor * Add chart test * Fix bug * コミットし忘れ * Refactoring * :v: * Add tests * Add test * Extarct note tests * Refactor * 存在しないユーザーにメンションできなくなっていた問題を修正 * Fix bug * Update update-meta.ts * Fix bug * Update mention.vue * Fix bug * Update meta.ts * Update CONTRIBUTING.md * Fix bug * Fix bug * Fix bug * Clean up * Clean up * Update notification.ts * Clean up * Add mute tests * Add test * Refactor * Add test * Fix test * Refactor * Refactor * Add tests * Update utils.ts * Update utils.ts * Fix test * Update package.json * Update update.ts * Update manifest.ts * Fix bug * Fix bug * Add test * :art: * Update endpoint permissions * Updaye permisison * Update person.ts #4299 * データベースと同期しないように * Fix bug * Fix bug * Update reversi-game.ts * Use a feature of Node v11.7.0 to extract a public key (#4644) * wip * wip * :v: * Refactoring #1540 * test * test * test * test * test * test * test * Fix bug * Fix test * :sushi: * wip * #4471 * Add test for #4335 * Refactor * Fix test * Add tests * :clock4: * Fix bug * Add test * Add test * rename * Fix bug
2019-04-07 14:50:36 +02:00
this.birthday = this.$store.state.i.birthday;
2018-05-27 06:49:09 +02:00
this.avatarId = this.$store.state.i.avatarId;
this.bannerId = this.$store.state.i.bannerId;
this.isCat = this.$store.state.i.isCat;
this.isBot = this.$store.state.i.isBot;
2018-09-13 11:23:44 +02:00
this.isLocked = this.$store.state.i.isLocked;
2018-10-13 13:11:00 +02:00
this.carefulBot = this.$store.state.i.carefulBot;
this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed;
2019-07-28 03:31:16 +02:00
this.fieldName0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].name : null;
this.fieldValue0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].value : null;
this.fieldName1 = this.$store.state.i.fields[1] ? this.$store.state.i.fields[1].name : null;
this.fieldValue1 = this.$store.state.i.fields[1] ? this.$store.state.i.fields[1].value : null;
this.fieldName2 = this.$store.state.i.fields[2] ? this.$store.state.i.fields[2].name : null;
this.fieldValue2 = this.$store.state.i.fields[2] ? this.$store.state.i.fields[2].value : null;
this.fieldName3 = this.$store.state.i.fields[3] ? this.$store.state.i.fields[3].name : null;
this.fieldValue3 = this.$store.state.i.fields[3] ? this.$store.state.i.fields[3].value : null;
2018-05-19 13:31:13 +02:00
},
2018-05-20 02:04:48 +02:00
methods: {
2018-05-20 07:01:47 +02:00
onAvatarChange([file]) {
2018-06-15 00:56:56 +02:00
this.avatarUploading = true;
2018-05-20 07:01:47 +02:00
const data = new FormData();
data.append('file', file);
2018-05-27 06:49:09 +02:00
data.append('i', this.$store.state.i.token);
2018-05-20 07:01:47 +02:00
fetch(apiUrl + '/drive/files/create', {
method: 'POST',
body: data
})
2018-08-19 06:32:02 +02: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 07:01:47 +02:00
},
onBannerChange([file]) {
2018-06-15 00:56:56 +02:00
this.bannerUploading = true;
2018-05-20 07:01:47 +02:00
const data = new FormData();
data.append('file', file);
2018-05-27 06:49:09 +02:00
data.append('i', this.$store.state.i.token);
2018-05-20 07:01:47 +02:00
fetch(apiUrl + '/drive/files/create', {
method: 'POST',
body: data
})
2018-08-19 06:32:02 +02: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 07:01:47 +02:00
},
2018-09-13 11:23:44 +02:00
save(notify) {
const fields = [
{ name: this.fieldName0, value: this.fieldValue0 },
{ name: this.fieldName1, value: this.fieldValue1 },
{ name: this.fieldName2, value: this.fieldValue2 },
{ name: this.fieldName3, value: this.fieldValue3 },
];
2018-05-19 13:31:13 +02:00
this.saving = true;
2018-11-09 00:13:34 +01:00
this.$root.api('i/update', {
2018-05-19 13:31:13 +02:00
name: this.name || null,
location: this.location || null,
description: this.description || null,
2018-12-03 12:08:18 +01:00
lang: this.lang,
2018-05-20 07:01:47 +02:00
birthday: this.birthday || null,
2018-11-28 20:54:36 +01:00
avatarId: this.avatarId || undefined,
bannerId: this.bannerId || undefined,
fields,
2018-11-09 00:41:06 +01:00
isCat: !!this.isCat,
isBot: !!this.isBot,
isLocked: !!this.isLocked,
carefulBot: !!this.carefulBot,
autoAcceptFollowed: !!this.autoAcceptFollowed
2018-05-20 07:01:47 +02:00
}).then(i => {
2018-05-19 13:31:13 +02:00
this.saving = false;
2018-05-27 06:49:09 +02: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 07:01:47 +02:00
2018-09-13 11:23:44 +02:00
if (notify) {
2018-12-02 07:28:52 +01:00
this.$root.dialog({
2018-10-10 14:23:38 +02:00
type: 'success',
text: this.$t('saved')
2018-10-10 14:23:38 +02:00
});
2018-09-13 11:23:44 +02:00
}
2019-07-17 06:28:27 +02:00
}).catch(err => {
this.saving = false;
switch(err.id) {
case 'f419f9f8-2f4d-46b1-9fb4-49d3a2fd7191':
this.$root.dialog({
type: 'error',
title: this.$t('unable-to-process'),
text: this.$t('avatar-not-an-image')
});
break;
case '75aedb19-2afd-4e6d-87fc-67941256fa60':
this.$root.dialog({
type: 'error',
title: this.$t('unable-to-process'),
text: this.$t('banner-not-an-image')
});
break;
default:
this.$root.dialog({
type: 'error',
text: this.$t('unable-to-process')
});
}
2018-05-19 13:31:13 +02:00
});
2018-11-29 08:23:45 +01:00
},
updateEmail() {
2018-12-02 12:10:53 +01:00
this.$root.dialog({
2018-11-29 12:19:02 +01:00
title: this.$t('@.enter-password'),
2018-12-02 12:10:53 +01:00
input: {
type: 'password'
}
}).then(({ canceled, result: password }) => {
if (canceled) return;
2018-11-29 12:19:02 +01:00
this.$root.api('i/update_email', {
password: password,
email: this.email == '' ? null : this.email
});
2018-11-29 08:23:45 +01:00
});
},
2019-02-06 12:56:48 +01:00
doExport() {
this.$root.api(
this.exportTarget == 'notes' ? 'i/export-notes' :
this.exportTarget == 'following' ? 'i/export-following' :
this.exportTarget == 'mute' ? 'i/export-mute' :
this.exportTarget == 'blocking' ? 'i/export-blocking' :
this.exportTarget == 'user-lists' ? 'i/export-user-lists' :
null, {}).then(() => {
this.$root.dialog({
type: 'info',
text: this.$t('export-requested')
});
}).catch((e: any) => {
this.$root.dialog({
type: 'error',
text: e.message
});
});
2019-02-20 17:30:21 +01:00
},
2019-03-11 11:43:58 +01:00
doImport() {
this.$chooseDriveFile().then(file => {
this.$root.api(
2019-03-11 16:34:19 +01:00
this.exportTarget == 'following' ? 'i/import-following' :
2019-03-11 11:43:58 +01:00
this.exportTarget == 'user-lists' ? 'i/import-user-lists' :
null, {
fileId: file.id
2019-03-29 10:35:47 +01:00
}).then(() => {
this.$root.dialog({
type: 'info',
text: this.$t('import-requested')
});
}).catch((e: any) => {
this.$root.dialog({
type: 'error',
text: e.message
2019-03-11 11:43:58 +01:00
});
});
});
},
2019-02-20 17:30:21 +01:00
async deleteAccount() {
const { canceled: canceled, result: password } = await this.$root.dialog({
title: this.$t('enter-password'),
input: {
type: 'password'
}
});
if (canceled) return;
this.$root.api('i/delete-account', {
password
}).then(() => {
this.$root.dialog({
type: 'success',
text: this.$t('account-deleted')
});
});
2018-05-19 13:31:13 +02:00
}
}
});
</script>
2018-11-09 10:32:09 +01:00
<style lang="stylus" scoped>
.esokaraujimuwfttfzgocmutcihewscl
> .header
height 150px
overflow hidden
background-size cover
background-position center
border-radius 4px
> .avatar
position absolute
top 0
bottom 0
left 0
right 0
display block
width 72px
height 72px
margin auto
.fields
> header
padding 8px 0px
font-weight bold
2018-11-09 10:32:09 +01:00
</style>