airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 24/28: AIRAVATA-2876 Deployments with read/write perm
Date Tue, 11 Sep 2018 17:12:12 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 49492826379b0b0f8e482ad13878ef0933f958ad
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Fri Sep 7 12:47:58 2018 -0400

    AIRAVATA-2876 Deployments with read/write perm
---
 .../applications/ApplicationDeploymentEditor.vue   | 16 ++++++--
 .../applications/ApplicationDeploymentsList.vue    |  6 ++-
 .../applications/ApplicationEditorContainer.vue    |  9 ++++-
 django_airavata/apps/api/serializers.py            | 24 ++++++++++--
 .../js/models/ApplicationDeploymentDescription.js  | 43 +++++++++++-----------
 5 files changed, 68 insertions(+), 30 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentEditor.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentEditor.vue
index ebfa79a..c619990 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentEditor.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentEditor.vue
@@ -1,10 +1,20 @@
 <template>
-    <div>Application Deployment Editor</div>
+  <div>Application Deployment Editor</div>
 </template>
 
 <script>
 export default {
-    name: 'application-deployment-editor'
-}
+  name: "application-deployment-editor",
+  props: {
+    id: {
+      type: String,
+      required: true
+    },
+    deployment_id: {
+      type: String,
+      required: true
+    }
+  }
+};
 </script>
 
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
index 29e29af..05b73e6 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationDeploymentsList.vue
@@ -4,7 +4,11 @@
 
       <b-table striped hover :fields="fields" :items="slotProps.items" sort-by="computeHostId">
         <template slot="action" slot-scope="data">
-          <router-link :to="{name: 'application_deployment', params: {id: id, deployment_id:
data.item.appDeploymentId}}">
+          <router-link v-if="!data.item.userHasWriteAccess" :to="{name: 'application_deployment',
params: {id: id, deployment_id: data.item.appDeploymentId}}">
+            View
+            <i class="fa fa-eye" aria-hidden="true"></i>
+          </router-link>
+          <router-link v-if="data.item.userHasWriteAccess" :to="{name: 'application_deployment',
params: {id: id, deployment_id: data.item.appDeploymentId}}">
             Edit
             <i class="fa fa-edit" aria-hidden="true"></i>
           </router-link>
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue
index a31261d..ef371b2 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationEditorContainer.vue
@@ -32,7 +32,8 @@ import { notifications } from "django-airavata-common-ui";
 export default {
   name: "application-editor-container",
   props: {
-    id: String
+    id: String,
+    deployment_id: String
   },
   data: function() {
     return {
@@ -60,6 +61,9 @@ export default {
   },
   created() {
     this.initialize();
+    if (this.deployment_id) {
+      this.loadApplicationDeployment(this.deployment_id);
+    }
   },
   methods: {
     ...mapActions("applications/modules", [
@@ -146,6 +150,9 @@ export default {
       if (to.params.id !== from.params.id) {
         this.initialize();
       }
+      if (this.deployment_id) {
+        this.loadApplicationDeployment(this.deployment_id);
+      }
     },
     currentModule: function(newModule) {
       // Clone the module from the store so we can modify it locally
diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index e26d31d..cefabd9 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -336,10 +336,26 @@ class SetEnvPathsSerializer(CustomSerializer):
         raise Exception("Not implemented")
 
 
-class ApplicationDeploymentDescriptionSerializer(thrift_utils.create_serializer_class(ApplicationDeploymentDescription)):
-    url = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:application-deployment-detail',
lookup_field='appDeploymentId', lookup_url_kwarg='app_deployment_id')
-    # Default values returned in these results have been overridden with app deployment defaults
for any that exist
-    queues = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:application-deployment-queues',
lookup_field='appDeploymentId', lookup_url_kwarg='app_deployment_id')
+class ApplicationDeploymentDescriptionSerializer(
+        thrift_utils.create_serializer_class(
+            ApplicationDeploymentDescription)):
+    url = FullyEncodedHyperlinkedIdentityField(
+        view_name='django_airavata_api:application-deployment-detail',
+        lookup_field='appDeploymentId',
+        lookup_url_kwarg='app_deployment_id')
+    # Default values returned in these results have been overridden with app
+    # deployment defaults for any that exist
+    queues = FullyEncodedHyperlinkedIdentityField(
+        view_name='django_airavata_api:application-deployment-queues',
+        lookup_field='appDeploymentId',
+        lookup_url_kwarg='app_deployment_id')
+    userHasWriteAccess = serializers.SerializerMethodField()
+
+    def get_userHasWriteAccess(self, appDeployment):
+        request = self.context['request']
+        return request.airavata_client.userHasAccess(
+            request.authz_token, appDeployment.appDeploymentId,
+            ResourcePermissionType.WRITE)
 
 
 class ComputeResourceDescriptionSerializer(thrift_utils.create_serializer_class(ComputeResourceDescription)):
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationDeploymentDescription.js
b/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationDeploymentDescription.js
index 881575f..f983455 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationDeploymentDescription.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/ApplicationDeploymentDescription.js
@@ -2,29 +2,30 @@ import BaseModel from './BaseModel'
 
 
 const FIELDS = [
-     'appDeploymentId',
-     'appModuleId',
-     'computeHostId',
-     'executablePath',
-     'parallelism',
-     'appDeploymentDescription',
-     // TODO: map these
-     // 'moduleLoadCmds',
-     // 'libPrependPaths',
-     // 'libAppendPaths',
-     // 'setEnvironment',
-     // 'preJobCommands',
-     // 'postJobCommands',
-     'defaultQueueName',
-     'defaultNodeCount',
-     'defaultCPUCount',
-     'defaultWalltime',
-     'editableByUser',
+  'appDeploymentId',
+  'appModuleId',
+  'computeHostId',
+  'executablePath',
+  'parallelism',
+  'appDeploymentDescription',
+  // TODO: map these
+  // 'moduleLoadCmds',
+  // 'libPrependPaths',
+  // 'libAppendPaths',
+  // 'setEnvironment',
+  // 'preJobCommands',
+  // 'postJobCommands',
+  'defaultQueueName',
+  'defaultNodeCount',
+  'defaultCPUCount',
+  'defaultWalltime',
+  'editableByUser',
+  'userHasWriteAccess'
 ];
 
 export default class ApplicationDeploymentDescription extends BaseModel {
 
-    constructor(data = {}) {
-        super(FIELDS, data);
-    }
+  constructor(data = {}) {
+    super(FIELDS, data);
+  }
 }


Mime
View raw message