2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2020-12-31 04:01:12 -06:00
|
|
|
<FormBase>
|
|
|
|
<FormGroup>
|
|
|
|
<template #label>{{ $ts._exportOrImport.allNotes }}</template>
|
|
|
|
<FormButton @click="doExport('notes')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
|
|
<template #label>{{ $ts._exportOrImport.followingList }}</template>
|
|
|
|
<FormButton @click="doExport('following')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
|
|
|
<FormButton @click="doImport('following', $event)"><Fa :icon="faUpload"/> {{ $ts.import }}</FormButton>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
|
|
<template #label>{{ $ts._exportOrImport.userLists }}</template>
|
|
|
|
<FormButton @click="doExport('user-lists')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
|
|
|
<FormButton @click="doImport('user-lists', $event)"><Fa :icon="faUpload"/> {{ $ts.import }}</FormButton>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
|
|
<template #label>{{ $ts._exportOrImport.muteList }}</template>
|
|
|
|
<FormButton @click="doExport('mute')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
|
|
<template #label>{{ $ts._exportOrImport.blockingList }}</template>
|
|
|
|
<FormButton @click="doExport('blocking')"><Fa :icon="faDownload"/> {{ $ts.export }}</FormButton>
|
|
|
|
</FormGroup>
|
|
|
|
</FormBase>
|
2020-01-29 13:37:25 -06:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 13:37:25 -06:00
|
|
|
import { faDownload, faUpload, faBoxes } from '@fortawesome/free-solid-svg-icons';
|
2021-03-23 03:30:14 -05:00
|
|
|
import FormSelect from '@client/components/form/select.vue';
|
|
|
|
import FormButton from '@client/components/form/button.vue';
|
|
|
|
import FormBase from '@client/components/form/base.vue';
|
|
|
|
import FormGroup from '@client/components/form/group.vue';
|
|
|
|
import * as os from '@client/os';
|
|
|
|
import { selectFile } from '@client/scripts/select-file';
|
2021-04-09 22:54:12 -05:00
|
|
|
import * as symbols from '@client/symbols';
|
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: {
|
2020-12-31 04:01:12 -06:00
|
|
|
FormBase,
|
|
|
|
FormGroup,
|
|
|
|
FormButton,
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
|
2020-12-31 04:01:12 -06:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-09 22:54:12 -05:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-31 04:01:12 -06:00
|
|
|
title: this.$ts.importAndExport,
|
|
|
|
icon: faBoxes
|
|
|
|
},
|
2020-01-29 13:37:25 -06:00
|
|
|
faDownload, faUpload, faBoxes
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-12-31 04:01:12 -06:00
|
|
|
mounted() {
|
2021-04-09 22:54:12 -05:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2020-12-31 04:01:12 -06:00
|
|
|
},
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
methods: {
|
2020-12-31 04:01:12 -06:00
|
|
|
doExport(target) {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.api(
|
2020-12-31 04:01:12 -06:00
|
|
|
target == 'notes' ? 'i/export-notes' :
|
|
|
|
target == 'following' ? 'i/export-following' :
|
|
|
|
target == 'blocking' ? 'i/export-blocking' :
|
|
|
|
target == 'user-lists' ? 'i/export-user-lists' :
|
|
|
|
target == 'mute' ? 'i/export-mute' :
|
2020-01-29 13:37:25 -06:00
|
|
|
null, {})
|
|
|
|
.then(() => {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.dialog({
|
2020-01-29 13:37:25 -06:00
|
|
|
type: 'info',
|
2020-12-25 19:47:36 -06:00
|
|
|
text: this.$ts.exportRequested
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
|
|
|
}).catch((e: any) => {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.dialog({
|
2020-01-29 13:37:25 -06:00
|
|
|
type: 'error',
|
|
|
|
text: e.message
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-12-31 04:01:12 -06:00
|
|
|
async doImport(target, e) {
|
2020-10-24 20:48:33 -05:00
|
|
|
const file = await selectFile(e.currentTarget || e.target);
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
os.api(
|
2020-12-31 04:01:12 -06:00
|
|
|
target == 'following' ? 'i/import-following' :
|
|
|
|
target == 'user-lists' ? 'i/import-user-lists' :
|
2020-01-29 13:37:25 -06:00
|
|
|
null, {
|
|
|
|
fileId: file.id
|
|
|
|
}).then(() => {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.dialog({
|
2020-01-29 13:37:25 -06:00
|
|
|
type: 'info',
|
2020-12-25 19:47:36 -06:00
|
|
|
text: this.$ts.importRequested
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
|
|
|
}).catch((e: any) => {
|
2020-10-17 06:12:00 -05:00
|
|
|
os.dialog({
|
2020-01-29 13:37:25 -06:00
|
|
|
type: 'error',
|
|
|
|
text: e.message
|
|
|
|
});
|
|
|
|
});
|
2020-10-24 20:48:33 -05:00
|
|
|
},
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|