You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@airavata.apache.org by GitBox <gi...@apache.org> on 2020/11/30 23:31:34 UTC

[GitHub] [airavata-django-portal] machristie commented on a change in pull request #52: AIRAVATA-3310: Enabling file edit at the experiments

machristie commented on a change in pull request #52:
URL: https://github.com/apache/airavata-django-portal/pull/52#discussion_r532962809



##########
File path: django_airavata/apps/api/views.py
##########
@@ -970,6 +970,16 @@ def get(self, request, format=None):
             data_product, context={'request': request})
         return Response(serializer.data)
 
+    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)
+
+        return UserStoragePathView().put(
+            request=request,
+            path=data_product.replicaLocations[0].filePath.replace("file://localhost:/tmp/default-admin/", "")

Review comment:
       `file://localhost:/tmp/default-admin/` only works based on your local setup, it doesn't generally work. You need a more reliable way to compute the user relative path to the file.
   
   `user_storage.get_rel_path` can return a relative path for a full path. https://github.com/apache/airavata-django-portal-sdk/blob/master/airavata_django_portal_sdk/user_storage.py#L499
   
   However, we need to also implement this for the remote API mode of user_storage, but that can be via a separate issue/PR.

##########
File path: django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue
##########
@@ -10,43 +10,60 @@
       @delete-file="deleteFile"
       @directory-selected="directorySelected"
       @file-content-changed="fileContentChanged"
+      :allow-preview="false"
     ></router-view>
   </div>
 </template>
 
 <script>
-import { services, utils } from "django-airavata-api";
-import { notifications } from "django-airavata-common-ui";
+import {services, utils} from "django-airavata-api";
+import {notifications} from "django-airavata-common-ui";
 
 export default {
   name: "user-storage-container",
-  computed: {
-    storagePath() {
-      let _storagePath = /~.*$/.exec(this.$route.fullPath);
-      if (_storagePath && _storagePath.length > 0) {
-        _storagePath = _storagePath[0];
+  computed: {},
+  data() {
+    return {
+      dataProductUri: null,
+      storagePath: null,
+      userStoragePath: null
+    };
+  },
+  methods: {
+    setDataProductUri() {
+      let _dataProductUri = /\?.*dataProductUri=(.*)/.exec(window.location.href);
+      if (_dataProductUri) {
+        _dataProductUri = _dataProductUri[1];
+      }
+
+      this.dataProductUri = _dataProductUri
+    },
+    async setStoragePath() {
+      this.setDataProductUri();
+      let _storagePath = null;
+      if (this.dataProductUri) {
+        const dataProduct = await utils.FetchUtils.get(`/api/data-products?product-uri=${this.dataProductUri}`);
+        _storagePath = dataProduct.replicaLocations[0].filePath.replace("file://localhost:/tmp/default-admin/", "~/")

Review comment:
       likewise here too

##########
File path: django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue
##########
@@ -10,43 +10,60 @@
       @delete-file="deleteFile"
       @directory-selected="directorySelected"
       @file-content-changed="fileContentChanged"
+      :allow-preview="false"
     ></router-view>
   </div>
 </template>
 
 <script>
-import { services, utils } from "django-airavata-api";
-import { notifications } from "django-airavata-common-ui";
+import {services, utils} from "django-airavata-api";
+import {notifications} from "django-airavata-common-ui";
 
 export default {
   name: "user-storage-container",
-  computed: {
-    storagePath() {
-      let _storagePath = /~.*$/.exec(this.$route.fullPath);
-      if (_storagePath && _storagePath.length > 0) {
-        _storagePath = _storagePath[0];
+  computed: {},
+  data() {
+    return {
+      dataProductUri: null,
+      storagePath: null,
+      userStoragePath: null
+    };
+  },
+  methods: {
+    setDataProductUri() {
+      let _dataProductUri = /\?.*dataProductUri=(.*)/.exec(window.location.href);

Review comment:
       Okay, I think I see. Keep in mind you can pass props to routes, that might be a better way to pass the dataProductUri https://router.vuejs.org/guide/essentials/passing-props.html. In fact you can keep the old behavior of the routing being based on the path but pass the dataProductUri as a prop.

##########
File path: django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/UserStorageContainer.vue
##########
@@ -10,43 +10,60 @@
       @delete-file="deleteFile"
       @directory-selected="directorySelected"
       @file-content-changed="fileContentChanged"
+      :allow-preview="false"
     ></router-view>
   </div>
 </template>
 
 <script>
-import { services, utils } from "django-airavata-api";
-import { notifications } from "django-airavata-common-ui";
+import {services, utils} from "django-airavata-api";
+import {notifications} from "django-airavata-common-ui";
 
 export default {
   name: "user-storage-container",
-  computed: {
-    storagePath() {
-      let _storagePath = /~.*$/.exec(this.$route.fullPath);
-      if (_storagePath && _storagePath.length > 0) {
-        _storagePath = _storagePath[0];
+  computed: {},
+  data() {
+    return {
+      dataProductUri: null,
+      storagePath: null,
+      userStoragePath: null
+    };
+  },
+  methods: {
+    setDataProductUri() {
+      let _dataProductUri = /\?.*dataProductUri=(.*)/.exec(window.location.href);

Review comment:
       Why is this needed? This seems like a weird way to get the data product URI.




----------------------------------------------------------------
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:
users@infra.apache.org