Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ d2f03cb3

History | View | Annotate | Download (19 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
    <script>
60
        //populate available image icons array
61
        var os_icons = {{image_icons|safe}};
62

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

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

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

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

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

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

140
        var VARIOUS = {
141
            'CONFIRM' : '{% trans "Confirm" %}',
142
            'CANCEL' : '{% trans "Cancel" %}'
143
        };
144

145
        // ajax error checking
146
        function ajax_error(status, serverID, action, responseText) {
147
            $('#error-success').addClass('error');
148
            $('#error-success').removeClass('success');
149

150
            var serverName = '';
151

152
            if (serverID !== undefined) {
153
                // standard view
154
                serverName = $("#" + serverID).find("span.name").text();
155
                if (serverName === "") { // list view
156
                    serverName = $("#" + serverID).parent().parent().find("span.name").text();
157
                }
158
            }
159

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

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

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

247
        // ajax success checking
248
        function ajax_success(status, password) {
249
            // prepare the error message
250
            // bring up success notification
251
            $('#error-success').addClass('success');
252
            $('#error-success').removeClass('error');
253
            if (status !== undefined && SUCCESS[status]) {
254
                if (password !== undefined && status === "CREATE_VM_SUCCESS") {
255

256
                    //stop the progress icon and hide the wizard
257
                    $('#wizard #start').text('{% trans "Create VM" %}');
258
                    $("#wizard").hide();
259

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

270
                    $("#error-success .popup-details").html("</div><div class=\"write-password-details\">" + CREATE_VM_SUCCESS_MSG + "</div>");
271
                    $("#error-success div.password").html("<div class=\"write-password\">" + SUCCESS["CREATE_VM_SUCCESS_TWO"] + "<div class=\"write-password-password\">" + password + "</div></div>");
272
                    //$("#error-success div.write-password").html(SUCCESS["CREATE_VM_SUCCESS_TWO"]);
273
                    //$("#error-success div.write-password-details").html(CREATE_VM_SUCCESS_MSG);
274
                } else {
275
                    $("#error-success h3").text(SUCCESS['HEADER']);
276
                    $("#error-success div.popup-body-inner").text("<p>" + SUCCESS[status] + "</p>");
277
                }
278
            } else {
279
                $("#error-success h3").text(SUCCESS['HEADER']);
280
                $("#error-success div.popup-body-inner").html("<p>" + SUCCESS['DEFAULT'] + "</p>");
281
            }
282

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

    
344
    <!-- activate tabs with JavaScript -->
345
    <script>
346

347
        $(function() {
348
            // check pane cookie to select the initial pane
349
            var initial = 0, pane = $.cookie("pane");
350
            if (pane > 0)
351
                initial = pane;
352
            //alert(initial);
353
            $("ul.css-tabs").tabs("div.css-panes div.pane", {
354
                initialIndex: initial,
355
                onBeforeClick: function(event, i) {
356
                    // get the pane to be opened
357
                    var pane = this.getPanes().eq(i);
358
                    //change the displaying title
359
                    $(".tab-name").text(this.getTabs().eq(i).attr("href"));
360
                    // load it with a page specified in the tab's href attribute
361
                    pane.load(this.getTabs().eq(i).attr("href"),function() {if (!i) {choose_view()}});
362
                }
363
            });
364
        });
365
        
366
        // set pane cookie whenever the user clicks on a different pane
367
        $("ul.css-tabs a").click(function(i) {
368
            $.cookie("pane", $("ul.css-tabs a").index(this));
369
        });
370
        
371
        //change menu title on hover
372
        $("ul.css-tabs li").hover(
373
            function () {
374
                if ($(this).find("a.current").length == 0) {
375
                    $(this).parent().parent().find(".tab-name").text($(this).find("a").attr("href"));
376
                }
377
            },
378
            function () {
379
                $(this).parent().parent().find(".tab-name").text($(this).parent().find("a.current").attr("href"));
380
            }
381
        );
382
        
383
    </script>
384
    <!-- base notification for error/success reporting -->
385
    <a id="notification" rel="#error-success" href="#"></a>
386

    
387
    <div class="modal" id="error-success">
388
        <h3 class="popup-header">
389
            <span class="header-box"></span>
390
        </h3>
391
        <div class="popup-body">
392
            <div class="popup-body-inner">
393
                <div class="machine-now-building"></div>
394
                <div class="popup-separator"></div>
395
                <div class="password-container">
396
                    <div class="password-header"></div>
397
                    <div class="password"></div>
398
                </div>
399
                <div class="popup-details">
400
                    <div class="write-password"></div>
401
                    <div class="write-password-details">{% trans "More details about the result"%}</div>
402
                </div>
403
            </div>
404
        </div>
405
    </div>
406
</body>
407
</html>