Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorJordan Augé <jordan.auge@lip6.fr>
Wed, 26 Feb 2014 16:28:39 +0000 (17:28 +0100)
committerJordan Augé <jordan.auge@lip6.fr>
Wed, 26 Feb 2014 16:28:39 +0000 (17:28 +0100)
Conflicts:
rest/__init__.py

portal/templates/institution.html
rest/__init__.py
setup.py

index 0f68468..44aa55d 100644 (file)
     <div class="home-panel" id="slices" style="display:none;">
         <br>
         <h1>Slices: onelab.upmc <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create a Slice</button></h1>
-        <table>
-            <tr>
-                <th>+/-</th>
-                <th>slice_hrn</th>
-                <th>number of users</th>
-                <th>expiration date</th>
-            </tr>
-            <tr>
-                <td><input type="checkbox"></td>
-                <td><a href="/portal/slice/ple.upmc.myslicedemo">onelab.upmc.myslicedemo</a></td>
-                <td>3</td>
-                <td>2014-02-11 17:20:37</td>
-            </tr>
-            <tr>
-                <td><input type="checkbox"></td>
-                <td><a href="/portal/slice/ple.upmc.zzzz">onelab.upmc.zzzz</a></td>
-                <td>3</td>
-                <td>2014-02-11 17:20:37</td>
-            </tr>
-        </table>
-        <div>
-            <button id="renewslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
-            <button id="deleteslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
+        <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+        <div id="slice-tab-loaded" style="display:none;">
+            <table id="slice-tab">
+                <tr>
+                    <th>+/-</th>
+                    <th>slice_hrn</th>
+                    <th>users</th>
+                    <th>url</th>
+                    <th>nodes</th>
+                    <th>expiration</th>
+                </tr>
+            </table>
+            <div>
+                <button id="renewslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
+                <button id="deleteslices" type="button" class="btn btn-default"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
+            </div>
         </div>
     </div>
 </div>
             window.location="/portal/slice_request/";
             */
         });
+        {% if person %}
+        $.getJSON("/rest/slice/", function( data ) {
+            var list_slices = [];
+            var table_slices = [];
+            /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "user", "slice_urn", "slice_expires" */
+            $.each( data, function( key, val ) {
+                list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
+                if(val.nodes=="undefined" || val.nodes==null){
+                    nodes_length=0;
+                }else{
+                    nodes_length=val.nodes.length;
+                }
+
+                if(val.user=="undefined" || val.user==null){
+                    user_length=0;
+                }else{
+                    user_length=val.user.length;
+                }
+
+                if(val.slice_url=="undefined" || val.slice_url==null){
+                    slice_url="";
+                }else{
+                    slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
+                }
+                
+                slice_row = "<tr>";
+                slice_row += "<td><input type='checkbox'></td>";
+                slice_row += "<td><a href=\"/portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
+                slice_row += "<td>"+user_length+"</td>";
+                slice_row += "<td>"+slice_url+"</td>";
+                slice_row += "<td>"+nodes_length+"</td>";
+                slice_row += "<td>"+val.slice_expires+"</td>";
+                table_slices.push(slice_row);
+                
+            });
+           
+            /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
+            $("table#slice-tab tr:last").after(table_slices.join( "" ));
+            $("div#slice-tab-loaded").css("display","block");
+            $("div#slice-tab-loading").css("display","none");
+         });
+         {% endif %}
     });
 </script>
 {% endblock unfold_main %}
index b8e733a..3c393d5 100644 (file)
@@ -78,8 +78,10 @@ def platform(request, object_name, object_properties, object_filters = None):
     query  = Query().get('local:platform').filter_by('disabled', '==', '0').filter_by('gateway_type', '==', 'sfa').filter_by('platform', '!=', 'myslice').select(object_properties)
     return send(request, execute_query(request, query), object_properties)
 
-def slice(request, object_name, object_properties, object_filters = None):
-    query = Query().get('slice').filter_by('user.user_hrn', '==', '$user_hrn').select(object_properties)
+# Add different filters possibilities [['user.user_hrn','==','$user_hrn'],['parent_authority','==','ple.upmc']]
+def slice(request, object_name, object_properties):
+    #query = Query().get('slice').filter_by('user.user_hrn', '==', '$user_hrn').select(object_properties)
+    query = Query().get('slice').filter_by('parent_authority', '==', 'ple.upmc').select(object_properties)
     return send(request, execute_query(request, query), object_properties)
 
 def resource(request, object_name, object_properties, object_filters = None):
@@ -114,4 +116,4 @@ def send(request, response, object_properties):
         return HttpResponse(json.dumps(response_data, cls=DecimalEncoder, default=DateEncoder), content_type="application/json")
 
 def error(request, object_name, object_properties):
-    return HttpResponse(json.dumps({'error' : 'an error has occurred'}), content_type="application/json")
\ No newline at end of file
+    return HttpResponse(json.dumps({'error' : 'an error has occurred'}), content_type="application/json")
index f3531de..d27df2b 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -6,6 +6,7 @@
 # INRIA (c) 2013
 
 import os.path
+import shutil
 from glob import glob
 from distutils.core import setup
 
@@ -13,6 +14,9 @@ from distutils.core import setup
 packages= [ os.path.dirname(init) for init in (glob("*/__init__.py")+glob("*/*/__init__.py")) ]
 print packages
 
+# Avoid troubles : clean /usr/share/unfold/
+shutil.rmtree('/usr/share/unfold/')
+
 setup(packages = packages,
       # xxx somehow this does not seem to show up in debian packaging
       scripts = [ 'apache/unfold-init-ssl.sh' ],