Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ 75c22372

History | View | Annotate | Download (20.1 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/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
            'APPLY' : '{% trans "Apply" %}'
158
        };
159

160
        // ajax error checking
161
        function ajax_error(status, serverID, action, responseText) {
162
             // close existing overlays to begin with
163
            close_all_overlays();
164
            // clear old deferred calls (stops all auto-updates)
165
            clearTimeout(deferred);
166

167
            $('#error-success').addClass('error');
168
            $('#error-success').removeClass('success');
169

170
            var serverName = '';
171

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

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

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

246
            // bring up error notification
247
            var triggers = $("a#notification").overlay({
248
                // some mask tweaks suitable for modal dialogs
249
                mask: '#666',
250
                top: 'center',
251
                closeOnClick: false,
252
                oneInstance: false,
253
                load: false,
254
                onClose: function () {
255
                    // refresh the whole page
256
                    location.reload();
257
                }
258
            });
259

260
            // we need to give the browser some time to close the old overlays before opening the new one
261
            setTimeout("$('a#notification').data('overlay').load()",400);
262
            return false;
263
        }
264

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

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

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

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

301
            var triggers = $("a#notification").overlay({
302
                // some mask tweaks suitable for modal dialogs
303
                mask: '#666',
304
                top: 'center',
305
                closeOnClick: false,
306
                oneInstance: false,
307
                load: false,
308
                onClose: function () {
309
                    // With partial refresh working properly,
310
                    // it is no longer necessary to refresh the whole page
311
                    // choose_view();
312
                }
313
            });
314
            $("a#notification").data('overlay').load();
315
            return false;
316
        }
317
    </script>
318
</head>
319
<body>
320
    <div id="container">
321
        <div id='header'>
322
            <div id='user'>
323
                <a href="#">{% trans "username" %}</a>
324
                {% get_available_languages as LANGUAGES %}
325
                {% for lang in LANGUAGES %}
326
                    &nbsp;|&nbsp;
327
                    <a {% if  == lang.0 %}class="current_lang" {% else %}  href="/lang/?l={{lang.0}}" {% endif %}>{{lang.0}}</a>
328
                {% endfor %}
329
            </div>
330
            <div class="header-logo">
331
                <a href="/">
332
                    <img src="static/okeanos.png" alt="okeanos"/>
333
                </a>
334
            </div>
335
        </div>
336
        <div id="content">
337
            <div id="wrapper">
338
                <!-- tabs -->
339
                <div class="tab-name">{% trans "machines" %}</div>
340
                <div class="tab-separator"></div>
341
                <ul class="css-tabs">
342
                    <li><a href="machines" title="{% trans "manage  virtual " %}" class="primary" id="machines">
343
                        <img src="static/machines-icon.png" /></a></li><div class="tab-separator"></div>
344
                    <li><a href="networks" title="{% trans "configure " %}" class="primary" id="networks">
345
                        <img src="static/networks-icon.png" /></a></li><div class="tab-separator"></div>
346
                    <li><a href="disks" title="{% trans "manage  storage " %}" class="primary" id="disks">
347
                        <img src="static/disks-icon.png" /></a></li>
348
                </ul>
349
                <div class="css-panes">
350
                    <div id="machines-pane" class="pane" style="display:block;"></div>
351
                    <div id="networks-pane" class="pane"></div>
352
                    <div id="disks-pane" class="pane"></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
                    this.getPanes().children().remove();
372
                    // get the pane to be opened
373
                    var pane = this.getPanes().eq(i);
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
        //load opera css fixes
400
        if ($.browser.opera) {
401
            $("<link/>", {
402
               rel: "stylesheet",
403
               type: "text/css",
404
               href: "static/opera.css"
405
            }).appendTo("head");
406
        }
407
    </script>
408
    <!-- base notification for error/success reporting -->
409
    <a id="notification" rel="#error-success" href="#"></a>
410

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