Statistics
| Branch: | Tag: | Revision:

root / ui / templates / home.html @ 038383b1

History | View | Annotate | Download (10.3 kB)

1
{% load i18n %}
2
<!DOCTYPE html>
3
<head>
4
        <title>{{ project }}</title>
5
        <!-- include the Tools -->
6
    <!-- jquery tools minified for deployment-->
7
    <script src="static/jquery.tools.min.js"></script>
8
    
9
        <!-- jquery tools source for JS debugging -->
10
    <!--
11
    <script src="http://flowplayer.org/tools/download/1.2.5/jquery-1.4.2.js"></script>   
12
        <script src="http://flowplayer.org/tools/download/1.2.5/tabs/tabs.js"></script>
13
        <script src="http://flowplayer.org/tools/download/1.2.5/scrollable/scrollable.js"></script>
14
        <script src="http://flowplayer.org/tools/download/1.2.5/overlay/overlay.js"></script>
15
        <script src="http://flowplayer.org/tools/download/1.2.5/rangeinput/rangeinput.js"></script>
16
        <script src="http://flowplayer.org/tools/download/1.2.5/toolbox/toolbox.expose.js"></script>
17
    -->
18
    
19
    <script src="static/jquery.cookie.js"></script>
20
    <script src="static/jQueryRotate.js"></script>
21
    <script src="static/jquery.dataTables.min.js"></script>
22
    <script src="static/synnefo.js"></script>
23
        <link rel="stylesheet" type="text/css" href="static/main.css"/>        
24
    <script>
25
        // timeout value from settings.py
26
        var TIMEOUT = {{timeout}};
27
        var UPDATE_INTERVAL = {{5000}};
28
        var STATUS_MESSAGES = {
29
            'BUILD'     : '{% trans "Building" %}',
30
            'REBOOT'     : '{% trans "Rebooting" %}',            
31
            'STOPPED'   : '{% trans "Stopped" %}',
32
            'ACTIVE'   : '{% trans "Running" %}',
33
            'ERROR'   : '{% trans "Error" %}'
34
        };
35
        
36
        var ERRORS = {
37
            // error message header
38
            'HEADER' : '{% trans "Error!" %}',
39
            // default
40
            'DEFAULT' : '{% trans "Could not contact the service. Please check your network connectivity and try again." %}',
41
            // bad request
42
            '400' : '{% trans "Malformed request." %}',
43
            // not found
44
            '404' : '{% trans "Your request has failed. Resource not found." %}',
45
            // internal server error
46
            '500' : '{% trans "There has been an Internal Error. Our administrators have been notified." %}',
47
            // service unavailable
48
            '501' : '{% trans "This server has not been implemented yet." %}',
49
            // service unavailable
50
            '503' : '{% trans "This service is unavailable right now, please try again later." %}',
51
            // no images found
52
            'NO_IMAGES' : '{% trans "Cannot show the Create machine wizard: No images found." %}',
53
            // no flavors found
54
            'NO_FLAVORS' : '{% trans "Cannot show the Create machine wizard: No machine configurations found." %}'
55
        };
56
        
57
        var SUCCESS = {
58
            'HEADER' : '{% trans "Success!" %}',
59
            'DEFAULT' : '{% trans "Your request has been succefully executed." %}',
60
            'CREATE_VM_SUCCESS' : '{% trans "Success!" %}',
61
            'CREATE_VM_SUCCESS_ONE' : '{% trans "Your machine is now being built." %}',
62
            'CREATE_VM_SUCCESS_TWO' : '{% trans "Please write down the following password:" %}',
63
            'CREATE_VM_SUCCESS_THREE' : '{% trans "Do not lose this! You will need it to connect to your machine, once it is ready." %}'
64
        };
65
        
66
        // ajax error checking  
67
        function ajax_error(status, serverID, action, responseText) {
68
            var serverName = '';
69
            
70
            if (serverID != undefined) {
71
                serverName = $("#"+serverID).parent().parent().find("span.name").text();
72
            }
73
            
74
            // prepare the error message
75
            $("#error-success h3").text(ERRORS['HEADER']);
76
            if (responseText != undefined){
77
                var errors = parse_error(responseText);
78
                if (serverName){
79
                    serverName="<p><strong>Server:</strong> " + serverName + "</p>";
80
                }
81
                $("#error-success div").html("<p>"+(errors[0].message || ERRORS[errors[0].code]) +"</p>"+serverName +"<p><strong>Action:</strong> " + action + "</p><p><strong>Code</strong>: " + errors[0].code + "</p><p><strong>Details:</strong> " + errors[0].details +"</p>");
82
            } else if (ERRORS[status] != undefined) {
83
                if (serverID == undefined){
84
                    $("#error-success p").text(ERRORS[status]);
85
                } else {
86
                    $("#error-success p").html("<b>" + serverName + "</b>" + ": " + ERRORS[status]);
87
                }
88
            } else {
89
                $("#error-success p").text(ERRORS['DEFAULT']);   
90
            }
91
            
92
            // bring up error notification
93
            var triggers = $("a#notification").overlay({
94
                // some mask tweaks suitable for modal dialogs
95
                mask: {
96
                    color: '#ebecff',
97
                    opacity: '0.9'
98
                },
99
                top: 'center',
100
                closeOnClick: false,
101
                oneInstance: false,
102
                load: false,
103
                onClose: function(){
104
                    // With partial refresh working properly,
105
                    // it is no longer necessary to refresh the whole page
106
                    // choose_view();
107
                }
108
            });
109
            $("a#notification").data('overlay').load();
110
            return false;
111
        }
