-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d6fb7b
commit de9c1ac
Showing
4 changed files
with
158 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<template> | ||
<div class="col-12 d-flex justify-content-between align-items-end"> | ||
<div class="fs-tiny"> | ||
Showing search results {{ positionInResults.firstElement }}-{{ | ||
positionInResults.lastElement | ||
}} | ||
of {{ pagination.total }} results | ||
</div> | ||
<div v-if="pagination.total > 0"> | ||
<button | ||
class="btn btn-sm btn-link link-secondary" | ||
@click="performExport" | ||
:disabled="exportInProgress" | ||
> | ||
Export as tsv | ||
</button> | ||
</div> | ||
</div> | ||
<div class="col-12"> | ||
<ExportProgress v-if="progress" :progress="progress" :error="exportError" /> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import type { BakrepApi } from "@/BakrepApi"; | ||
import { | ||
toPosition, | ||
type PaginationData, | ||
type PositionInResult, | ||
} from "@/components/pagination/Pagination"; | ||
import type { Query } from "@/model/Search"; | ||
import { useExportTsv } from "./ExportTsv"; | ||
import { computed, onUnmounted } from "vue"; | ||
import ExportProgress from "./ExportProgress.vue"; | ||
const props = defineProps<{ | ||
pagination: PaginationData; | ||
api: BakrepApi; | ||
query: Query; | ||
}>(); | ||
const emit = defineEmits<{ | ||
(e: "exporting"): void; | ||
(e: "exportDone"): void; | ||
(e: "exportFailed", err: unknown): void; | ||
}>(); | ||
const positionInResults = computed<PositionInResult>(() => | ||
toPosition(props.pagination), | ||
); | ||
const { | ||
cancelTsvExport, | ||
exportError, | ||
exportInProgress, | ||
exportTsv, | ||
progress, | ||
resetTsvExport, | ||
} = useExportTsv(props.api); | ||
onUnmounted(() => { | ||
cancelTsvExport(); | ||
}); | ||
function performExport() { | ||
emit("exporting"); | ||
exportTsv(props.query, props.pagination) | ||
.then(() => emit("exportDone")) | ||
.catch((err) => emit("exportFailed", err)); | ||
} | ||
defineExpose({ resetTsvExport }); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters