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 d04ded4f156f80e4aab125ef6917d0b5ed9dd9e5 Author: Marcus Christie <[email protected]> AuthorDate: Fri May 24 12:20:00 2019 -0400 AIRAVATA-3034 Upload files, add new directory --- django_airavata/apps/api/views.py | 1 + django_airavata/apps/workspace/package.json | 4 +- .../js/containers/UserStorageContainer.vue | 87 +++++++++++++++++++--- django_airavata/static/common/package.json | 2 +- 4 files changed, 79 insertions(+), 15 deletions(-) diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py index 94eed4f..c93df77 100644 --- a/django_airavata/apps/api/views.py +++ b/django_airavata/apps/api/views.py @@ -1356,6 +1356,7 @@ class UserStoragePathView(APIView): if not data_products_helper.dir_exists(request, user_storage_path): data_products_helper.create_user_dir(request, user_storage_path) + data_product = None if 'file' in request.FILES: user_file = request.FILES['file'] data_product = data_products_helper.save( diff --git a/django_airavata/apps/workspace/package.json b/django_airavata/apps/workspace/package.json index 833f1dc..2e3fd10 100644 --- a/django_airavata/apps/workspace/package.json +++ b/django_airavata/apps/workspace/package.json @@ -14,8 +14,8 @@ "test:unit:watch": "vue-cli-service test:unit --watch" }, "dependencies": { - "bootstrap": "^4.0.0-beta.2", - "bootstrap-vue": "^2.0.0-rc.11", + "bootstrap": "^4.3.1", + "bootstrap-vue": "^2.0.0-rc.20", "django-airavata-api": "file:../api", "django-airavata-common-ui": "file:../../static/common", "django-airavata-workspace-plugin-api": "file:django-airavata-workspace-plugin-api", 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 b198dd2..0674abd 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 @@ -1,15 +1,47 @@ <template> - <div class="row"> - <div class="col"> - <h1 class="h4"> - Storage - </h1> - <p> - <small class="text-muted"><i class="fa fa-folder-open"></i> {{ username }}</small> - </p> - <b-card> - <router-view :user-storage-path="userStoragePath"></router-view> - </b-card> + <div> + <div class="row"> + <div class="col"> + <h1 class="h4"> + Storage + </h1> + <p> + <small class="text-muted"><i class="fa fa-folder-open"></i> {{ username }}</small> + </p> + </div> + </div> + <div class="row"> + <div class="col"> + <b-form-file + v-model="file" + ref="file-input" + placeholder="Add file" + @input="fileChanged" + class="mb-2" + ></b-form-file> + </div> + <div class="col"> + <b-input-group> + <b-form-input + v-model="dirName" + placeholder="New directory name" + @keydown.native.enter="addDirectory" + ></b-form-input> + <b-input-group-append> + <b-button + @click="addDirectory" + :disabled="!this.dirName" + >Add directory</b-button> + </b-input-group-append> + </b-input-group> + </div> + </div> + <div class="row"> + <div class="col"> + <b-card> + <router-view :user-storage-path="userStoragePath"></router-view> + </b-card> + </div> </div> </div> </template> @@ -34,7 +66,9 @@ export default { }, data() { return { - userStoragePath: null + userStoragePath: null, + file: null, + dirName: null }; }, methods: { @@ -64,6 +98,35 @@ export default { duration: 2 }) ); + }, + fileChanged() { + if (this.file) { + let data = new FormData(); + data.append("file", this.file); + utils.FetchUtils.post( + "/api/user-storage/" + this.storagePath, + data + ).then(result => { + // this.file = null; + this.$refs["file-input"].reset(); + this.loadUserStoragePath(this.storagePath); + }); + } + }, + addDirectory() { + if (this.dirName) { + let newDirPath = this.storagePath; + if (!newDirPath.endsWith("/")) { + newDirPath = newDirPath + "/"; + } + newDirPath = newDirPath + this.dirName; + utils.FetchUtils.post("/api/user-storage/" + newDirPath).then( + result => { + this.dirName = null; + this.loadUserStoragePath(this.storagePath); + } + ); + } } }, created() { diff --git a/django_airavata/static/common/package.json b/django_airavata/static/common/package.json index eff789e..c1c7da6 100644 --- a/django_airavata/static/common/package.json +++ b/django_airavata/static/common/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@fortawesome/fontawesome-free": "^5.6.3", - "bootstrap": "^4.2.1", + "bootstrap": "^4.3.1", "bootstrap-vue": "^2.0.0-rc.11", "clipboard": "^2.0.4", "django-airavata-api": "file:../../apps/api",
