2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2021-11-28 05:07:37 -06:00
|
|
|
<div class="_formRoot">
|
2021-10-03 09:51:54 -05:00
|
|
|
<FormSection>
|
2020-12-31 04:01:12 -06:00
|
|
|
<template #label>{{ $ts._exportOrImport.allNotes }}</template>
|
2021-12-09 10:22:35 -06:00
|
|
|
<MkButton :class="$style.button" inline @click="exportNotes()"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
2021-10-03 09:51:54 -05:00
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 04:01:12 -06:00
|
|
|
<template #label>{{ $ts._exportOrImport.followingList }}</template>
|
2021-12-09 10:22:35 -06:00
|
|
|
<FormGroup>
|
|
|
|
<FormSwitch v-model="excludeMutingUsers" class="_formBlock">
|
|
|
|
{{ $ts._exportOrImport.excludeMutingUsers }}
|
|
|
|
</FormSwitch>
|
|
|
|
<FormSwitch v-model="excludeInactiveUsers" class="_formBlock">
|
|
|
|
{{ $ts._exportOrImport.excludeInactiveUsers }}
|
|
|
|
</FormSwitch>
|
|
|
|
<MkButton :class="$style.button" inline @click="exportFollowing()"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
|
|
<MkButton :class="$style.button" inline @click="importFollowing($event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
|
|
|
</FormGroup>
|
2021-10-03 09:51:54 -05:00
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 04:01:12 -06:00
|
|
|
<template #label>{{ $ts._exportOrImport.userLists }}</template>
|
2021-12-09 10:22:35 -06:00
|
|
|
<MkButton :class="$style.button" inline @click="exportUserLists()"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
<MkButton :class="$style.button" inline @click="importUserLists($event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
2021-10-03 09:51:54 -05:00
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 04:01:12 -06:00
|
|
|
<template #label>{{ $ts._exportOrImport.muteList }}</template>
|
2021-12-09 10:22:35 -06:00
|
|
|
<MkButton :class="$style.button" inline @click="exportMuting()"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
<MkButton :class="$style.button" inline @click="importMuting($event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
2021-10-03 09:51:54 -05:00
|
|
|
</FormSection>
|
|
|
|
<FormSection>
|
2020-12-31 04:01:12 -06:00
|
|
|
<template #label>{{ $ts._exportOrImport.blockingList }}</template>
|
2021-12-09 10:22:35 -06:00
|
|
|
<MkButton :class="$style.button" inline @click="exportBlocking()"><i class="fas fa-download"></i> {{ $ts.export }}</MkButton>
|
|
|
|
<MkButton :class="$style.button" inline @click="importBlocking($event)"><i class="fas fa-upload"></i> {{ $ts.import }}</MkButton>
|
2021-10-03 09:51:54 -05:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-12-09 10:22:35 -06:00
|
|
|
import { defineComponent, onMounted, ref } from 'vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2021-12-09 10:22:35 -06:00
|
|
|
import FormGroup from '@/components/form/group.vue';
|
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { selectFile } from '@/scripts/select-file';
|
|
|
|
import * as symbols from '@/symbols';
|
2021-12-09 10:22:35 -06:00
|
|
|
import { i18n } from '@/i18n';
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
2020-01-29 13:37:25 -06:00
|
|
|
components: {
|
2021-10-03 09:51:54 -05:00
|
|
|
FormSection,
|
2021-12-09 10:22:35 -06:00
|
|
|
FormGroup,
|
|
|
|
FormSwitch,
|
2021-10-03 09:51:54 -05:00
|
|
|
MkButton,
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
|
2020-12-31 04:01:12 -06:00
|
|
|
emits: ['info'],
|
|
|
|
|
2021-12-09 10:22:35 -06:00
|
|
|
setup(props, context) {
|
|
|
|
const INFO = {
|
2022-01-27 20:39:49 -06:00
|
|
|
title: i18n.ts.importAndExport,
|
2021-12-09 10:22:35 -06:00
|
|
|
icon: 'fas fa-boxes',
|
|
|
|
bg: 'var(--bg)',
|
|
|
|
};
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2021-12-09 10:22:35 -06:00
|
|
|
const excludeMutingUsers = ref(false);
|
|
|
|
const excludeInactiveUsers = ref(false);
|
2020-12-31 04:01:12 -06:00
|
|
|
|
2021-12-09 10:22:35 -06:00
|
|
|
const onExportSuccess = () => {
|
|
|
|
os.alert({
|
|
|
|
type: 'info',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.exportRequested,
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
2021-12-09 10:22:35 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
const onImportSuccess = () => {
|
|
|
|
os.alert({
|
|
|
|
type: 'info',
|
2022-01-27 20:39:49 -06:00
|
|
|
text: i18n.ts.importRequested,
|
2021-12-09 10:22:35 -06:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const onError = (e) => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
text: e.message,
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
2021-12-09 10:22:35 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
const exportNotes = () => {
|
|
|
|
os.api('i/export-notes', {}).then(onExportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const exportFollowing = () => {
|
|
|
|
os.api('i/export-following', {
|
|
|
|
excludeMuting: excludeMutingUsers.value,
|
|
|
|
excludeInactive: excludeInactiveUsers.value,
|
|
|
|
})
|
|
|
|
.then(onExportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const exportBlocking = () => {
|
|
|
|
os.api('i/export-blocking', {}).then(onExportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const exportUserLists = () => {
|
|
|
|
os.api('i/export-user-lists', {}).then(onExportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const exportMuting = () => {
|
|
|
|
os.api('i/export-mute', {}).then(onExportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const importFollowing = async (ev) => {
|
|
|
|
const file = await selectFile(ev.currentTarget || ev.target);
|
|
|
|
os.api('i/import-following', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const importUserLists = async (ev) => {
|
|
|
|
const file = await selectFile(ev.currentTarget || ev.target);
|
|
|
|
os.api('i/import-user-lists', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const importMuting = async (ev) => {
|
|
|
|
const file = await selectFile(ev.currentTarget || ev.target);
|
|
|
|
os.api('i/import-muting', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
const importBlocking = async (ev) => {
|
|
|
|
const file = await selectFile(ev.currentTarget || ev.target);
|
|
|
|
os.api('i/import-blocking', { fileId: file.id }).then(onImportSuccess).catch(onError);
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
[symbols.PAGE_INFO]: INFO,
|
|
|
|
excludeMutingUsers,
|
|
|
|
excludeInactiveUsers,
|
|
|
|
|
|
|
|
exportNotes,
|
|
|
|
exportFollowing,
|
|
|
|
exportBlocking,
|
|
|
|
exportUserLists,
|
|
|
|
exportMuting,
|
|
|
|
|
|
|
|
importFollowing,
|
|
|
|
importUserLists,
|
|
|
|
importMuting,
|
|
|
|
importBlocking,
|
|
|
|
};
|
|
|
|
},
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
|
|
|
</script>
|
2021-10-03 09:51:54 -05:00
|
|
|
|
|
|
|
<style module>
|
|
|
|
.button {
|
|
|
|
margin-right: 16px;
|
|
|
|
}
|
|
|
|
</style>
|