root / ui / templates / instances.html @ ec06b07c
History | View | Annotate | Download (14 kB)
1 |
{% load i18n %} |
---|---|
2 |
|
3 |
<div id="instances" class="seperator"></div> |
4 |
|
5 |
<a id="create" rel="#wizard" href="#">{% trans "Create New +" %}</a> |
6 |
<a id="notify" rel="#misc" href="#"></a> |
7 |
<div id="view-select"> |
8 |
<a id="standard" class="current" href="/instances">#</a> |
9 |
| |
10 |
<a id="list" href="/instances/list">=</a> |
11 |
</div>
|
12 |
|
13 |
|
14 |
|
15 |
<div id="instancesview" class="standard"> |
16 |
|
17 |
<div class="instance" id="instance-template" style="display:none"> |
18 |
<div class="state"> |
19 |
<div class="status">Running</div> |
20 |
<div class="indicator"></div> |
21 |
<div class="indicator"></div> |
22 |
<div class="indicator"></div> |
23 |
<div class="indicator"></div> |
24 |
</div>
|
25 |
<img class="logo" src="static/machines/ubuntu.png" /> |
26 |
<a href="#" class="name"> |
27 |
<h5>Hostname: <span class="name">node.name</span><span class="rename"></span></h5> |
28 |
</a>
|
29 |
<a href="#" class="ip"> |
30 |
<h5>IP: <span class="public">node.public_ip</span></h5> |
31 |
</a>
|
32 |
<h5 class="storage"> |
33 |
Show: <a href="#">disks</a> | <a href="#">networks</a> | <a href="#">group</a> |
34 |
</h5>
|
35 |
<div class="actions"> |
36 |
<a href="#" class="action">Reboot</a> |
37 |
<a href="#" class="action">Shutdown</a> |
38 |
<a href="#" class="more">more …</a> |
39 |
</div>
|
40 |
</div>
|
41 |
|
42 |
<div class="running"> |
43 |
</div>
|
44 |
<div id="mini" class="seperator"></div> |
45 |
<div class="terminated"> |
46 |
</div>
|
47 |
</div>
|
48 |
|
49 |
<div id="instances" class="seperator"></div> |
50 |
|
51 |
<!-- the form -->
|
52 |
<form action="#"> |
53 |
<!-- scrollable root element -->
|
54 |
<div class="modal" id="wizard"> |
55 |
<!-- status bar -->
|
56 |
<ul id="status"> |
57 |
<li class="active"><strong>1.</strong> Image</li> |
58 |
<li><strong>2.</strong> Instance</li> |
59 |
<li><strong>3.</strong> Review</li> |
60 |
</ul>
|
61 |
<!-- scrollable items -->
|
62 |
<div class="items"> |
63 |
<!-- pages -->
|
64 |
<div class="page"> |
65 |
<h2>Select an OS</h2> |
66 |
<ul class="tabs"> |
67 |
<li><a href="#">standard</a></li> |
68 |
<li><a href="#">custom</a></li> |
69 |
</ul>
|
70 |
<div class="panes"> |
71 |
<li id="image-template" style="display:none"> |
72 |
<label for="image.id"> |
73 |
<a><div class="image"> |
74 |
<img src="static/os_logos/image.logo" class="image-logo"/> |
75 |
<strong class="image-title">image.title</strong> |
76 |
<input class="radio" type="radio" name="image-id" id="image-id" /> |
77 |
<br /> |
78 |
<span class="description">image.description</span> |
79 |
<span class="size">?? MB</span> |
80 |
|
81 |
</div></a> |
82 |
</label>
|
83 |
</li>
|
84 |
<ul class="pane" id="standard-images"> |
85 |
<!-- standard images -->
|
86 |
</ul>
|
87 |
<ul class="pane" id="custom-images"> |
88 |
<!-- custom images -->
|
89 |
|
90 |
</ul>
|
91 |
</div>
|
92 |
<button type="button" class="prev" id="cancel">Cancel</button> |
93 |
<button type="button" class="next right">Next »</button> |
94 |
</div>
|
95 |
<div class="page"> |
96 |
<h2>Select CPU, RAM and storage</h2> |
97 |
<ul>
|
98 |
<li>
|
99 |
<div class="instance-type"> |
100 |
<label for="small"> |
101 |
<input type="radio" id="small" name="instance-type" value="small" checked="true" /> |
102 |
<strong>small</strong> |
103 |
</label>
|
104 |
</div>
|
105 |
<div class="instance-type"> |
106 |
<label for="medium"> |
107 |
<input type="radio" id="medium" name="instance-type" value="medium" /> |
108 |
<strong>medium</strong> |
109 |
</label>
|
110 |
</div>
|
111 |
<div class="instance-type"> |
112 |
<label for="large"> |
113 |
<input type="radio" id="large" name="instance-type" value="large" /> |
114 |
<strong>large</strong> |
115 |
</label>
|
116 |
</div>
|
117 |
<div class="instance-type"> |
118 |
<label for="custom"> |
119 |
<input type="radio" name="instance-type" id="custom" value="large" /> |
120 |
<strong>custom</strong> |
121 |
</label>
|
122 |
</div>
|
123 |
</li>
|
124 |
<li>
|
125 |
<label><strong class="sliders">CPU (cores)</strong></label> |
126 |
<input type="range" id="cpu" value="1" max="8" min="1" /> |
127 |
</li>
|
128 |
<li>
|
129 |
<label><strong class="sliders">RAM (MB)</strong></label> |
130 |
<input type="range" id="ram" value="256" max="2048" min="256" step="256" /> |
131 |
</li>
|
132 |
<li>
|
133 |
<label><strong class="sliders">Storage (GB)</strong></label> |
134 |
<input type="range" id="storage" value="5" step="1" max="100" min="2" /> |
135 |
</li>
|
136 |
<li>
|
137 |
<div class="cost"> |
138 |
Cost per hour: 20 credits | Credits currently in account: 10.000 |
139 |
</div>
|
140 |
</li>
|
141 |
</ul>
|
142 |
<button type="button" class="prev">« Back</button> |
143 |
<button type="button" class="next right">Next »</button> |
144 |
</div>
|
145 |
<div class="page"> |
146 |
<h2>Confirm your settings</h2> |
147 |
<ul>
|
148 |
<li class="required"> |
149 |
<label>
|
150 |
<strong>Instance name</strong> |
151 |
<input type="text" class="text" name="instance_name" value="My Ubuntu 10.04 x86_64 server"/> |
152 |
</label>
|
153 |
</li>
|
154 |
<li>
|
155 |
<strong>Image:</strong> <span>Ubuntu 10.04 x86_64 server</span> |
156 |
</li>
|
157 |
<li>
|
158 |
<strong>CPU:</strong> <span>2 cores</span> |
159 |
</li>
|
160 |
<li>
|
161 |
<strong>RAM:</strong> <span>1024MB</span> |
162 |
</li>
|
163 |
<li>
|
164 |
<strong>Storage:</strong> <span>10GB</span> |
165 |
</li>
|
166 |
<li>
|
167 |
<strong>Cost per hour:</strong> <span>20 credits</span> |
168 |
</li>
|
169 |
<li>
|
170 |
<strong>Remaining credits:</strong> <span>10.000</span> |
171 |
</li>
|
172 |
</ul>
|
173 |
<button type="button" class="prev">« Back</button> |
174 |
<button type="button" class="next right" id="start">Create VM</button> |
175 |
</div>
|
176 |
</div>
|
177 |
</div>
|
178 |
</form>
|
179 |
|
180 |
<div class="modal" id="misc"> |
181 |
<h3>Your VM is being created!</h3> |
182 |
<p>Your password is:<strong> sdeEFre</strong></p> |
183 |
<p>Please copy this! Without it you can not connect to your VM.</p> |
184 |
</div>
|
185 |
|
186 |
<script>
|
187 |
// <![CDATA[
|
188 |
var image_tags = {
|
189 |
1: 'archlinux',
|
190 |
2: 'centos',
|
191 |
3: 'debian',
|
192 |
4: 'freebsd',
|
193 |
5: 'gentoo',
|
194 |
6: 'netbsd',
|
195 |
7: 'openbsd',
|
196 |
8: 'redhat',
|
197 |
9: 'slackware',
|
198 |
10: 'suse',
|
199 |
11: 'ubuntu',
|
200 |
12: 'windows',
|
201 |
};
|
202 |
|
203 |
function update() {
|
204 |
|
205 |
$("div.running").text('');
|
206 |
$("div.terminated").text('');
|
207 |
$("ul#standard-images").text('');
|
208 |
$("ul#custom-images").text('');
|
209 |
|
210 |
$.ajax({
|
211 |
url: '/api/v1.0/servers/detail',
|
212 |
type: "GET",
|
213 |
// async: false,
|
214 |
dataType: "json",
|
215 |
success: function(data) {
|
216 |
$.each(data.servers, function(i,server){
|
217 |
var instance = $('#instance-template').clone().attr("id",server.id).fadeIn("slow");
|
218 |
instance.find("a.name span.name").text(server.name);
|
219 |
instance.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'.png');
|
220 |
instance.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'.png');
|
221 |
instance.find("a.ip span.public").text(String(server.addresses.public));
|
222 |
|
223 |
if (server.status == 'BUILD'){
|
224 |
instance.find("div.status").text('Building');
|
225 |
instance.appendTo("div.running");
|
226 |
} else if (server.status == 'ACTIVE') {
|
227 |
instance.find("div.status").text('Running');
|
228 |
instance.appendTo("div.running");
|
229 |
} else if (server.status == 'SUSPENDED') {
|
230 |
instance.find("div.status").text('Terminated');
|
231 |
instance.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
|
232 |
instance.appendTo("div.terminated");
|
233 |
} else {
|
234 |
instance.find("div.status").text('Unknown');
|
235 |
instance.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
|
236 |
instance.appendTo("div.terminated");
|
237 |
}
|
238 |
|
239 |
|
240 |
});
|
241 |
}
|
242 |
});
|
243 |
|
244 |
$.ajax({
|
245 |
url: '/api/v1.0/images/detail',
|
246 |
type: "GET",
|
247 |
// async: false,
|
248 |
dataType: "json",
|
249 |
success: function(data) {
|
250 |
$.each(data.images, function(i,image){
|
251 |
var img = $('#image-template').clone().attr("id","img-"+image.id).fadeIn("slow");
|
252 |
img.find("label").attr('for',"img-radio-" + image.id);
|
253 |
img.find(".image-title").text(image.name);
|
254 |
img.find("input.radio").attr('id',"img-radio-" + image.id);
|
255 |
if (i==0) img.find("input.radio").attr("checked","checked");
|
256 |
img.find("img.image-logo").attr('src','static/os_logos/'+image_tags[image.id]+'.png');
|
257 |
if (image.serverId) {
|
258 |
img.appendTo("ul#custom-images");
|
259 |
} else {
|
260 |
img.appendTo("ul#standard-images");
|
261 |
}
|
262 |
});
|
263 |
}
|
264 |
});
|
265 |
}
|
266 |
update();
|
267 |
$("#list").click(function(event){
|
268 |
$("div.standard#instancesview").load($("#list").attr("href"));
|
269 |
$("a#standard")[0].className += ' activelink'
|
270 |
this.style.color = '#5f8dd3';
|
271 |
update();
|
272 |
return false;
|
273 |
});
|
274 |
|
275 |
$("a#standard").click(function(event){
|
276 |
href=$("a#standard").attr("href");
|
277 |
$("div.pane#instances-pane").load(href);
|
278 |
//$("a#standard")[0].className += ' activelink'
|
279 |
//this.style.color = '#5f8dd3';
|
280 |
return false;
|
281 |
});
|
282 |
|
283 |
$("ul.tabs").tabs("div.panes ul");
|
284 |
|
285 |
$(":range").rangeinput({progress:true});
|
286 |
|
287 |
function disableSliders() {
|
288 |
$("#cpu").attr('disabled',true);
|
289 |
$("#ram").attr('disabled',true);
|
290 |
$("#storage").attr('disabled',true);
|
291 |
}
|
292 |
|
293 |
$("#custom").click(function(event){
|
294 |
$("#cpu").attr('disabled',false);
|
295 |
$("#ram").attr('disabled',false);
|
296 |
$("#storage").attr('disabled',false);
|
297 |
$("strong.sliders").style = 'color: #778899;';
|
298 |
});
|
299 |
|
300 |
$("#small").click(function(event){
|
301 |
$("#cpu").data('rangeinput').setValue(1);
|
302 |
$("#ram").data('rangeinput').setValue(256);
|
303 |
$("#storage").data('rangeinput').setValue(5);
|
304 |
});
|
305 |
|
306 |
$("#medium").click(function(event){
|
307 |
$("#cpu").data('rangeinput').setValue(4);
|
308 |
$("#ram").data('rangeinput').setValue(1024);
|
309 |
$("#storage").data('rangeinput').setValue(30);
|
310 |
});
|
311 |
|
312 |
$("#large").click(function(event){
|
313 |
$("#cpu").data('rangeinput').setValue(8);
|
314 |
$("#ram").data('rangeinput').setValue(4096);
|
315 |
$("#storage").data('rangeinput').setValue(80);
|
316 |
});
|
317 |
|
318 |
$("#cancel").click(function(event){
|
319 |
$("a#create[rel]").overlay().close();
|
320 |
});
|
321 |
|
322 |
$("#start").click(function(event){
|
323 |
|
324 |
var triggers = $("a#notify").overlay({
|
325 |
// some mask tweaks suitable for modal dialogs
|
326 |
mask: {
|
327 |
color: '#ebecff',
|
328 |
opacity: '0.9'
|
329 |
},
|
330 |
top: 'center',
|
331 |
closeOnClick: false,
|
332 |
oneInstance: false,
|
333 |
load: true
|
334 |
});
|
335 |
$("#wizard").hide();
|
336 |
update();
|
337 |
$("a#create[rel]").overlay({mask: '#000', effect: 'default', top: '5%', oneInstance: false, closeOnClick: false});
|
338 |
});
|
339 |
|
340 |
$("a#create").click(function(event){
|
341 |
$("#wizard").scrollable().begin();
|
342 |
});
|
343 |
|
344 |
$("#cpu").change(function(event){
|
345 |
$("#custom").click();
|
346 |
});
|
347 |
|
348 |
$("#ram").change(function(event){
|
349 |
$("#custom").click();
|
350 |
});
|
351 |
|
352 |
$("#storage").change(function(event){
|
353 |
$("#custom").click();
|
354 |
});
|
355 |
|
356 |
$(function() {
|
357 |
$("a#create[rel]").overlay({mask: '#000', effect: 'default', top: '5%', oneInstance: false, closeOnClick: false});
|
358 |
});
|
359 |
|
360 |
$(function() {
|
361 |
var root = $("#wizard").scrollable();
|
362 |
|
363 |
// some variables that we need
|
364 |
var api = root.scrollable();
|
365 |
|
366 |
// rangeinput with default configuration
|
367 |
// validation logic is done inside the onBeforeSeek callback
|
368 |
api.onBeforeSeek(function(event, i) {
|
369 |
// we are going 1 step backwards so no need for validation
|
370 |
if (api.getIndex() < i) {
|
371 |
// 1. get current page
|
372 |
var page = root.find(".page").eq(api.getIndex()),
|
373 |
// 2. .. and all required fields inside the page
|
374 |
inputs = page.find(".required :input").removeClass("error"),
|
375 |
// 3. .. which are empty
|
376 |
empty = inputs.filter(function() {
|
377 |
return $(this).val().replace(/\s*/g, '') == '';
|
378 |
});
|
379 |
// if there are empty fields, then
|
380 |
if (empty.length) {
|
381 |
// add a CSS class name "error" for empty & required fields
|
382 |
empty.addClass("error");
|
383 |
// cancel seeking of the scrollable by returning false
|
384 |
return false;
|
385 |
// everything is good
|
386 |
}
|
387 |
}
|
388 |
// update status bar
|
389 |
$("#status li").removeClass("active").eq(i).addClass("active");
|
390 |
});
|
391 |
|
392 |
// if tab is pressed on the next button seek to next page
|
393 |
root.find("button.next").keydown(function(e) {
|
394 |
if (e.keyCode == 9) {
|
395 |
// seeks to next tab by executing our validation routine
|
396 |
api.next();
|
397 |
e.preventDefault();
|
398 |
}
|
399 |
});
|
400 |
// ]]>
|
401 |
});
|
402 |
</script>
|
403 |
|