Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into fibre
[myslice.git] / portal / templates / fibre / fibre_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">
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>
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                                 {%if 'is_pi'  in pi %}
38                                 <input style='display:none' type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization" 
39                                 title="An authority responsible for vetting your slice" required="required" readonly>
40                                 {%else%}
41                             <input style='display:none' type="text" class="form-control" display=none  id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;" 
42                                 title="An authority responsible for vetting your slice" required="required" readonly>
43                                 {%endif%}
44                           </div>
45                           <div class="form-group">
46                             <input type="text" class="form-control" name="exp_url" id="exp_url" style="width:300px" placeholder="Experiment URL (if one exists)"
47                                 title="Please provide the url of your experiment if you have one." value="{{exp_url}}">
48                           </div>
49                           <div class="form-group">
50                                 <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Experiment purpose" style="width:300px" 
51                                 title="Purpose of your experiment (informative)" required="required">{{ purpose }}</textarea>
52                           </div>
53                           <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
54                           <button type="button" class="btn btn-onelab" onclick="window.location.href='/'">Home</button>
55                         </form>
56         
57                 </div>
58         </div>
59                 
60 <script>
61 jQuery(document).ready(function(){
62         
63         /*$("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
64                 var jsonData = JSON.parse(data);
65         $(this).attr("value", jsonData[0]['parent_authority']);
66     });*/
67     console.log("test");
68     test = "{{authority.name}}";
69     if(test){
70         console.log("true");
71             $("#authority_hrn").val("{{authority_name}}");
72     }else{
73         console.log("false");
74             $("#authority_hrn").val("{{authority_hrn}}");
75     }
76
77         var availableTags = [
78     {% if authorities %}
79         {% for authority in authorities %}
80             {% if authority.name %}
81                 {value:"{{ authority.name }}",label:"{{authority.name}}"},
82             {% else %}
83                 {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
84             {% endif %}
85         {% endfor %}    
86     {% else %}
87         {value:"",label:"No authority found !!!"}
88     {% endif %}
89     ];
90         // sorting the list
91         availableTags.sort(function(a,b){
92                 var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase();
93                 if (nameA < nameB) {
94                 return -1;
95                 }
96                 if (nameA > nameB) {
97                 return 1;
98                 }
99         return 0;
100         }); 
101     $( "#authority_hrn" ).autocomplete({
102       source: availableTags,
103       minLength: 0,
104       select: function( event, ui ) {console.log(jQuery(this));}
105     });
106 });
107 </script>
108 {% endblock %}
109