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/05: Show new user message when created in last week and no access to run any apps
Date Thu, 18 Jul 2019 18:56:15 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 b1c97409054fd59c68a951e6426b9ff035a23f48
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Wed Jul 17 16:06:58 2019 -0400

    Show new user message when created in last week and no access to run any apps
---
 .../api/static/django_airavata_api/js/index.js     |   2 +-
 .../django_airavata_api/js/service_config.js       |   2 +-
 django_airavata/apps/api/views.py                  |   9 +-
 .../js/containers/DashboardContainer.vue           | 103 ++++++++++++++-------
 4 files changed, 81 insertions(+), 35 deletions(-)

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 1576fe3..3f019eb 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
@@ -135,7 +135,7 @@ const services = {
   UnverifiedEmailUserProfileService: ServiceFactory.service(
     "UnverifiedEmailUsers"
   ),
-  UserProfileService,
+  UserProfileService: ServiceFactory.service("UserProfiles"),
   UserStoragePathService: ServiceFactory.service("UserStoragePaths"),
   WorkspacePreferencesService: ServiceFactory.service("WorkspacePreferences")
 };
diff --git a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
index 94e1c9f..1855a75 100644
--- a/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
+++ b/django_airavata/apps/api/static/django_airavata_api/js/service_config.js
@@ -329,7 +329,7 @@ export default {
   },
   UserProfiles: {
     url: "/api/user-profiles",
-    viewSet: ["list"],
+    viewSet: ["list", "retrieve"],
     modelClass: UserProfile
   },
   UserStoragePaths: {
diff --git a/django_airavata/apps/api/views.py b/django_airavata/apps/api/views.py
index 90c0247..1ae5f87 100644
--- a/django_airavata/apps/api/views.py
+++ b/django_airavata/apps/api/views.py
@@ -906,7 +906,9 @@ def delete_file(request):
         raise Http404(str(e)) from e
 
 
-class UserProfileViewSet(mixins.ListModelMixin, GenericAPIBackedViewSet):
+class UserProfileViewSet(mixins.RetrieveModelMixin,
+                         mixins.ListModelMixin,
+                         GenericAPIBackedViewSet):
     serializer_class = serializers.UserProfileSerializer
 
     def get_list(self):
@@ -914,6 +916,11 @@ class UserProfileViewSet(mixins.ListModelMixin, GenericAPIBackedViewSet):
         return user_profile_client.getAllUserProfilesInGateway(
             self.authz_token, self.gateway_id, 0, -1)
 
+    def get_instance(self, lookup_value):
+        user_profile_client = self.request.profile_service['user_profile']
+        return user_profile_client.getUserProfileById(
+            self.authz_token, self.request.user.username, self.gateway_id)
+
 
 class GroupResourceProfileViewSet(APIBackedViewSet):
     serializer_class = serializers.GroupResourceProfileSerializer
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/DashboardContainer.vue
b/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/DashboardContainer.vue
index 5347df4..b3ec934 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/DashboardContainer.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/containers/DashboardContainer.vue
@@ -1,43 +1,82 @@
 <template>
-    <div>
-        <div class="row">
-            <div class="col">
-                <h1 class="h4 mb-4">Dashboard</h1>
-            </div>
-        </div>
-        <div class="row">
-            <application-card v-for="item in applicationModules" v-bind:appModule="item"
-                v-bind:key="item.appModuleId" @app-selected="handleAppSelected">
-            </application-card>
-        </div>
-
+  <div>
+    <div class="row">
+      <div class="col">
+        <h1 class="h4 mb-4">Dashboard</h1>
+      </div>
+    </div>
+    <div
+      class="row"
+      v-if="showNewUserMessage"
+    >
+      <div class="col">
+        <b-alert
+          variant="info"
+          show
+        >Welcome {{ userProfile.firstName }} {{ userProfile.lastName }}!
+          You currently don't have access to run any applications but the
+          administrator of this gateway has been notified and will be in
+          contact to grant you the appropriate privileges.</b-alert>
+      </div>
     </div>
+    <div class="row">
+      <application-card
+        v-for="item in applicationModules"
+        v-bind:appModule="item"
+        v-bind:key="item.appModuleId"
+        @app-selected="handleAppSelected"
+      >
+      </application-card>
+    </div>
+
+  </div>
 </template>
 
 <script>
-
-import { services } from 'django-airavata-api'
-import { components as comps } from 'django-airavata-common-ui'
+import { services, session } from "django-airavata-api";
+import { components as comps } from "django-airavata-common-ui";
 import urls from "../utils/urls";
 
 export default {
-    name: 'dashboard-container',
-    data () {
-        return {
-            applicationModules: null,
-        }
-    },
-    components: {
-        'application-card': comps.ApplicationCard,
-    },
-    methods: {
-        handleAppSelected: function(appModule) {
-            urls.navigateToCreateExperiment(appModule);
-        },
+  name: "dashboard-container",
+  data() {
+    return {
+      applicationModules: null,
+      userProfile: null
+    };
+  },
+  components: {
+    "application-card": comps.ApplicationCard
+  },
+  methods: {
+    handleAppSelected: function(appModule) {
+      urls.navigateToCreateExperiment(appModule);
+    }
+  },
+  computed: {
+    isNewUser() {
+      return (
+        this.userProfile &&
+        Date.now() - this.userProfile.creationTime.getTime() <
+          7 * 24 * 60 * 60 * 1000
+      );
     },
-    beforeMount: function () {
-        services.ApplicationModuleService.list()
-            .then(result => this.applicationModules = result);
+    showNewUserMessage() {
+      return (
+        this.isNewUser &&
+        this.userProfile &&
+        this.applicationModules &&
+        this.applicationModules.length === 0
+      );
     }
-}
+  },
+  beforeMount: function() {
+    services.ApplicationModuleService.list().then(
+      result => (this.applicationModules = result)
+    );
+    services.UserProfileService.retrieve({
+      lookup: session.Session.username
+    }).then(userProfile => (this.userProfile = userProfile));
+  }
+};
 </script>


Mime
View raw message