Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ bcb81dc8

History | View | Annotate | Download (20 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>{{ project }}</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/json2.js"></script>
56
    <script src="static/jquery.dataTables.min.js"></script>
57
    <script src="static/synnefo.js"></script>
58
    <link rel="stylesheet" type="text/css" href="static/main.css"/>
59
    <!--[if IE]><style type="text/css" media="all">@import url(static/ie.css);</style><![endif]-->    
60
    <script>
61
        //populate available image icons array
62
        var os_icons = {{image_icons|safe}};
63

64
        // timeout value from settings.py
65
        var TIMEOUT = {{timeout}};
66
        var UPDATE_INTERVAL = {{update_interval}};
67

68
        // server statuses and transitions
69
        var STATUSES = {
70
            'UNKNOWN'   : '{% trans "Unknown" %}',
71
            'BUILD'     : '{% trans "Building" %}',
72
            'REBOOT'    : '{% trans "Rebooting" %}',
73
            'STOPPED'   : '{% trans "Stopped" %}',
74
            'ACTIVE'    : '{% trans "Running" %}',
75
            'ERROR'     : '{% trans "Error" %}'
76
        };
77

78
        var TRANSITIONS = {
79
            'Shutting down' : '{% trans "Shutting down" %}',
80
            'Rebooting'     : '{% trans "Rebooting" %}',
81
            'Starting'      : '{% trans "Starting" %}',
82
            'Destroying'    : '{% trans "Destroying" %}',
83
            'Connecting'    : '{% trans "Connecting" %}',   // used only in networks
84
            'Disconnecting' : '{% trans "Disconnecting" %}' // used only in networks
85
        };
86

87
        // Server statuses and transitions that should be displayed as active or inactive
88
        var ACTIVE_STATES = [
89
            '{% trans "Building" %}',
90
            '{% trans "Rebooting" %}',
91
            '{% trans "Running" %}',
92
            '{% trans "Shutting down" %}',
93
            '{% trans "Rebooting" %}',
94
            '{% trans "Destroying" %}'
95
        ];
96

97
        var INACTIVE_STATES = [
98
            '{% trans "Unknown" %}',
99
            '{% trans "Stopped" %}',
100
            '{% trans "Error" %}',
101
            '{% trans "Starting" %}',
102
            '{% trans "Destroying" %}'
103
        ];
104

105
        // Network statuses and transitions
106
        var NET_STATES = {
107
            'ACTIVE'        : '{% trans "Private network" %}',  // this comes from the API
108
            'DELETED'       : '{% trans "Deleted" %}',          // this comes from the API
109
            'Destroying'    : '{% trans "Destroying" %}',
110
            'Connecting'    : '{% trans "Connecting" %}',
111
            'Disconnecting' : '{% trans "Disconnecting" %}'
112
        };
113

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

143
        var SUCCESS = {
144
            'HEADER' : '{% trans "Success" %}',
145
            'DEFAULT' : '{% trans "Your request has been succefully executed." %}',
146
            'PASSWORD' : '{% trans "Password:" %}',
147
            'CREATE_VM_SUCCESS' : '{% trans "Success" %}',
148
            'CREATE_VM_SUCCESS_ONE' : '{% trans "Your new machine is now buidling... (this might take a few minutes)" %}',
149
            'CREATE_VM_SUCCESS_TWO' : '{% trans "Write down your password now:" %}',
150
            'CREATE_VM_SUCCESS_THREE' : '{% trans "You will need this later to connect to your machine." %}',
151
            'CREATE_VM_SUCCESS_FOUR' : '{% trans "After closing this window you will NOT be able to retrieve it again." %}'
152
        };
153

154
        var VARIOUS = {
155
            'CONFIRM' : '{% trans "Confirm" %}',
156
            'CANCEL' : '{% trans "Cancel" %}'
157
        };
158

159
        // ajax error checking
160
        function ajax_error(status, serverID, action, responseText) {
161
             // close existing overlays to begin with
162
            close_all_overlays();       
163
            // clear old deferred calls (stops all auto-updates)
164
            clearTimeout(deferred);
165
            
166
            $('#error-success').addClass('error');
167
            $('#error-success').removeClass('success');
168
            
169
            var serverName = '';
170

171
            if (serverID !== undefined) {
172
                // standard view
173
                serverName = $("#" + serverID).find("span.name").text();
174
                if (serverName === "") { // list view
175
                    serverName = $("#" + serverID).parent().parent().find("span.name").text();
176
                }
177
            }
178

179
            // prepare the error message
180
            $("#error-success h3").text(ERRORS['HEADER']);
181
            if (responseText !== undefined) {
182
                var errors = parse_error(responseText, status), details = '';
183
                if (serverName) {
184
                    serverName = "<p>{% trans "Server" %}: " + serverName + "</p>";
185
                }
186
                if ((errors[0].details === undefined) || (errors[0].details === "")) {
187
                    details = ERRORS["NO_DETAILS"];
188
                } else {
189
                    details = errors[0].details;
190
                }
191

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

245
            // bring up error notification
246
            var triggers = $("a#notification").overlay({
247
                // some mask tweaks suitable for modal dialogs
248
                mask: '#666',
249
                top: 'center',
250
                closeOnClick: false,
251
                oneInstance: false,
252
                load: false,
253
                onClose: function () {
254
                    // refresh the whole page
255
                    location.reload();
256
                }
257
            });
258
            
259
            // we need to give the browser some time to close the old overlays before opening the new one
260
            setTimeout("$('a#notification').data('overlay').load()",400);
261
            return false;
262
        }
263

264
        // ajax success checking
265
        function ajax_success(status, password) {
266
            // prepare the error message
267
            // bring up success notification
268
            $('#error-success').addClass('success');
269
            $('#error-success').removeClass('error');
270
            if (status !== undefined && SUCCESS[status]) {
271
                if (password !== undefined && status === "CREATE_VM_SUCCESS") {
272

273
                    //stop the progress icon and hide the wizard
274
                    $('#wizard #start').text('{% trans "Create VM" %}');
275
                    $("#wizard").hide();
276

277
                    $("#error-success h3 span.header-box").text(SUCCESS[status]);
278
                    var CREATE_VM_SUCCESS_MSG = SUCCESS["CREATE_VM_SUCCESS_THREE"] + '<br / >'
279
                        + SUCCESS["CREATE_VM_SUCCESS_FOUR"];
280
                    $("#error-success div.machine-now-building").html(SUCCESS["CREATE_VM_SUCCESS_ONE"]);
281
                    $("#error-success .popup-header").removeClass("popup-header-error");
282
                    $("#error-success").removeClass("popup-border-error");
283
                    $("#error-success .popup-details").removeClass("popup-details-error");
284
                    $("#error-success .popup-separator").removeClass("popup-separator-error");
285
                    $("#error-success .password-container").show();
286

287
                    $("#error-success .popup-details").html("</div><div class=\"write-password-details\">" + CREATE_VM_SUCCESS_MSG + "</div>");
288
                    $("#error-success div.password").html("<div class=\"write-password\">" + SUCCESS["CREATE_VM_SUCCESS_TWO"] + "<div class=\"write-password-password\">" + password + "</div></div>");
289
                    //$("#error-success div.write-password").html(SUCCESS["CREATE_VM_SUCCESS_TWO"]);
290
                    //$("#error-success div.write-password-details").html(CREATE_VM_SUCCESS_MSG);
291
                } else {
292
                    $("#error-success h3").text(SUCCESS['HEADER']);
293
                    $("#error-success div.popup-body-inner").text("<p>" + SUCCESS[status] + "</p>");
294
                }
295
            } else {
296
                $("#error-success h3").text(SUCCESS['HEADER']);
297
                $("#error-success div.popup-body-inner").html("<p>" + SUCCESS['DEFAULT'] + "</p>");
298
            }
299

300
            var triggers = $("a#notification").overlay({
301
                // some mask tweaks suitable for modal dialogs
302
                mask: '#666',
303
                top: 'center',
304
                closeOnClick: false,
305
                oneInstance: false,
306
                load: false,
307
                onClose: function () {
308
                    // With partial refresh working properly,
309
                    // it is no longer necessary to refresh the whole page
310
                    // choose_view();
311
                }
312
            });
313
            $("a#notification").data('overlay').load();
314
            return false;
315
        }
316
    </script>
317
</head>
318
<body>
319
    <div id="container">
320
        <div id='header'>
321
            <div id='user'>
322
                <a href="#">{% trans "username" %}</a>
323
                {% get_available_languages as LANGUAGES %}
324
                {% for lang in LANGUAGES %}
325
                    &nbsp;|&nbsp;
326
                    <a {% if  == lang.0 %}class="current_lang" {% else %}  href="/lang/?l={{lang.0}}" {% endif %}>{{lang.0}}</a>
327
                {% endfor %}
328
            </div>
329
            <div class="header-logo">
330
                <a href="/">
331
                    <img src="static/okeanos.png" alt="okeanos"/>
332
                </a>
333
            </div>
334
        </div>
335
        <div id="content">
336
            <div id="wrapper">
337
                <!-- tabs -->
338
                <div class="tab-name">{% trans "machines" %}</div>
339
                <div class="tab-separator"></div>
340
                <ul class="css-tabs">
341
                    <li><a href="machines" title="{% trans "manage  virtual " %}" class="primary" id="machines">
342
                        <img src="static/machines-icon.png" /></a></li><div class="tab-separator"></div>
343
                    <li><a href="networks" title="{% trans "configure " %}" class="primary" id="networks">
344
                        <img src="static/networks-icon.png" /></a></li><div class="tab-separator"></div>
345
                    <li><a href="disks" title="{% trans "manage  storage " %}" class="primary" id="disks">
346
                        <img src="static/disks-icon.png" /></a></li>
347
                </ul>
348
                <div class="css-panes">
349
                    <div id="machines-pane" class="pane" style="display:block;"></div>
350
                    <div id="networks-pane" class="pane"></div>
351
                    <div id="disks-pane" class="pane"></div>
352
                </div>
353
            </div>
354
        </div>
355
        {% include "footer.html" %}
356
    </div>
357

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

361
        $(function() {
362
            // check pane cookie to select the initial pane
363
            var initial = 0, pane = $.cookie("pane");
364
            if (pane > 0)
365
                initial = pane;
366
            //alert(initial);
367
            $("ul.css-tabs").tabs("div.css-panes div.pane", {
368
                initialIndex: initial,
369
                onBeforeClick: function(event, i) {
370
                    // get the pane to be opened
371
                    var pane = this.getPanes().eq(i);
372
                    //change the displaying title
373
                    $(".tab-name").text(this.getTabs().eq(i).attr("href"));
374
                    // load it with a page specified in the tab's href attribute
375
                    pane.load(this.getTabs().eq(i).attr("href"),function() {if (!i) {choose_view()}});
376
                }
377
            });
378
        });
379

380
        // set pane cookie whenever the user clicks on a different pane
381
        $("ul.css-tabs a").click(function(i) {
382
            $.cookie("pane", $("ul.css-tabs a").index(this));
383
        });
384

385
        //change menu title on hover
386
        $("ul.css-tabs li").hover(
387
            function () {
388
                if ($(this).find("a.current").length == 0) {
389
                    $(this).parent().parent().find(".tab-name").text($(this).find("a").attr("href"));
390
                }
391
            },
392
            function () {
393
                $(this).parent().parent().find(".tab-name").text($(this).parent().find("a.current").attr("href"));
394
            }
395
        );
396

397
        //load opera css fixes
398
        if ($.browser.opera) {
399
            $("<link/>", {
400
               rel: "stylesheet",
401
               type: "text/css",
402
               href: "static/opera.css"
403
            }).appendTo("head");
404
        }
405
    </script>
406
    <!-- base notification for error/success reporting -->
407
    <a id="notification" rel="#error-success" href="#"></a>
408

    
409
    <div class="modal" id="error-success">
410
        <h3 class="popup-header">
411
            <span class="header-box"></span>
412
        </h3>
413
        <div class="popup-body">
414
            <div class="popup-body-inner">
415
                <div class="machine-now-building"></div>
416
                <div class="popup-separator"></div>
417
                <div class="password-container">
418
                    <div class="password-header"></div>
419
                    <div class="password"></div>
420
                </div>
421
                <div class="popup-details">
422
                    <div class="write-password"></div>
423
                    <div class="write-password-details">{% trans "More details about the result"%}</div>
424
                </div>
425
            </div>
426
        </div>
427
    </div>
428
</body>
429
</html>