From 2d703e799363e2c5077e4a612fe799c14c625b0f Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Thu, 11 Jan 2024 15:52:20 -0500 Subject: [PATCH 1/9] Include dynamic text for staging environment for dandi download --- .gitignore | 3 ++- .../FileBrowser/FileUploadInstructions.vue | 14 +++++++++++++- .../views/DandisetLandingView/DownloadDialog.vue | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 63dc29fef..89c8ded57 100644 --- a/.gitignore +++ b/.gitignore @@ -123,4 +123,5 @@ dmypy.json # End of https://www.gitignore.io/api/django # Editor settings -.vscode +.vscode +.idea/ diff --git a/web/src/components/FileBrowser/FileUploadInstructions.vue b/web/src/components/FileBrowser/FileUploadInstructions.vue index 3dad8d55c..16bd2a190 100644 --- a/web/src/components/FileBrowser/FileUploadInstructions.vue +++ b/web/src/components/FileBrowser/FileUploadInstructions.vue @@ -22,7 +22,7 @@ width="60%" class="white--text pl-2 py-1 text-left" > -
> dandi download https://dandiarchive.org/dandiset/{{ dandisetIdentifier }}/draft
+
{{ downloadCommand }}
> cd {{ dandisetIdentifier }}
> dandi organize <source_folder> -f dry
> dandi organize <source_folder>
@@ -53,4 +53,16 @@ import { useDandisetStore } from '@/stores/dandiset'; const store = useDandisetStore(); const dandisetIdentifier = computed(() => store.dandiset?.dandiset.identifier); + +const downloadCommand = computed(() => { + const baseUrl = import.meta.env.VITE_APP_DANDI_API_ROOT === 'https://api-staging.dandiarchive.org/api/' + ? 'https://gui-staging.dandiarchive.org/dandiset/' + : 'https://dandiarchive.org/dandiset/'; + + return dandisetIdentifier.value + ? `> dandi download ${baseUrl}${dandisetIdentifier.value}/draft` + : ''; // Empty string just as a fallback in case store.dandiset? is undefined +}); + + diff --git a/web/src/views/DandisetLandingView/DownloadDialog.vue b/web/src/views/DandisetLandingView/DownloadDialog.vue index 867391d7b..083852110 100644 --- a/web/src/views/DandisetLandingView/DownloadDialog.vue +++ b/web/src/views/DandisetLandingView/DownloadDialog.vue @@ -122,14 +122,20 @@ import CopyText from '@/components/CopyText.vue'; function formatDownloadCommand(identifier: string, version: string): string { if (version === 'draft') { - return `dandi download https://dandiarchive.org/dandiset/${identifier}/draft`; + const baseUrl = import.meta.env.VITE_APP_DANDI_API_ROOT === 'https://api-staging.dandiarchive.org/api/' + ? 'https://gui-staging.dandiarchive.org/dandiset/' + : 'https://dandiarchive.org/dandiset/'; + return `dandi download ${baseUrl}${identifier}/draft`; } + if (!version) { return `dandi download DANDI:${identifier}`; } + return `dandi download DANDI:${identifier}/${version}`; } + const store = useDandisetStore(); const currentDandiset = computed(() => store.dandiset); From 62d88205e9270fd4afec1787dcdfa5c19caa5969 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 23 Feb 2024 10:11:22 -0500 Subject: [PATCH 2/9] Revert .gitignore update --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 89c8ded57..89f7c44ba 100644 --- a/.gitignore +++ b/.gitignore @@ -124,4 +124,3 @@ dmypy.json # Editor settings .vscode -.idea/ From b983ab547fb67ad72d05038f3febdabe66e8d434 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 23 Feb 2024 10:46:31 -0500 Subject: [PATCH 3/9] Revert spacing changes --- web/src/components/FileBrowser/FileUploadInstructions.vue | 2 -- web/src/views/DandisetLandingView/DownloadDialog.vue | 3 --- 2 files changed, 5 deletions(-) diff --git a/web/src/components/FileBrowser/FileUploadInstructions.vue b/web/src/components/FileBrowser/FileUploadInstructions.vue index 16bd2a190..49cce1f0e 100644 --- a/web/src/components/FileBrowser/FileUploadInstructions.vue +++ b/web/src/components/FileBrowser/FileUploadInstructions.vue @@ -64,5 +64,3 @@ const downloadCommand = computed(() => { : ''; // Empty string just as a fallback in case store.dandiset? is undefined }); - - diff --git a/web/src/views/DandisetLandingView/DownloadDialog.vue b/web/src/views/DandisetLandingView/DownloadDialog.vue index 083852110..475f1532a 100644 --- a/web/src/views/DandisetLandingView/DownloadDialog.vue +++ b/web/src/views/DandisetLandingView/DownloadDialog.vue @@ -127,15 +127,12 @@ function formatDownloadCommand(identifier: string, version: string): string { : 'https://dandiarchive.org/dandiset/'; return `dandi download ${baseUrl}${identifier}/draft`; } - if (!version) { return `dandi download DANDI:${identifier}`; } - return `dandi download DANDI:${identifier}/${version}`; } - const store = useDandisetStore(); const currentDandiset = computed(() => store.dandiset); From fc46cffa94552de8ae82d3a81aa9e2ab2e8456c9 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 23 Feb 2024 10:52:18 -0500 Subject: [PATCH 4/9] Revert spacing change --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 89f7c44ba..63dc29fef 100644 --- a/.gitignore +++ b/.gitignore @@ -123,4 +123,4 @@ dmypy.json # End of https://www.gitignore.io/api/django # Editor settings -.vscode +.vscode From b19f9d0f91eba365a627533b8490de8d8af4040a Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 23 Feb 2024 12:29:43 -0500 Subject: [PATCH 5/9] Use window.location instead of URL selection logic --- web/src/components/FileBrowser/FileUploadInstructions.vue | 6 +----- web/src/views/DandisetLandingView/DownloadDialog.vue | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/web/src/components/FileBrowser/FileUploadInstructions.vue b/web/src/components/FileBrowser/FileUploadInstructions.vue index 49cce1f0e..d0a1578a2 100644 --- a/web/src/components/FileBrowser/FileUploadInstructions.vue +++ b/web/src/components/FileBrowser/FileUploadInstructions.vue @@ -55,12 +55,8 @@ const store = useDandisetStore(); const dandisetIdentifier = computed(() => store.dandiset?.dandiset.identifier); const downloadCommand = computed(() => { - const baseUrl = import.meta.env.VITE_APP_DANDI_API_ROOT === 'https://api-staging.dandiarchive.org/api/' - ? 'https://gui-staging.dandiarchive.org/dandiset/' - : 'https://dandiarchive.org/dandiset/'; - return dandisetIdentifier.value - ? `> dandi download ${baseUrl}${dandisetIdentifier.value}/draft` + ? `> dandi download ${window.location.origin}/dandiset/${dandisetIdentifier.value}/draft` : ''; // Empty string just as a fallback in case store.dandiset? is undefined }); diff --git a/web/src/views/DandisetLandingView/DownloadDialog.vue b/web/src/views/DandisetLandingView/DownloadDialog.vue index 475f1532a..58991ab03 100644 --- a/web/src/views/DandisetLandingView/DownloadDialog.vue +++ b/web/src/views/DandisetLandingView/DownloadDialog.vue @@ -122,10 +122,7 @@ import CopyText from '@/components/CopyText.vue'; function formatDownloadCommand(identifier: string, version: string): string { if (version === 'draft') { - const baseUrl = import.meta.env.VITE_APP_DANDI_API_ROOT === 'https://api-staging.dandiarchive.org/api/' - ? 'https://gui-staging.dandiarchive.org/dandiset/' - : 'https://dandiarchive.org/dandiset/'; - return `dandi download ${baseUrl}${identifier}/draft`; + return `dandi download ${window.location.origin}/dandiset/${identifier}/draft`; } if (!version) { return `dandi download DANDI:${identifier}`; From dbea9f83bd800a3503f26603f6f486e899dd2475 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 23 Feb 2024 12:35:12 -0500 Subject: [PATCH 6/9] Throw an error if store.dandiset is not set This should not cause problems at runtime, as we only ever instantiate this component inside the DLP, where of necessity a dandiset is set. If that assumption fails, we will want to know about it rather than just handing the user a blank command string. --- web/src/components/FileBrowser/FileUploadInstructions.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/components/FileBrowser/FileUploadInstructions.vue b/web/src/components/FileBrowser/FileUploadInstructions.vue index d0a1578a2..810b2b35e 100644 --- a/web/src/components/FileBrowser/FileUploadInstructions.vue +++ b/web/src/components/FileBrowser/FileUploadInstructions.vue @@ -54,9 +54,11 @@ import { useDandisetStore } from '@/stores/dandiset'; const store = useDandisetStore(); const dandisetIdentifier = computed(() => store.dandiset?.dandiset.identifier); +if (dandisetIdentifier.value === undefined) { + throw new Error('store.dandiset must be defined'); +} + const downloadCommand = computed(() => { - return dandisetIdentifier.value - ? `> dandi download ${window.location.origin}/dandiset/${dandisetIdentifier.value}/draft` - : ''; // Empty string just as a fallback in case store.dandiset? is undefined + return `> dandi download ${window.location.origin}/dandiset/${dandisetIdentifier.value}/draft` }); From 54f171476a22cea316717aac4153155af0b81b4e Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 23 Feb 2024 14:44:31 -0500 Subject: [PATCH 7/9] Factor the command string out of its presentation --- web/src/components/FileBrowser/FileUploadInstructions.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/components/FileBrowser/FileUploadInstructions.vue b/web/src/components/FileBrowser/FileUploadInstructions.vue index 810b2b35e..c8afc85e3 100644 --- a/web/src/components/FileBrowser/FileUploadInstructions.vue +++ b/web/src/components/FileBrowser/FileUploadInstructions.vue @@ -22,7 +22,7 @@ width="60%" class="white--text pl-2 py-1 text-left" > -
{{ downloadCommand }}
+
> {{ downloadCommand }}
> cd {{ dandisetIdentifier }}
> dandi organize <source_folder> -f dry
> dandi organize <source_folder>
@@ -59,6 +59,6 @@ if (dandisetIdentifier.value === undefined) { } const downloadCommand = computed(() => { - return `> dandi download ${window.location.origin}/dandiset/${dandisetIdentifier.value}/draft` + return `dandi download ${window.location.origin}/dandiset/${dandisetIdentifier.value}/draft` }); From f4564cd16f87447b7d084c9b26f3f9283f61f3c8 Mon Sep 17 00:00:00 2001 From: Aaron Kanzer Date: Tue, 7 May 2024 13:11:57 -0400 Subject: [PATCH 8/9] Add more logic per Yarik's comment --- web/src/views/DandisetLandingView/DownloadDialog.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/src/views/DandisetLandingView/DownloadDialog.vue b/web/src/views/DandisetLandingView/DownloadDialog.vue index 58991ab03..41f13a1bd 100644 --- a/web/src/views/DandisetLandingView/DownloadDialog.vue +++ b/web/src/views/DandisetLandingView/DownloadDialog.vue @@ -124,10 +124,12 @@ function formatDownloadCommand(identifier: string, version: string): string { if (version === 'draft') { return `dandi download ${window.location.origin}/dandiset/${identifier}/draft`; } + const isDandiDomain = window.location.origin === 'https://dandiarchive.org'; if (!version) { - return `dandi download DANDI:${identifier}`; + return isDandiDomain ? `dandi download DANDI:${identifier}` : `dandi download ${window.location.origin}/dandiset/${identifier}`; } - return `dandi download DANDI:${identifier}/${version}`; + // For other specific versions + return isDandiDomain ? `dandi download DANDI:${identifier}/${version}` : `dandi download ${window.location.origin}/dandiset/${identifier}/${version}`; } const store = useDandisetStore(); From 8b846b31c063c72f3ec537fcdb1ac8c2950322b9 Mon Sep 17 00:00:00 2001 From: Roni Choudhury Date: Fri, 20 Sep 2024 10:06:51 -0400 Subject: [PATCH 9/9] Simplify download command string function --- .../DandisetLandingView/DownloadDialog.vue | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/web/src/views/DandisetLandingView/DownloadDialog.vue b/web/src/views/DandisetLandingView/DownloadDialog.vue index 41f13a1bd..c5cf6d8b8 100644 --- a/web/src/views/DandisetLandingView/DownloadDialog.vue +++ b/web/src/views/DandisetLandingView/DownloadDialog.vue @@ -120,16 +120,16 @@ import { computed, ref } from 'vue'; import { useDandisetStore } from '@/stores/dandiset'; import CopyText from '@/components/CopyText.vue'; -function formatDownloadCommand(identifier: string, version: string): string { - if (version === 'draft') { - return `dandi download ${window.location.origin}/dandiset/${identifier}/draft`; - } - const isDandiDomain = window.location.origin === 'https://dandiarchive.org'; - if (!version) { - return isDandiDomain ? `dandi download DANDI:${identifier}` : `dandi download ${window.location.origin}/dandiset/${identifier}`; - } - // For other specific versions - return isDandiDomain ? `dandi download DANDI:${identifier}/${version}` : `dandi download ${window.location.origin}/dandiset/${identifier}/${version}`; +function downloadCommand(identifier: string, version: string): string { + // Use the special 'DANDI:' url prefix if appropriate. + const generalUrl = `${window.location.origin}/dandiset/${identifier}`; + const dandiUrl = `DANDI:${identifier}`; + const url = window.location.origin == 'https://dandiarchive.org' ? dandiUrl : generalUrl; + + // Prepare a url suffix to specify a specific version (or not). + const versionPath = version ? `/${version}` : ''; + + return `dandi download ${url}${versionPath}`; } const store = useDandisetStore(); @@ -149,7 +149,7 @@ const availableVersions = computed( ); const defaultDownloadText = computed( - () => (identifier.value ? formatDownloadCommand(identifier.value, currentVersion.value) : ''), + () => (identifier.value ? downloadCommand(identifier.value, currentVersion.value) : ''), ); const customDownloadText = computed(() => { @@ -157,11 +157,11 @@ const customDownloadText = computed(() => { return ''; } if (selectedDownloadOption.value === 'draft') { - return formatDownloadCommand(identifier.value, 'draft'); + return downloadCommand(identifier.value, 'draft'); } if (selectedDownloadOption.value === 'latest') { - return formatDownloadCommand(identifier.value, ''); + return downloadCommand(identifier.value, ''); } if (selectedDownloadOption.value === 'other') { - return formatDownloadCommand( + return downloadCommand( identifier.value, availableVersions.value[selectedVersion.value].version, );