You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/10/07 16:43:14 UTC
[airavata-django-portal] branch master updated (8065673 -> 88f974f)
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git.
from 8065673 Expose dev server port 9000
new 49d1982 AIRAVATA-3081 Move Uppy into common components
new d7b576e AIRAVATA-3081 Factor out common tus upload handling code
new 88f974f AIRAVATA-3221 Keep InputFileSelector in UI until uploading finishes
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
django_airavata/apps/api/tus.py | 31 ++++++++++++++++
django_airavata/apps/api/views.py | 41 ++++++----------------
.../experiment/input-editors/FileInputEditor.vue | 17 ++++++---
.../experiment/input-editors/InputFileSelector.vue | 12 +++----
.../js/containers/UserStorageContainer.vue | 8 ++---
.../common/js/components}/Uppy.vue | 0
django_airavata/static/common/js/index.js | 4 ++-
7 files changed, 66 insertions(+), 47 deletions(-)
create mode 100644 django_airavata/apps/api/tus.py
rename django_airavata/{apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors => static/common/js/components}/Uppy.vue (100%)
[airavata-django-portal] 02/03: AIRAVATA-3081 Factor out common tus
upload handling code
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit d7b576e9a4091b51a858e9c11a38629ae7398180
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Oct 2 15:37:25 2019 -0400
AIRAVATA-3081 Factor out common tus upload handling code
---
django_airavata/apps/api/tus.py | 31 +++++++++++++++++++++++++++++
django_airavata/apps/api/views.py | 41 +++++++++++----------------------------
2 files changed, 42 insertions(+), 30 deletions(-)
diff --git a/django_airavata/apps/api/tus.py b/django_airavata/apps/api/tus.py
new file mode 100644
index 0000000..c9cf64a
--- /dev/null
+++ b/django_airavata/apps/api/tus.py
@@ -0,0 +1,31 @@
+import json
+import logging
+import os
+from urllib.parse import urlparse
+
+from django.conf import settings
+
+logger = logging.getLogger(__name__)
+
+
+def move_tus_upload(upload_url, move_function):
+ """
+ Move upload identified by upload_url using the provided move_function.
+
+ move_function signature should be (file_path, file_name). It's
+ return value will be returned.
+ """
+ # file UUID is last path component in URL. For example:
+ # http://localhost:1080/files/2c44415fdb6259a22f425145b87d0840
+ upload_uuid = urlparse(upload_url).path.split("/")[-1]
+ upload_bin_path = os.path.join(settings.TUS_DATA_DIR,
+ f"{upload_uuid}.bin")
+ logger.debug(f"upload_bin_path={upload_bin_path}")
+ upload_info_path = os.path.join(settings.TUS_DATA_DIR,
+ f"{upload_uuid}.info")
+ with open(upload_info_path) as upload_info_file:
+ upload_info = json.load(upload_info_file)
+ filename = upload_info['MetaData']['filename']
+ result = move_function(upload_bin_path, filename)
+ os.remove(upload_info_path)
+ return result
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 2e35642..dccf505 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -2,7 +2,6 @@ import json
import logging
import os
from datetime import datetime, timedelta
-from urllib.parse import urlparse
from django.conf import settings
from django.contrib.auth.decorators import login_required
@@ -52,6 +51,7 @@ from . import (
output_views,
serializers,
thrift_utils,
+ tus,
view_utils
)
@@ -912,20 +912,11 @@ def upload_input_file(request):
def tus_upload_finish(request):
log.debug("POST={}".format(request.POST))
uploadURL = request.POST['uploadURL']
- # file UUID is last path component in URL. For example:
- # http://localhost:1080/files/2c44415fdb6259a22f425145b87d0840
- upload_uuid = urlparse(uploadURL).path.split("/")[-1]
- upload_bin_path = os.path.join(settings.TUS_DATA_DIR, f"{upload_uuid}.bin")
- log.debug(f"upload_bin_path={upload_bin_path}")
- upload_info_path = os.path.join(settings.TUS_DATA_DIR,
- f"{upload_uuid}.info")
- with open(upload_info_path) as upload_info_file:
- upload_info = json.load(upload_info_file)
- filename = upload_info['MetaData']['filename']
- data_product = data_products_helper\
- .move_input_file_upload_from_filepath(
- request, upload_bin_path, name=filename)
- os.remove(upload_info_path)
+
+ def move_input_file(file_path, file_name):
+ return data_products_helper.move_input_file_upload_from_filepath(
+ request, file_path, name=file_name)
+ data_product = tus.move_tus_upload(uploadURL, move_input_file)
serializer = serializers.DataProductSerializer(
data_product, context={'request': request})
return JsonResponse({'uploaded': True,
@@ -1462,22 +1453,12 @@ class UserStoragePathView(APIView):
request, path, user_file)
# Handle a tus upload
elif 'uploadURL' in request.POST:
- # TODO: factor out tus uploadURL parsing, retrieval
uploadURL = request.POST['uploadURL']
- # file UUID is last path component in URL. For example:
- # http://localhost:1080/files/2c44415fdb6259a22f425145b87d0840
- upload_uuid = urlparse(uploadURL).path.split("/")[-1]
- upload_bin_path = os.path.join(settings.TUS_DATA_DIR,
- f"{upload_uuid}.bin")
- log.debug(f"upload_bin_path={upload_bin_path}")
- upload_info_path = os.path.join(settings.TUS_DATA_DIR,
- f"{upload_uuid}.info")
- with open(upload_info_path) as upload_info_file:
- upload_info = json.load(upload_info_file)
- filename = upload_info['MetaData']['filename']
- data_product = data_products_helper.move_from_filepath(
- request, upload_bin_path, path, name=filename)
- os.remove(upload_info_path)
+
+ def move_file(file_path, file_name):
+ return data_products_helper.move_from_filepath(
+ request, file_path, path, name=file_name)
+ data_product = tus.move_tus_upload(uploadURL, move_file)
return self._create_response(request, path, uploaded=data_product)
def delete(self, request, path="/", format=None):
[airavata-django-portal] 03/03: AIRAVATA-3221 Keep
InputFileSelector in UI until uploading finishes
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 88f974f03426de5295320abf7d5d693e7bb358d2
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Oct 7 12:42:30 2019 -0400
AIRAVATA-3221 Keep InputFileSelector in UI until uploading finishes
---
.../experiment/input-editors/FileInputEditor.vue | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
index d3059ce..71ffc8d 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
@@ -41,10 +41,10 @@
</b-link>
</div>
<input-file-selector
- v-if="!isDataProductURI"
+ v-if="!isDataProductURI || uploading"
:selectedDataProductURIs="selectedDataProductURIs"
- @uploadstart="$emit('uploadstart')"
- @uploadend="$emit('uploadend')"
+ @uploadstart="uploadStart"
+ @uploadend="uploadEnd"
@selected="fileSelected"
/>
</div>
@@ -90,7 +90,8 @@ export default {
data() {
return {
dataProduct: null,
- fileContent: null
+ fileContent: null,
+ uploading: false
};
},
created() {
@@ -148,6 +149,14 @@ export default {
this.fileContent = text;
this.$refs.modal.show();
});
+ },
+ uploadStart() {
+ this.uploading = true;
+ this.$emit("uploadstart");
+ },
+ uploadEnd() {
+ this.uploading = false;
+ this.$emit("uploadend");
}
}
};
[airavata-django-portal] 01/03: AIRAVATA-3081 Move Uppy into common
components
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit 49d19825029fb6e5765e89aaa2925f12c801de9e
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Wed Oct 2 15:17:30 2019 -0400
AIRAVATA-3081 Move Uppy into common components
---
.../experiment/input-editors/InputFileSelector.vue | 12 +++++-------
.../js/containers/UserStorageContainer.vue | 8 +++-----
.../input-editors => static/common/js/components}/Uppy.vue | 0
django_airavata/static/common/js/index.js | 4 +++-
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputFileSelector.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputFileSelector.vue
index df3063b..2c01d84 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputFileSelector.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/InputFileSelector.vue
@@ -30,8 +30,8 @@
<script>
import { models } from "django-airavata-api";
+import { components } from "django-airavata-common-ui";
import UserStorageFileSelectionContainer from "../../storage/UserStorageFileSelectionContainer";
-import Uppy from "./Uppy";
export default {
name: "input-file-selector",
@@ -47,17 +47,15 @@ export default {
},
components: {
UserStorageFileSelectionContainer,
- Uppy
- },
- computed: {
+ uppy: components.Uppy
},
+ computed: {},
data() {
return {
- isSelectingFile: false,
+ isSelectingFile: false
};
},
- created() {
- },
+ created() {},
methods: {
unselect() {
this.file = null;
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue
index d3a2aab..c8aec4d 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue
@@ -54,14 +54,12 @@
<script>
import { services, session, utils } from "django-airavata-api";
-import { notifications } from "django-airavata-common-ui";
-
-import Uppy from "../components/experiment/input-editors/Uppy";
+import { components, notifications } from "django-airavata-common-ui";
export default {
name: "user-storage-container",
components: {
- Uppy
+ uppy: components.Uppy
},
computed: {
storagePath() {
@@ -82,7 +80,7 @@ export default {
data() {
return {
userStoragePath: null,
- dirName: null,
+ dirName: null
};
},
methods: {
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/Uppy.vue b/django_airavata/static/common/js/components/Uppy.vue
similarity index 100%
rename from django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/Uppy.vue
rename to django_airavata/static/common/js/components/Uppy.vue
diff --git a/django_airavata/static/common/js/index.js b/django_airavata/static/common/js/index.js
index 9bec96e..25b3519 100644
--- a/django_airavata/static/common/js/index.js
+++ b/django_airavata/static/common/js/index.js
@@ -19,6 +19,7 @@ import Sidebar from "./components/Sidebar.vue";
import SidebarFeed from "./components/SidebarFeed.vue";
import SidebarHeader from "./components/SidebarHeader.vue";
import UnsavedChangesGuard from "./components/UnsavedChangesGuard.vue";
+import Uppy from "./components/Uppy";
import GlobalErrorHandler from "./errors/GlobalErrorHandler";
import ValidationErrors from "./errors/ValidationErrors";
@@ -55,7 +56,8 @@ const components = {
Sidebar,
SidebarFeed,
SidebarHeader,
- UnsavedChangesGuard
+ UnsavedChangesGuard,
+ Uppy
};
const errors = {