7f9bd44921df4a229e232150e9ef29264e936f95
[unfold.git] / portal / templates / base.html
1 {% load portal_filters %}
2 {# This is required by insert_above #}{% insert_handler %}<!DOCTYPE html>
3 <html lang="en">
4 <head>
5 <title>{{theme}} portal - {{ section }}</title>
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
8 <!--Selecting favicon based on theme. Add more for other portals -->
9 {% if theme == "fed4fire" %}
10     <link rel="shortcut icon" href="/static/img/fed4fire_favicon.ico">
11 {% elif theme == "smartfire" %}
12     <link rel="shortcut icon" href="/static/img/smartfire_favicon.ico">
13 {% else %}
14     <link rel="shortcut icon" href="/static/img/favicon.ico">
15 {% endif %}
16
17 {# This is where insert_str will end up #}{% media_container prelude %}
18 {% include 'messages-transient-header.html' %}
19 <script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script>
20 <!--<script src="{{ STATIC_URL }}js/jquery-ui.js"></script>-->
21 <script src="{{ STATIC_URL }}js/jquery.dataTables.min.js"></script>
22 <script src="{{ STATIC_URL }}js/jquery.qtip.min.js"></script>
23 <script src="{{ STATIC_URL }}js/bootstrap.datatables.js"></script>
24 <script src="{{ STATIC_URL }}js/common.functions.js"></script>
25 <script src="{{ STATIC_URL }}js/myslice.js"></script>
26 <script src="{{ STATIC_URL }}js/myslice-ui.js"></script>
27
28 <script type="text/javascript" src="{{STATIC_URL}}/js/spin-presets.js"></script>
29 <script type="text/javascript" src="{{STATIC_URL}}/js/spin.min.js"></script>
30 <script type="text/javascript" src="{{STATIC_URL}}/js/jquery.spin.js"></script>
31
32 <style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style>
33 {{ header_prelude }}
34 {% block head %} {% endblock head %}
35 {# let's add these ones no matter what #}
36 {#NOTE: DO NOT ADD JQUERY-UI JS & CSS HERE. IT BREAKS THE RESOURCE BROWSING PAGE -- DETAILS WITH JORDAN AUGE#}
37 {% insert_str prelude "js/jquery.min.js" %}
38 {% insert_str prelude "js/angular/angular.min.js" %}
39 {% insert_str prelude "js/jquery.html5storage.min.js" %}
40 {% insert_str prelude "js/messages-runtime.js" %}
41 {% insert_str prelude "js/class.js" %}
42 {% insert_str prelude "js/plugin-helper.js" %}
43 {% insert_str prelude "js/mustache.js" %}
44 {% insert_str prelude "js/hashtable.js" %}
45 {% insert_str prelude "js/plugin.js" %}
46 {% insert_str prelude "js/manifold.js" %}
47 {% insert_str prelude "css/manifold.css" %}
48 {% insert_str prelude "css/plugin.css" %}
49 {% insert_str prelude "js/bootstrap.js" %}
50 {% insert_str prelude "css/bootstrap.css" %}
51 {% insert_str prelude "js/bootstrap-datepicker.js" %}
52 {% insert_str prelude "css/datepicker.css" %}
53 {% insert_str prelude "js/bootstrap-slider.js" %}
54 {% insert_str prelude "css/slider.css" %}
55 {% insert_str prelude "css/topmenu.css" %}
56 {% insert_str prelude "js/logout.js" %}
57 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/{{ theme }}.css">
58 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/myslice.css">
59 <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.qtip.min.css">
60
61
62 <script type="text/javascript">
63 /*
64 XXX TODO: session
65 This list of slices should go into SESSION !
66 */
67 $(document).ready(function() {
68 {% if username %}
69     myslice.login(function(){
70         user = myslice.get_user();
71
72         var slices = [];
73         if($.isEmptyObject(user)){
74             $("div#home-slice-list").html(
75                         "<div>You do not yet have a slice</div>");
76             $("ul#dropdown-slice-list").append("<li>no slice</li>");
77             slices.push("no slice");
78         }else{
79             slices = user.slices;
80             {% if theme != "fed4fire" or "onelab" in theme %}
81             drawSlices(slices);
82             {% endif %}
83         }
84         {% if theme == "fed4fire" or "onelab" in theme%}
85         p = myslice.get_projects();
86         if(p != null){
87             //drawProjects(p);
88             drawProjectsTree(p,slices);
89         }
90         {% endif %}
91     });
92
93     function drawSlices(slices){
94         var items = [];
95         console.log(slices);
96         $.each( slices, function(i, val) {
97             items.push( "<li><a href=\"/resources/"+val+"\" title='Add resources to slice "+val+"'><img src='/static/img/icon_slices_small.png' style='width: 12px;'>" + val + "</a></li>" );
98         });
99         $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
100         $("ul#dropdown-slice-list").append(items.join( "" ));
101     }
102     
103     {% if theme == "fed4fire" or "onelab" in theme%}
104     function drawProjects(projects){
105         var items = [];
106                 
107         $.each( projects, function(i, val) {
108             items.push( "<li><a href=\"/portal/project/"+val+"\" title='Manage project "+val+"'>" + val + "</a></li>" );
109         });
110         $("div#home-project-list").html($( "<ul/>", { html: items.join( "" ) }));
111         $("ul#dropdown-project-list").append(items.join( "" ));
112     }
113     function drawProjectsTree(projects,slices) {
114         var items = [];
115         var items_sl = [];
116         var slices_no_project = [];
117         $.each( projects, function(i, p) {
118             $.each( slices, function(y, s) {
119                 if (s.match('^' + escapeRegExp(p))) {
120                     slicename = s.replace(p + '.','')
121                     items_sl.push( "<li><a href=\"/resources/" + s + "\" title='Add resources to slice "+slicename+"'><img src='/static/img/icon_slices_small.png' style='width: 12px;'>  " + slicename + "</a></li>" );
122                 }else if(s.split('.').length < 4){
123                      slices_no_project.push( "<li><a href=\"/resources/" + s + "\" title='Add resources to slice "+s+"'><img src='/static/img/icon_slices_small.png' style='width: 12px;'>  " + s + "</a></li>" );
124                 }
125             });
126             el = "<li><a href=\"/portal/project/" + p + "\" title='Manage project "+p+"' >" + p + "</a>";
127             if (items_sl.length > 0) {
128                 el += "<ul>" + items_sl.join( "" ) + "</ul>";
129             }
130             el += "</li>";
131             items.push(el);
132             items_sl = [];
133         });
134         if (projects.length == 0){
135             $.each( slices, function(y, s) {
136                 slices_no_project.push( "<li><a href=\"/resources/" + s + "\" title='Add resources to slice "+s+"'><img src='/static/img/icon_slices_small.png' style='width: 12px;'>  " + s + "</a></li>" );
137             });
138         }
139         if (slices_no_project.length > 0) {
140             elm = '<li>other slices <span class="glyphicon glyphicon-info-sign" title="these are <b>legacy slices</b> from now on, slices must be created within a project">&nbsp;</span>';
141             elm += "<ul>" + slices_no_project.join( "" ) + "</ul>";
142             elm += "</li>";
143             items.push(elm);
144         }
145
146         $("div#home-project-tree").html($( "<ul/>", { html: items.join( "" ) }));
147         if (projects.length > 0) {
148             $('.dashboard-create-slice').show();
149         }
150     }
151     
152     window.setTimeout(function() {
153         $('.projects-loading').hide();
154     },20000);
155     {% endif %}
156 {% endif %}
157         jQuery('[title!=""]').qtip();
158 });
159 </script>
160 </head>
161 <body ng-app="ManifoldApp">
162 <div class="row">
163 {% widget '_widget-message.html' %}
164 </div>
165 {% block container %}
166         {% block topmenu %}
167         {% widget "_widget-topmenu.html" %}
168         {% endblock topmenu %}
169         {% block base_content %}
170         {% endblock %}
171 {% endblock container %}
172 {% widget "_footer.html" %}
173 <div class="loading">
174         <div><img src="{{ STATIC_URL }}/img/loading.gif" /> Loading...</div>
175         <div>&nbsp;</div>
176         <div class="message"></div>
177 </div>
178 </body>
179 </html>