paricafe/packages/client/src/pages/settings/import-export.vue

166 lines
5.9 KiB
Vue
Raw Normal View History

<template>
2021-11-28 05:07:37 -06:00
<div class="_formRoot">
2021-10-03 09:51:54 -05:00
<FormSection>
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts._exportOrImport.allNotes }}</template>
2022-06-23 20:51:45 -05:00
<FormFolder>
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.export }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-download"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="exportNotes()"><i class="fas fa-download"></i> {{ i18n.ts.export }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
2021-10-03 09:51:54 -05:00
</FormSection>
<FormSection>
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts._exportOrImport.followingList }}</template>
2022-06-23 20:51:45 -05:00
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.export }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-download"></i></template>
2021-12-09 10:22:35 -06:00
<FormSwitch v-model="excludeMutingUsers" class="_formBlock">
2022-07-20 08:24:26 -05:00
{{ i18n.ts._exportOrImport.excludeMutingUsers }}
2021-12-09 10:22:35 -06:00
</FormSwitch>
<FormSwitch v-model="excludeInactiveUsers" class="_formBlock">
2022-07-20 08:24:26 -05:00
{{ i18n.ts._exportOrImport.excludeInactiveUsers }}
2021-12-09 10:22:35 -06:00
</FormSwitch>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="exportFollowing()"><i class="fas fa-download"></i> {{ i18n.ts.export }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.import }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-upload"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="importFollowing($event)"><i class="fas fa-upload"></i> {{ i18n.ts.import }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
2021-10-03 09:51:54 -05:00
</FormSection>
<FormSection>
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts._exportOrImport.userLists }}</template>
2022-06-23 20:51:45 -05:00
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.export }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-download"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="exportUserLists()"><i class="fas fa-download"></i> {{ i18n.ts.export }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.import }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-upload"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="importUserLists($event)"><i class="fas fa-upload"></i> {{ i18n.ts.import }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
2021-10-03 09:51:54 -05:00
</FormSection>
<FormSection>
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts._exportOrImport.muteList }}</template>
2022-06-23 20:51:45 -05:00
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.export }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-download"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="exportMuting()"><i class="fas fa-download"></i> {{ i18n.ts.export }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.import }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-upload"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="importMuting($event)"><i class="fas fa-upload"></i> {{ i18n.ts.import }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
2021-10-03 09:51:54 -05:00
</FormSection>
<FormSection>
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts._exportOrImport.blockingList }}</template>
2022-06-23 20:51:45 -05:00
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.export }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-download"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="exportBlocking()"><i class="fas fa-download"></i> {{ i18n.ts.export }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
<FormFolder class="_formBlock">
2022-07-20 08:24:26 -05:00
<template #label>{{ i18n.ts.import }}</template>
2022-06-23 20:51:45 -05:00
<template #icon><i class="fas fa-upload"></i></template>
2022-07-20 08:24:26 -05:00
<MkButton primary :class="$style.button" inline @click="importBlocking($event)"><i class="fas fa-upload"></i> {{ i18n.ts.import }}</MkButton>
2022-06-23 20:51:45 -05:00
</FormFolder>
2021-10-03 09:51:54 -05:00
</FormSection>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import MkButton from '@/components/MkButton.vue';
2021-11-11 11:02:25 -06:00
import FormSection from '@/components/form/section.vue';
2022-06-23 20:51:45 -05:00
import FormFolder from '@/components/form/folder.vue';
2021-12-09 10:22:35 -06:00
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';
2021-12-09 10:22:35 -06:00
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
const excludeMutingUsers = ref(false);
const excludeInactiveUsers = ref(false);
const onExportSuccess = () => {
os.alert({
type: 'info',
text: i18n.ts.exportRequested,
});
};
const onImportSuccess = () => {
os.alert({
type: 'info',
text: i18n.ts.importRequested,
});
};
const onError = (ev) => {
os.alert({
type: 'error',
text: ev.message,
});
};
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);
};
const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata({
title: i18n.ts.importAndExport,
icon: 'fas fa-boxes',
});
</script>
2021-10-03 09:51:54 -05:00
<style module>
.button {
margin-right: 16px;
}
</style>