Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ a70fb308

History | View | Annotate | Download (19.4 kB)

1
<!--
2
Copyright 2011 GRNET S.A. All rights reserved.
3

4
Redistribution and use in source and binary forms, with or
5
without modification, are permitted provided that the following
6
conditions are met:
7

8
  1. Redistributions of source code must retain the above
9
     copyright notice, this list of conditions and the following
10
     disclaimer.
11

12
  2. Redistributions in binary form must reproduce the above
13
     copyright notice, this list of conditions and the following
14
     disclaimer in the documentation and/or other materials
15
     provided with the distribution.
16

17
THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
POSSIBILITY OF SUCH DAMAGE.
29

30
The views and conclusions contained in the software and
31
documentation are those of the authors and should not be
32
interpreted as representing official policies, either expressed
33
or implied, of GRNET S.A.
34
-->
35

    
36
{% load i18n %}
37
<!DOCTYPE html>
38
<head>
39
    <title>{{ project }}</title>
40
    <!-- include the Tools -->
41
    <!-- jquery tools minified for deployment-->
42
    <script src="static/jquery.tools.min.js"></script>
43
    <!-- jquery tools source for JS debugging -->
44
    <!--
45
    <script src="http://flowplayer.org/tools/download/1.2.5/jquery-1.4.2.js"></script>
46
    <script src="http://flowplayer.org/tools/download/1.2.5/tabs/tabs.js"></script>
47
    <script src="http://flowplayer.org/tools/download/1.2.5/scrollable/scrollable.js"></script>
48
    <script src="http://flowplayer.org/tools/download/1.2.5/overlay/overlay.js"></script>
49
    <script src="http://flowplayer.org/tools/download/1.2.5/rangeinput/rangeinput.js"></script>
50
    <script src="http://flowplayer.org/tools/download/1.2.5/toolbox/toolbox.expose.js"></script>
51
    -->
52
    <script src="static/jquery.cookie.js"></script>
53
    <script src="static/jquery.dataTables.min.js"></script>
54
    <script src="static/synnefo.js"></script>
55
    <link rel="stylesheet" type="text/css" href="static/main.css"/>
56
    <script>
57
        //populate available image icons array
58
        var os_icons = {{image_icons|safe}};
59

60
        // timeout value from settings.py
61
        var TIMEOUT = {{timeout}};
62
        var UPDATE_INTERVAL = {{update_interval}};
63
        var STATUSES = {
64
            'UNKNOWN'   : '{% trans "Unknown" %}',
65
            'BUILD'     : '{% trans "Building" %}',
66
            'REBOOT'    : '{% trans "Rebooting" %}',
67
            'STOPPED'   : '{% trans "Stopped" %}',
68
            'ACTIVE'    : '{% trans "Running" %}',
69
            'ERROR'     : '{% trans "Error" %}'
70
        };
71

72
        var TRANSITIONS = {
73
            'Shutting down' : '{% trans "Shutting down" %}',
74
            'Rebooting'     : '{% trans "Rebooting" %}',
75
            'Starting'      : '{% trans "Starting" %}',
76
            'Destroying'    : '{% trans "Destroying" %}'
77
        };
78

79
        // Statuses and transitions that should be displayed as active or inactive
80
        var ACTIVE_STATES = [
81
            '{% trans "Building" %}',
82
            '{% trans "Rebooting" %}',
83
            '{% trans "Running" %}',
84
            '{% trans "Shutting down" %}',
85
            '{% trans "Rebooting" %}',
86
            '{% trans "Destroying" %}'
87
        ];
88

89
        var INACTIVE_STATES = [
90
            '{% trans "Unknown" %}',
91
            '{% trans "Stopped" %}',
92
            '{% trans "Error" %}',
93
            '{% trans "Starting" %}',
94
            '{% trans "Destroying" %}'
95
        ];
96

