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.

100 lines
2.9 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="wrap" v-if="!fileUploaded && !uploading">
  3. <Toast position="top-right" />
  4. <Panel header="Please upload a file">
  5. <FileUpload
  6. name="demo[]"
  7. :customUpload="true"
  8. :auto="true"
  9. @uploader="uploadFile"
  10. >
  11. <template #empty>
  12. <p>Drag and drop files to here to upload.</p>
  13. </template>
  14. </FileUpload>
  15. </Panel>
  16. <BlockUI :blocked="uiBlocked" :fullScreen="true"></BlockUI>
  17. </div>
  18. <div class="wrap" v-else-if="!fileUploaded && uploading">
  19. <Skeleton />
  20. <Skeleton />
  21. <Skeleton />
  22. <Skeleton />
  23. <Skeleton />
  24. <Skeleton />
  25. <Skeleton />
  26. </div>
  27. <div class="wrap" v-else>
  28. <process-file :file="uploadResult" :filters="filters"></process-file>
  29. </div>
  30. </template>
  31. <script lang="ts">
  32. import axios from 'axios';
  33. // import Vue from 'vue';
  34. // import Component from 'vue-class-component';
  35. import { Vue, Component, Prop } from 'vue-property-decorator';
  36. @Component
  37. export default class Home extends Vue {
  38. @Prop({ default: [] })
  39. public readonly filters!: Array<object>
  40. public uiBlocked = false;
  41. public uploading = false;
  42. public fileUploaded: boolean = false;
  43. public uploadResult = null;
  44. /**
  45. *
  46. */
  47. public created()
  48. {
  49. console.log(this.filters);
  50. }
  51. /**
  52. * A method which uploads the files to the server for processing
  53. *
  54. * @param event The event containing the uploaded files information
  55. */
  56. public uploadFile(event: any): void {
  57. this.uploading = true;
  58. this.fileUploaded = false;
  59. this['$toast'].add({severity:'success', summary: 'Success Message', detail:'Order submitted', life: 3000});
  60. let file = event.files[0];
  61. let formData = new FormData();
  62. formData.append('file', file);
  63. setTimeout(
  64. () => {
  65. axios.post(
  66. 'http://core.sandd/api/file',
  67. formData,
  68. {
  69. headers: {
  70. 'Content-Type': 'multipart/form-data'
  71. }
  72. }
  73. ).then(
  74. (response) => {
  75. this.fileUploaded = true;
  76. this.uploadResult = response.data;
  77. // console.log('Success: ', response);
  78. }
  79. ).catch(
  80. (err) => {
  81. console.log('Error: ', err);
  82. }
  83. );
  84. }, 500
  85. )
  86. }
  87. }
  88. </script>