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