airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 08/08: AIRAVATA-3034 Delete directories, path
Date Fri, 24 May 2019 18:28:44 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 87f4d831b83982c636d7911f8c429bebab39ce38
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Fri May 24 12:41:48 2019 -0400

    AIRAVATA-3034 Delete directories, path
---
 .../components/storage/UserStoragePathViewer.vue   | 22 ++++++++++++++++++++++
 .../js/containers/UserStorageContainer.vue         | 19 ++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

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 95ba055..a2286f2 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
@@ -28,11 +28,20 @@
       >
         <span :title="data.item.createdTime.toString()">{{ fromNow(data.item.createdTime)}}</span>
       </template>
+      <template
+        slot="actions"
+        slot-scope="data"
+      >
+        <delete-button @delete="deleteItem(data.item)">
+          Are you sure you want to delete {{ data.item.name }}?
+        </delete-button>
+      </template>
     </b-table>
   </div>
 </template>
 <script>
 import UserStoragePathBreadcrumb from "./UserStoragePathBreadcrumb.vue";
+import { components } from "django-airavata-common-ui";
 import moment from "moment";
 
 export default {
@@ -43,6 +52,7 @@ export default {
     }
   },
   components: {
+    "delete-button": components.DeleteButton,
     UserStoragePathBreadcrumb
   },
   computed: {
@@ -63,6 +73,10 @@ export default {
           label: "Created Time",
           key: "createdTimestamp",
           sortable: true
+        },
+        {
+          label: "Actions",
+          key: "actions"
         }
       ];
     },
@@ -82,6 +96,7 @@ export default {
           return {
             name: f.name,
             type: "file",
+            dataProductURI: f.dataProductURI,
             downloadURL: f.downloadURL,
             createdTime: f.createdTime,
             createdTimestamp: f.createdTime.getTime(), // for sorting
@@ -108,6 +123,13 @@ export default {
       } else {
         return size + " bytes";
       }
+    },
+    deleteItem(item) {
+      if (item.type === "dir") {
+        this.$emit("delete-dir", item.path);
+      } else if (item.type === "file") {
+        this.$emit("delete-file", item.dataProductURI);
+      }
     }
   }
 };
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 0674abd..809bcb2 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
@@ -39,7 +39,11 @@
     <div class="row">
       <div class="col">
         <b-card>
-          <router-view :user-storage-path="userStoragePath"></router-view>
+          <router-view
+            :user-storage-path="userStoragePath"
+            @delete-dir="deleteDir"
+            @delete-file="deleteFile"
+          ></router-view>
         </b-card>
       </div>
     </div>
@@ -127,6 +131,19 @@ export default {
           }
         );
       }
+    },
+    deleteDir(path) {
+      utils.FetchUtils.delete("/api/user-storage/~/" + path).then(result => {
+        this.loadUserStoragePath(this.storagePath);
+      });
+    },
+    deleteFile(dataProductURI) {
+      utils.FetchUtils.delete(
+        "/api/delete-file?data-product-uri=" +
+          encodeURIComponent(dataProductURI)
+      ).then(() => {
+        this.loadUserStoragePath(this.storagePath);
+      });
     }
   },
   created() {


Mime
View raw message