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.

120 lines
3.1 KiB

  1. import axios from 'axios';
  2. // import OverlayPanel from 'primevue/overlaypanel/OverlayPanel';
  3. import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
  4. import { FileData } from '@interfaces/FileData';
  5. @Component
  6. export default class ProcessFile extends Vue {
  7. /**
  8. * Props
  9. */
  10. // The data for the file we are processing
  11. @Prop({ default: { id: -1, file: '', path: '' } })
  12. public readonly file!: FileData;
  13. // The list of available searchers
  14. @Prop({ default: [] })
  15. public readonly searchers!: { [keys: string]: string; }
  16. /**
  17. * Class members
  18. */
  19. public $refs!: {
  20. 'searchers-overlay': any
  21. }
  22. // The id of the interval used to query the file status
  23. private intervalId!: any;
  24. // The content of the file we are processing
  25. private fileContent: string = '';
  26. // The list of filters/searchers in a format usable by the datatable
  27. private searchersData: Array<{ id: string; name: string; }> = [];
  28. // The list of selected filters/searchers
  29. private selectedSearchers: Array<{ id: string; name: string; }> = [];
  30. //The list of expanded rows in the selected filters/searchers table
  31. private expandedRows: Array<{id: string; name: string; }> = [];
  32. /**
  33. *
  34. */
  35. created() {
  36. for(let index in this.searchers) {
  37. let searcherData = {
  38. id: index,
  39. name: this.searchers[index]
  40. };
  41. this.searchersData.push(searcherData);
  42. }
  43. this.intervalId = setInterval(this.waitForFile, 3000);
  44. }
  45. /**
  46. *
  47. */
  48. private async waitForFile() {
  49. const response = await this.$api.getFileData(this.file.id);
  50. if (response.text !== null && response.ready === true) {
  51. if (response.ingest_status === 'fail') {
  52. this.$toast.add({
  53. severity: 'error',
  54. summary: 'File error',
  55. detail: 'THere was an error processing the file in ingest',
  56. life: 3000
  57. });
  58. } else {
  59. this.fileContent = response.documentContent;
  60. this.$toast.add({
  61. severity:'success',
  62. summary: 'File loaded',
  63. detail: 'The file has been processed by ingest.',
  64. life: 3000
  65. });
  66. clearInterval(this.intervalId);
  67. }
  68. } else {
  69. console.log('FILE NOT READY YET!');
  70. }
  71. }
  72. private toggleSearchersMenu($event: any) {
  73. this.$refs['searchers-overlay'].toggle($event);
  74. }
  75. private onRowSelect($event: any) {
  76. console.log('SELECT: ', $event);
  77. console.log(this.selectedSearchers);
  78. }
  79. private onRowUnselect($event: any) {
  80. console.log('UNSELECT: ', $event);
  81. console.log(this.selectedSearchers);
  82. }
  83. private onSelectedSearchersReorder($event: any)
  84. {
  85. this.selectedSearchers = $event.value;
  86. }
  87. private onSelectedSearcherExpand($event:any)
  88. {
  89. }
  90. private onSelectedSearcherCollapse($event:any)
  91. {
  92. }
  93. }