Statistics
| Branch: | Tag: | Revision:

root / ui / templates / machines.html @ 9eef701d

History | View | Annotate | Download (25.7 kB)

1
{% load i18n %}
2

    
3
<div id="machines" class="seperator"></div>
4

    
5
<!-- the create button -->
6
<a id="create" rel="#wizard" href="#">{% trans "Create New +" %}</a>
7

    
8
<!-- changing between standard/list view -->
9
<div id="view-select">
10
    <a id="standard" class="current" href="/machines">#</a>
11
    <span class="view-seperator">|</span>
12
    <a id="list" href="/machines/list">=</a>
13
</div>
14

    
15
<!-- the standard view -->
16
<div id="machinesview" class="standard">
17
    <div id="spinner"></div>
18
    <div class="machine" id="machine-template" style="display:none">
19
        <div class="state">
20
            <div class="status">{% trans "Running" %}</div>
21
            <div class="indicator"></div>
22
            <div class="indicator"></div>
23
            <div class="indicator"></div>
24
            <div class="indicator"></div>
25
        </div>
26
        <img class="logo" src="" />
27
        <a href="#" class="name">
28
            <h5>Νame: <span class="name">node.name</span><span class="rename"></span></h5>
29
        </a>
30
        <a href="#" class="ip">
31
            <h5>IP: <span class="public">node.public_ip</span></h5>
32
        </a>
33
        <h5 class="settings">
34
            {% trans "Show:" %} <a href="#">{% trans "disks" %}</a> | <a href="#">{% trans "networks" %}</a> | <a href="#">{% trans "group" %}</a>
35
        </h5>
36
        <div class="actions">
37
            <a href="#" class="action-reboot">{% trans "Reboot" %}</a>
38
            <a href="#" class="action-shutdown">{% trans "Shutdown" %}</a>
39
            <a href="#" class="more">{% trans "more &hellip;" %}</a>
40
            <a href="#" class="action-start">{% trans "Start" %}</a>
41
        </div>
42
        <div class="seperator"></div>
43
    </div>
44

    
45
    <div class="running"></div>
46
    <div id="mini" class="seperator"></div>
47
    <div class="terminated"></div>
48
</div>
49

    
50
<div id="machines" class="seperator"></div>
51

    
52
<!-- the form -->
53
<form action="#">
54
        <!-- scrollable root element -->
55
        <div class="modal" id="wizard">
56
                <!-- status bar -->
57
                <ul id="status">
58
                        <li class="active"><strong>1.</strong> {% trans "Image" %}</li>
59
                        <li><strong>2.</strong> {% trans "Machine" %}</li>
60
                        <li><strong>3.</strong> {% trans "Review" %}</li>
61
                </ul>
62
                <!-- scrollable items -->
63
                <div class="items">
64
                        <!-- pages -->
65
                        <div class="page">
66
                <h2>{% trans "Select an OS" %}</h2>
67
                <ul class="tabs">
68
                    <li><a href="#">{% trans "standard" %}</a></li>
69
                    <li><a href="#">{% trans "custom" %}</a></li>
70
                </ul>
71
                <div class="panes">
72
                            <li id="image-template" style="display:none">
73
                                    <label for="image.id"> 
74
                            <a><div class="image">
75
                                <img src="" class="image-logo"/>
76
                                <strong class="image-title">image.title</strong>
77
                                <input class="radio" type="radio" name="image-id" id="image-id" />
78
                                <br />
79
                                <span class="description">image.description</span> 
80
                                <span class="size">?? MB</span>
81
                                
82
                            </div></a>
83
                                    </label>
84
                            </li>
85
                    <ul class="pane" id="standard-images">
86
                                            <!-- standard images -->
87
                                    </ul>
88
                    <ul class="pane" id="custom-images">
89
                                            <!-- custom images -->
90

    
91
                    </ul>
92
                </div>
93
                                <button type="button" class="prev" id="cancel">{% trans "Cancel" %}</button>
94
                                <button type="button" class="next right">{% trans "Next" %} &raquo;</button>
95
            </div>
96
                        <div class="page">
97
                                <h2>{% trans "Select CPU, RAM and storage" %}</h2>
98
                <ul>
99
                    <li>
100
                        <div class="machine-type">
101
                            <label for="small">
102
                                <input type="radio" id="small" name="machine-type" value="small" checked="true" />
103
                                <strong>{% trans "small" %}</strong>
104
                            </label>
105
                        </div>
