Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. import { Vue, Component, Prop } from 'vue-property-decorator';
  2. import FileUploadResponse from '@interfaces/responses/FileUploadResponse';
  3. @Component
  4. export default class Home extends Vue {
  5. @Prop({ default: [] })
  6. public readonly searchers!: { [key: string]: string; }
  7. public uiBlocked = false;
  8. public uploading = false;
  9. public fileUploaded: boolean = false;
  10. public uploadResult: FileUploadResponse = {
  11. id: '',
  12. file: '',
  13. path: ''
  14. };
  15. /**
  16. *
  17. */
  18. public created()
  19. {}
  20. /**
  21. * A method which uploads the files to the server for processing
  22. *
  23. * @param event The event containing the uploaded files information
  24. */
  25. public async uploadFile(event: any): Promise<void> {
  26. this.uploading = true;
  27. this.fileUploaded = false;
  28. this.$toast.add({severity:'info', summary: 'Uploading...', detail:'Uploading your file...', life: 3000});
  29. try {
  30. let file = event.files[0];
  31. let response = await this.$api.uploadFile(file);
  32. this.fileUploaded = true;
  33. this.uploadResult = response;
  34. } catch (err) {
  35. console.log('Error uploading file: ', err);
  36. this.$toast.add({
  37. severity: 'error',
  38. summary: 'Error!',
  39. detail: 'There was an error uploading your file. Please try again later',
  40. life: 3000
  41. });
  42. this.uploading = false;
  43. this.fileUploaded = false;
  44. }
  45. }
  46. }