airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 02/02: AIRAVATA-2598 Project selector
Date Mon, 04 Dec 2017 17:19:00 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit ef81b612db28ea7cbe9c9bd3dba2633a6348786c
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Mon Dec 4 12:18:51 2017 -0500

    AIRAVATA-2598 Project selector
---
 .../js/services/ProjectService.js                  |  8 ++++++++
 django_airavata/apps/api/views.py                  |  9 ++++++++-
 .../js/views/ExperimentEditor.vue                  | 23 ++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/django_airavata/apps/api/static/django_airavata_api/js/services/ProjectService.js
b/django_airavata/apps/api/static/django_airavata_api/js/services/ProjectService.js
index 7ecae97..598e4d6 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/services/ProjectService.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/services/ProjectService.js
@@ -16,6 +16,14 @@ class ProjectService {
         }
     }
 
+    listAll() {
+        return fetch('/api/projects/list_all/', {
+            credentials: 'include'
+        })
+        .then(response => response.json())
+        .then(json => json.map(project => new Project(project)));
+    }
+
     create(project) {
         return FetchUtils.post('/api/projects/', project.toJSONForCreate())
             .then(result => new Project(result));
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index b411baa..c610ddc 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -2,7 +2,9 @@
 from . import serializers
 
 from rest_framework import status, mixins, pagination
-from rest_framework.decorators import api_view, detail_route
+from rest_framework.decorators import api_view
+from rest_framework.decorators import detail_route
+from rest_framework.decorators import list_route
 from rest_framework.views import APIView
 from rest_framework.viewsets import GenericViewSet
 from rest_framework.response import Response
@@ -211,6 +213,11 @@ class ProjectViewSet(APIBackedViewSet):
         project = serializer.save()
         self.request.airavata_client.updateProject(self.authz_token, project.projectID, project)
 
+    @list_route()
+    def list_all(self, request):
+        projects = self.request.airavata_client.getUserProjects(self.authz_token, self.gateway_id,
self.username, -1, 0)
+        serializer = serializers.ProjectSerializer(projects, many=True, context={'request':
request})
+        return Response(serializer.data)
 
     @detail_route()
     def experiments(self, request, project_id=None):
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/views/ExperimentEditor.vue
b/django_airavata/apps/workspace/static/django_airavata_workspace/js/views/ExperimentEditor.vue
index 07d9b2e..aec3969 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/views/ExperimentEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/views/ExperimentEditor.vue
@@ -18,6 +18,14 @@
                                 type="text" v-model="experiment.experimentName" required
                                 placeholder="Experiment name"></b-form-input>
                             </b-form-group>
+                            <b-form-group label="Project" label-for="project">
+                                <b-form-select id="project"
+                                v-model="experiment.projectId" :options="projectOptions"
required>
+                                <template slot="first">
+                                    <option :value="null" disabled>Select a Project</option>
+                                </template>
+                            </b-form-select>
+                            </b-form-group>
                         </b-form>
                     </div>
                 </div>
@@ -27,13 +35,28 @@
 </template>
 
 <script>
+import {models, services} from 'django-airavata-api'
+
 export default {
     name: 'edit-experiment',
     props: ['experiment', 'appModule'],
     data () {
         return {
+            'projects': [],
         }
     },
+    mounted: function () {
+        services.ProjectService.listAll()
+            .then(projects => this.projects = projects);
+    },
+    computed: {
+        projectOptions: function() {
+            return this.projects.map(project => ({
+                value: project.projectID,
+                text: project.name,
+            }));
+        }
+    }
 }
 </script>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@airavata.apache.org" <commits@airavata.apache.org>.

Mime
View raw message