AccompanyingCourseWorkEdit: download existing documents

This commit is contained in:
nobohan
2022-03-14 14:42:04 +01:00
parent 9f0ab5aee7
commit 1beae4d713
5 changed files with 63 additions and 6 deletions

View File

@@ -73,6 +73,7 @@ var download = (button) => {
button.type = mimeType;
button.textContent = labelReady;
if (hasFilename) {
button.download = filename;
if (extension !== false) {
button.download = button.download + '.' + extension;
@@ -92,4 +93,4 @@ window.addEventListener('load', function(e) {
initializeButtons(e.target);
});
module.exports = initializeButtons;
export { initializeButtons, download };

View File

@@ -1,6 +1,6 @@
var algo = 'AES-CBC';
import Dropzone from 'dropzone';
var initializeDownload = require('./downloader.js');
import { initializeButtons } from './downloader.js';
/**
@@ -359,7 +359,7 @@ var insertDownloadButton = (zone, zoneData) => {
addBelowButton(newButton, zone, zoneData);
//zone.appendChild(newButton);
initializeDownload(zone);
initializeButtons(zone);
};
window.addEventListener('load', function(e) {

View File

@@ -0,0 +1,45 @@
<template>
<a
class="btn btn-download"
:title="$t(buttonTitle)"
:data-key=JSON.stringify(storedObject.keyInfos)
:data-iv=JSON.stringify(storedObject.iv)
:data-mime-type=storedObject.type
:data-label-preparing="$t('dataLabelPreparing')"
:data-label-ready="$t('dataLabelReady')"
:data-temp-url-get-generator="url"
@click.once="downloadDocument">
</a>
</template>
<script>
import { download } from '../../module/async_upload/downloader';
const i18n = {
messages: {
fr: {
dataLabelPreparing: "Chargement...",
dataLabelReady: "",
}
}
};
export default {
name: "AddAsyncUploadDownloader",
i18n,
props: [
'buttonTitle',
'storedObject'
],
computed: {
url() {
return `/asyncupload/temp_url/generate/GET?object_name=${this.storedObject.filename}`;
}
},
methods: {
downloadDocument(e) {
download(e.target);
}
}
}
</script>