106
                        <div class="machine-type">      
107
                            <label for="medium">
108
                                <input type="radio" id="medium" name="machine-type" value="medium" />                  
109
                                <strong>{% trans "medium" %}</strong>
110
                            </label>
111
                        </div>
112
                        <div class="machine-type">
113
                            <label for="large">
114
                                <input type="radio" id="large" name="machine-type" value="large" />
115
                                <strong>{% trans "large" %}</strong>
116
                            </label>
117
                        </div>
118
                        <div class="machine-type">
119
                            <label for="custom">
120
                                <input type="radio" name="machine-type" id="custom" value="large" />
121
                                <strong>{% trans "custom" %}</strong>
122
                            </label>
123
                        </div>
124
                    </li>
125
                    <li>
126
                                    <label><strong class="sliders">CPU (cores)</strong></label>
127
                        <input type="range" id="cpu" value="1" max="8" min="1" />
128
                    </li>
129
                    <li>
130
                                    <label><strong class="sliders">RAM (MB)</strong></label>
131
                        <input type="range" id="ram" value="256" max="2048" min="256" step="256" />
132
                    </li>
133
                    <li>
134
                                <label><strong class="sliders">Storage (GB)</strong></label>
135
                        <input type="range" id="storage" value="5" step="1" max="100" min="2" />
136
                    </li>
137
                    <li>
138
                        <div class="cost">
139
                            {% trans "Cost per hour:" %} 20 {% trans "credits" %} | {% trans "Credits currently in account:" %} 10.000
140
                        </div>
141
                    </li>
142
                </ul>
143
                                <button type="button" class="prev">&laquo; {% trans "Back" %}</button>
144
                                <button type="button" class="next right">{% trans "Next" %} &raquo;</button>
145
            </div>
146
                        <div class="page">
147
                                <h2>{% trans "Confirm your settings" %}</h2>
148
                <ul>
149
                    <li class="required">
150
                        <label>
151
                            <strong>Machine name</strong>
152
                            <input type="text" class="text" name="machine_name" value="My Ubuntu 10.04 x86_64 server"/>
153
                        </label>
154
                    </li>
155
                    <li>
156
                        <strong>{% trans "Image:" %}</strong> <span>Ubuntu 10.04 x86_64 server</span>
157
                    </li>
158
                    <li>
159
                        <strong>{% trans "CPU:" %}</strong> <span>2 cores</span>
160
                    </li>
161
                    <li>
162
                        <strong>{% trans "RAM:" %}</strong> <span>1024MB</span>
163
                    </li>
164
                    <li>
165
                        <strong>{% trans "Storage:" %}</strong> <span>10GB</span>
166
                    </li>
167
                    <li>
168
                        <strong>{% trans "Cost per hour:" %}</strong> <span>20 {% trans "credits" %}</span>
169
                    </li>
170
                    <li>
171
                        <strong>{% trans "Remaining credits:" %}</strong> <span>10.000</span>
172
                    </li>
173
                </ul>
174
                                <button type="button" class="prev">&laquo; {% trans "Back" %}</button>
175
                                <button type="button" class="next right" id="start">{% trans "Create VM" %}</button>        
176
            </div>
177
                </div>
178
        </div>
179
</form>
180

    
181
<!-- notification after wizard completion -->
182
<a id="notification" rel="#error-success" href="#"></a>
183

    
184
<div class="modal" id="error-success">
185
    <h3>{% trans "Error!/Success!" %}</h3>
186
    <p>{% trans "More details about the result"%}</p>
187
</div>
188

    
189
<!-- confirmation before executing an action -->
190
<a id="confirmation" rel="#yes-no" href="#"></a>
191

    
192
<div class="modal" id="yes-no">
193
    <h3>{% trans "You are about to xxx machine yyy" %}</h3>
194
    <p>{% trans "Are you sure you want to proceed?" %}</p>
195
    <button>{% trans "Yes" %}</button>
196
        <button>{% trans "No" %}</button>
197
</div>
198

    
199
<script type="text/javascript"> 
200
var TIMEOUT = {{timeout}};
201
</script>
202

    
203
<script>
204
// hardcoded image types
205
var image_tags = {
206
                1: 'archlinux',
207
                2: 'centos',
208
                3: 'debian',
209
                4: 'freebsd',
210
                5: 'gentoo',
211
                6: 'netbsd',
212
                7: 'openbsd',
213
                8: 'redhat',
214
                9: 'slackware',
215
                10: 'suse',
216
                11: 'ubuntu',
217
                12: 'windows',
218
                20: 'ubuntu',
219
               };