97
        var ERRORS = {
98
            // error message header
99
            'HEADER' : '{% trans "Error" %}',
100
            // default
101
            'DEFAULT' : '{% trans "Could not contact the service. Please check your network connectivity and try again." %}',
102
            // bad request
103
            '400' : '{% trans "Malformed request." %}',
104
            // not found
105
            '404' : '{% trans "Your request has failed. Resource not found." %}',
106
            // internal server error
107
            '500' : '{% trans "There has been an Internal Error. Our administrators have been notified." %}',
108
            // service unavailable
109
            '501' : '{% trans "This server has not been implemented yet." %}',
110
            // service unavailable
111
            '502' : '{% trans "Bad Gateway error." %}',
112
            // service unavailable
113
            '503' : '{% trans "This service is unavailable right now, please try again later." %}',
114
            // no server handshake
115
            '0' : '{% trans "Could not contact the server." %}',
116
            // no images found
117
            'NO_IMAGES' : '{% trans "Cannot show the Create machine wizard: No images found." %}',
118
            // no flavors found
119
            'NO_FLAVORS' : '{% trans "Cannot show the Create machine wizard: No machine configurations found." %}',
120
            // error box title
121
            'GENERIC_POPUP_HEADER' : '{% trans "Something seems to have gone wrong :( Here is what happened:" %}',
122
            // no advanced details
123
            'NO_DETAILS' : '{% trans "Νο advanced details provided" %}'
124
        };
125

126
        var SUCCESS = {
127
            'HEADER' : '{% trans "Success" %}',
128
            'DEFAULT' : '{% trans "Your request has been succefully executed." %}',
129
            'PASSWORD' : '{% trans "Password:" %}',
130
            'CREATE_VM_SUCCESS' : '{% trans "Success" %}',
131
            'CREATE_VM_SUCCESS_ONE' : '{% trans "Your new machine is now buidling... (this might take a few minutes)" %}',
132
            'CREATE_VM_SUCCESS_TWO' : '{% trans "Write down your password now:" %}',
133
            'CREATE_VM_SUCCESS_THREE' : '{% trans "You will need this later to connect to your machine." %}',
134
            'CREATE_VM_SUCCESS_FOUR' : '{% trans "After closing this window you will NOT be able to retrieve it again." %}'
135
        };
136

137
        // ajax error checking
138
        function ajax_error(status, serverID, action, responseText) {
139
            $('#error-success').addClass('error');
140
            $('#error-success').removeClass('success');
141

142
            var serverName = '';
143

144
            if (serverID != undefined) {
145
                // standard view
146
                serverName = $("#"+serverID).find("span.name").text();
147
                if (serverName == "") { // list view
148
                    serverName = $("#"+serverID).parent().parent().find("span.name").text();
149
                }
150
            }
151

152
            // prepare the error message
153
            $("#error-success h3").text(ERRORS['HEADER']);
154
            if (responseText != undefined){
155
                var errors = parse_error(responseText, status), details = '';
156
                if (serverName){
157
                    serverName="<p>{% trans "Server" %}: " + serverName + "</p>";
158
                }
159
                if ((errors[0].details == undefined) || (errors[0].details == "")) {
160
                    details = ERRORS["NO_DETAILS"];
161
                } else {
162
                    details = errors[0].details;
163
                }
164

165
                //$("#error-success div.popup-body-inner").html("<p>"+(errors[0].message || ERRORS[errors[0].code]) +"</p>"+serverName +"<p><strong>{% trans "Action" %}:</strong> " + action + "</p><p><strong>{% trans "Code" %}:</strong> " + errors[0].code + "</p>" + details);
166
                $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
167
                $("#error-success .popup-header").addClass("popup-header-error");
168
                $("#error-success").addClass("popup-border-error");
169
                $("#error-success .password-container").hide();
170
                $("#error-success .popup-details").addClass("popup-details-error");
171
                $("#error-success .popup-separator").addClass("popup-separator-error");
172
                $("#error-success .popup-details").html("<p>"+(errors[0].message || ERRORS[errors[0].code]) +"</p>"+serverName +"<p>{% trans "Action" %}: " + action + "</p><p>{% trans "Code" %}: " + errors[0].code + "<p><a class='expand-details' href='#'>{% trans 'Details' %}</a><div class='more-details'>" + details + "</div></p>");
173
            } else if (ERRORS[status] != undefined) {
174
                if (serverID == undefined){
175
                    //eg no_images, no_flavors cases
176
                    $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
177
                    $("#error-success .popup-header").addClass("popup-header-error");
178
                    $("#error-success").addClass("popup-border-error");
179
                    $("#error-success .password-container").hide();
180
                    $("#error-success .popup-details").addClass("popup-details-error");
181
                    $("#error-success .popup-separator").addClass("popup-separator-error");
182
                    $("#error-success .popup-details").html("<p>"+ ERRORS[status] +"</p></div></p>");
183
                } else {
184
                    $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
185
                    $("#error-success .popup-header").addClass("popup-header-error");
186
                    $("#error-success").addClass("popup-border-error");
187
                    $("#error-success .password-container").hide();
188
                    $("#error-success .popup-details").addClass("popup-details-error");
189
                    $("#error-success .popup-separator").addClass("popup-separator-error");
190
                    $("#error-success .popup-details").html("<p>"+ ERRORS[status] +"</p>"+serverName +"</div></p>");
191
                }
192
            } else {
193
                    $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
194
                    $("#error-success .popup-header").addClass("popup-header-error");
195
                    $("#error-success").addClass("popup-border-error");
196
                    $("#error-success .password-container").hide();
197
                    $("#error-success .popup-details").addClass("popup-details-error");
198
                    $("#error-success .popup-separator").addClass("popup-separator-error");
199
            }
200
            $("#error-success p:first").css("padding-bottom","10px");
201
            $("#error-success p:first").css("color","#800000");
202
            $("#error-success div.more-details").hide();
203
            $("#error-success a.expand-details").live('click', function() {
204
                $(this).parent().parent().find("div.more-details").slideToggle(600);
205
                return false;
206
                });
207
            //stop the progress icon and hide the wizard
208
            if (action != undefined) {
209
                if (action == 'Create VM') {
210
                    $('#wizard #start').text('{% trans "Create VM" %}');
211
                    $("#wizard").hide();
212
                } else if (action == 'Create network') {
213
                    $('#networks-wizard').hide();
214
                } else if (action == 'Add server to network') {
215
                    $('#add-machines-wizard').hide();
216
                }
217
            }
218

219
            // bring up error notification
220
            var triggers = $("a#notification").overlay({
221
                // some mask tweaks suitable for modal dialogs
222
                mask: {
223
                    color: '#ebecff',
224
                    opacity: '0.9'
225
                },
226
                top: 'center',
227
                closeOnClick: false,
228
                oneInstance: false,
229
                load: false,
230
                onClose: function(){
231
                    // With partial refresh working properly,
232
                    // it is no longer necessary to refresh the whole page
233
                    // choose_view();
234
                }
235
            });
236
            $("a#notification").data('overlay').load();
237
            return false;
238
        }
