Statistics
| Branch: | Tag: | Revision:

root / ui / templates / instances.html @ 89976b6c

History | View | Annotate | Download (11.9 kB)

1
<a id="create" rel="#wizard" href="#">Create New +</a>
2

    
3
<div id="instancesview" class="standard">
4
    <a id="list" href="/instances/list">list view</a>
5
    <div class="running">
6
        {% for node in nodes %}
7
            {% if node.state == '3' %}        
8
                <div class="instance running">
9
                    <div class="actions">
10
                        <a href="#" class="action">reboot</a>
11
                        <a href="#" class="action">shutdown</a>
12
                        <a href="#" class="more">more &hellip;</a>
13
                    </div>
14
                    <div class="state">
15
                        <div>Running</div>
16
                        <div class="indicator" />
17
                        <div class="indicator" />
18
                        <div class="indicator" />
19
                        <div class="indicator" />
20
                        <div class="uptime">24 days uptime</div>
21
                    </div>
22
                    <img src="static/server.png" />
23
                    <a href="#" class="name">
24
                        <h3><span>{{ node.name }}</span><span class="rename">rename</span></h3>
25
                    </a>
26
                    <a href="#" class="ip">
27
                        <h5><span>{{ node.public_ip }}</span><span class="configure">configure networking</span></h5>
28
                    </a>
29
                    <a href="#" class="storage">
30
                        <h5>34GB of total storage in 3 volumes <span class="configure">configure storage</span></h5>
31
                    </a>
32
                    </div>
33
                </div>
34
            {% endif %}
35
        {% endfor %}
36
    </div>
37
</div>
38

    
39
<!-- the form -->
40
<form action="#">
41
        <!-- scrollable root element -->
42
        <div class="modal" id="wizard">
43
                <!-- status bar -->
44
                <ul id="status">
45
                        <li class="active"><strong>1.</strong> Select image</li>
46
                        <li><strong>2.</strong> Instance type</li>
47
                        <li><strong>3.</strong> Review</li>
48
                </ul>
49
                <!-- scrollable items -->
50
                <div class="items">
51
                        <!-- pages -->
52
                        <div class="page">
53
                <h2>
54
                                        <strong>Step 1: </strong> Select image
55
                                        <em>Select an OS image to boot from</em>
56
                                </h2>
57
                <ul class="tabs">
58
                    <li><a href="#">standard</a></li>
59
                    <li><a href="#">custom</a></li>
60
                </ul>
61
                <div class="panes">
62
                    <ul class="pane">
63
                                            <!-- standard images -->
64
                        {% for image in images %}
65
                            {% if image.type == 'standard' %}
66
                                                    <li>
67
                                                            <label> 
68
                                        <a><div class="image">
69
                                            <img src={{ image.logo }} class="image-logo"/>
70
                                            <strong>{{ image.title }}</strong>
71
                                            <br />
72
                                            <span class="description">{{ image.description }}</span> 
73
                                            <span class="size">{{ image.size }}MB</span>
74
                                            <input class="radio" type="radio" name="image-id" id={{ image.id }} />
75
                                        </div></a>
76
                                                            </label>
77
                                                    </li>
78
                            {% endif %}
79
                        {% endfor %} 
80
                                    </ul>
81
                    <ul class="pane">
82
                                            <!-- custom images -->
83
                        {% for image in images %}
84
                            {% if image.type == 'custom' %}
85
                                                    <li>
86
                                                            <label> 
87
                                        <a><div class="image">
88
                                            <img src={{ image.logo }} class="image-logo"/>
89
                                            <strong>{{ image.title }}</strong>
90
                                            <br />
91
                                            <span class="description">{{ image.description }}</span> 
92
                                            <span class="size">{{ image.size }}MB</span>
93
                                            <input class="radio" type="radio" name="image-id" id={{ image.id }} />
94
                                        </div></a>
95
                                                            </label>
96
                                                    </li>
97
                            {% endif %}
98
                        {% endfor %}
