airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 01/03: AIRAVATA-2975 Bulleted list for inputs. Added input name for data products
Date Wed, 08 May 2019 12:56:12 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit b832d99c52ca58a34fa0f9eeef81b49d3d7aa340
Author: aparappi <aparappi@iu.edu>
AuthorDate: Sun May 5 17:31:09 2019 -0400

    AIRAVATA-2975 Bulleted list for inputs. Added input name for data products
---
 .../js/components/experiment/ExperimentSummary.vue | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
index 123c07e..dedf98f 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/ExperimentSummary.vue
@@ -200,9 +200,11 @@ export default {
     }
   },
   data() {
+
     return {
       localFullExperiment: this.fullExperiment.clone()
     };
+
   },
   components: {
     DataProductViewer,
@@ -210,6 +212,34 @@ export default {
     "share-button": components.ShareButton
   },
   computed: {
+    stringInputs: function() {
+      return this.localFullExperiment.experiment.experimentInputs.filter(function (e) {
+          return e.type.value == 0
+      })
+    },
+    dataProductInputs: function(){
+      // Filters out only data products. These objects will contain
+      // name of the file and inputOrder also
+      var allFileInputs = this.localFullExperiment.experiment.experimentInputs.filter(function
(e) {
+            return e.type.value == 3;
+      });
+
+      // For each data product, find the "name" and "inputOrder" field for it
+      // from the array evaluated above. Product URI is used as a key to find
+      // matching data products (as it is unique to each file)
+      // Returns the array sorted by inputOrder in ascending order
+      var allDataProducts =  this.localFullExperiment.inputDataProducts.filter(function (dp)
{
+        for(var i = 0; i < allFileInputs.length; i++){
+          if(allFileInputs[i]["value"] == dp["productUri"]){
+            dp["name"] = allFileInputs[i]["name"]
+            dp["inputOrder"] = allFileInputs[i]["inputOrder"]
+          }
+        }
+        return dp
+      })
+
+      return sortByKey(allDataProducts, "inputOrder");
+    },
     creationTime: function() {
       return moment(this.localFullExperiment.experiment.creationTime).fromNow();
     },
@@ -281,10 +311,34 @@ export default {
     this.initPollingExperiment();
   }
 };
+/**
+*  Generic function that sorts an array
+*  of objects by key
+*  Default sorting order is ascending
+*  @param {Array} array
+*  @param {string} key
+*  @param {string} order (either asc or desc)
+*/
+function sortByKey(array, key, order = "asc") {
+  return array.sort(function(obj1, obj2) {
+    // If key doesn't exist, returns 0
+    if(!obj1.hasOwnProperty(key) || !obj2.hasOwnProperty(key)) {
+      return 0;
+    }
+    let sortOrder = (order == 'desc') ? -1 : 1;
+    var val1 = (typeof obj1[key] === 'string') ? obj1[key].toLowerCase() : obj1[key];
+    var val2 = (typeof obj2[key] === 'string') ? obj2[key].toLowerCase() : obj2[key];
+    return ((val1 < val2) ? -1 * sortOrder : ((val1 > val2) ? 1 * sortOrder : 0));
+    });
+  }
 </script>
 
 <style scoped>
 .data-product + .data-product {
   margin-left: 0.5em;
 }
+.input-list {
+  padding-left: .5em;
+  margin-bottom: 0;
+}
 </style>


Mime
View raw message