You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/04/25 14:01:57 UTC

[airavata-django-portal] branch master updated (af9df3c -> 632ef1e)

This is an automated email from the ASF dual-hosted git repository.

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


    from af9df3c  AIRAVATA-2611 InputEditorMixin for common input editor functionality
     new 0177a60  AIRAVATA-2611 InputEditorMixin refactor
     new 632ef1e  AIRAVATA-2760 Use editor UI component in metadata if available

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 django_airavata/apps/api/serializers.py            | 17 +++++-
 .../js/models/InputDataObjectType.js               | 19 +++++++
 django_airavata/apps/api/views.py                  |  4 +-
 .../js/components/experiment/ExperimentEditor.vue  |  5 ++
 .../experiment/input-editors/FileInputEditor.vue   | 60 +---------------------
 .../experiment/input-editors/StringInputEditor.vue | 56 ++------------------
 6 files changed, 47 insertions(+), 114 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-django-portal] 01/02: AIRAVATA-2611 InputEditorMixin refactor

Posted by ma...@apache.org.
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 0177a607777b3eb78930362fd6a123953aa658cf
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Mon Apr 23 13:28:06 2018 -0400

    AIRAVATA-2611 InputEditorMixin refactor
---
 .../experiment/input-editors/FileInputEditor.vue   | 60 +---------------------
 .../experiment/input-editors/StringInputEditor.vue | 56 ++------------------
 2 files changed, 5 insertions(+), 111 deletions(-)

diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
index 4efa9b1..34f8c4b 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/FileInputEditor.vue
@@ -9,65 +9,9 @@
 </template>
 
 <script>
-import {models} from 'django-airavata-api'
+import InputEditorMixin from './InputEditorMixin'
 export default {
     name: 'file-input-editor',
-    props: {
-        value: {
-            required: false,
-        },
-        experiment: {
-            type: models.Experiment,
-            required: true,
-        },
-        experimentInput: {
-            type: models.InputDataObjectType,
-            required: true,
-        },
-    },
-    data () {
-        return {
-            data: this.value,
-            inputHasBegun: false,
-        }
-    },
-    computed: {
-        validationResults: function() {
-            return this.experimentInput.validate(this.experiment, this.data);
-        },
-        valid: function() {
-            return Object.keys(this.validationResults).length === 0;
-        },
-        validationFeedback: function() {
-            // Only display validation feedback after the user has provided
-            // input so that missing required value errors are only displayed
-            // after interacting with the input editor
-            return this.inputHasBegun && 'value' in this.validationResults
-                ? this.validationResults['value']
-                : null;
-        },
-        validationState: function() {
-            return this.inputHasBegun && 'value' in this.validationResults
-                ? 'invalid'
-                : null;
-        },
-    },
-    methods: {
-        valueChanged: function() {
-            this.inputHasBegun = true;
-            this.$emit('input', this.data);
-            this.checkValidation();
-        },
-        checkValidation: function() {
-            if (this.valid) {
-                this.$emit('valid');
-            } else {
-                this.$emit('invalid');
-            }
-        }
-    },
-    mounted: function() {
-        this.checkValidation();
-    }
+    mixins: [InputEditorMixin],
 }
 </script>
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue
index 4a3a96a..3063896 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/StringInputEditor.vue
@@ -9,66 +9,16 @@
 </template>
 
 <script>
-import {models} from 'django-airavata-api'
+import InputEditorMixin from './InputEditorMixin'
+
 export default {
     name: 'string-input-editor',
+    mixins: [InputEditorMixin],
     props: {
         value: {
             type: String,
-            required: false,
-        },
-        experiment: {
-            type: models.Experiment,
-            required: true,
-        },
-        experimentInput: {
-            type: models.InputDataObjectType,
             required: true,
         },
     },
-    data () {
-        return {
-            data: this.value,
-            inputHasBegun: false,
-        }
-    },
-    computed: {
-        validationResults: function() {
-            return this.experimentInput.validate(this.experiment, this.data);
-        },
-        valid: function() {
-            return Object.keys(this.validationResults).length === 0;
-        },
-        validationFeedback: function() {
-            // Only display validation feedback after the user has provided
-            // input so that missing required value errors are only displayed
-            // after interacting with the input editor
-            return this.inputHasBegun && 'value' in this.validationResults
-                ? this.validationResults['value']
-                : null;
-        },
-        validationState: function() {
-            return this.inputHasBegun && 'value' in this.validationResults
-                ? 'invalid'
-                : null;
-        },
-    },
-    methods: {
-        valueChanged: function() {
-            this.inputHasBegun = true;
-            this.$emit('input', this.data);
-            this.checkValidation();
-        },
-        checkValidation: function() {
-            if (this.valid) {
-                this.$emit('valid');
-            } else {
-                this.$emit('invalid');
-            }
-        }
-    },
-    mounted: function() {
-        this.checkValidation();
-    }
 }
 </script>
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-django-portal] 02/02: AIRAVATA-2760 Use editor UI component in metadata if available