239

240
        // ajax success checking
241
        function ajax_success(status, password) {
242
            // prepare the error message
243
            // bring up success notification
244
            $('#error-success').addClass('success');
245
            $('#error-success').removeClass('error');
246
            if (status != undefined && SUCCESS[status]) {
247
                if (password != undefined && status == "CREATE_VM_SUCCESS") {
248

249
                    //stop the progress icon and hide the wizard
250
                    $('#wizard #start').text('{% trans "Create VM" %}');
251
                    $("#wizard").hide();
252

253
                    $("#error-success h3 span.header-box").text(SUCCESS[status]);
254
                    var CREATE_VM_SUCCESS_MSG = SUCCESS["CREATE_VM_SUCCESS_THREE"] + '<br / >'
255
                        + SUCCESS["CREATE_VM_SUCCESS_FOUR"];
256
                    $("#error-success div.machine-now-building").html(SUCCESS["CREATE_VM_SUCCESS_ONE"]);
257
                    $("#error-success .popup-header").removeClass("popup-header-error");
258
                    $("#error-success").removeClass("popup-border-error");
259
                    $("#error-success .popup-details").removeClass("popup-details-error");
260
                    $("#error-success .popup-separator").removeClass("popup-separator-error");
261
                    $("#error-success .password-container").show();
262

263
                    $("#error-success .popup-details").html("</div><div class=\"write-password-details\">" + CREATE_VM_SUCCESS_MSG +"</div>");
264
                    $("#error-success div.password").html("<div class=\"write-password\">"+ SUCCESS["CREATE_VM_SUCCESS_TWO"] + "<div class=\"write-password-password\">" + password +"</div></div>");
265
                    //$("#error-success div.write-password").html(SUCCESS["CREATE_VM_SUCCESS_TWO"]);
266
                    //$("#error-success div.write-password-details").html(CREATE_VM_SUCCESS_MSG);
267
                } else {
268
                    $("#error-success h3").text(SUCCESS['HEADER']);
269
                    $("#error-success div.popup-body-inner").text("<p>" + SUCCESS[status] + "</p>");
270
                }
271
            } else {
272
                $("#error-success h3").text(SUCCESS['HEADER']);
273
                $("#error-success div.popup-body-inner").html("<p>" + SUCCESS['DEFAULT'] + "</p>");
274
            }
275

276
            var triggers = $("a#notification").overlay({
277
                // some mask tweaks suitable for modal dialogs
278
                mask: {
279
                    color: '#ebecff',
280
                    opacity: '0.9'
281
                },
282
                top: 'center',
283
                closeOnClick: false,
284
                oneInstance: false,
285
                load: false,
286
                onClose: function(){
287
                    // With partial refresh working properly,
288
                    // it is no longer necessary to refresh the whole page
289
                    // choose_view();
290
                }
291
            });
292
            $("a#notification").data('overlay').load();
293
            return false;
294
        }
