downloadDialog.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const html = require('choo/html');
  2. module.exports = function() {
  3. return function(state, emit, close) {
  4. const archive = state.fileInfo;
  5. return html`
  6. <send-download-dialog
  7. class="flex flex-col w-full max-w-sm h-full mx-auto items-center justify-center"
  8. >
  9. <h1 class="text-3xl font-bold mb-4">
  10. ${state.translate('downloadConfirmTitle')}
  11. </h1>
  12. <p
  13. class="w-full text-grey-80 text-center leading-normal dark:text-grey-40 mb-8"
  14. >
  15. ${state.translate('downloadConfirmDescription')}
  16. </p>
  17. <div class="checkbox inline-block mr-3 mb-8">
  18. <input
  19. id="trust-download"
  20. type="checkbox"
  21. autocomplete="off"
  22. onchange="${toggleDownloadEnabled}"
  23. />
  24. <label for="trust-download">
  25. ${state.translate('downloadTrustCheckbox')}
  26. </label>
  27. </div>
  28. <button
  29. id="download-btn"
  30. disabled
  31. class="btn rounded-lg w-full flex-shrink-0"
  32. onclick="${download}"
  33. title="${state.translate('downloadButtonLabel')}"
  34. >
  35. ${state.translate('downloadButtonLabel')}
  36. </button>
  37. <a href="/report" class="link-blue mt-8"
  38. >${state.translate('reportFile')}</a
  39. >
  40. </send-download-dialog>
  41. `;
  42. function toggleDownloadEnabled(event) {
  43. event.stopPropagation();
  44. const checked = event.target.checked;
  45. const btn = document.getElementById('download-btn');
  46. btn.disabled = !checked;
  47. }
  48. function download(event) {
  49. event.preventDefault();
  50. close();
  51. event.target.disabled = true;
  52. emit('download', archive);
  53. }
  54. };
  55. };