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/28: AIRAVATA-2876 Change to HTML5 History API routing
Date Tue, 11 Sep 2018 17:11:49 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 ab00f5b97177dba0ab4229567ec80795a66adc9b
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Mon Aug 27 20:24:47 2018 -0400

    AIRAVATA-2876 Change to HTML5 History API routing
---
 .../GroupComputeResourcePreference.vue             | 28 ++++++++++------------
 ...dminDashboard.vue => ApplicationsDashboard.vue} |  0
 .../ComputeResourcePreferenceDashboard.vue         | 12 ++--------
 .../admin/static/django_airavata_admin/src/main.js |  9 +------
 .../static/django_airavata_admin/src/router.js     |  8 ++++---
 .../apps/admin/templates/admin/app_catalog.html    |  8 -------
 .../templates/admin/group_resource_profile.html    |  8 -------
 django_airavata/apps/admin/urls.py                 |  6 ++---
 django_airavata/apps/admin/views.py                | 18 +++++++++-----
 9 files changed, 36 insertions(+), 61 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
index 2218d95..d0f7a98 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
@@ -32,10 +32,20 @@
               :group-resource-profile="data"/>
           </template>
           <template slot="action" slot-scope="row">
-            <a href="#" @click.prevent="computePreferenceClickHandler(row.item.computeResourceId)">
+            <router-link :to="{
+                name: 'compute_preference',
+                params: {
+                  value: row.item,
+                  id: id,
+                  host_id: row.item.computeResourceId,
+                  groupResourceProfile: data,
+                  computeResourcePolicy: data.getComputeResourcePolicy(row.item.computeResourceId),
+                  batchQueueResourcePolicies: data.getBatchQueueResourcePolicies(row.item.computeResourceId)
+                }
+              }">
               Edit
               <i class="fa fa-edit" aria-hidden="true"></i>
-            </a>
+            </router-link>
             <a href="#" class="text-danger" @click.prevent="removeComputePreference(row.item.computeResourceId)">
               Delete
               <i class="fa fa-trash" aria-hidden="true"></i>
@@ -169,12 +179,6 @@
           this.$router.push('/group-resource-profiles');
         });
       },
-      computePreferenceClickHandler: function (computeResourceId) {
-        let computeResourcePreference = this.data.computePreferences.find(pref => pref.computeResourceId
=== computeResourceId);
-        const computeResourcePolicy = this.data.getComputeResourcePolicy(computeResourceId);
-        const batchQueueResourcePolicies = this.data.getBatchQueueResourcePolicies(computeResourceId);
-        this.navigateToComputeResourcePreference(computeResourcePreference, computeResourcePolicy,
batchQueueResourcePolicies);
-      },
       getComputeResourceName: function (computeResourceId) {
         // TODO: load compute resources to get the real name
         return (computeResourceId && computeResourceId.indexOf("_") > 0) ? computeResourceId.split("_")[0]
: computeResourceId;
@@ -189,18 +193,12 @@
         const computeResourcePreference = new models.GroupComputeResourcePreference();
         const computeResourceId = this.selectedComputeResource;
         computeResourcePreference.computeResourceId = computeResourceId;
-        this.navigateToComputeResourcePreference(computeResourcePreference);
-      },
-      navigateToComputeResourcePreference: function(computeResourcePreference, computeResourcePolicy=null,
batchQueueResourcePolicies=null) {
-        const routeName = (this.id) ? 'compute_preference' : 'compute_preference_for_new_group_resource_profile';
         this.$router.push({
-          name: routeName, params: {
+          name: 'compute_preference_for_new_group_resource_profile', params: {
             value: computeResourcePreference,
             id: this.id,
             host_id: computeResourcePreference.computeResourceId,
             groupResourceProfile: this.data,
-            computeResourcePolicy: computeResourcePolicy,
-            batchQueueResourcePolicies: batchQueueResourcePolicies,
           }
         });
       },
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/AdminDashboard.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue
similarity index 100%
rename from django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/AdminDashboard.vue
rename to django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ApplicationsDashboard.vue
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ComputeResourcePreferenceDashboard.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ComputeResourcePreferenceDashboard.vue
index a4548bd..42a2520 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ComputeResourcePreferenceDashboard.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/dashboards/ComputeResourcePreferenceDashboard.vue
@@ -5,10 +5,10 @@
 
       <b-table striped hover :fields="fields" :items="slotProps.items">
         <template slot="action" slot-scope="data">
-          <a href="#" @click.prevent="clickHandler(data.item)" v-if="data.item.userHasWriteAccess">
+          <router-link :to="{name: 'group_resource_preference', params: {value: data.item,
id: data.item.groupResourceProfileId}}">
             Edit
             <i class="fa fa-edit" aria-hidden="true"></i>
-          </a>
+          </router-link>
           <a href="#" class="text-danger" @click.prevent="removeGroupResourceProfile(data.item)"
v-if="data.item.userHasWriteAccess">
             Delete
             <i class="fa fa-trash" aria-hidden="true"></i>
