X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=portal%2Ftemplates%2Ffed4fire%2Ffed4fire_slicerequest_view.html;h=7bcd56dec7e79ac778df0cf9f15d6d32ac286745;hb=56a406a324edea50be41bdd649319491fa391ca4;hp=c8fecf6391cfe7d2b2756fae0b68a6c63250b69b;hpb=ac575fb40a8a128cdac22bdc0b868012011c5e66;p=unfold.git diff --git a/portal/templates/fed4fire/fed4fire_slicerequest_view.html b/portal/templates/fed4fire/fed4fire_slicerequest_view.html index c8fecf63..7bcd56de 100644 --- a/portal/templates/fed4fire/fed4fire_slicerequest_view.html +++ b/portal/templates/fed4fire/fed4fire_slicerequest_view.html @@ -34,15 +34,24 @@ title="Please enter a name for your slice"required="required">
- {%if 'is_pi' in pi %} + {% if pi %} - {%else%} - - {%endif%} + Authority:   +
+ Loading authority +
+ {% endif %}
+ Project:
Loading projects
+ +
+
@@ -50,11 +59,11 @@ - {%if 'is_pi' in pi %} + {% if pi %} - {%else%} + {% else %} - {%endif%} + {% endif %} @@ -66,7 +75,15 @@ jQuery(document).ready(function(){ $("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) { var jsonData = JSON.parse(data); $(this).attr("value", jsonData[0]['parent_authority']); + {% if pi %} + draw_projects(jsonData[0]['parent_authority']); + {% else %} + $('#authority_display').html(jsonData[0]['parent_authority']); + draw_projects(''); + {% endif %} }); + + {% if pi %} $("#authority_hrn").val("{{authority_name}}"); var availableTags = [ {% if authorities %} @@ -96,13 +113,46 @@ jQuery(document).ready(function(){ $( "#authority_hrn" ).autocomplete({ source: availableTags, minLength: 0, - select: function( event, ui ) {console.log(jQuery(this));} + select: function( event, ui ) { + $("#project").hide(); + $("#project_loading").css('display', 'inline-block'); + draw_projects(jQuery('.ui-state-focus').html()); + }, }); - - $("#submit_pi").click(function() { - localStorage.clear(); - }); + {% endif %} }); + +function draw_projects(authority_hrn){ + + var projects = []; + project_row = ""; + projects.push(project_row); + + if(authority_hrn.length > 0){ + // Not for root authority + if(authority_hrn.split('.').length > 1){ + $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS'+authority_hrn}}, function( data ) { + + $.each( data, function( key, val ) { + project_row = ""; + projects.push(project_row); + }); + $("#project").html(projects.join( "" )); + }); + }else{ + $("#project").html(projects.join( "" )); + } + }else{ + my_projects = JSON.parse(localStorage.getItem('projects')); + $.each( my_projects, function( i, val ) { + project_row = ""; + projects.push(project_row); + }); + $("#project").html(projects.join( "" )); + } + $("#project").show(); + $("#project_loading").hide(); +} {% endblock %}