220

221
// ajax error checking  
222
function ajax_error(jqXHR) {; 
223
    // prepare the error message
224
    $("#error-success h3").text('Error!');
225
    // check the error code
226
    switch (jqXHR.status) {
227
        case 503: // XX error/message
228
            $("#error-success p").text('Your request caused a <strong>' + jqXHR.status + '</strong> error');
229
            break;
230
        case 400: // YY error/message
231
            $("#error-success p").text('Your request caused a <strong>' + jqXHR.status + '</strong> error');
232
            break;
233
        default: // XXYY error/message
234
            $("#error-success p").text('Your request caused a <strong>' + jqXHR.status + '</strong> error');
235
    }
236
    // bring up error notification
237
    var triggers = $("a#notification").overlay({
238
            // some mask tweaks suitable for modal dialogs
239
            mask: {
240
                    color: '#ebecff',
241
                    opacity: '0.9'
242
            },
243
        top: 'center',
244
            closeOnClick: false,
245
        oneInstance: false,
246
        load: true,
247
        onClose: function(){
248
            $("div.pane#machines-pane").load($("a#standard").attr("href"));
249
        }
250
    });
251
    return false;
252
}
253

254
// ajax success checking
255
function ajax_success() {
256
    // prepare the error message
257
    $("#error-success h3").text('Success!');
258
    $("#error-success p").text('Your request has been succefully executed.');
259
    // bring up success notification
260
    var triggers = $("a#notification").overlay({
261
            // some mask tweaks suitable for modal dialogs
262
            mask: {
263
                    color: '#ebecff',
264
                    opacity: '0.9'
265
            },
266
        top: 'center',
267
            closeOnClick: false,
268
        oneInstance: false,
269
        load: true,
270
        onClose: function(){
271
            $("div.pane#machines-pane").load($("a#standard").attr("href"));
272
        }
273
    });
274
    return false;
275
}
276

277
// confirmation overlay generation
278
function confirm_action(action_string, action_function, serverID, serverName) {
279
    $("#yes-no h3").text('You are about to ' + action_string + ' vm ' + serverName);
280
    // action confirmation overlay
281
    var triggers = $("a#confirmation").overlay({
282
            // some mask tweaks suitable for modal dialogs
283
            mask: {
284
                    color: '#ebecff',
285
                    opacity: '0.9'
286
            },
287
        top: 'center',
288
        load: true
289
    });
290
    // yes or no?
291
    var buttons = $("#yes-no button").click(function(e) {
292
            // get user input
293
            var yes = buttons.index(this) === 0;
294
        //close the confirmation window
295
        $("a#confirmation").overlay().close(); 
296
        // return true=yes or false=no
297
        if (yes) {
298
            action_function(serverID);
299
        }
300
    });
301
    //close the window, no matter the answer
302
    return false;
303
}
304

