Added resources to the platform description, fixed link in querytable for the init_ke...
authorLoic Baron <loic.baron@lip6.fr>
Fri, 7 Feb 2014 22:21:00 +0000 (23:21 +0100)
committerLoic Baron <loic.baron@lip6.fr>
Fri, 7 Feb 2014 22:21:00 +0000 (23:21 +0100)
manifold/manifoldproxy.py
plugins/querytable/static/js/querytable.js
portal/platformsview.py
portal/platformview.py
portal/static/css/onelab_marko.css
portal/templates/platform.html
portal/validationview.py

index d43a3cd..debd1f7 100644 (file)
@@ -55,6 +55,7 @@ with the query passed using POST"""
             admin_user, admin_password = Config().manifold_admin_user_password()
             manifold_api_session_auth = {'AuthMethod': 'password', 'Username': admin_user, 'AuthString': admin_password}
         else:
+            print request.session['manifold']
             manifold_api_session_auth = request.session['manifold']['auth']
 
         if debug_empty and manifold_query.action.lower()=='get':
index 19ecd6c..15ee6f1 100644 (file)
                     else
                         line.push(record['hostname']);
 
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
+                } else if (colnames[j] == this.init_key && typeof(record) != 'undefined') {
+                    obj = this.object
+                    o = obj.split(':');
+                    if(o.length>1){
+                        obj = o[1];
+                    }else{
+                        obj = o[0];
+                    }
+                    /* XXX TODO: Remove this and have something consistant */
+                    if(obj=='resource'){
+                        line.push('<a href="../'+obj+'/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record[this.init_key]);
+                    }else{
+                        line.push('<a href="../'+obj+'/'+record[this.init_key]+'"><span class="glyphicon glyphicon-search"></span></a> '+record[this.init_key]);
+                    }
                 } else {
                     if (record[colnames[j]])
                         line.push(record[colnames[j]]);
index 7e7d53a..8c7640b 100644 (file)
@@ -26,6 +26,7 @@ class PlatformsView(FreeAccessView):
             query = platform_query,
             query_all = platform_query,
             checkboxes = False,
+            init_key   = 'platform',
             datatables_options = { 
                 'iDisplayLength': 10,
                 'bLengthChange' : True,
index 86d282b..6f537d0 100644 (file)
@@ -1,11 +1,21 @@
+from django.template             import RequestContext
+from django.shortcuts            import render_to_response
+
 from manifold.core.query         import Query
 from unfold.page                 import Page
+from plugins.raw                 import Raw
+from plugins.stack               import Stack
+from plugins.tabs                import Tabs
+from plugins.googlemap           import GoogleMap
+from plugins.senslabmap          import SensLabMap
 
 from unfold.loginrequired        import FreeAccessView
 from ui.topmenu                  import topmenu_items_live, the_user
 
 from plugins.querytable          import QueryTable
 
+from myslice.config              import Config
+
 # View for 1 platform and its details
 class PlatformView(FreeAccessView):
     template_name = "platform.html"
@@ -13,6 +23,7 @@ class PlatformView(FreeAccessView):
     def get_context_data(self, **kwargs):
         page = Page(self.request)
         page.add_js_files  ( [ "js/common.functions.js" ] )
+
         for key, value in kwargs.iteritems():
             print "%s = %s" % (key, value)       
             if key == "platformname":
@@ -23,6 +34,16 @@ class PlatformView(FreeAccessView):
             .select('platform','platform_longname','gateway_type')
         page.enqueue_query(network_query)
 
+        # ListResources of the platform
+        metadata = page.get_metadata()
+        resource_md = metadata.details_by_object('resource')
+        resource_fields = [column['name'] for column in resource_md['column']]
+        resources = platformname + ':resource'
+        query_resource_all = Query.get(resources).select(resource_fields)
+        page.enqueue_query(query_resource_all)
+        query_resource_default_fields = Query.get(resources).select('hrn','hostname', 'type','country')
+        page.enqueue_query(query_resource_default_fields)
+
         page.expose_js_metadata()
         networklist = QueryTable(
             page  = page,
@@ -37,17 +58,80 @@ class PlatformView(FreeAccessView):
             'bLengthChange'  : True,
             },
         )
-#
+
 #        networklist = SimpleList(
 #            title = None,
 #            page  = page,
 #            key   = 'platform',
 #            query = network_query,
 #        )
+#
+        # --------------------------------------------------------------------------
+        # RESOURCES
+        # for internal use in the querytable plugin;
+        # needs to be a unique column present for each returned record
+        main_query_init_key = 'hrn'
+
+        # the resources part is made of a Tabs (Geographic, List), 
+        resources_as_gmap = GoogleMap(
+            page       = page,
+            title      = 'Geographic view',
+            domid      = 'resources-map',
+            # tab's sons preferably turn this off
+            togglable  = False,
+            query      = query_resource_default_fields,
+            query_all  = query_resource_all,
+            # this key is the one issued by google
+            googlemap_api_key = Config().googlemap_api_key(),
+            # the key to use at init-time
+            init_key   = main_query_init_key,
+            checkboxes = False,
+            # center on Paris
+            latitude   = 49.,
+            longitude  = 9,
+            zoom       = 4,
+        )
+        resources_as_3dmap = SensLabMap(
+            page       = page,
+            title      = '3D Map',
+            domid      = 'senslabmap',
+            query      = query_resource_default_fields,
+            query_all  = query_resource_all,
+        )
+        resources_as_list = QueryTable(
+            page       = page,
+            domid      = 'resources-list',
+            title      = 'List view',
+            # this is the query at the core of the slice list
+            query      = query_resource_default_fields,
+            query_all  = query_resource_all,
+            init_key     = main_query_init_key,
+            checkboxes = False,
+            datatables_options = {
+                'iDisplayLength': 25,
+                'bLengthChange' : True,
+                'bAutoWidth'    : True,
+                },
+            )
+        resources_sons = [
+             resources_as_gmap,
+             resources_as_3dmap,
+             resources_as_list,
+             ]
+        resources_area = Tabs ( page=page,
+                                domid="resources",
+                                togglable=True,
+                                title="Resources",
+                                outline_complete=True,
+                                sons= resources_sons,
+                                active_domid = 'resources-map',
+                                persistent_active=True,
+                                )
 
         context = super(PlatformView, self).get_context_data(**kwargs)
         context['person']   = self.request.user
         context['networks'] = networklist.render(self.request)
+        context['resources'] = resources_area.render(self.request)
 
         # XXX This is repeated in all pages
         # more general variables expected in the template
index be647a3..d310399 100644 (file)
 table {
    color:white;
 }
+table.dataTable {
+   color:black;
+}
+
 
 .container h1, .container h2 {
     color: #fff !important;
index 48afd94..136a8bf 100644 (file)
@@ -5,7 +5,8 @@
 {% endblock %}
 
 {% block unfold_main %}
-
 <h1>Platform</h1>
 {{networks}}
+<br>
+{{resources}}
 {% endblock %}
index de79034..ad69a2e 100644 (file)
@@ -141,6 +141,10 @@ class ValidatePendingView(FreeAccessView):
             print 'credential_authorities =', credential_authorities
             print 'credential_authorities_expired =', credential_authorities_expired
 
+            # Using cache manifold-tables to get the list of authorities faster
+            all_authorities_query = Query.get('authority').select('name', 'authority_hrn')
+            all_authorities = execute_query(self.request, all_authorities_query)
+
             # ** Where am I a PI **
             # For this we need to ask SFA (of all authorities) = PI function
             pi_authorities_query = Query.get('user').filter_by('user_hrn', '==', '$user_hrn').select('pi_authorities')
@@ -149,6 +153,16 @@ class ValidatePendingView(FreeAccessView):
             for pa in pi_authorities_tmp:
                 pi_authorities |= set(pa['pi_authorities'])
 
+# include all sub-authorities of the PI
+# if PI on ple, include all sub-auths ple.upmc, ple.inria and so on...
+#            a = set()
+#            for authority in authorities:
+#                for my_authority in my_authorities:
+#                    if authority.startswith(my_authority) and authority not in a:
+#                        a.add(authority)
+            
+
+
             print "pi_authorities =", pi_authorities
             
             # My authorities + I have a credential