diff options
| author | taehoon <th.dev91@gmail.com> | 2019-03-29 21:58:20 -0400 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-04-27 08:31:06 -0400 |
| commit | 562120ae48945d87a24f2248f9b16185b49159d0 (patch) | |
| tree | 6dd44cb102078b7ebf29cb05956df0710501f8c5 /src/components/importer | |
| parent | 9e2fa50b74eb83e3c3eadb9a68d24ddaa1d9da48 (diff) | |
split out follow’s importer as a separate component
Diffstat (limited to 'src/components/importer')
| -rw-r--r-- | src/components/importer/importer.js | 36 | ||||
| -rw-r--r-- | src/components/importer/importer.vue | 19 |
2 files changed, 55 insertions, 0 deletions
diff --git a/src/components/importer/importer.js b/src/components/importer/importer.js new file mode 100644 index 00000000..8d6c8b3f --- /dev/null +++ b/src/components/importer/importer.js @@ -0,0 +1,36 @@ +const Importer = { + data () { + return { + file: null, + error: false, + success: false, + uploading: false + } + }, + methods: { + change () { + this.file = this.$refs.input.files[0] + }, + submit () { + this.uploading = true + // eslint-disable-next-line no-undef + const formData = new FormData() + formData.append('list', this.file) + this.$store.state.api.backendInteractor.followImport({params: formData}) + .then((status) => { + if (status) { + this.success = true + } else { + this.error = true + } + this.uploading = false + }) + }, + dismiss () { + this.success = false + this.error = false + } + } +} + +export default Importer diff --git a/src/components/importer/importer.vue b/src/components/importer/importer.vue new file mode 100644 index 00000000..0fd83b7c --- /dev/null +++ b/src/components/importer/importer.vue @@ -0,0 +1,19 @@ +<template> + <div class="importer"> + <form> + <input type="file" ref="input" v-on:change="change" /> + </form> + <i class="icon-spin4 animate-spin uploading" v-if="uploading"></i> + <button class="btn btn-default" v-else @click="submit">{{$t('general.submit')}}</button> + <div v-if="success"> + <i class="icon-cross" @click="dismiss"></i> + <p>{{$t('settings.follows_imported')}}</p> + </div> + <div v-else-if="error"> + <i class="icon-cross" @click="dismiss"></i> + <p>{{$t('settings.follow_import_error')}}</p> + </div> + </div> +</template> + +<script src="./importer.js"></script> |
