Tools tab: handle async Describe calls and gives a warning if no resources are reserv...
authorLoic Baron <loic.baron@lip6.fr>
Wed, 17 Jun 2015 13:01:40 +0000 (15:01 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Wed, 17 Jun 2015 13:01:40 +0000 (15:01 +0200)
portal/slicetabexperiment.py
portal/templates/slice-tab-experiment.html

index 7ed6d31..79471d2 100644 (file)
@@ -34,6 +34,7 @@ class ExperimentView (FreeAccessView, ThemeView):
         pf_query = Query().get('local:platform').filter_by('disabled', '==', '0').filter_by('gateway_type', '==', 'sfa').select('platform')
         res_platforms = execute_query(request, pf_query)
         platforms = [p['platform'] for p in res_platforms]
+        len_platforms = len(platforms)
         #query_current_resources = Query.get('slice').select('resource','parent_authority').filter_by('slice_hrn','==',slicename)
         #current_resources = execute_query(request, query_current_resources)
 
@@ -107,6 +108,7 @@ class ExperimentView (FreeAccessView, ThemeView):
         env = { 'theme' : self.theme,
                 'slicename':slicename, 
                 'platforms':platforms,
+                'len_platforms': len_platforms,
                 #'ple_slicename':ple_slicename, 
                 #'username':username, 
                 #'ple_resources':ple_resource_list, 
index 0ca620a..9673ad6 100644 (file)
@@ -1,6 +1,16 @@
 <script type="text/javascript">
+function is_finished(len_platforms, pf_status){
+    if(len_platforms == pf_status){
+        return true;
+    }else{
+        return false;
+    }
+}
+
 // Specific DIVs for each type of testbed
 $(document).ready(function() {
+    var platform_status = Array();
+    var platform_empty = Array();
     console.log('{{platforms}}');
     {% for platform in platforms %}
     // /sfa/Describe?hrn=onelab.upmc.projectx.slicex&platform[]={{platform}}&type=slice
@@ -18,6 +28,15 @@ $(document).ready(function() {
                     render_node('{{platform}}',rspec['node']);
                 }
             }
+        }else{
+            platform_empty.push('{{platform}}');
+        }
+        platform_status.push('{{platform}}');
+        if(is_finished({{len_platforms}},platform_status.length)){
+            $("#loading").hide();
+            if(platform_empty.length > 0){
+                $("#warning_message").show();
+            }
         }
     });
     {% endfor %}
@@ -26,11 +45,15 @@ $(document).ready(function() {
 
 <div class="col-md-10 col-md-offset-1">
 <div id="access">
-    <h2>How to access your reserved resources</h2>
+    <h2>How to access your reserved resources?</h2>
     <img src="{{ STATIC_URL }}img/loading.gif" id="loading" alt="Loading reserved resources" />
 </div>
+<div id="warning_message" style="display:none; color:orange; font-weigh:bold;">
+Please add resources to your slice from the left tab <a href="/resources/{{slicename}}">"Resources"</a>
+</div>
 <div id="default">
 </div>
+{% if "ple" in platforms %}
 <div id="ple_header" style="display:none;">
        <h3>PlanetLab Europe</h3>
        
@@ -101,6 +124,8 @@ $(document).ready(function() {
     </script>
     <br>
 </div>
+{% endif %}
+{% if "iotlab" in platforms %}
 <div id="iotlab_header" style="display:none;">
        <h3>FIT IoT-Lab</h3>
        <p>FIT IoT-Lab resources are accessible directly via SSH and <a href="https://www.iot-lab.info/testbed/" target="_blank">web GUI.</a>
@@ -110,6 +135,8 @@ $(document).ready(function() {
 </div>
 <div id="iotlab" style="display:none;">
 </div>
+{% endif %}
+{% if "nitos" in platforms %}
 <div id="nitos_header" style="display:none;">
        <h3>NITOS Volos (Greece)</h3>
        
@@ -131,7 +158,8 @@ $(document).ready(function() {
        <p>To learn more about OMF, please click <a href="http://omf.mytestbed.net/projects/omf/wiki/OMF_Main_Page" target="_blank">here.</a></p>
 
 </div>
-
+{% endif %}
+{% if "nitos-paris" in platforms %}
 <div id="paris.fit-nitos.fr_header" style="display:none;">
        <h4>FIT NITOS-Lab Paris</h4>
 </div>
@@ -153,6 +181,7 @@ $(document).ready(function() {
     <p>OMF based experiments' tutorials are available <a href="http://nitlab.inf.uth.gr/NITlab/index.php/testbed/instructions/omf-tutorials-scenarios" target="_blank">here.</a></p> 
        <p>To learn more about OMF, please click <a href="http://omf.mytestbed.net/projects/omf/wiki/OMF_Main_Page" target="_blank">here.</a></p>
 </div>
+{% endif %}
 <div style="padding-top:20px;">        
        <h2>Available Tools</h2>
        <p><img src="{{ STATIC_URL }}img/terminal_icon.png" width="50"> <b>SSH</b></p>