112
        
113
        // ajax success checking
114
        function ajax_success(status, password) {
115
            // prepare the error message
116
            // bring up success notification
117
            if (status != undefined && SUCCESS[status]) {
118
                if (password != undefined && status == "CREATE_VM_SUCCESS") {
119
                    $("#error-success h3").text(SUCCESS[status]);
120
                    var CREATE_VM_SUCCESS_MSG = SUCCESS["CREATE_VM_SUCCESS_ONE"] + '<br />'
121
                        + SUCCESS["CREATE_VM_SUCCESS_TWO"] + '<br /><br />' + '<b>' + password + '</b>'
122
                        + '<br /><br />' + SUCCESS["CREATE_VM_SUCCESS_THREE"] ;
123
                    $("#error-success div").html("<p>" + CREATE_VM_SUCCESS_MSG + "</p>");             
124
                } else {
125
                    $("#error-success h3").text(SUCCESS['HEADER']);
126
                    $("#error-success div").text("<p>" + SUCCESS[status] + "</p>");             
127
                }
128
            } else {
129
                $("#error-success h3").text(SUCCESS['HEADER']);
130
                $("#error-success div").html("<p>" + SUCCESS['DEFAULT'] + "</p>");             
131

132
            }
133

134

135
            var triggers = $("a#notification").overlay({
136
                // some mask tweaks suitable for modal dialogs
137
                mask: {
138
                    color: '#ebecff',
139
                    opacity: '0.9'
140
                },
141
                top: 'center',
142
                closeOnClick: false,
143
                oneInstance: false,
144
                load: false,
145
                onClose: function(){
146
                    // With partial refresh working properly,
147
                    // it is no longer necessary to refresh the whole page
148
                    // choose_view();
149
                }
150
            });
151
            $("a#notification").data('overlay').load();
152
            return false;
153
        }
154
    </script>
155
</head>
156
<body>
157
    <div id="wrapper">
158
        <div id='user'>
159
            <a href="#">{% trans "username" %}</a> &nbsp;|&nbsp; <a href="#">{% trans "settings" %}</a>
160
            {% get_available_languages as LANGUAGES %}
161
            {% for lang in LANGUAGES %}
162
                &nbsp;|&nbsp;
163
                <a {% if  == lang.0 %}class="current_lang" {% else %}  href="/lang/?l={{lang.0}}" {% endif %}>{{lang.0}}</a> 
164
            {% endfor %}
165
        </div>
166
        <div id='header'>
167
            <a href="/" class="logo">
168
                <img src="static/nefo.png" alt="+nefo"/>
169
            </a>
170
            <div class='fatborder'></div>
171
        </div>
172
        <!-- tabs -->
173
        <ul class="css-tabs">
174
                <li><a href="machines" title="{% trans "manage  virtual " %}" class="primary" id="machines">
175
                {% trans "machines" %}</a></li>
176
                <li><a href="disks" title="{% trans "manage  storage " %}" class="primary" id="disks">
177
                {% trans "disks" %}</a></li>
178
                <li><a href="images" title="{% trans "manage  images" %}" class="primary" id="images">
179
                {% trans "images" %}</a></li>
180
                <li><a href="networks" title="{% trans "configure " %}" class="primary" id="networks">
181
                {% trans "networks" %}</a></li>
182
            <li><a href="files" title="{% trans "your " %}" class="secondary" id="files">
183
                {% trans "files" %}</a></li>
184
                <li><a href="desktops" title="{% trans "your " %}" class="secondary" id="desktops">
185
                {% trans "desktops" %}</a></li>
186
                <li><a href="apps" title="{% trans "your " %}" class="secondary" id="apps">
187
                {% trans "apps" %}</a></li>
188
        </ul>
189
        <div class="more-tabs"><img src="static/arrow.png" id="arrow"></img></div>
190
        <div class="css-panes">
191
                <div id="machines-pane" class="pane" style="display:block">{% include "machines.html" %}</div>
192
                <div id="disks-pane" class="pane"></div>
193
                <div id="images-pane" class="pane"></div>
194
                <div id="networks-pane" class="pane"></div>
195
            <div id="files-pane" class="pane"></div>
196
                <div id="desktops-pane" class="pane"></div>
197
                <div id="apps-pane" class="pane"></div>
198
        </div>
199
    </div>
200
    <!-- activate tabs with JavaScript -->
201
    <script>
202
                $(function() {
203
                    $('ul.css-tabs li').hover(function(){
204
                            $(this).find('a:not(.current)').animate({top:'0px'},{queue:false,duration:150});
205
            }, function(){
206
                $('ul.css-tabs li a:not(.current)').animate({top:'9px'},{queue:false,duration:150});
207
                    });
208
                });
209
                
210
        $(function() {
211
                $("ul.css-tabs").tabs("div.css-panes div.pane", {        
212
                        onBeforeClick: function(event, i) {
213
                    $('ul.css-tabs li a').animate({top:'9px'},{queue:false,duration:150});
214
                                // get the pane to be opened
215
                                var pane = this.getPanes().eq(i);
216
                    pane.text('');
217
                                // load it with a page specified in the tab's href attribute
218
                                pane.load(this.getTabs().eq(i).attr("href"),function(){if (!i) {choose_view()}});
219
                        }
220
                });
221
        });
222

223
        // toggle main menu
224
        $("#arrow").click(function(event){
225
                toggleMenu();
226
        });    
227
        
228
    </script>
229
</body>
230
</html>
231