305
// get and show a list of running and terminated machines
306
function update_vms() {
307

308
    $(".running").text('');
309
    $(".terminated").text('');
310
    $("ul#standard-images").text('');
311
    $("ul#custom-images").text('');
312

313
    $.ajax({
314
        url: '/api/v1.0/servers/detail',
315
        type: "GET",
316
        timeout: TIMEOUT,
317
        dataType: "json",
318
        error: function(jqXHR, textStatus, errorThrown) { 
319
                    ajax_error(jqXHR);
320
                    },
321
        success: function(data, textStatus, jqXHR) {
322
            if ($(".running a.name").length + $(".terminated a.name").length == 0) {
323
            
324
                $.each(data.servers, function(i,server){
325
                    // if the machine is deleted it should not be included in any list
326
                    if (server.status == 'DELETED') {
327
                        return;
328
                    }
329
                    var machine = $("#machine-template").clone().attr("id", server.id).fadeIn("slow");
330
                    machine.find("input[type='checkbox']").attr("id", "input-" + server.id);
331
                    machine.find("input[type='checkbox']").attr("class", server.status);
332
                    machine.find("a.name span.name").text(server.name);
333
                    machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'.png');
334
                    machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'.png');
335
                    machine.find("img.list-logo").attr("title",image_tags[server.imageId]);
336
                    machine.find("span.imagetag").text(image_tags[server.imageId]);
337
    
338
                    machine.find("a.ip span.public").text(String(server.metadata.addresses.public).replace(',',' '));            
339
    
340
                    // TODO: handle SHARE_IP, SHARE_IP_NO_CONFIG, DELETE_IP, REBUILD, QUEUE_RESIZE, PREP_RESIZE, RESIZE, VERIFY_RESIZE, PASSWORD, RESCUE
341
                    if (server.status == 'BUILD'){
342
                        machine.find(".status").text('Building');
343
                        machine.appendTo(".running");
344
                    } else if (server.status == 'ACTIVE') {
345
                        machine.find(".status").text('Running');
346
                        machine.appendTo(".running"); 
347
                    } else if (server.status == 'REBOOT' || server.status == 'HARD_REBOOT') {
348
                        machine.find(".status").text('Rebooting');
349
                        machine.appendTo(".running");
350
                    } else if (server.status == 'STOPPED') {
351
                        machine.find(".status").text('Stopped');
352
                        machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
353
                        machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
354
                        machine.appendTo(".terminated");
355
                    } else if (server.status == 'ERROR') {
356
                        machine.find(".status").text('Error');
357
                        machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
358
                        machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
359
                        machine.appendTo(".terminated");
360
                    } 
361
                    else {
362
                        machine.find(".status").text('Unknown');
363
                        machine.find("img.logo").attr("src","static/machines/"+image_tags[server.imageId]+'-off.png');
364
                        machine.find("img.list-logo").attr("src","static/os_logos/"+image_tags[server.imageId]+'-off.png');
365
                        machine.appendTo(".terminated");
366
                    }
367
                });
368
                // if the terminated list is populated then the seperator must be shown
369
                if ($(".terminated a.name").length > 0) {
370
                    $("#mini.seperator").fadeIn("slow");
371
                }
372
            }
373
            $("div.machine:last-child").find("div.seperator").hide();
374
            $("#spinner").hide();
375
            if ($("div.list table.list-running tbody.running tr").length > 0) {
376
                $("div.list table.list-running").dataTable({
377
                    "bInfo": false,
378
                    "bPaginate": false,
379
                            "bAutoWidth": false,
380
                            "bSort": true,    
381
                    "bStateSave": true,
382
                    "aoColumnDefs": [
383
                        { "bSortable": false, "aTargets": [ 0 ] }
384
                    ]//,
385
                    //"sScrollY": "310px",
386
                    //"bScrollCollapse": true
387
                });
388
                $("div.list table.list-running").show();
389
                $("div.list div.actions").show();
390
            }
391
            if ($("div.list table.list-terminated tbody.terminated tr").length > 0) {
392
                $("div.list table.list-terminated").dataTable({
393
                    "bInfo": false,
394
                    "bPaginate": false,
395
                            "bSort": true,    
396
                            "bAutoWidth": false,
397
                    "bStateSave": true,
398
                    "aoColumnDefs": [
399
                        { "bSortable": false, "aTargets": [ 0 ] }
400
                    ]//,
401
                    //"sScrollY": "200px",
402
                    //"bScrollCollapse": true
403
                });
404
                $("div.list table.list-terminated").show();
405
                $("div.list div.actions").show();
406
            }
407
        }
408
    });
409
    return false;
410
}
411

412
// get and show a list of anvailable standard and custom images
413
function update_images() { 
414
    $.ajax({
415
        url: '/api/v1.0/images/detail',
416
        type: "GET",
417
        //async: false,
418
        dataType: "json",
419
        timeout: TIMEOUT,
420
        error: function(jqXHR, textStatus, errorThrown) { 
421
                    ajax_error(jqXHR);
422
                    },
423
        success: function(data, textStatus, jqXHR) {
424
            if ($("ul#standard-images li").toArray().length + $("ul#custom-images li").toArray().length == 0) {
425
                $.each(data.images, function(i,image){
426
                    var img = $('#image-template').clone().attr("id","img-"+image.id).fadeIn("slow");
427
                    img.find("label").attr('for',"img-radio-" + image.id);
428
                    img.find(".image-title").text(image.name);
429
                    img.find(".description").text(image.description);
430
                    img.find("input.radio").attr('id',"img-radio-" + image.id);
431
                    if (i==0) img.find("input.radio").attr("checked","checked"); 
432
                    img.find("img.image-logo").attr('src','static/os_logos/'+image_tags[image.id]+'.png');
433
                    if (image.serverId) {
434
                        img.appendTo("ul#custom-images");
435
                    } else {
436
                        img.appendTo("ul#standard-images");
437
                    }
438
                });
439
            }
440
        }
441
    });
442
    return false;
443
}
444

