airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 03/03: AIRAVATA-3034 user storage breadcrumbs
Date Fri, 24 May 2019 13:08:09 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch airavata-3016
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit 2620f18fbff8e16916aff35b0568fd3167bc5e9d
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Thu May 23 20:49:25 2019 -0400

    AIRAVATA-3034 user storage breadcrumbs
---
 django_airavata/apps/api/serializers.py            |  1 +
 .../js/models/UserStoragePath.js                   |  5 +++
 django_airavata/apps/api/views.py                  | 10 +++++
 .../storage/UserStoragePathBreadcrumb.vue          | 39 +++++++++++++++++++
 .../components/storage/UserStoragePathViewer.vue   | 45 ++++++++++++++--------
 5 files changed, 83 insertions(+), 17 deletions(-)

diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 2f7c726..a37a0ac 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -774,6 +774,7 @@ class UserStorageDirectorySerializer(serializers.Serializer):
 class UserStoragePathSerializer(serializers.Serializer):
     directories = UserStorageDirectorySerializer(many=True)
     files = UserStorageFileSerializer(many=True)
+    parts = serializers.ListField(child=serializers.CharField())
     # uploaded is populated after a file upload
     uploaded = DataProductSerializer(read_only=True)
 
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/UserStoragePath.js
b/django_airavata/apps/api/static/django_airavata_api/js/models/UserStoragePath.js
index 108a7fd..3653f65 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/UserStoragePath.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/UserStoragePath.js
@@ -12,6 +12,11 @@ const FIELDS = [
     name: "directories",
     type: UserStorageDirectory,
     list: true
+  },
+  {
+    name: "parts",
+    type: "string",
+    list: true
   }
 ];
 
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index a51028b..94eed4f 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -1377,9 +1377,19 @@ class UserStoragePathView(APIView):
         }
         if uploaded is not None:
             data['uploaded'] = uploaded
+        data['parts'] = self._split_path(path)
         serializer = self.serializer_class(data, context={'request': request})
         return Response(serializer.data)
 
+    def _split_path(self, path):
+        head, tail = os.path.split(path)
+        if head != "":
+            return self._split_path(head) + [tail]
+        elif tail != "":
+            return [tail]
+        else:
+            return []
+
 
 class WorkspacePreferencesView(APIView):
     serializer_class = serializers.WorkspacePreferencesSerializer
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathBreadcrumb.vue
b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathBreadcrumb.vue
new file mode 100644
index 0000000..0860a83
--- /dev/null
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathBreadcrumb.vue
@@ -0,0 +1,39 @@
+<template>
+  <b-breadcrumb :items="items"></b-breadcrumb>
+</template>
+
+<script>
+export default {
+  name: "user-storage-path-breadcrumb",
+  props: {
+    parts: {
+      type: Array,
+      required: true
+    }
+  },
+  computed: {
+    items() {
+      const homeItem = [
+        {
+          text: "Home",
+          to: { path: "/~/" }
+        }
+      ];
+      if (this.parts) {
+        const subparts = [];
+        const partsItems = this.parts.map(part => {
+          subparts.push(part);
+          return {
+            text: part,
+            to: { path: "/~/" + subparts.join("/") + "/" }
+          };
+        });
+        return homeItem.concat(partsItems);
+      } else {
+        return homeItem;
+      }
+    }
+  }
+};
+</script>
+
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
index 350ce99..5ff9587 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
@@ -1,24 +1,32 @@
 <template>
-  <b-table
-    :fields="fields"
-    :items="items"
-  >
-    <template
-      slot="name"
-      slot-scope="data"
+  <div>
+    <user-storage-path-breadcrumb
+      v-if="userStoragePath"
+      :parts="userStoragePath.parts"
+    />
+    <b-table
+      :fields="fields"
+      :items="items"
     >
-      <router-link
-        v-if="data.item.type === 'dir'"
-        :to="'/~/' + data.item.path"
-      >{{ data.item.name }}</router-link>
-      <b-link
-        v-else
-        :href="data.item.downloadURL"
-      >{{ data.item.name }}</b-link>
-    </template>
-  </b-table>
+      <template
+        slot="name"
+        slot-scope="data"
+      >
+        <router-link
+          v-if="data.item.type === 'dir'"
+          :to="'/~/' + data.item.path"
+        >{{ data.item.name }}</router-link>
+        <b-link
+          v-else
+          :href="data.item.downloadURL"
+        >{{ data.item.name }}</b-link>
+      </template>
+    </b-table>
+  </div>
 </template>
 <script>
+import UserStoragePathBreadcrumb from "./UserStoragePathBreadcrumb.vue";
+
 export default {
   name: "user-storage-path-viewer",
   props: {
@@ -26,6 +34,9 @@ export default {
       required: true
     }
   },
+  components: {
+    UserStoragePathBreadcrumb
+  },
   computed: {
     fields() {
       return [


Mime
View raw message