295
    </script>
296
</head>
297
<body>
298
    <div id="container">
299
        <div id='header'>
300
            <div id='user'>
301
                <a href="#">{% trans "username" %}</a>
302
                {% get_available_languages as LANGUAGES %}
303
                {% for lang in LANGUAGES %}
304
                    &nbsp;|&nbsp;
305
                    <a {% if  == lang.0 %}class="current_lang" {% else %}  href="/lang/?l={{lang.0}}" {% endif %}>{{lang.0}}</a>
306
                {% endfor %}
307
            </div>
308
            <div class="header-logo">
309
                <a href="/">
310
                    <img src="static/okeanos.png" alt="okeanos"/>
311
                </a>
312
            </div>
313
        </div>
314
        <div id="content">
315
            <div id="wrapper">
316
                <!-- tabs -->
317
                <div class="tab-name">{% trans "machines" %}</div>
318
                <div class="tab-separator"></div>
319
                <ul class="css-tabs">
320
                    <li><a href="machines" title="{% trans "manage  virtual " %}" class="primary" id="machines">
321
                        <img src="static/machines-icon.png" /></a></li><div class="tab-separator"></div>
322
                    <li><a href="networks" title="{% trans "configure " %}" class="primary" id="networks">
323
                        <img src="static/networks-icon.png" /></a></li><div class="tab-separator"></div>
324
                    <li><a href="disks" title="{% trans "manage  storage " %}" class="primary" id="disks">
325
                        <img src="static/disks-icon.png" /></a></li>
326
                </ul>
327
                <div class="css-panes">
328
                    <div id="machines-pane" class="pane" style="display:block">{% include "machines.html" %}</div>
329
                    <div id="networks-pane" class="pane"></div>
330
                    <div id="disks-pane" class="pane"></div>
331
                </div>
332
                <!-- base notification for error/success reporting -->
333
                <a id="notification" rel="#error-success" href="#"></a>
334

    
335
                <div class="modal" id="error-success">
336
                    <h3 class="popup-header">
337
                        <span class="header-box"></span>
338
                    </h3>
339
                    <div class="popup-body">
340
                        <div class="popup-body-inner">
341
                            <div class="machine-now-building"></div>
342
                            <div class="popup-separator"></div>
343
                            <div class="password-container">
344
                                <div class="password-header"></div>
345
                                <div class="password"></div>
346
                            </div>
347
                            <div class="popup-details">
348
                                <div class="write-password"></div>
349
                                <div class="write-password-details">{% trans "More details about the result"%}</div>
350
                            </div>
351
                        </div>
352
                    </div>
353
                </div>
354
            </div>
355
        </div>
356
        {% include "footer.html" %}
357
    </div>
358

    
359
    <!-- activate tabs with JavaScript -->
360
    <script>
361

362
        $(function() {
363
            // check pane cookie to select the initial pane
364
            var initial = 0, pane = $.cookie("pane");
365
            if (pane > 0)
366
                initial = pane;
367
            //alert(initial);
368
            $("ul.css-tabs").tabs("div.css-panes div.pane", {
369
                initialIndex: initial,
370
                onBeforeClick: function(event, i) {
371
                    // get the pane to be opened
372
                    var pane = this.getPanes().eq(i);
373
                    pane.text('');
374
                    //change the displaying title
375
                    $(".tab-name").text(this.getTabs().eq(i).attr("href"));
376
                    // load it with a page specified in the tab's href attribute
377
                    pane.load(this.getTabs().eq(i).attr("href"),function(){if (!i) {choose_view()}});
378
                }
379
            });
380
        });
381
        
382
        // set pane cookie whenever the user clicks on a different pane
383
        $("ul.css-tabs a").click(function(i){
384
            $.cookie("pane", $("ul.css-tabs a").index(this));
385
        });
386
        
387
        //change menu title on hover
388
        $("ul.css-tabs li").hover(
389
            function () {
390
                if ($(this).find("a.current").length == 0) {
391
                    $(this).parent().parent().find(".tab-name").text($(this).find("a").attr("href"));
392
                }
393
            },
394
            function () {
395
                $(this).parent().parent().find(".tab-name").text($(this).parent().find("a.current").attr("href"));
396
            }
397
        );
398
        
399
    </script>
400
</body>
401
</html>