Create Slice: Load list of projects min length 0
[unfold.git] / portal / templates / fed4fire / fed4fire_slicerequest_view.html
1 {% extends "layout.html" %}
2 {% load i18n %}
3
4 {% block content %}
5         <div class="row">
6                 <div class="col-md-12">
7                          <div class="breadcrumbs" style="line-height: 3;">
8                                  Experiment &nbsp;>&nbsp; Request a new Slice
9                          </div>
10                 </div>
11         </div>
12
13         {% if errors %}
14         <div class="row">
15                 <div class="col-md-12">
16                 <ul class="error">
17                   {% for error in errors %}
18                   <li>{{ error }}</li>
19                   {% endfor %}
20                 </ul>
21                 </div>
22         </div>
23         {% endif %}
24         
25         <div class="row">
26                 <div class="col-md-8 el">
27                         <form role="form" method="post">
28                         {% csrf_token %}
29                           <div class="form-group" style="display:none">
30                             <input type="email" class="form-control" id="email" style="width:300px" value="{{ email }}" readonly="readonly">
31                           </div>
32                           <div class="form-group">
33                             <input type="text" class="form-control" name="slice_name" id="slice_name" style="width:300px" placeholder="Slice name" value="{{slice_name}}" 
34                                 title="Please enter a name for your slice"required="required">
35                           </div>
36                           <div class="form-group">
37                                 <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Project" 
38                                 title="Select a project under which you want to create your slice. Don't have any project yet! Create/Join project from the dashboard." required="required">
39                           </div>
40                           <div class="form-group">
41                             <input type="text" class="form-control" name="url" id="url" style="width:300px" placeholder="Experiment URL (if one exists)"
42                                 title="Please provide the url of your experiment if you have one." value="{{url}}">
43                           </div>
44                           <div class="form-group">
45                                 <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Experiment purpose" style="width:300px" 
46                                 title="Purpose of your experiment (informative)" required="required">{{ purpose }}</textarea>
47                           </div>
48                           <button type="submit" id=submit_pi class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
49                         </form>
50         
51                 </div>
52         </div>
53                 
54 <script>
55 jQuery(document).ready(function(){
56     var myprojects = JSON.parse(localStorage.getItem('projects'));
57     $( "#authority_hrn" ).autocomplete({
58         minLength: 0,
59         source: myprojects,
60         change: function (event, ui) {
61                 if(!ui.item){
62                     //http://api.jqueryui.com/autocomplete/#event-change -
63                     // The item selected from the menu, if any. Otherwise the property is null
64                     //so clear the item for force selection
65                     $("#authority_hrn").val("");
66                 }
67         }
68     });
69 });
70
71 /*function draw_projects(authority_hrn){
72
73     var projects = [];
74     project_row = "<option value=''> - </option>";
75     projects.push(project_row);
76
77     if(authority_hrn.length > 0){
78         // Not for root authority
79         if(authority_hrn.split('.').length > 1){
80             $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS'+authority_hrn}}, function( data ) {
81                
82                 $.each( data, function( key, val ) {
83                     project_row = "<option value='"+val.authority_hrn+"'>"+val.authority_hrn+"</option>";
84                     projects.push(project_row);
85                 });
86                 $("#project").html(projects.join( "" ));
87             });
88         }else{
89             $("#project").html(projects.join( "" ));
90         }
91     }else{
92         my_projects = JSON.parse(localStorage.getItem('projects'));
93         $.each( my_projects, function( i, val ) {
94             project_row = "<option value='"+val+"'>"+val+"</option>";
95             projects.push(project_row);
96         });
97         $("#project").html(projects.join( "" ));
98     }
99     $("#project").show();
100     $("#project_loading").hide();
101 }*/
102 </script>
103 {% endblock %}
104