Posted by ma...@apache.org.
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 632ef1e10af87f642fcd462a974ecf87dfadca04
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Apr 25 10:01:47 2018 -0400

    AIRAVATA-2760 Use editor UI component in metadata if available
---
 django_airavata/apps/api/serializers.py               | 17 ++++++++++++++++-
 .../js/models/InputDataObjectType.js                  | 19 +++++++++++++++++++
 django_airavata/apps/api/views.py                     |  4 ++--
 .../js/components/experiment/ExperimentEditor.vue     |  5 +++++
 4 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 3d64f7d..fffdd5f 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -1,6 +1,7 @@
 
 import copy
 import datetime
+import json
 import logging
 from urllib.parse import quote, urlencode
 
@@ -113,6 +114,20 @@ class GatewayIdDefaultField(serializers.CharField):
         self.default = settings.GATEWAY_ID
 
 
+class StoredJSONField(serializers.JSONField):
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+
+    def to_representation(self, value):
+        try:
+            if value:
+                return json.loads(value)
+            else:
+                return value
+        except Exception:
+            return value
+
+
 class GroupSerializer(serializers.Serializer):
     url = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:group-detail', lookup_field='id', lookup_url_kwarg='group_id')
     id = serializers.CharField(default=GroupModel.thrift_spec[1][4], read_only=True)
@@ -198,7 +213,7 @@ class InputDataObjectTypeSerializer(serializers.Serializer):
     type = serializers.IntegerField(required=False)
     applicationArgument = serializers.CharField(required=False)
     standardInput = serializers.BooleanField(required=False)
-    metaData = serializers.CharField(required=False)
+    metaData = StoredJSONField(required=False)
     inputOrder = serializers.IntegerField(required=False)
     isRequired = serializers.BooleanField(required=False)
     requiredToAddedToCommandLine = serializers.BooleanField(required=False)
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js b/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js
index eb5407b..c403d1d 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/models/InputDataObjectType.js
@@ -26,6 +26,25 @@ export default class InputDataObjectType extends BaseModel {
         super(FIELDS, data);
     }
 
+    get uiComponentId() {
+        const metadata = this._getMetadata();
+        if (metadata && 'editor' in metadata && 'ui-component-id' in metadata['editor']) {
+            return metadata['editor']['ui-component-id'];
+        } else {
+            return null;
+        }
+    }
+
+    _getMetadata() {
+        // metaData could really be anything, here we expect it to be an object
+        // so safely check if it is first
+        if (this.metaData && typeof this.metaData === 'object') {
+            return this.metaData;
+        } else {
+            return null;
+        }
+    }
+
     validate(experiment, value = undefined) {
         let inputValue = typeof value != 'undefined' ? value : this.value;
         let results = {};
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 5e4f3d1..35ead26 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -445,8 +445,8 @@ class ApplicationModuleViewSet(APIBackedViewSet):
             if app_module_id in app_interface.applicationModules:
                 app_interfaces.append(app_interface)
         if len(app_interfaces) == 1:
-            serializer = thrift_utils.create_serializer(
-                ApplicationInterfaceDescription, instance=app_interfaces[0], context={'request': request})
+            serializer = serializers.ApplicationInterfaceDescriptionSerializer(
+                app_interfaces[0], context={'request': request})
             return Response(serializer.data)
         elif len(app_interfaces) > 1:
             log.error(
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue
index 94a8d44..dd201b2 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentEditor.vue
@@ -205,6 +205,11 @@ export default {
             return this.getValidationFeedback(properties) ? 'invalid' : null;
         },
         getInputEditorComponentName: function(experimentInput) {
+            // If input specifices an editor UI component, use that
+            if (experimentInput.uiComponentId) {
+                return experimentInput.uiComponentId;
+            }
+            // Default UI components based on input type
             if (experimentInput.type === models.DataType.STRING) {
                 return 'string-input-editor';
             } else if (experimentInput.type === models.DataType.URI) {

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.