Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
[unfold.git] / portal / templates / fed4fire / fed4fire_projectrequest_view.html
1 {% extends "layout.html" %}
2 {% load i18n %}
3
4 {% block content %}
5 <br />
6 <div class="row">
7     <div class="col-md-12">
8         <ul class="nav nav-tabs nav-section">
9             <li class="active"><a href="#existing">Join existing Project</a></li>
10             <li><a href="#new">Create new Project</a></li>
11             
12         </ul>
13     </div>
14 </div>
15
16 {% if errors %}
17 <div class="row">
18     <div class="col-md-12">
19     <ul class="error">
20       {% for error in errors %}
21       <li>{{ error }}</li>
22       {% endfor %}
23     </ul>
24     </div>
25 </div>
26 {% endif %}
27
28 <div class="container tab-content">
29     
30         <div class="tab-pane active" id="existing"> 
31         <div class="row">
32             <div class="col-md-6">
33                  <h3>Join an existing Project</h3>
34             </div>
35             <div class="col-md-6">
36                  <h3>List of projects you are part of</h3>
37             </div>
38         </div>
39         <div class="row">
40             <div class="col-md-6">
41                 <form role="form" method="post">
42                 {% csrf_token %}
43                 <select id="projects"></select> <button type="submit" class="btn">Join</button>
44                 </form>
45             </div>
46             <div class="col-md-6">
47                 <table class="table project-list">
48                     {% for pending in pending_projects %}
49                     <tr><td>(PENDING) {{ pending.project_name }}</td><td>{{ pending.authority_hrn }}</td><td>{{ pending.created|date:"d/m/Y" }}</td></tr>
50                     {% endfor %}
51                 </table>
52             </div>
53         </div>
54     </div>
55     
56     <div class="tab-pane" id="new"> 
57         <div class="row">
58             <div class="col-md-12">
59                  <h3>Create a new Project</h3>
60             </div>
61         </div>
62     
63         
64         <div class="row">
65             <div class="col-md-12">
66                 <form role="form" method="post" action="/portal/project_request">
67                 {% csrf_token %}
68                   <div class="form-group">
69                     <input type="text" name="project_name" value="" placeholder="Name" required>
70                   </div>
71                   <div class="form-group">
72                     <select id="org_name" name="authority_name" class="form-control" style="width:590px" value="{{ organization }}" required> 
73                     {% if authorities %}
74                         {% for authority in authorities %}
75                             {% if authority.name %}
76                                 <option value="{{ authority.authority_hrn }}">{{authority.name}}</option>
77                             {% else %}
78                                 <option value="{{ authority.authority_hrn }}">{{authority.authority_hrn}}</option>
79                             {% endif %}
80                         {% endfor %} 
81                     {% endif %}
82                     </select>
83                   </div>
84                   
85                   
86                   <div class="form-group">
87                     <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Description" style="width:300px" title="Purpose of your project (informative)" required="required"></textarea>
88                   </div>
89                   <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Send Request</button>
90                 </form>
91         
92             </div>
93         </div>
94     </div>
95     
96 </div>
97                 
98 <script>
99 $(document).ready(function() {
100     var myprojects = localStorage.getItem('projects');
101     console.log(myprojects);
102     if (myprojects) {
103         
104     } else {
105         $('.project-list').html('<tr><td>no projetcs</td></tr>');
106     }
107     
108     $('.nav-tabs a').click(function (e) {
109         e.preventDefault();
110         $(this).tab('show');
111     });
112     $.post("/rest/myslice:authority/",{'fields':['authority_hrn','pi_users'],'filters':{'authority_hrn':'CONTAINS{{ authority_hrn }}' }}, function( data ) {
113        
114         var projects = [];
115         project_row = "<option value=''> - </option>";
116         projects.push(project_row);
117        
118         $.each( data, function( key, val ) {
119             console.log(val);
120             project_row = "<option value='"+val.authority_hrn+"'>"+val.authority_hrn+"</option>";
121             projects.push(project_row);
122         });
123         $("#projects").html(projects.join( "" ));
124     });
125 /*
126         
127         $("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
128                 var jsonData = JSON.parse(data);
129         $(this).attr("value", jsonData[0]['parent_authority']);
130     });
131         $("#authority_hrn").val("{{authority_name}}");
132         var availableTags = [
133     {% if authorities %}
134         {% for authority in authorities %}
135             {% if authority.name %}
136                 {value:"{{ authority.name }}",label:"{{authority.name}}"},
137                         // to show only full name
138             {% else %}
139                 {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
140             {% endif %}
141         {% endfor %}    
142     {% else %}
143         {value:"",label:"No authority found !!!"}
144     {% endif %}
145     ];
146         // sorting the list
147         availableTags.sort(function(a,b){
148                 var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase();
149                 if (nameA < nameB) {
150                 return -1;
151                 }
152                 if (nameA > nameB) {
153                 return 1;
154                 }
155         return 0;
156         }); 
157     $( "#authority_hrn" ).autocomplete({
158       source: availableTags,
159       minLength: 0,
160       select: function( event, ui ) {console.log(jQuery(this));}
161     });
162 */
163         $("#submit_pi").click(function() {
164                 localStorage.clear();
165         });
166         // auto-complete the form
167     //jQuery("#org_name").combobox();
168
169 });
170 </script>
171 {% endblock %}
172