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.

86 lines
2.4 KiB

  1. <template>
  2. <div>
  3. <h1> Searchers </h1>
  4. <div v-if=" ! allowSelect" style="margin-bottom: 1rem;">
  5. <a href="/searchers/create">
  6. <Button class="fc-button p-button-success">
  7. Add searcher
  8. </Button>
  9. </a>
  10. </div>
  11. <div class="content">
  12. <DataTable
  13. :value.sync="searchers"
  14. :selection.sync="selectedSearcher"
  15. dataKey="id"
  16. :selectionMode="allowSelect ? 'single' : ''"
  17. class="p-datatable-md"
  18. :paginator="true"
  19. :rows="10"
  20. paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
  21. currentPageReportTemplate="Showing {first} to {last} of {totalRecords}"
  22. :rowsPerPageOptions="[10,20,50]">
  23. <Column v-if="allowSelect" selectionMode="single" headerStyle="width: 3em"></Column>
  24. <Column header="Name" sortable>
  25. <template #body="slotProps">
  26. <a @click.stop="onOpen(slotProps.data.id)" class="searcher-link">
  27. {{ slotProps.data.name }}
  28. </a>
  29. </template>
  30. </Column>
  31. </DataTable>
  32. </div>
  33. </div>
  34. </template>
  35. <script lang="ts">
  36. import {Component, Prop, Vue, Watch} from "vue-property-decorator";
  37. import {Searcher} from "@/interfaces/Searcher";
  38. @Component({
  39. })
  40. export default class Index extends Vue {
  41. private searchers: Array<Searcher> = [];
  42. private selectedSearcher: any = {};
  43. @Prop({default: false})
  44. public readonly allowSelect!: boolean;
  45. @Prop({default: () => []})
  46. public readonly ignoreSearcherIds!: Array<string>;
  47. async boot() {
  48. try {
  49. const { data } = await (window as any).axios.get('/searchers');
  50. this.searchers = data.searchers.filter((searcher: Searcher) => {
  51. return ! this.ignoreSearcherIds.includes(searcher.id);
  52. });
  53. } catch (e) {
  54. }
  55. }
  56. onOpen(id: string) {
  57. window.open(this.getURL(id), '_blank');
  58. }
  59. getURL(id: string) {
  60. return `/searchers/${id}`;
  61. }
  62. @Watch('selectedSearcher')
  63. selectedSearcherIdChanged(value: any) {
  64. this.$emit('selected', value);
  65. }
  66. created() {
  67. this.boot();
  68. }
  69. };
  70. </script>