445
// switch to list view
446
$("#list").click(function(){
447
    $.cookie("list", '1'); // set list cookie
448
    $("div.standard#machinesview").load($("#list").attr("href"));
449
    $("a#standard")[0].className += ' activelink'
450
    this.style.color = '#5f8dd3';
451
    update_vms();
452
    return false;
453
});
454

455
// switch to standard view
456
$("a#standard").click(function(){
457
    $.cookie("list", '0');
458
    href=$("a#standard").attr("href");
459
    $("div.pane#machines-pane").load(href);
460
    return false;
461
});
462

463
// redirect to list view if the list cookie is set
464
if ($.cookie("list") == '1') {
465
    $("#list").click();
466
} else {
467
    // execute the update function to populate the list
468
    update_vms();
469
}
470

471
// launch VM creation wizard
472
$("a#create").click(function(){
473
    // populate image list
474
    update_images();
475
    // launch the wizard
476
    $("#wizard").scrollable().begin();
477
});
478

479
// create wizard overlay
480
$(function() { 
481
    $("a#create").overlay({
482
        mask: '#000', 
483
        effect: 'default', 
484
        top: '5%', 
485
        oneInstance: false,
486
        closeOnClick: false
487
    });
488
});
489

490
// wizard
491
$(function() {
492
    var root = $("#wizard").scrollable();
493

494
    // some variables that we need
495
    var api = root.scrollable();
496

497
    // rangeinput with default configuration
498
    // validation logic is done inside the onBeforeSeek callback
499
    api.onBeforeSeek(function(event, i) {
500
            // we are going 1 step backwards so no need for validation
501
            if (api.getIndex() < i) {
502
             // 1. get current page
503
                     var page = root.find(".page").eq(api.getIndex()),
504
                         // 2. .. and all required fields inside the page
505
                         inputs = page.find(".required :input").removeClass("error"),
506
                         // 3. .. which are empty
507
                         empty = inputs.filter(function() {
508
                                return $(this).val().replace(/\s*/g, '') == '';
509
                         });
510
                     // if there are empty fields, then
511
                    if (empty.length) {
512
                            // add a CSS class name "error" for empty & required fields
513
                            empty.addClass("error");
514
                            // cancel seeking of the scrollable by returning false
515
                            return false;
516
                    // everything is good
517
                    } 
518
            }
519
            // update status bar
520
            $("#status li").removeClass("active").eq(i).addClass("active");
521
    });
522

523
    // if tab is pressed on the next button seek to next page
524
    root.find("button.next").keydown(function(e) {
525
            if (e.keyCode == 9) {
526
                    // seeks to next tab by executing our validation routine
527
                    api.next();
528
                    e.preventDefault();
529
            }
530
    });
531
});
532

533
// sliders for selecting VM flavor
534
$(":range").rangeinput({progress:true});
535

536
// disable sliders in flavor selection
537
function disableSliders() {
538
    $("#cpu").attr('disabled',true);
539
    $("#ram").attr('disabled',true);
540
    $("#storage").attr('disabled',true);
541
}
542

543
// selecting the small size
544
$("#small").click(function(){
545
    $("#cpu").data('rangeinput').setValue(1);
546
    $("#ram").data('rangeinput').setValue(256);
547
    $("#storage").data('rangeinput').setValue(5);
548
});
549

550
// selecting the medium size
551
$("#medium").click(function(){
552
    $("#cpu").data('rangeinput').setValue(4);
553
    $("#ram").data('rangeinput').setValue(1024);
554
    $("#storage").data('rangeinput').setValue(30);
555
});
556

557
// selecting the large size
558
$("#large").click(function(){
559
    $("#cpu").data('rangeinput').setValue(8);
560
    $("#ram").data('rangeinput').setValue(4096);
561
    $("#storage").data('rangeinput').setValue(80);
562
});
563

564
// selecting the custom flavor enables the sliders
565
$("#custom").click(function(){
566
    $("#cpu").attr('disabled',false);
567
    $("#ram").attr('disabled',false);
568
    $("#storage").attr('disabled',false);
569
    $("strong.sliders").style = 'color: #778899;';
570
});
571

572
// get cpu value for custom flavor
573
$("#cpu").change(function(){
574
    $("#custom").click();
575
});
576

