Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ cb748f1f

History | View | Annotate | Download (22.6 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
<html>
37

    
38
{% load i18n %}
39
<!DOCTYPE html>
40
<head>
41
    <title>~okeanos</title>
42
    <!-- include the Tools -->
43
    <!-- jquery tools minified for deployment-->
44
    <script src="static/jquery.tools.min.js"></script>
45
    <!-- jquery tools source for JS debugging -->
46
    <!--
47
    <script src="http://flowplayer.org/tools/download/1.2.5/jquery-1.4.2.js"></script>
48
    <script src="http://flowplayer.org/tools/download/1.2.5/tabs/tabs.js"></script>
49
    <script src="http://flowplayer.org/tools/download/1.2.5/scrollable/scrollable.js"></script>
50
    <script src="http://flowplayer.org/tools/download/1.2.5/overlay/overlay.js"></script>
51
    <script src="http://flowplayer.org/tools/download/1.2.5/rangeinput/rangeinput.js"></script>
52
    <script src="http://flowplayer.org/tools/download/1.2.5/toolbox/toolbox.expose.js"></script>
53
    -->
54
    <script src="static/jquery.cookie.js"></script>
55
    <script src="static/jquery.client.js"></script>
56
    <script src="static/json2.js"></script>
57
    <script src="static/jquery.dataTables.min.js"></script>
58
    <script src="static/invitations.js"></script>
59
    <script src="static/synnefo.js"></script>
60

    
61
    <link rel="stylesheet" type="text/css" href="static/main.css"/>
62
    <!--[if IE]><style type="text/css" media="all">@import url(static/ie.css);</style><![endif]-->
63
    <script>
64
        // empty object for console to avoid errors in browsers that don't support it
65
        if (!window.console) {window.console = {}; window.console.log = window.console.info = window.console.debug =
66
            window.console.error = function() {}};
67

68
        //populate available image icons array
69
        var os_icons = {{image_icons|safe}};
70

71
        // timeout value from settings.py
72
        var TIMEOUT = {{timeout}};
73
        var UPDATE_INTERVAL = {{update_interval}};
74
        var LOGOUT_REDIRECT = undefined;
75
        var INVITATIONS_URL = "{% url invitations %}"
76
        var INVITATIONS_TITLE = "{% trans "Invitations" %}"
77

78
        // server statuses and transitions
79
        var STATUSES = {
80
            'UNKNOWN'   : '{% trans "Unknown" %}',
81
            'BUILD'     : '{% trans "Building" %}',
82
            'REBOOT'    : '{% trans "Rebooting" %}',
83
            'STOPPED'   : '{% trans "Stopped" %}',
84
            'ACTIVE'    : '{% trans "Running" %}',
85
            'ERROR'     : '{% trans "Error" %}'
86
        };
87

88
        var TRANSITIONS = {
89
            'Shutting down' : '{% trans "Shutting down" %}',
90
            'Rebooting'     : '{% trans "Rebooting" %}',
91
            'Starting'      : '{% trans "Starting" %}',
92
            'Destroying'    : '{% trans "Destroying" %}',
93
            'Connecting'    : '{% trans "Connecting" %}',   // used only in networks
94
            'Disconnecting' : '{% trans "Disconnecting" %}' // used only in networks
95
        };
96

97
        // Server statuses and transitions that should be displayed as active or inactive
98
        var ACTIVE_STATES = [
99
            '{% trans "Building" %}',
100
            '{% trans "Rebooting" %}',
101
            '{% trans "Running" %}',
102
            '{% trans "Shutting down" %}',
103
            '{% trans "Rebooting" %}',
104
            '{% trans "Destroying" %}'
105
        ];
106

107
        var INACTIVE_STATES = [
108
            '{% trans "Unknown" %}',
109
            '{% trans "Stopped" %}',
110
            '{% trans "Error" %}',
111
            '{% trans "Starting" %}',
112
            '{% trans "Destroying" %}'
113
        ];
114

115
        // Network statuses and transitions
116
        var NET_STATES = {
117
            'ACTIVE'        : '{% trans "Private network" %}',  // this comes from the API
118
            'DELETED'       : '{% trans "Deleted" %}',          // this comes from the API
119
            'Destroying'    : '{% trans "Destroying" %}',
120
            'Connecting'    : '{% trans "Connecting" %}',
121
            'Disconnecting' : '{% trans "Disconnecting" %}'
122
        };
123

124
        var ERRORS = {
125
            // error message header
126
            'HEADER' : '{% trans "Error" %}',
127
            // default
128
            'DEFAULT' : '{% trans "Could not contact the service. Please check your network connectivity and try again." %}',
129
            // bad request
130
            '400' : '{% trans "Malformed request." %}',
131
            // not found
132
            '404' : '{% trans "Your request has failed. Resource not found." %}',
133
            // internal server error
134
            '500' : '{% trans "There has been an Internal Error. Our administrators have been notified." %}',
135
            // service unavailable
136
            '501' : '{% trans "This server has not been implemented yet." %}',
137
            // service unavailable
138
            '502' : '{% trans "Bad Gateway error." %}',
139
            // service unavailable
140
            '503' : '{% trans "This service is unavailable right now, please try again later." %}',
141
            // no server handshake
142
            '0' : '{% trans "Could not contact the server." %}',
143
            // no images found
144
            'NO_IMAGES' : '{% trans "Cannot show the Create machine wizard: No images found." %}',
145
            // no flavors found
146
            'NO_FLAVORS' : '{% trans "Cannot show the Create machine wizard: No machine configurations found." %}',
147
            // error box title
148
            'GENERIC_POPUP_HEADER' : '{% trans "Something seems to have gone wrong :( Here is what happened:" %}',
149
            // no advanced details
150
            'NO_DETAILS' : '{% trans "Νο advanced details provided" %}'
151
        };
152

153
        var SUCCESS = {
154
            'HEADER' : '{% trans "Success" %}',
155
            'DEFAULT' : '{% trans "Your request has been succefully executed." %}',
156
            'PASSWORD' : '{% trans "Password:" %}',
157
            'CREATE_VM_SUCCESS' : '{% trans "Success" %}',
158
            'CREATE_VM_SUCCESS_ONE' : '{% trans "Your new machine is now buidling... (this might take a few minutes)" %}',
159
            'CREATE_VM_SUCCESS_TWO' : '{% trans "Write down your password now:" %}',
160
            'CREATE_VM_SUCCESS_THREE' : '{% trans "You will need this later to connect to your machine." %}',
161
            'CREATE_VM_SUCCESS_FOUR' : '{% trans "After closing this window you will NOT be able to retrieve it again." %}'
162
        };
163

164
        var VARIOUS = {
165
            'CONFIRM' : '{% trans "Confirm" %}',
166
            'CANCEL' : '{% trans "Cancel" %}',
167
            'APPLY' : '{% trans "Apply" %}',
168
            'OFF' : '{% trans "Off" %}',
169
            'ON' : '{% trans "On" %}'
170
        };
171

172
        // ajax error checking
173
        function ajax_error(status, serverID, action, responseText) {
174
             // close existing overlays to begin with
175
            close_all_overlays();
176
            // clear old deferred calls (stops all auto-updates)
177
            clearTimeout(deferred);
178

179
            $('#error-success').addClass('error');
180
            $('#error-success').removeClass('success');
181

182
            var serverName = '';
183

184
            if (serverID !== undefined) {
185
                // standard view
186
                serverName = $("#" + serverID).find("span.name").text();
187
                if (serverName === "") { // list view
188
                    serverName = $("#" + serverID).parent().parent().find("span.name").text();
189
                }
190
            }
191

192
            // prepare the error message
193
            $("#error-success h3").text(ERRORS['HEADER']);
194
            if (responseText !== undefined) {
195
                var errors = parse_error(responseText, status), details = '';
196
                if (serverName) {
197
                    serverName = "<p>{% trans "Server" %}: " + serverName + "</p>";
198
                }
199
                if ((errors[0].details === undefined) || (errors[0].details === "")) {
200
                    details = ERRORS["NO_DETAILS"];
201
                } else {
202
                    details = errors[0].details;
203
                }
204

205
                $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
206
                $("#error-success .popup-header").addClass("popup-header-error");
207
                $("#error-success").addClass("popup-border-error");
208
                $("#error-success .password-container").hide();
209
                $("#error-success .popup-details").addClass("popup-details-error");
210
                $("#error-success .popup-separator").addClass("popup-separator-error");
211
                $("#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>");
212
            } else if (ERRORS[status] !== undefined) {
213
                if (serverID === undefined) {
214
                    //eg no_images, no_flavors cases
215
                    $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
216
                    $("#error-success .popup-header").addClass("popup-header-error");
217
                    $("#error-success").addClass("popup-border-error");
218
                    $("#error-success .password-container").hide();
219
                    $("#error-success .popup-details").addClass("popup-details-error");
220
                    $("#error-success .popup-separator").addClass("popup-separator-error");
221
                    $("#error-success .popup-details").html("<p>" + ERRORS[status] + "</p>");
222
                } else {
223
                    $("#error-success .machine-now-building").html(ERRORS["GENERIC_POPUP_HEADER"]);
224
                    $("#error-success .popup-header").addClass("popup-header-error");
225
                    $("#error-success").addClass("popup-border-error");
226
                    $("#error-success .password-container").hide();
227
                    $("#error-success .popup-details").addClass("popup-details-error");
228
                    $("#error-success .popup-separator").addClass("popup-separator-error");
229
                    $("#error-success .popup-details").html("<p>" + ERRORS[status] + "</p><p>" + serverName + "</p>");
230
                }
231
            } else {
232
                $("#error-success .machine-now-building").html(ERRORS["DEFAULT"]);
233
                $("#error-success .popup-header").addClass("popup-header-error");
234
                $("#error-success").addClass("popup-border-error");
235
                $("#error-success .password-container").hide();
236
                $("#error-success .popup-details").hide();
237
                $("#error-success .popup-separator").hide();
238
            }
239
            $("#error-success p:first").css("padding-bottom", "10px");
240
            $("#error-success p:first").css("color", "#800000");
241
            $("#error-success div.more-details").hide();
242
            $("#error-success a.expand-details").live('click', function () {
243
                $(this).parent().parent().find("div.more-details").slideToggle(600);
244
                return false;
245
            });
246
            //stop the progress icon and hide the wizard
247
            if (action !== undefined) {
248
                if (action === 'Create VM') {
249
                    $('#wizard #start').text('{% trans "Create VM" %}');
250
                    $("#wizard").hide();
251
                } else if (action === 'Create network') {
252
                    $('#networks-wizard').hide();
253
                } else if (action === 'Add server to network') {
254
                    $('#add-machines-wizard').hide();
255
                }
256
            }
257

258
            // bring up error notification
259
            var triggers = $("a#notification").overlay({
260
                // some mask tweaks suitable for modal dialogs
261
                mask: '#666',
262
                top: 'center',
263
                closeOnClick: false,
264
                oneInstance: false,
265
                load: false,
266
                onClose: function () {
267
                    // refresh the whole page
268
                    location.reload();
269
                }
270
            });
271

272
            // we need to give the browser some time to close the old overlays before opening the new one
273
            setTimeout("$('a#notification').data('overlay').load()",400);
274
            return false;
275
        }
276

277
        // ajax success checking
278
        function ajax_success(status, password) {
279
            // prepare the error message
280
            // bring up success notification
281
            $('#error-success').addClass('success');
282
            $('#error-success').removeClass('error');
283
            if (status !== undefined && SUCCESS[status]) {
284
                if (password !== undefined && status === "CREATE_VM_SUCCESS") {
285

286
                    //stop the progress icon and hide the wizard
287
                    $('#wizard #start').text('{% trans "Create VM" %}');
288
                    $("#wizard").hide();
289

290
                    $("#error-success h3 span.header-box").text(SUCCESS[status]);
291
                    var CREATE_VM_SUCCESS_MSG = SUCCESS["CREATE_VM_SUCCESS_THREE"] + '<br / >'
292
                        + SUCCESS["CREATE_VM_SUCCESS_FOUR"];
293
                    $("#error-success div.machine-now-building").html(SUCCESS["CREATE_VM_SUCCESS_ONE"]);
294
                    $("#error-success .popup-header").removeClass("popup-header-error");
295
                    $("#error-success").removeClass("popup-border-error");
296
                    $("#error-success .popup-details").removeClass("popup-details-error");
297
                    $("#error-success .popup-separator").removeClass("popup-separator-error");
298
                    $("#error-success .password-container").show();
299

300
                    $("#error-success .popup-details").html("</div><div class=\"write-password-details\">" + CREATE_VM_SUCCESS_MSG + "</div>");
301
                    $("#error-success div.password").html("<div class=\"write-password\">" + SUCCESS["CREATE_VM_SUCCESS_TWO"] + "<div class=\"write-password-password\">" + password + "</div></div>");
302
                    //$("#error-success div.write-password").html(SUCCESS["CREATE_VM_SUCCESS_TWO"]);
303
                    //$("#error-success div.write-password-details").html(CREATE_VM_SUCCESS_MSG);
304
                } else {
305
                    $("#error-success h3").text(SUCCESS['HEADER']);
306
                    $("#error-success div.popup-body-inner").text("<p>" + SUCCESS[status] + "</p>");
307
                }
308
            } else {
309
                $("#error-success h3").text(SUCCESS['HEADER']);
310
                $("#error-success div.popup-body-inner").html("<p>" + SUCCESS['DEFAULT'] + "</p>");
311
            }
312

313
            var triggers = $("a#notification").overlay({
314
                // some mask tweaks suitable for modal dialogs
315
                mask: '#666',
316
                top: 'center',
317
                closeOnClick: false,
318
                oneInstance: false,
319
                load: false,
320
                onClose: function () {
321
                    // With partial refresh working properly,
322
                    // it is no longer necessary to refresh the whole page
323
                    // choose_view();
324
                }
325
            });
326
            $("a#notification").data('overlay').load();
327
            return false;
328
        }
329
    </script>
330
</head>
331
<body>
332
    <div id="container">
333
        <div id='header'>
334
            <div id='user'>
335
                <div class="usermenu">
336
                    <div class="username">{{ request.user.uniq }}</div>
337
                    <ul class="useractions">
338
                        <li class="logout"><a class="action" href="#">{% trans "logout" %}</a></li>
339
                        <li class="invitations last"><a class="action" href="#">{% trans "Invitations" %}</a></li>
340
                    </ul>
341
                </div>
342
                <div class="langmenu">
343
                {% get_available_languages as LANGUAGES %}
344
                {% for lang in LANGUAGES %}
345
                    <a {% if  == lang.0 %}class="current_lang" {% else %}  href="/lang/?l={{lang.0}}" {% endif %}>{{lang.0}}</a>
346
                    {% if not forloop.last %}<span class="sep">~</span>{% endif %}
347
                    {% endfor %}
348
                </div>
349
            </div>
350
            <div class="header-logo">
351
                <a href="/">
352
                    <img src="static/okeanos.png" alt="okeanos"/>
353
                </a>
354
            </div>
355
        </div>
356
        <div id="content">
357
            <div id="wrapper">
358
                <!-- tabs -->
359
                <div class="tab-name">{% trans "machines" %}</div>
360
                <div class="tab-separator"></div>
361
                <ul class="css-tabs">
362
                    <li><a href="machines" title="{% trans "manage  virtual " %}" class="primary" id="machines">
363
                        <img src="static/machines-icon.png" /></a></li><div class="tab-separator"></div>
364
                    <li><a href="networks" title="{% trans "configure " %}" class="primary" id="networks">
365
                        <img src="static/networks-icon.png" /></a></li><div class="tab-separator"></div>
366
                    <li><a href="disks" title="{% trans "manage  storage " %}" class="primary" id="disks">
367
                        <img src="static/disks-icon.png" /></a></li>
368
                </ul>
369
                <div class="css-panes">
370
                    <div id="machines-pane" class="pane" style="display:block;"></div>
371
                    <div id="networks-pane" class="pane"></div>
372
                    <div id="disks-pane" class="pane"></div>
373
                </div>
374
            </div>
375
        </div>
376
        {% include "footer.html" %}
377
    </div>
378

    
379
    <!-- activate tabs with JavaScript -->
380
    <script>
381

382
        $(function() {
383
            // check pane cookie to select the initial pane
384
            var initial = 0, pane = $.cookie("pane");
385
            if (pane > 0)
386
                initial = pane;
387
            //alert(initial);
388
            $("ul.css-tabs").tabs("div.css-panes div.pane", {
389
                initialIndex: initial,
390
                onBeforeClick: function(event, i) {
391
                    this.getPanes().children().remove();
392
                    // get the pane to be opened
393
                    var pane = this.getPanes().eq(i);
394
                    //change the displaying title
395
                    $(".tab-name").text(this.getTabs().eq(i).attr("href"));
396
                    // load it with a page specified in the tab's href attribute
397
                    pane.load(this.getTabs().eq(i).attr("href"),function() {if (!i) {choose_view()}});
398
                }
399
            });
400
        });
401

402
        // set pane cookie whenever the user clicks on a different pane
403
        $("ul.css-tabs a").click(function(i) {
404
            $.cookie("pane", $("ul.css-tabs a").index(this));
405
        });
406

407
        //change menu title on hover
408
        $("ul.css-tabs li").hover(
409
            function () {
410
                if ($(this).find("a.current").length == 0) {
411
                    $(this).parent().parent().find(".tab-name").text($(this).find("a").attr("href"));
412
                }
413
            },
414
            function () {
415
                $(this).parent().parent().find(".tab-name").text($(this).parent().find("a.current").attr("href"));
416
            }
417
        );
418

419
        //load opera css fixes
420
        if ($.browser.opera) {
421
            $("<link/>", {
422
               rel: "stylesheet",
423
               type: "text/css",
424
               href: "static/opera.css"
425
            }).appendTo("head");
426
        }
427

428
        $(document).ready(function(){
429
            // user menu interaction
430
            var resetUserMenu = function() {
431
                $(this).removeClass("hovered");
432
                $(this).removeClass("active");
433
            }
434
            $(".usermenu").live("click", function(){
435
                $(this).addClass("active");
436
            });
437
            $(".usermenu").bind('mouseleave', resetUserMenu);
438
            $(".usermenu").live("mouseover", function(){
439
                $(this).addClass("hovered");
440
            });
441

442
            $(".usermenu li").mouseenter(function(){$(this).addClass("hovered")})
443
            $(".usermenu li").mouseleave(function(){$(this).removeClass("hovered")});
444

445
            // bind menu actions
446
            $(".usermenu .logout").click(function() {
447
                user_session_logout();
448
            });
449

450
            $(".usermenu .invitations").click(show_invitations);
451
            
452
        });
453
    </script>
454
    <!-- base notification for error/success reporting -->
455
    <a id="notification" rel="#error-success" href="#"></a>
456
    <a id="msgbox" rel="#notification-box" href="#"></a>
457

    
458
    <div class="modal" id="error-success">
459
        <h3 class="popup-header">
460
            <span class="header-box"></span>
461
        </h3>
462
        <div class="popup-body">
463
            <div class="popup-body-inner">
464
                <div class="machine-now-building"></div>
465
                <div class="popup-separator"></div>
466
                <div class="password-container">
467
                    <div class="password-header"></div>
468
                    <div class="password"></div>
469
                </div>
470
                <div class="popup-details">
471
                    <div class="write-password"></div>
472
                    <div class="write-password-details">{% trans "More details about the result"%}</div>
473
                </div>
474
            </div>
475
        </div>
476
    </div>
477

    
478
    <div class="modal" id="notification-box">
479
        <h3 class="popup-header">
480
            <span class="header-box"></span>
481
        </h3>
482
        <div class="popup-body">
483
            <div class="popup-body-inner">
484
                <div class="machine-now-building"></div>
485
                <div class="popup-separator"></div>
486
                <div class="password-container">
487
                    <div class="password-header"></div>
488
                    <div class="password"></div>
489
                </div>
490
            </div>
491
        </div>
492
    </div>
493
</body>
494
</html>