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.

256 lines
9.8 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="p-d-flex p-flex-row p-jc-between p-ai-stretch">
  3. <Card class="p-mr-2 p-as-stretch file-card">
  4. <template #header>
  5. <Toolbar>
  6. <template #left>
  7. <h3>Original document content</h3>
  8. </template>
  9. <template #right>
  10. <Button
  11. label="Try another document"
  12. icon="pi pi-upload"
  13. class="p-button-success p-button-outlined p-button-sm"
  14. @click="toggleUploadDialog()"/>
  15. </template>
  16. </Toolbar>
  17. </template>
  18. <template #content>
  19. <div class="md-viewer" style="text-align: start; font-size: 0.7em;">
  20. <template v-if="fileContent === ''">
  21. <Skeleton/>
  22. <br/>
  23. <Skeleton/>
  24. <br/>
  25. <Skeleton/>
  26. <br/>
  27. <Skeleton/>
  28. <br/>
  29. <Skeleton/>
  30. <br/>
  31. <Skeleton/>
  32. <br/>
  33. <Skeleton/>
  34. <br/>
  35. </template>
  36. <template v-else>
  37. <div v-html="compiledFileContent"></div>
  38. </template>
  39. </div>
  40. </template>
  41. </Card>
  42. <Card class="p-mr-2 p-as-stretch file-card">
  43. <template #header>
  44. <Toolbar>
  45. <template #left>
  46. <h3>Processed document content</h3>
  47. </template>
  48. <template #right>
  49. <label for="show-diff-highlight" class="switch-label">Highlight differences:</label>
  50. <InputSwitch
  51. v-model="showDiffHighlight"
  52. name="show-diff-highlight"
  53. inputId="show-diff-highlight"
  54. :disabled="processedFileContent == ''"/>
  55. <Button
  56. label="Download document"
  57. icon="pi pi-download"
  58. class="p-button-secondary p-button-outlined p-button-sm"
  59. :disabled="processedFileContent == ''"
  60. @click="downloadOdt"/>
  61. <Button
  62. label="Run filters"
  63. icon="pi pi-play"
  64. class="p-button-success p-button-outlined p-button-sm"
  65. :disabled="fileContent == '' || Object.keys(selectedSearchers).length === 0"
  66. @click="runSearchers"/>
  67. </template>
  68. </Toolbar>
  69. </template>
  70. <template #content>
  71. <div class="md-viewer" style="text-align: start; font-size: 0.7em;">
  72. <template v-if="processing === true">
  73. <Skeleton/>
  74. <br/>
  75. <Skeleton/>
  76. <br/>
  77. <Skeleton/>
  78. <br/>
  79. <Skeleton/>
  80. <br/>
  81. <Skeleton/>
  82. <br/>
  83. <Skeleton/>
  84. <br/>
  85. <Skeleton/>
  86. <br/>
  87. </template>
  88. <template v-else-if="processedFileContentPreview !== ''">
  89. <div v-html="compiledProcessedFileContentPreview" v-if="showDiffHighlight"></div>
  90. <div v-html="compiledProcessedFileContent" v-else></div>
  91. </template>
  92. <template v-else>
  93. <Message severity="info" :closable="false">
  94. Not processed yet. Please select and run some filters to see the result.
  95. </Message>
  96. </template>
  97. </div>
  98. </template>
  99. </Card>
  100. <Sidebar
  101. :visible="true"
  102. :showCloseIcon="false"
  103. :class="{'p-sidebar-md': true, 'p-sidebar-leave-to': !searchersSidebarVisible}"
  104. :dismissable="true"
  105. :modal="false"
  106. :autoZIndex="true"
  107. :baseZIndex="1000"
  108. position="right">
  109. <div class="p-grid p-jc-start">
  110. <Button
  111. icon="pi pi-list"
  112. class="p-button-info p-button-icon-only sidebar-toggle-button"
  113. @click="toggleSearchersSidebar()"/>
  114. </div>
  115. <div class="p-grid p-jc-between sidebar-title-container">
  116. <div class="p-col sidebar-title">
  117. <h3>Document searchers</h3>
  118. </div>
  119. <div class="p-col-2">
  120. <Button
  121. icon="pi pi-plus"
  122. class="p-button-success p-button-sm p-button-text add-searchers"
  123. @click="toggleSearchersDialog(true)"
  124. aria:haspopup="true"
  125. aria-controls="searcers_dialog"/>
  126. </div>
  127. </div>
  128. <Dialog header="Available document searchers"
  129. :visible.sync="searchersDialogVisible"
  130. :maximizable="true"
  131. :style="{width: '50vw'}"
  132. :contentStyle="{overflow: 'visible'}"
  133. id="searchers_dialog"
  134. ref="searchers-dialog">
  135. <DataTable
  136. :value.sync="searchers"
  137. :selection.sync="newlySelectedSearchers"
  138. dataKey="id"
  139. selectionMode="multiple"
  140. class="p-datatable-sm"
  141. :metaKeySelection="false"
  142. :paginator="true"
  143. :rows="10"
  144. paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
  145. currentPageReportTemplate="Showing {first} to {last} of {totalRecords}"
  146. :rowsPerPageOptions="[10,20,50]">
  147. <Column selectionMode="multiple" headerStyle="width: 3em"></Column>
  148. <Column field="name" header="Name" sortable></Column>
  149. </DataTable>
  150. <template #footer>
  151. <Button
  152. label="Done"
  153. icon="pi pi-check"
  154. class="p-button-info p-button-outlined p-button-sm"
  155. @click="toggleSearchersDialog(false)"/>
  156. </template>
  157. </Dialog>
  158. <DataTable
  159. :value.sync="Object.values(selectedSearchers)"
  160. dataKey="id"
  161. class="p-datatable-sm"
  162. :expandedRows.sync="expandedRows"
  163. @row-reorder="onSelectedSearchersReorder"
  164. :scrollable="true"
  165. scrollHeight="80vh">
  166. <Column :rowReorder="true" headerStyle="width: 3rem"/>
  167. <Column field="name" header="Name"></Column>
  168. <Column headerStyle="width: 3rem">
  169. <template #body="slotProps">
  170. <Button icon="pi pi-trash"
  171. class="p-button-rounded p-button-warning"
  172. @click="confirmDeleteProduct(slotProps.data)"/>
  173. </template>
  174. </Column>
  175. <Column :expander="true" headerStyle="width: 3rem"/>
  176. <template #expansion="slotProps">
  177. <div class="options-subtable">
  178. <div class="p-fluid">
  179. <div class="p-field">
  180. <label :for="`replace_with__${slotProps.data.id}`">
  181. Replace values with:
  182. </label>
  183. <InputText
  184. :id="`replace_with__${slotProps.data.id}`"
  185. type="text"
  186. class="p-inputtext-sm"
  187. v-model="searchersOptions[slotProps.data.id]"/>
  188. </div>
  189. </div>
  190. </div>
  191. </template>
  192. <template #footer>
  193. <Button
  194. label="Run filters"
  195. icon="pi pi-play"
  196. class="p-button-success p-button-sm"
  197. :disabled="fileContent == '' || Object.keys(selectedSearchers).length === 0"
  198. @click="toggleSearchersSidebar(); runSearchers()"/>
  199. </template>
  200. </DataTable>
  201. </Sidebar>
  202. <!-- File upload dialog -->
  203. <Dialog header="Upload a new file"
  204. :visible.sync="uploadDialogVisible"
  205. :maximizable="true"
  206. :style="{width: '50vw'}"
  207. :contentStyle="{overflow: 'visible'}"
  208. id="upload_dialog"
  209. ref="upload-dialog">
  210. <FileUpload
  211. name="upload[]"
  212. :customUpload="true"
  213. :auto="true"
  214. @uploader="uploadFile">
  215. <template #empty>
  216. <p>Drag and drop files to here to upload.</p>
  217. </template>
  218. </FileUpload>
  219. </Dialog>
  220. </div>
  221. </template>
  222. <script lang="ts" src="./ProcessFile.ts"></script>
  223. <style lang="scss" src="./ProcessFile.scss"></style>