99
                    </ul>
100
                </div>
101
                                <button type="button" class="prev" id="cancel">Cancel</button>
102
                                <button type="button" class="next right">Next &raquo;</button>
103
            </div>
104
                        <div class="page">
105
                                <h2>
106
                                        <strong>Step 2: </strong> Instance type <b></b>
107
                                        <em>Select CPU cores, RAM and storage space for your instance</em>
108
                                </h2>
109
                <ul>
110
                    <li>
111
                        <div class="instance-type">
112
                            <label for="small">
113
                                <input type="radio" id="small" name="instance-type" value="small" checked="true" />
114
                                <strong>small</strong>
115
                            </label>
116
                        </div>
117
                        <div class="instance-type">      
118
                            <label for="medium">
119
                                <input type="radio" id="medium" name="instance-type" value="medium" />                  
120
                                <strong>medium</strong>
121
                            </label>
122
                        </div>
123
                        <div class="instance-type">
124
                            <label for="large">
125
                                <input type="radio" id="large" name="instance-type" value="large" />
126
                                <strong>large</strong>
127
                            </label>
128
                        </div>
129
                        <div class="instance-type">
130
                            <label for="custom">
131
                                <input type="radio" name="instance-type" id="custom" value="large" />
132
                                <strong>custom</strong>
133
                            </label>
134
                        </div>
135
                    </li>
136
                    <li>
137
                                    <label><strong class="sliders">CPU (cores)</strong></label>
138
                        <input type="range" id="cpu" value="1" max="8" min="1" />
139
                    </li>
140
                    <li>
141
                                    <label><strong class="sliders">RAM (MB)</strong></label>
142
                        <input type="range" id="ram" value="256" max="2048" min="256" step="256" />
143
                    </li>
144
                    <li>
145
                                <label><strong class="sliders">Storage (GB)</strong></label>
146
                        <input type="range" id="storage" value="5" step="1" max="100" min="2" />
147
                    </li>
148
                    <li>
149
                        <div class="cost">
150
                            Cost per hour for this VM: 20 credits | Credits currently in account: 10.000
151
                        </div>
152
                    </li>
153
                </ul>
154
                                <button type="button" class="prev">&laquo; Back</button>
155
                                <button type="button" class="next right">Next &raquo;</button>
156
            </div>
157
                        <div class="page">
158
                                <h2>
159
                                        <strong>Step 3: </strong> Review <b></b>
160
                                        <em>Confirm the settings below and create your new instance</em>
161
                                </h2>
162
                <ul>
163
                    <li class="required">
164
                        <label>
165
                            <strong></strong> Instance name <span>*</span><br />
166
                            <input type="text" class="text" name="instance_name" value="My Ubuntu 10.04 x86_64 server"/>
167
                        </label>
168
                    </li>
169
                    <li>
170
                        <strong>Image:</strong> <span>Ubuntu 10.04 x86_64 server</span>
171
                    </li>
172
                    <li>
173
                        <strong>CPU:</strong> <span>2 cores</span>
174
                    </li>
175
                    <li>
176
                        <strong>RAM:</strong> <span>1024MB</span>
177
                    </li>
178
                    <li>
179
                        <strong>Storage:</strong> <span>10GB</span>
180
                    </li>
181
                    <li>
182
                        <strong>Cost per hour:</strong> <span>20 credits</span>
183
                    </li>
184
                    <li>
185
                        <strong>Remaining credits:</strong> <span>10.000</span>
186
                    </li>
187
                </ul>
188
                                <button type="button" class="prev">&laquo; Back</button>
189
                                <button type="button" class="next right" id="start">Create VM</button>        
190
            </div>
191
                </div>
192
        </div>
193
</form>
194

    
195
<div class="modal" id="misc">
196
    <h3>Your VM is being created!</h3>
197
    <p>Your password is:<strong> sdeEFre</strong></p>
198
    <p>Please copy this! Without it you can not connect to your VM.</p>
