logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

importer.js (959B)


  1. import { library } from '@fortawesome/fontawesome-svg-core'
  2. import {
  3. faCircleNotch,
  4. faTimes
  5. } from '@fortawesome/free-solid-svg-icons'
  6. library.add(
  7. faCircleNotch,
  8. faTimes
  9. )
  10. const Importer = {
  11. props: {
  12. submitHandler: {
  13. type: Function,
  14. required: true
  15. },
  16. submitButtonLabel: { type: String },
  17. successMessage: { type: String },
  18. errorMessage: { type: String }
  19. },
  20. data () {
  21. return {
  22. file: null,
  23. error: false,
  24. success: false,
  25. submitting: false
  26. }
  27. },
  28. methods: {
  29. change () {
  30. this.file = this.$refs.input.files[0]
  31. },
  32. submit () {
  33. this.dismiss()
  34. this.submitting = true
  35. this.submitHandler(this.file)
  36. .then(() => { this.success = true })
  37. .catch(() => { this.error = true })
  38. .finally(() => { this.submitting = false })
  39. },
  40. dismiss () {
  41. this.success = false
  42. this.error = false
  43. }
  44. }
  45. }
  46. export default Importer