577
// get ram value for custom flavor
578
$("#ram").change(function(){
579
    $("#custom").click();
580
});
581

582
// get storage value for custom flavor
583
$("#storage").change(function(){
584
    $("#custom").click();
585
});
586

587
// exit the wizard
588
$("#cancel").click(function(){
589
    $("a#create").overlay().close();
590
});
591

592
// starting a new VM through the wizard
593
$("#start").click(function(){
594
    // ajax port create call
595
    $.ajax({
596
    url: '/api/v1.0/servers',
597
    type: "POST",
598
    data: {
599
        "create": '{"cpu" : "2", "ram": "1024", "storage": "15", "name": "image name"}'
600
        },
601
    //TODO: get the real data
602
    dataType: "json",
603
    timeout: TIMEOUT,
604
    error: function(jqXHR, textStatus, errorThrown) { 
605
                ajax_error(jqXHR);
606
           },
607
    success: function(data, textStatus, jqXHR) {
608
                if ( jqXHR.status == '202') {
609
                    ajax_success(jqXHR);                   
610
                } else {
611
                    ajax_error(jqXHR);
612
                }}
613
    });
614
    $("#wizard").hide();
615
});
616

617
// reboot action
618
function reboot(serverID){
619
    // ajax post reboot call
620
    $.ajax({
621
        url: '/api/v1.0/servers/' + serverID + '/action',
622
        type: "POST",
623
        data: {
624
            "reboot": '{"type" : "HARD"}'
625
            },
626
        dataType: "json",
627
        timeout: TIMEOUT,
628
        error: function(jqXHR, textStatus, errorThrown) { 
629
                    ajax_error(jqXHR);
630
                    },
631
        success: function(data, textStatus, jqXHR) {
632
                    if ( jqXHR.status == '202') {
633
                        ajax_success(jqXHR);
634
                    } else {
635
                        ajax_error(jqXHR);
636
                    }}
637
    });
638
    return false;
639
}
640

641
// shutdown action
642
function shutdown(serverID) {
643
    // ajax post shutdown call
644
    $.ajax({
645
            url: '/api/v1.0/servers/' + serverID + '/action',
646
            type: "POST",
647
            data: {
648
                    "shutdown": '{"timeout" : "5"}'
649
                    },
650
            dataType: "json",
651
        timeout: TIMEOUT,
652
        error: function(jqXHR, textStatus, errorThrown) { 
653
                    ajax_error(jqXHR);
654
                    },
655
        success: function(data, textStatus, jqXHR) {
656
                    if ( jqXHR.status == '202') {
657
                        ajax_success(jqXHR);
658
                    } else {
659
                        ajax_error(jqXHR);
660
                    }}             
661
    });
662
    return false;    
663
}
664

665

666
// start action
667
function start(serverID){
668
    // ajax post start call
669
    $.ajax({
670
        url: '/api/v1.0/servers/' + serverID + '/action',
671
        type: "POST",
672
        data: {
673
            "start": '{"type" : "NORMAL"}'
674
            },
675
        dataType: "json",
676
        timeout: TIMEOUT,
677
        error: function(jqXHR, textStatus, errorThrown) { 
678
                    ajax_error(jqXHR);
679
                    },
680
        success: function(data, textStatus, jqXHR) {
681
                    if ( jqXHR.status == '202') {
682
                        ajax_success(jqXHR);
683
                    } else {
684
                        ajax_error(jqXHR);
685
                    }}
686
    });
687
    return false;
688
}
689

690

691
// basic functions executed on page load
692

693
// create tabs for main menu
694
$("ul.tabs").tabs("div.panes ul");
695

696
// intercept reboot click 
697
$("div.actions a.action-reboot").live('click', function(){ 
698
    var serverID = $(this).parent().parent().attr("id");
699
    var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
700
    confirm_action('reboot', reboot, serverID, serverName);
701
    return false;
702
});
703

704
// intercept shutdown click
705
$("div.actions a.action-shutdown").live('click', function(){ 
706
    var serverID = $(this).parent().parent().attr("id");
707
    var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
708
    confirm_action('shutdown', shutdown, serverID, serverName);
709
    return false;
710
});
711
// intercept start click
712
$("div.actions a.action-start").live('click', function(){ 
713
    var serverID = $(this).parent().parent().attr("id");
714
    var serverName = $(this).parent().prevAll("a.name").find("span.name").text();
715
    confirm_action('start', start, serverID, serverName);
716
    return false;
717
});
718
</script>