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/08/14 19:51:44 UTC
[airavata-django-portal] 02/13: AIRAVATA-2727 Adding ids to routes
so data can be fetched on reload
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 6f9a1a109d08cfeef02a95d7db2f515468bbfcf6
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Aug 8 12:56:37 2018 -0400
AIRAVATA-2727 Adding ids to routes so data can be fetched on reload
---
.../group_resource_preferences/ComputePreference.vue | 15 ++++++++++++---
.../GroupComputeResourcePreference.vue | 19 +++++++++++++------
.../dashboards/ComputeResourcePreferenceDashboard.vue | 3 ++-
.../admin/static/django_airavata_admin/src/main.js | 4 +++-
.../admin/static/django_airavata_admin/src/router.js | 8 ++++----
5 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
index 5fd7cba..f3fca9f 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/ComputePreference.vue
@@ -125,11 +125,20 @@
newCreation: {
type: Boolean,
default: false
+ },
+ id: {
+ type: String,
+ },
+ host_id: {
+ type: String,
}
},
mounted: function () {
- if (this.value && this.value.computeResourceId) {
- this.fetchComputeResource(this.value.computeResourceId);
+ if (!this.value && this.id && this.host_id) {
+ // TODO: load the Group Resource Profile and get the compute preferences for this host_id
+ }
+ if (this.host_id) {
+ this.fetchComputeResource(this.host_id);
} else {
this.fetchComputeResources();
}
@@ -141,7 +150,7 @@
data.computeResourcePolicies = [];
data.computeResourcePolicies.push(this.createComputeResourcePolicy());
}
- if(!data.computeResourceId){
+ if(!this.host_id){
enablePopup = true;
}
return {
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 eb3b2ad..32a3094 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
@@ -15,7 +15,7 @@
<h4>Compute Preferences</h4>
<div>
<a class="list-item" v-for="computePreference,index in data.computePreferences" v-bind:key="index"
- v-on:click="computePreferenceClickHandler(index)">
+ v-on:click="computePreferenceClickHandler(computePreference.computeResourceId)">
<span v-if="computePreference.groupResourceProfileId">
{{getComputeResourceName(computePreference.computeResourceId)}}
</span>
@@ -73,6 +73,12 @@
if (this.value.groupResourceProfileId) {
DjangoAiravataAPI.services.ServiceFactory.service("SharedEntities").retrieve({lookup: this.value.groupResourceProfileId})
.then(sharedEntity => this.sharedEntity = sharedEntity);
+ } else if (this.$route.params.id) {
+ // TODO: switch to using props to get the id param
+ DjangoAiravataAPI.services.ServiceFactory.service("GroupResourcePreference").retrieve({lookup: this.$route.params.id})
+ .then(grp => this.data = this.transformData(grp));
+ DjangoAiravataAPI.services.ServiceFactory.service("SharedEntities").retrieve({lookup: this.$route.params.id})
+ .then(sharedEntity => this.sharedEntity = sharedEntity);
}
},
data: function () {
@@ -206,12 +212,13 @@
});
}
},
- computePreferenceClickHandler: function (index) {
+ computePreferenceClickHandler: function (computeResourceId) {
+ let computeResourcePreference = this.data.computePreferences.find(pref => pref.computeResourceId === computeResourceId);
this.$router.push({
- name: 'compute_preferences', params: {
- value: this.data,
- index: index,
- newCreation: this.newCreation
+ name: 'compute_preference', params: {
+ value: computeResourcePreference,
+ id: this.data.groupResourceProfileId,
+ host_id: computeResourceId,
}
});
},
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 4c547fd..87896c8 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
@@ -49,7 +49,8 @@
clickHandler: function (groupResourceProfile) {
this.$router.push({
name: 'group_resource_preference', params: {
- value: groupResourceProfile
+ value: groupResourceProfile,
+ id: groupResourceProfile.groupResourceProfileId
}
});
},
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 ff18980..fa8a27b 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
@@ -43,7 +43,9 @@ export function initializeApacheAiravataDashboard(dashboardName) {
ComputeResourcePreferenceDashboard
},
mounted:function () {
- this.$router.push({name:dashboardName})
+ if (this.$router.currentRoute.path === '/') {
+ this.$router.push({ name: dashboardName })
+ }
}
})
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 a47d90d..6d54012 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
@@ -5,7 +5,7 @@ import ApplicationDetails from './components/admin/ApplicationDetails.vue'
import ApplicationInterface from './components/admin/ApplicationInterface.vue'
import ApplicationDeployments from './components/admin/ApplicationDeployments.vue'
import GroupComputeResourcePreference from './components/admin/group_resource_preferences/GroupComputeResourcePreference'
-import ComputePreferences from './components/admin/group_resource_preferences/ComputePreferences'
+import ComputePreference from './components/admin/group_resource_preferences/ComputePreference'
import ComputeResourcePreferenceDashboard from './components/dashboards/ComputeResourcePreferenceDashboard'
import CredentialStoreDashboard from './components/dashboards/CredentialStoreDashboard'
import VueRouter from 'vue-router'
@@ -34,15 +34,15 @@ const routes = [
{path: '/admin', component: AdminDashboard, name: "admin_dashboard"},
{path: '/experiments', component: ExperimentsDashboard, name: 'experiments_dashboard'},
{
- path: '/group/resource/profile', component: GroupComputeResourcePreference, name: 'group_resource_preference',
+ path: '/group-resource-profiles/:id', component: GroupComputeResourcePreference, name: 'group_resource_preference',
props: true
},
{
- path: '/group/resource/compute/preferences', component: ComputePreferences, name: 'compute_preferences',
+ path: '/group-resource-profiles/:id/compute-preferences/:host_id', component: ComputePreference, name: 'compute_preference',
props: true
},
{
- path: '/dashboards/group/resource/profiles',
+ path: '/group-resource-profiles',
component: ComputeResourcePreferenceDashboard,
name: 'group_resource_preference_dashboard',
},