From 3e258ea369c790b4e0697048f237179286b46e61 Mon Sep 17 00:00:00 2001 From: Jelmer van der Linde Date: Mon, 21 Aug 2023 17:05:49 +0100 Subject: [PATCH] Button to "Download all of them!" Fixes #93. --- frontend/src/store/downloads.js | 9 ++++--- frontend/src/views/AddDatasetView.vue | 35 ++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/frontend/src/store/downloads.js b/frontend/src/store/downloads.js index 16258df..23023a4 100644 --- a/frontend/src/store/downloads.js +++ b/frontend/src/store/downloads.js @@ -34,13 +34,16 @@ async function fetchDownloads() { return await fetchJSON(`/api/download/downloads/`); } -export function startDownload(dataset) { - requestDownloadSelection([dataset]).then(update => { - console.log('update'); +export function startDownloads(datasets) { + requestDownloadSelection(datasets).then(update => { Object.assign(downloads, castDownloadListToMap(update)); }); } +export function startDownload(dataset) { + return startDownloads([dataset]); +} + export function isDownloading(dataset) { return dataset.id in downloads && ['pending', 'downloading', 'downloaded'].includes(downloads[dataset.id].state) diff --git a/frontend/src/views/AddDatasetView.vue b/frontend/src/views/AddDatasetView.vue index 4d84d42..9951229 100644 --- a/frontend/src/views/AddDatasetView.vue +++ b/frontend/src/views/AddDatasetView.vue @@ -3,11 +3,12 @@ import {ref, reactive, computed, watch, onMounted} from 'vue'; import {RouterLink, useRouter} from 'vue-router'; import { formatSize } from '../format.js'; import VueSelect from 'vue-select'; -import {DownloadCloudIcon, CheckIcon} from 'vue3-feather'; +import {DownloadCloudIcon, CheckIcon, LoaderIcon} from 'vue3-feather'; import DownloadPopup from '../components/DownloadPopup.vue'; import {fetchJSON} from '../store/fetch.js'; import { startDownload, + startDownloads, isDownloading, fetchDownloadableDatasets, fetchSourceLanguages, @@ -167,12 +168,23 @@ const datasets = computed(() => { return datasets; }); +const downloadableDatasets = computed(() => datasets.value.filter((dataset) => { + // Datasets that have a path, or that are being downloaded right now, are not + // offered as downloadable. + if (('paths' in dataset) || isDownloading(dataset)) + return false; + return true; +})); + onMounted(async () => { fetchSourceLanguages().then(languages => { srcLangs.value = languages; }) }) +function beep(list) { + alert(list.length); +} function assignList(current, update, key = 'id') { const updates = Object.fromEntries(update.map(entry => [entry[key], entry])); @@ -228,6 +240,10 @@ const countFormat = new Intl.NumberFormat(); Sort by: +
@@ -239,7 +255,7 @@ const countFormat = new Intl.NumberFormat();