machristie commented on a change in pull request #52:
URL:
https://github.com/apache/airavata-django-portal/pull/52#discussion_r535268570
##########
File path: django_airavata/apps/api/serializers.py
##########
@@ -513,6 +515,13 @@ def get_isInputFileUpload(self, data_product):
request = self.context['request']
return user_storage.is_input_file(request, data_product)
+ def get_path(self, data_product):
+ """Getter for path field."""
+ if len(data_product.replicaLocations) > 0:
+ return re.sub(r'.*/tmp/[^/]*/', "",
data_product.replicaLocations[0].filePath)
Review comment:
This won't work because not all locations are in /tmp/. That's just kind
of a local development setup. I think we just need to treat data products
differently than paths in user storage.
##########
File path: django_airavata/apps/api/views.py
##########
@@ -974,10 +974,12 @@ def put(self, request, format=None):
data_product_uri = request.query_params['product-uri']
data_product = request.airavata_client.getDataProduct(
request.authz_token, data_product_uri)
+ serializer = self.serializer_class(
+ data_product, context={'request': request})
return UserStoragePathView().put(
Review comment:
Instead of calling `UserStoragePathView().put()`, what if we had either
a different version of `user_storage.update_file_content` (maybe called
`update_data_product_content`?) or one that took an optional `data_product`
argument that would figure out the path internally. `user_storage` already has
a `_get_replica_filepath` function -
https://github.com/apache/airavata-django-portal-sdk/blob/master/airavata_django_portal_sdk/user_storage.py#L624.
##########
File path:
django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/storage-edit/UserStorageLink.vue
##########
@@ -0,0 +1,54 @@
+<template>
+ <b-link :href="storageFileViewRouteUrl()" @click="showFilePreview($event)">
+ {{ fileName }}
+ <b-modal :title="fileName" ref="modal" scrollable size="lg">
+ <user-storage-file-edit-viewer
+ :file-name="fileName"
+ :data-product-uri="dataProductUri"
+ :mime-type="mimeType"
+ @file-content-changed="
+ (fileContent) => $emit('file-content-changed', fileContent)
+ "
+ />
+ <template slot="modal-footer">
+ <a :href="storageFileViewRouteUrl()" target="_blank">Open in a new
window</a>
+ </template>
+ </b-modal>
+ </b-link>
+</template>
+
+<script>
+import UserStorageFileEditViewer from "./UserStorageEditViewer";
+
+export default {
+ name: "user-storage-link",
+ components: {UserStorageFileEditViewer},
+ props: {
+ fileName: {
+ required: true
+ },
+ dataProductUri: {
+ required: true
+ },
+ mimeType: {
+ required: true
+ },
+ allowPreview: {
+ default: true,
+ required: true
+ }
+ },
+ methods: {
+ showFilePreview(event) {
+ if (this.allowPreview) {
+ this.$refs.modal.show();
+ event.preventDefault();
+ }
+ },
+ storageFileViewRouteUrl() {
+ // This endpoint can handle XHR upload or a TUS uploadURL
+ return `/workspace/storage/~?dataProductUri=${this.dataProductUri}`;
Review comment:
It would be nice if we could keep the regular URL path and pass the
dataProductUri as a prop instead.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]