Unverified Commit 18891fd7 authored by davelopez's avatar davelopez
Browse files

Make direct downloads more obvious

Now the download "preparation" step has been clearly separated from the download form the export record.
Hopefully this will make more obvious that the first step now only prepares the history to be downloaded and once the export record is ready you can download it from there.
parent 385f1541
Loading
Loading
Loading
Loading
+35 −35
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import LoadingSpan from "components/LoadingSpan";
import ExportRecordDetails from "components/Common/ExportRecordDetails.vue";
import ExportRecordTable from "components/Common/ExportRecordTable.vue";
import ExportOptions from "./ExportOptions.vue";
import ExportToFileSourceForm from "components/Common/ExportForm.vue";
import ExportForm from "components/Common/ExportForm.vue";
import { getHistoryById } from "@/store/historyStore/model/queries";
import { getExportRecords, exportToFileSource, reimportHistoryFromRecord } from "./services";
import { useTaskMonitor } from "composables/taskMonitor";
@@ -29,7 +29,7 @@ const { hasWritable: hasWritableFileSources } = useFileSources();

const {
    isPreparing: isPreparingDownload,
    downloadHistory,
    prepareHistoryDownload,
    downloadObjectByRequestId,
    getDownloadObjectUrl,
} = useShortTermStorage();
@@ -56,6 +56,14 @@ const exportRecords = ref(null);

const historyName = computed(() => history.value?.name ?? props.historyId);
const latestExportRecord = computed(() => (exportRecords.value?.length ? exportRecords.value.at(0) : null));
const isLatestExportRecordReadyToDownload = computed(
    () =>
        latestExportRecord.value &&
        latestExportRecord.value.isUpToDate &&
        latestExportRecord.value.canDownload &&
        latestExportRecord.value.exportParams?.equals(exportParams)
);
const canGenerateDownload = computed(() => !isPreparingDownload.value && !isLatestExportRecordReadyToDownload.value);
const previousExportRecords = computed(() => (exportRecords.value ? exportRecords.value.slice(1) : null));
const hasPreviousExports = computed(() => previousExportRecords.value?.length > 0);
const availableRecordsMessage = computed(() =>
@@ -114,12 +122,7 @@ async function doExportToFileSource(exportDirectory, fileName) {
}

async function prepareDownload() {
    const upToDateDownloadRecord = findValidUpToDateDownloadRecord();
    if (upToDateDownloadRecord) {
        downloadObjectByRequestId(upToDateDownloadRecord.stsDownloadId);
        return;
    }
    await downloadHistory(props.historyId, { pollDelayInMs: POLLING_DELAY, exportParams: exportParams });
    await prepareHistoryDownload(props.historyId, { pollDelayInMs: POLLING_DELAY, exportParams: exportParams });
    updateExports();
}

@@ -136,14 +139,6 @@ function copyDownloadLinkFromRecord(record) {
    }
}

function findValidUpToDateDownloadRecord() {
    return exportRecords.value
        ? exportRecords.value.find(
              (record) => record.canDownload && record.isUpToDate && record.exportParams?.equals(exportParams)
          )
        : null;
}

async function reimportFromRecord(record) {
    const confirmed = await confirm(
        `Do you really want to import a new copy of this history exported ${record.elapsedTime}?`
@@ -185,11 +180,13 @@ function updateExportParams(newParams) {

        <export-options
            id="history-export-options"
            class="mt-3"
            :export-params="exportParams"
            @onValueChanged="updateExportParams" />

        <h2 class="h-md mt-3">How do you want to export this history?</h2>
        <b-card no-body class="mt-3">
            <b-tabs pills card>
            <b-tabs pills card vertical>
                <b-tab id="direct-download-tab" title="to direct download" title-link-class="tab-export-to-link" active>
                    <p>
                        Here you can generate a temporal download for your history. When your download link expires or
@@ -201,15 +198,19 @@ function updateExportParams(newParams) {
                        Galaxy server.
                    </b-alert>
                    <b-button
                        class="direct-download-btn"
                        :disabled="isPreparingDownload"
                        class="gen-direct-download-btn"
                        :disabled="!canGenerateDownload"
                        variant="primary"
                        @click="prepareDownload">
                        Download
                        Generate direct download
                    </b-button>
                    <span v-if="isPreparingDownload">
                        <loading-span message="Galaxy is preparing your download, this will likely take a while" />
                    </span>
                    <b-alert v-else-if="isLatestExportRecordReadyToDownload" variant="success" class="mt-3" show>
                        The latest export record is ready. Use the download button below to download it or change the
                        advanced export options above to generate a new one.
                    </b-alert>
                </b-tab>
                <b-tab
                    v-if="hasWritableFileSources"
@@ -221,10 +222,7 @@ function updateExportParams(newParams) {
                        one of the available remote file sources here. You will be able to re-import it later as long as
                        it remains available on the remote server.
                    </p>
                    <export-to-file-source-form
                        what="history"
                        :clear-input-after-export="true"
                        @export="doExportToFileSource" />
                    <export-form what="history" :clear-input-after-export="true" @export="doExportToFileSource" />
                </b-tab>
            </b-tabs>
        </b-card>
@@ -232,8 +230,9 @@ function updateExportParams(newParams) {
        <b-alert v-if="errorMessage" id="last-export-record-error-alert" variant="danger" class="mt-3" show>
            {{ errorMessage }}
        </b-alert>
        <div v-else-if="latestExportRecord">
            <h2 class="h-md mt-3">Latest Export Record</h2>
            <export-record-details
            v-else-if="latestExportRecord"
                :record="latestExportRecord"
                object-type="history"
                class="mt-3"
@@ -243,6 +242,7 @@ function updateExportParams(newParams) {
                @onCopyDownloadLink="copyDownloadLinkFromRecord"
                @onReimport="reimportFromRecord"
                @onActionMessageDismissed="onActionMessageDismissedFromRecord" />
        </div>
        <b-alert v-else id="no-export-records-alert" variant="info" class="mt-3" show>
            {{ availableRecordsMessage }}
        </b-alert>
+1 −1
Original line number Diff line number Diff line
@@ -425,7 +425,7 @@ history_export:

history_export_tasks:
  selectors:
    direct_download: '.direct-download-btn'
    direct_download: '.gen-direct-download-btn'
    file_source_tab: '.tab-export-to-file'
    remote_file_name_input: '#file-source-tab #name'
    toggle_options_link: '#toggle-options-link'