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.

49 lines
1.4 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_name: '',
  13. };
  14. /**
  15. * A method which uploads the files to the server for processing
  16. *
  17. * @param event The event containing the uploaded files information
  18. */
  19. public async uploadFile(event: any): Promise<void> {
  20. this.uploading = true;
  21. this.fileUploaded = false;
  22. this.$toast.add({severity: 'info', summary: 'Uploading...', detail: 'Uploading your file...', life: 3000});
  23. try {
  24. let file = event.files[0];
  25. let response = await this.$api.uploadFile(file);
  26. this.fileUploaded = true;
  27. this.uploadResult = response;
  28. } catch (err) {
  29. console.log('Error uploading file: ', err);
  30. this.$toast.add({
  31. severity: 'error',
  32. summary: 'Error!',
  33. detail: 'There was an error uploading your file. Please try again later',
  34. life: 3000
  35. });
  36. this.uploading = false;
  37. this.fileUploaded = false;
  38. }
  39. }
  40. }