2018-02-13 19:32:59 +00:00
|
|
|
const html = require('choo/html');
|
2018-07-31 18:09:18 +00:00
|
|
|
const titleSection = require('../../templates/title');
|
|
|
|
const downloadButton = require('../../templates/downloadButton');
|
|
|
|
const downloadedFiles = require('../../templates/uploadedFileList');
|
2018-02-13 19:32:59 +00:00
|
|
|
|
2018-07-31 18:09:18 +00:00
|
|
|
module.exports = function(state, emit) {
|
|
|
|
const storageFile = state.storage.getFileById(state.params.id);
|
|
|
|
const multifiles = Array.from(storageFile.manifest.files);
|
2018-02-13 19:32:59 +00:00
|
|
|
|
2018-07-31 22:19:18 +00:00
|
|
|
const trySendLink = html`
|
|
|
|
<a class="link link--action" href="/">
|
|
|
|
${state.translate('sendYourFilesLink')}
|
|
|
|
</a>`;
|
|
|
|
const cancelButton = html`
|
|
|
|
<button class="btn--cancel"
|
|
|
|
onclick=${cancel}
|
|
|
|
>
|
|
|
|
${state.translate('downloadCancel')}
|
|
|
|
</button>
|
|
|
|
`;
|
|
|
|
|
|
|
|
const bottomLink =
|
|
|
|
state.transfer.state === 'downloading' ? cancelButton : trySendLink;
|
|
|
|
|
2018-02-16 20:56:53 +00:00
|
|
|
return html`
|
2018-02-13 19:32:59 +00:00
|
|
|
<div class="page">
|
2018-07-31 18:09:18 +00:00
|
|
|
${titleSection(state)}
|
|
|
|
|
|
|
|
${downloadedFiles(multifiles, state, emit)}
|
|
|
|
<div class="description">${state.translate('downloadMessage2')}</div>
|
|
|
|
${downloadButton(state, emit)}
|
|
|
|
|
2018-07-31 22:19:18 +00:00
|
|
|
${bottomLink}
|
2018-07-31 18:09:18 +00:00
|
|
|
|
2018-02-13 19:32:59 +00:00
|
|
|
</div>
|
|
|
|
`;
|
2018-07-31 22:19:18 +00:00
|
|
|
|
|
|
|
function cancel() {
|
|
|
|
if (state.transfer.state === 'downloading') {
|
|
|
|
emit('cancel');
|
|
|
|
}
|
|
|
|
}
|
2018-02-13 19:32:59 +00:00
|
|
|
};
|