diff --git a/src/action/AsyncActions.ts b/src/action/AsyncActions.ts index 17623ddc..21d99a98 100644 --- a/src/action/AsyncActions.ts +++ b/src/action/AsyncActions.ts @@ -1133,9 +1133,15 @@ export function loadLatestTextAnalysisRecord(resourceIri: IRI) { /** * Downloads the content of a file with the specified IRI (assuming it is stored on the server). * @param fileIri File identifier - * @param at Timestamp of the file version to download + * @param options File export options */ -export function exportFileContent(fileIri: IRI, at?: string) { +export function exportFileContent( + fileIri: IRI, + options: { + at?: string; + withoutUnconfirmedOccurrences?: boolean; + } = {} +) { const action = { type: ActionType.EXPORT_FILE_CONTENT, }; @@ -1147,7 +1153,11 @@ export function exportFileContent(fileIri: IRI, at?: string) { url, param("namespace", fileIri.namespace) .param("attachment", "true") - .param("at", at) + .param("at", options.at) + .param( + "withoutUnconfirmedOccurrences", + options.withoutUnconfirmedOccurrences?.toString() + ) .responseType("arraybuffer") ) .then((resp: AxiosResponse) => { diff --git a/src/component/annotator/Annotator.tsx b/src/component/annotator/Annotator.tsx index 2aae447f..d4cfa446 100644 --- a/src/component/annotator/Annotator.tsx +++ b/src/component/annotator/Annotator.tsx @@ -56,6 +56,7 @@ import { AnnotationClass, AnnotationOrigin, } from "../../model/AnnotatorLegendFilter"; +import AnnotatorDownloadActions from "./AnnotatorDownloadActions"; interface AnnotatorProps extends HasI18n { fileIri: IRI; @@ -657,6 +658,10 @@ export class Annotator extends React.Component { )} /> , + , , ]} /> diff --git a/src/component/annotator/AnnotatorDownloadActions.tsx b/src/component/annotator/AnnotatorDownloadActions.tsx new file mode 100644 index 00000000..f13bc4e5 --- /dev/null +++ b/src/component/annotator/AnnotatorDownloadActions.tsx @@ -0,0 +1,78 @@ +import React from "react"; +import { IRI } from "../../util/VocabularyUtils"; +import { useI18n } from "../hook/useI18n"; +import { + DropdownItem, + DropdownMenu, + DropdownToggle, + UncontrolledButtonDropdown, +} from "reactstrap"; +import { FaCloudDownloadAlt } from "react-icons/fa"; +import { useDispatch } from "react-redux"; +import { ThunkDispatch } from "../../util/Types"; +import { exportFileContent } from "../../action/AsyncActions"; +import { trackPromise } from "react-promise-tracker"; +import { DateTime } from "luxon"; +import Constants from "../../util/Constants"; + +const AnnotatorDownloadActions: React.FC<{ fileIri: IRI }> = ({ fileIri }) => { + const { i18n } = useI18n(); + const dispatch: ThunkDispatch = useDispatch(); + + const downloadCurrentFile = () => { + trackPromise(dispatch(exportFileContent(fileIri)), "annotator"); + }; + const downloadOriginalFile = () => { + const timestamp = DateTime.fromMillis(0).toFormat( + Constants.TIMESTAMP_PARAM_FORMAT + ); + trackPromise( + dispatch(exportFileContent(fileIri, { at: timestamp })), + "annotator" + ); + }; + const downloadWithoutUnconfirmed = () => { + trackPromise( + dispatch( + exportFileContent(fileIri, { withoutUnconfirmedOccurrences: true }) + ), + "annotator" + ); + }; + + return ( + + + + + {i18n("resource.metadata.file.content.download")} + + + + + {i18n("annotator.download.thisFile")} + + + {i18n("annotator.download.original")} + + + {i18n("annotator.download.withoutUnconfirmed")} + + + + ); +}; + +export default AnnotatorDownloadActions; diff --git a/src/component/resource/document/DocumentFiles.tsx b/src/component/resource/document/DocumentFiles.tsx index 8b6cf76b..ea2a6c88 100644 --- a/src/component/resource/document/DocumentFiles.tsx +++ b/src/component/resource/document/DocumentFiles.tsx @@ -71,7 +71,9 @@ export const DocumentFiles = (props: DocumentFilesProps) => { Constants.TIMESTAMP_PARAM_FORMAT ); dispatch( - exportFileContent(VocabularyUtils.create(termitFile.iri), timestamp) + exportFileContent(VocabularyUtils.create(termitFile.iri), { + at: timestamp, + }) ); }; diff --git a/src/i18n/cs.ts b/src/i18n/cs.ts index a99a857a..3df037b3 100644 --- a/src/i18n/cs.ts +++ b/src/i18n/cs.ts @@ -671,6 +671,9 @@ const cs = { annotator: "Anotátor", "annotator.content.loading": "Načítám obsah souboru...", + "annotator.download.thisFile": "Tento soubor", + "annotator.download.original": "Originál", + "annotator.download.withoutUnconfirmed": "Bez nepotvrzených výskytů", "annotator.vocabulary": "Používá pojmy ze slovníku", "annotator.selectionPurpose.dialog.title": "K čemu bude sloužit vybraný text?", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 00c1b1a3..e4b33ab6 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -661,6 +661,9 @@ const en = { annotator: "Annotator", "annotator.content.loading": "Loading file content...", + "annotator.download.thisFile": "This file", + "annotator.download.original": "Original", + "annotator.download.withoutUnconfirmed": "Without unconfirmed occurrences", "annotator.vocabulary": "Uses terms from vocabulary", "annotator.selectionPurpose.dialog.title": "What do you want to do with the selected text?",