199
</div>
200

    
201
<script>
202
// <![CDATA[ 
203

204
$("#list").click(function(event){
205
    $("div#instancesview").load($("#list").attr("href"));
206
    return false;
207
});
208

209
$("ul.tabs").tabs("div.panes ul");
210

211
$(":range").rangeinput();
212

213
function disableSliders() {
214
    $("#cpu").attr('disabled',true);
215
    $("#ram").attr('disabled',true);
216
    $("#storage").attr('disabled',true);
217
}
218

219
$("#custom").click(function(event){
220
    $("#cpu").attr('disabled',false);
221
    $("#ram").attr('disabled',false);
222
    $("#storage").attr('disabled',false);
223
    $("strong.sliders").style = 'color: #778899;';
224
});
225

226
$("#small").click(function(event){
227
    $("#cpu").data('rangeinput').setValue(1);
228
    $("#ram").data('rangeinput').setValue(256);
229
    $("#storage").data('rangeinput').setValue(5);
230
});
231

232
$("#medium").click(function(event){
233
    $("#cpu").data('rangeinput').setValue(4);
234
    $("#ram").data('rangeinput').setValue(1024);
235
    $("#storage").data('rangeinput').setValue(30);
236
});
237

238
$("#large").click(function(event){
239
    $("#cpu").data('rangeinput').setValue(8);
240
    $("#ram").data('rangeinput').setValue(4096);
241
    $("#storage").data('rangeinput').setValue(80);
242
});
243

244
$("#cancel").click(function(event){
245
    $("a#create[rel]").overlay().close();
246
});
247

248
$("#start").click(function(event){
249
    $("a#create[rel]").overlay().close();
250

251
    var triggers = $("div#misc").overlay({
252
            // some mask tweaks suitable for modal dialogs
253
            mask: {
254
                    color: '#ebecff',
255
                    opacity: '0.9'
256
            },
257
        top: 'center',
258
        load: 'true',
259
            closeOnClick: 'false'  
260
    });
261
});
262

263
$("a#create").click(function(event){
264
    $("#wizard").scrollable().begin();
265
});
266

267
$("#cpu").change(function(event){
268
    $("#custom").click();
269
});
270

271
$("#ram").change(function(event){
272
    $("#custom").click();
273
});
274

275
$("#storage").change(function(event){
276
    $("#custom").click();
277
});
278

279
$(function() { 
280
    $("a#create[rel]").overlay({mask: '#000', effect: 'default', top: '5%'});
281

282
});
283

284
$(function() {
285
    var root = $("#wizard").scrollable();
286

287
    // some variables that we need
288
    var api = root.scrollable();
289

290
    // rangeinput with default configuration
291
    // validation logic is done inside the onBeforeSeek callback
292
    api.onBeforeSeek(function(event, i) {
293
            // we are going 1 step backwards so no need for validation
294
            if (api.getIndex() < i) {
295
             // 1. get current page
296
                     var page = root.find(".page").eq(api.getIndex()),
297
                         // 2. .. and all required fields inside the page
298
                         inputs = page.find(".required :input").removeClass("error"),
299
                         // 3. .. which are empty
300
                         empty = inputs.filter(function() {
301
                                return $(this).val().replace(/\s*/g, '') == '';
302
                         });
303
                     // if there are empty fields, then
304
                    if (empty.length) {
305
                            // add a CSS class name "error" for empty & required fields
306
                            empty.addClass("error");
307
                            // cancel seeking of the scrollable by returning false
308
                            return false;
309
                    // everything is good
310
                    } 
311
            }
312
            // update status bar
313
            $("#status li").removeClass("active").eq(i).addClass("active");
314
    });
315

316
    // if tab is pressed on the next button seek to next page
317
    root.find("button.next").keydown(function(e) {
318
            if (e.keyCode == 9) {
319
                    // seeks to next tab by executing our validation routine
320
                    api.next();
321
                    e.preventDefault();
322
            }
323
    });
324
// ]]>
325
});
326
</script>
327