@@ -50,14 +50,6 @@
       }
     },
     methods: {
-      clickHandler: function (groupResourceProfile) {
-        this.$router.push({
-          name: 'group_resource_preference', params: {
-            value: groupResourceProfile,
-            id: groupResourceProfile.groupResourceProfileId
-          }
-        });
-      },
       newGroupResourcePreference: function () {
         this.$router.push({
           name: 'new_group_resource_preference'
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/main.js b/django_airavata/apps/admin/static/django_airavata_admin/src/main.js
index 28c151e..92bc6ab 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/main.js
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/main.js
@@ -3,7 +3,6 @@ import VueResource from 'vue-resource';
 import VueRouter from 'vue-router';
 
 import ExperimentsDashboard from './components/dashboards/ExperimentDashboard.vue';
-import AdminDashboard from './components/dashboards/AdminDashboard.vue';
 import CredentialStore from './components/dashboards/CredentialStoreDashboard.vue'
 import Loading from './components/Loading.vue'
 import ComputeResourceDashboard from './components/dashboards/ComputeResourceDashboard'
@@ -40,19 +39,13 @@ export function initializeApacheAiravataDashboard(dashboardName) {
     template: template,
     components: {
       ExperimentsDashboard,
-      AdminDashboard,
+      // AdminDashboard,
       CredentialStore,
       Loading,
       ComputeResourceDashboard,
       ComputeResourcePreferenceDashboard,
       'notifications-display': components.NotificationsDisplay,
-    },
-    mounted:function () {
-      if (this.$router.currentRoute.path === '/') {
-        this.$router.push({ name: dashboardName })
-      }
     }
-
   })
   Vue.config.devtools = true
   Vue.config.debug = true
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/router.js b/django_airavata/apps/admin/static/django_airavata_admin/src/router.js
index 4f883d5..62893e3 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/router.js
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/router.js
@@ -1,4 +1,4 @@
-import AdminDashboard from './components/dashboards/AdminDashboard.vue'
+import ApplicationsDashboard from './components/dashboards/ApplicationsDashboard.vue'
 import NewApplication from './components/admin/NewApplication.vue'
 import ExperimentsDashboard from './components/dashboards/ExperimentDashboard.vue'
 import ApplicationDetails from './components/admin/ApplicationDetails.vue'
@@ -31,7 +31,7 @@ const routes = [
       }
     ]
   },
-  {path: '/admin', component: AdminDashboard, name: "admin_dashboard"},
+  {path: '/applications', component: ApplicationsDashboard},
   {path: '/experiments', component: ExperimentsDashboard, name: 'experiments_dashboard'},
   {
     path: '/group-resource-profiles/new', component: GroupComputeResourcePreference, name:
'new_group_resource_preference',
@@ -61,5 +61,7 @@ const routes = [
   },
 ];
 export default new VueRouter({
-  routes: routes
+  mode: 'history',
+  base: '/admin/',
+  routes: routes,
 });
diff --git a/django_airavata/apps/admin/templates/admin/app_catalog.html b/django_airavata/apps/admin/templates/admin/app_catalog.html
deleted file mode 100644
index ed1eced..0000000
--- a/django_airavata/apps/admin/templates/admin/app_catalog.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends "admin/admin_base.html"%}
-{% load static %}
-{% block scripts %}
-   <script>
-    window.airavataDashboardName='admin_dashboard'
-   </script>
-    {{ block.super }}
-{% endblock %}
diff --git a/django_airavata/apps/admin/templates/admin/group_resource_profile.html b/django_airavata/apps/admin/templates/admin/group_resource_profile.html
deleted file mode 100644
index 31594b5..0000000
--- a/django_airavata/apps/admin/templates/admin/group_resource_profile.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends "admin/admin_base.html"%}
-{% load static %}
-{% block scripts %}
-   <script>
-    window.airavataDashboardName='group_resource_preference_dashboard'
-   </script>
-    {{ block.super }}
-{% endblock %}
diff --git a/django_airavata/apps/admin/urls.py b/django_airavata/apps/admin/urls.py
index b87bd53..c763365 100644
--- a/django_airavata/apps/admin/urls.py
+++ b/django_airavata/apps/admin/urls.py
@@ -4,8 +4,8 @@ from . import views
 
 app_name = 'django_airavata_admin'
 urlpatterns = [
-    url(r'^$', views.app_catalog, name='home'),
-    url(r'^app_catalog/$', views.app_catalog, name='app_catalog'),
+    url(r'^$', views.home, name='home'),
+    url(r'^applications/', views.app_catalog, name='app_catalog'),
     url(r'^credential_store$', views.credential_store, name='credential_store'),
-    url(r'^group_resource_profile$', views.group_resource_profile, name='group_resource_profile'),
+    url(r'^group-resource-profiles/', views.group_resource_profile, name='group_resource_profile'),
 ]
diff --git a/django_airavata/apps/admin/views.py b/django_airavata/apps/admin/views.py
index 4cd513b..d8c710c 100644
--- a/django_airavata/apps/admin/views.py
+++ b/django_airavata/apps/admin/views.py
@@ -1,25 +1,31 @@
-from django.shortcuts import render
+from django.contrib.auth.decorators import login_required
+from django.shortcuts import redirect, render
+from django.urls import reverse
 
-# Create your views here.
 
-from django.contrib.auth.decorators import login_required
-from django.shortcuts import render
+@login_required
+def home(request):
+    return redirect(reverse('django_airavata_admin:app_catalog'))
+
 
 @login_required
 def app_catalog(request):
     request.active_nav_item = 'app_catalog'
-    return render(request, 'admin/app_catalog.html')
+    return render(request, 'admin/admin_base.html')
+
 
 @login_required
 def credential_store(request):
     request.active_nav_item = 'credential_store'
     return render(request, 'admin/credential_store.html')
 
+
 @login_required
 def compute_resource(request):
     return render(request, 'admin/compute_resource.html')
 
+
 @login_required
 def group_resource_profile(request):
     request.active_nav_item = 'group_resource_profile'
-    return render(request, 'admin/group_resource_profile.html')
+    return render(request, 'admin/admin_base.html')


Mime
View raw message