airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 08/28: AIRAVATA-2876 create, update application module
Date Tue, 11 Sep 2018 17:11:56 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 571efed9a78a387e79dcb8cec30dfbf16df82452
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Wed Aug 29 16:59:52 2018 -0400

    AIRAVATA-2876 create, update application module
---
 .gitignore                                         |  1 +
 .../applications/ApplicationEditorContainer.vue    | 14 +++++++--
 .../applications/ApplicationModuleEditor.vue       |  5 +++
 .../dashboards/ApplicationsDashboard.vue           | 18 ++++++++---
 .../src/store/applications/app_modules.js          | 36 +++++++++++++++++++---
 django_airavata/apps/api/serializers.py            | 10 ++----
 .../api/static/django_airavata_api/js/index.js     |  4 ++-
 .../django_airavata_api/js/utils/StringUtils.js    |  9 ++++++
 8 files changed, 77 insertions(+), 20 deletions(-)

diff --git a/.gitignore b/.gitignore
index 73476c5..368692d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@ dist/
 ENV
 venv/
 .vscode/
+jsconfig.json
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 21ec362..642cb59 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
@@ -25,6 +25,7 @@
 
 <script>
 import {mapActions, mapState} from 'vuex'
+import {models} from 'django-airavata-api'
 
 export default {
     name: 'application-editor-container',
@@ -58,9 +59,13 @@ export default {
     methods: {
         ...mapActions('applications/modules', [
             'loadApplicationModule',
+            'createApplicationModule',
+            'updateApplicationModule',
         ]),
         initialize() {
-            if (this.id) {
+            if (this.currentModule && this.currentModule.appModuleId === this.id)
{
+                this.module = this.currentModule.clone();
+            } else if (this.id) {
                 this.loadApplicationModule(this.id);
             } else {
                 this.module = new models.ApplicationModule();
@@ -75,10 +80,13 @@ export default {
             } else {
                 this.createApplicationModule(this.module)
                     .then(appModule => {
-                        this.$router.push({name: 'application', params: {id: appModule.appModuleId}});
+                        this.$router.push({name: 'application_module', params: {id: appModule.appModuleId}});
                     });
             }
-        }
+        },
+        cancelModule() {
+            this.$router.push({path: '/applications'});
+        },
     },
     watch: {
         '$route': 'initialize',
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue
index 9f929ff..0ce2952 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/applications/ApplicationModuleEditor.vue
@@ -61,6 +61,11 @@ export default {
         cancel() {
             this.$emit('cancel');
         }
+    },
+    watch: {
+        value: function(newValue) {
+            this.appModule = newValue.clone();
+        }
     }
 }
 </script>
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue
index 8a77ed0..be75406 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue
@@ -8,7 +8,7 @@
       <h6 style="color: #666666;">APPLICATIONS</h6>
       <div class="container-fluid">
         <div class="row">
-            <application-card v-for="item in modules" v-bind:app-module="item"
+            <application-card v-for="item in sortedModules" v-bind:app-module="item"
                 v-bind:key="item.appModuleId" v-on:app-selected="clickHandler(item)">
             </application-card>
         </div>
@@ -20,21 +20,31 @@
   import NewApplication from '../admin/NewApplication.vue'
   import Loading from '../Loading.vue'
 
-  import Utils from '../../utils'
   import {mapActions, mapState} from 'vuex'
 
   import { components as comps } from 'django-airavata-common-ui'
 
+  import { utils } from 'django-airavata-api'
+
   export default {
     components:{
       NewApplication, Loading,
       'application-card': comps.ApplicationCard,
     },
     mounted:function () {
-      this.loadApplications();
+      if (!this.modules) {
+        this.loadApplications();
+      }
     },
     computed: {
       ...mapState('applications/modules', ['modules']),
+      sortedModules() {
+        if (this.modules) {
+          return utils.StringUtils.sortIgnoreCase(this.modules.slice(), a => a.appModuleName);
+        } else {
+          return [];
+        }
+      }
     },
     methods:{
       clickHandler: function (item) {
@@ -52,7 +62,7 @@
       newApplicationHandler:function () {
         this.setTitle('Create New Application')
         this.resetApplication()
-        this.$router.push({name: 'details'})
+        this.$router.push({name: 'new_application_module'})
       }
       ,
       ...mapActions({loadApplications: 'applications/modules/loadApplicationModules', setModule:'newApplication/setModule',setTitle:'newApplication/setTitle',restInterface:'newApplication/appInterfaceTab/resetState',resetDetails:'newApplication/appDetailsTab/resetState',resetDeployment:'newApplication/appDeploymentsTab/resetState'}),
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_modules.js
b/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_modules.js
index 85b5d10..3b92e94 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_modules.js
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/store/applications/app_modules.js
@@ -16,20 +16,46 @@ export default {
     },
     actions: {
         loadApplicationModules({ commit }) {
-            services.ApplicationModuleService.list()
-                .then(appModules => commit('setModules', appModules));
+            return services.ApplicationModuleService.list()
+                .then(appModules => {
+                    commit('setModules', appModules);
+                    return appModules;
+                });
         },
         loadApplicationModule({ commit, state }, appModuleId) {
             if (state.modules) {
                 const appModule = state.modules.find(appModule => appModule.appModuleId
=== appModuleId);
                 if (appModule) {
                     commit('setModule', appModule);
-                    return;
+                    return Promise.resolve(appModule);
                 }
             }
             // Otherwise fetch from the backend
-            services.ApplicationModuleService.retrieve({lookup: appModuleId})
-                .then(appModule => commit('setModule', appModule));
+            return services.ApplicationModuleService.retrieve({lookup: appModuleId})
+                .then(appModule => {
+                    commit('setModule', appModule);
+                    return appModule;
+                });
+        },
+        createApplicationModule({ commit, state }, appModule) {
+            return services.ApplicationModuleService.create({data: appModule})
+                .then(appModule => {
+                    commit('setModule', appModule);
+                    const appModulesCopy = state.modules.slice();
+                    appModulesCopy.push(appModule);
+                    commit('setModules', appModulesCopy);
+                    return appModule;
+                });
+        },
+        updateApplicationModule({ commit, state }, appModule) {
+            return services.ApplicationModuleService.update({lookup: appModule.appModuleId,
data: appModule})
+                .then(appModule => {
+                    commit('setModule', appModule);
+                    const appModules = state.modules.filter(mod => mod.appModuleId !==
appModule.appModuleId)
+                    appModules.push(appModule);
+                    commit('setModules', appModules);
+                    return appModule;
+                })
         }
     }
 }
diff --git a/django_airavata/apps/api/serializers.py b/django_airavata/apps/api/serializers.py
index 585f9c6..31a4152 100644
--- a/django_airavata/apps/api/serializers.py
+++ b/django_airavata/apps/api/serializers.py
@@ -226,21 +226,17 @@ class ProjectSerializer(serializers.Serializer):
         return instance
 
 
-class ApplicationModuleSerializer(serializers.Serializer):
+class ApplicationModuleSerializer(
+        thrift_utils.create_serializer_class(ApplicationModule)):
     url = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:application-detail',
lookup_field='appModuleId', lookup_url_kwarg='app_module_id')
-    appModuleId = serializers.CharField(required=True)
-    appModuleName = serializers.CharField(required=True)
-    appModuleDescription = serializers.CharField()
-    appModuleVersion = serializers.CharField()
     applicationInterface = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:application-application-interface',
lookup_field='appModuleId', lookup_url_kwarg='app_module_id')
     applicationDeployments = FullyEncodedHyperlinkedIdentityField(view_name='django_airavata_api:application-application-deployments',
lookup_field='appModuleId', lookup_url_kwarg='app_module_id')
 
-
     def create(self, validated_data):
         return ApplicationModule(**validated_data)
 
     def update(self, instance, validated_data):
-        raise Exception("Not implemented")
+        return self.create(validated_data)
 
 
 class InputDataObjectTypeSerializer(serializers.Serializer):
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/index.js b/django_airavata/apps/api/static/django_airavata_api/js/index.js
index bd6e70e..d82fe04 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/index.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/index.js
@@ -25,7 +25,6 @@ import UserPermission from './models/UserPermission'
 
 import ApplicationDeploymentService from './services/ApplicationDeploymentService'
 import ApplicationInterfaceService from './services/ApplicationInterfaceService'
-import ApplicationModuleService from './services/ApplicationModuleService'
 import ExperimentService from './services/ExperimentService'
 import ExperimentSearchService from './services/ExperimentSearchService'
 import FullExperimentService from './services/FullExperimentService'
@@ -41,8 +40,10 @@ import SCPDataMovementService from './services/SCPDataMovementService'
 import GridFTPDataMovementService from './services/GridFTPDataMovementService'
 import UnicoreDataMovementService from './services/UnicoreDataMovementService'
 import ServiceFactory from './services/ServiceFactory'
+
 import FetchUtils from './utils/FetchUtils'
 import PaginationIterator from './utils/PaginationIterator'
+import StringUtils from './utils/StringUtils'
 
 exports.errors = {
     UnhandledError,
@@ -100,4 +101,5 @@ exports.services = {
 exports.utils = {
     FetchUtils,
     PaginationIterator,
+    StringUtils,
 }
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/utils/StringUtils.js b/django_airavata/apps/api/static/django_airavata_api/js/utils/StringUtils.js
new file mode 100644
index 0000000..22d57ff
--- /dev/null
+++ b/django_airavata/apps/api/static/django_airavata_api/js/utils/StringUtils.js
@@ -0,0 +1,9 @@
+
+function sortIgnoreCase(arr, keyFunction) {
+    arr.sort((a, b) => keyFunction(a).toLowerCase().localeCompare(keyFunction(b).toLowerCase()));
+    return arr;
+}
+
+export default {
+    sortIgnoreCase,
+}


Mime
View raw message