Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ e4f32f27

History | View | Annotate | Download (19.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>{{ 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/jquery.dataTables.min.js"></script>
56
    <script src="static/synnefo.js"></script>
57
    <link rel="stylesheet" type="text/css" href="static/main.css"/>
58
    <script>
59
        //populate available image icons array
60
        var os_icons = {{image_icons|safe}};
61

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

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

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

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

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

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

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

144
            var serverName = '';
145

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

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

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

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

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

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

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

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

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

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

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

363
        $(function() {
364
            // check pane cookie to select the initial pane
365
            var initial = 0, pane = $.cookie("pane");
366
            if (pane > 0)
367
                initial = pane;
368
            //alert(initial);
369
            $("ul.css-tabs").tabs("div.css-panes div.pane", {
370
                initialIndex: initial,
371
                onBeforeClick: function(event, i) {
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
    </script>
400
</body>
401
</html>