Revision 6dd01959

b/ui/static/synnefo.js
1885 1885
                        ' to ' + STATUSES[new_status]);
1886 1886
        } else {
1887 1887
            console.info(server_entry.find("div.name span.name").text() +
1888
                        ' from ' + server_entry.find(".status").text() +
1888
                        ' from ' + server_entry.find(".status").text().replace(TRANSITION_STATE_APPEND, "") +
1889 1889
                        ' to ' + STATUSES[new_status]);
1890 1890
        }
1891 1891
    } catch(err) {}
b/ui/templates/home.html
106 106
            '{% trans "Rebooting" %}',
107 107
            '{% trans "Destroying" %}'
108 108
        ];
109
        
110
        var TRANSITION_STATES = [
111
            '{% trans "Building" %}',
112
            '{% trans "Rebooting" %}',
113
            '{% trans "Starting" %}',
114
            '{% trans "Shutting down" %}',
115
            '{% trans "Destroying" %}',
116
            '{% trans "Connecting" %}',
117
            '{% trans "Disconnectig" %}'
118
        ]
119
        var TRANSITION_STATE_APPEND = "...";
109 120

  
110 121
        var INACTIVE_STATES = [
111 122
            '{% trans "Unknown" %}',
......
319 330

  
320 331
                        setTimeout('show_feedback_form(fdb_msg, 1); $("#exposeMask").show();', 400);
321 332
                    } catch (err) {
322
                        console.log(err);
323 333
                        sel(".send-btn").hide();
324 334
                        sel(".errormsg").fadeIn();
325 335
                        window.FEEDBACK_PENDING = false;
b/ui/templates/machines.html
1007 1007
            }
1008 1008
        }
1009 1009
        action[0]([serverID]); // execute action
1010
        update_transition_names();
1010 1011
    }
1011 1012
    $('#machinesview-list .actions .selected').removeClass('selected');
1012 1013
    update_confirmations();
b/ui/templates/machines_icon.html
176 176
// handle connect machine image states
177 177
$("div.connect-arrow, div.running .machine .logo").live('mouseover',
178 178
    function() {
179
        if ($(this).parent().parent().find('.status').text() != STATUSES['ACTIVE']) { return };
179
        if ($(this).parent().parent().find('.status').text().replace(TRANSITION_STATE_APPEND, "") != STATUSES['ACTIVE']) { return };
180 180
        set_machine_os_image($(this).parent().parent(), "icon", "hover", undefined, 1);
181 181
        var parent = $(this).parent().parent();
182 182
        parent.find(".connect-arrow").show().addClass('border-hover');
......
184 184

  
185 185
$("div.connect-arrow, div.running .machine .logo").live('mouseleave',
186 186
    function() {
187
        if ($(this).parent().parent().find('.status').text() != STATUSES['ACTIVE']) { return };
187
        if ($(this).parent().parent().find('.status').text().replace(TRANSITION_STATE_APPEND, "") != STATUSES['ACTIVE']) { return };
188 188
        set_machine_os_image($(this).parent().parent(), "icon", "hover", undefined, 1, "hover");
189 189
        // mouseup outside the element is not fired
190 190
        set_machine_os_image($(this).parent().parent(), "icon", "hover", undefined, 1, "click");
......
207 207
// actions on machine mouseover
208 208
$("#machinesview-icon.standard .machine").live('mouseover', function() {
209 209
    // show connect button only if the machine is active
210
    if ($(this).find('.status').text() == STATUSES['ACTIVE']) {
210
    if ($(this).find('.status').text().replace(TRANSITION_STATE_APPEND, "") == STATUSES['ACTIVE']) {
211 211
        $(this).find("div.connect-arrow").show();
212 212
        $(this).find("div.connect-border").show();
213 213
    }
......
510 510
            action[0]([action[1]]); // execute action
511 511
        }
512 512
    }
513

  
513 514
    $(this).parent().hide();
514 515
    $(this).closest('div.actions').find('a').removeClass('selected');
515 516
    $(this).closest("div.machine").children('.state').children('.spinner').show()
516 517
    $(this).closest("div.machine").children('div.actions').removeClass('display');
518
    update_transition_names();
517 519
    update_confirmations();
518 520
    return false;
519 521
});
......
557 559
            var server_image = "unknown"
558 560
        }
559 561
        // get server status message, if it exists
560
        var current_message = existing.find(".status").text();
562
        var current_message = existing.find(".status").text().replace(TRANSITION_STATE_APPEND,"");
561 563
        // if multiple machines exist in the DOM, delete all but one
562 564
        // defensive coding - that shouldn't happen normally
563 565
        while (existing.length > 1){
......
753 755
    } else {
754 756
        $('.confirm_multiple').removeClass('fixed');
755 757
    }
758

  
759
    update_transition_names();
756 760
}
757 761

  
758 762
// reposition multiple confirmation box on window resize
......
785 789
    $("#machinesview-icon.standard div.#" +serverID).find(".metadata-count").text(i);
786 790
}
787 791

  
792
// define these to avoid exceptions
793
function display_reboot_success() {
794
}
795

  
796
function display_reboot_failure() {
797
}
798

  
799
// append string to transition states
800
function update_transition_names() {
801
    $(".state .status").each(function(index,el){
802
    var tr_text = $(this).text().replace(TRANSITION_STATE_APPEND,"");
803
    if (TRANSITION_STATES.indexOf(tr_text) >= 0) {
804
            $(this).text(tr_text + TRANSITION_STATE_APPEND);
805
        }
806
    })
807
}
808

  
788 809
// indicate that the requested action was succesfully completed
789 810
function display_success(serverID) {
790 811

  
b/ui/templates/machines_list.html
282 282
        if (current != -1) { // if it's there, update the values
283 283
            // get current status description, including non api states
284 284
            var server_row = $('#machinesview .list #' + server.id).parent().parent();
285
            var status_desc = server_row.find('span.status').text();
285
            var status_desc = server_row.find('span.status').text().replace(TRANSITION_STATE_APPEND, "");
286 286
            // firebug console logging
287 287
            try {
288 288
                console.info(server.name + ' from ' + status_desc + ' to ' + STATUSES[server.status]);
......
293 293
            } else { // when server is not deleted, it should be updated
294 294
                if (['BUILD','ACTIVE','REBOOT'].indexOf(server.status) >= 0 &&
295 295
                    [STATUSES['STOPPED'], STATUSES['ERROR'], STATUSES['UNKNOWN'],
296
                     TRANSITIONS['Starting']].indexOf(server_row.find('span.status').text()) >= 0) {
296
                     TRANSITIONS['Starting']].indexOf(server_row.find('span.status').text().replace(TRANSITION_STATE_APPEND, "")) >= 0) {
297 297
                    // from stopped, on error or starting to building, active or rebooting
298 298
                    // starting is not an api state, it means the server is stopped or on error
299 299
                    tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>";
......
307 307
                    setTimeout("$('#machinesview .list #"+server.id+"').parent().parent().find('.list-logo').attr('src','static/icons/machines/small/" + osIcon + "')", 1600);
308 308
                } else if (['STOPPED','ERROR', 'UNKNOWN'].indexOf(server.status) >= 0 &&
309 309
                           [STATUSES['ACTIVE'], STATUSES['BUILD'], STATUSES['REBOOT'],
310
                            TRANSITIONS['Shutting down']].indexOf(server_row.find('span.status').text()) >= 0) {
310
                            TRANSITIONS['Shutting down']].indexOf(server_row.find('span.status').text().replace(TRANSITION_STATE_APPEND, "")) >= 0) {
311 311
                    tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>";
312 312
                    imgSrc = "static/icons/indicators/small/wave.gif";
313 313
                    imgStr = "<img class=list-logo src=" + imgSrc + " title=" + osTag + "></img>";
......
317 317
                    tableData[current][4] = "<span class=status>" + STATUSES[server.status] + "</span>";
318 318
                    vmTable.fnUpdate(tableData[current],current);
319 319
                    setTimeout("$('#machinesview .list #"+server.id+"').parent().parent().find('.list-logo').attr('src','static/icons/machines/small/" + osTag + "-off.png')", 1600);
320
                } else if ( STATUSES[server.status] == server_row.find('span.status').text()) {
320
                } else if ( STATUSES[server.status] == server_row.find('span.status').text().replace(TRANSITION_STATE_APPEND, "")) {
321 321

  
322 322
                } else if (server.status == 'ACTIVE' &&
323
                           [STATUSES['BUILD'],TRANSITIONS['Rebooting']].indexOf(server_row.find('span.status').text()) >= 0) {
323
                           [STATUSES['BUILD'],TRANSITIONS['Rebooting']].indexOf(server_row.find('span.status').text().replace(TRANSITION_STATE_APPEND, "")) >= 0) {
324 324
                    tableData[current][0] = "<input class="+server.status+" id="+server.id+" type=checkbox>";
325 325
                    imgSrc = "static/icons/indicators/small/wave.gif";
326 326
                    imgStr = "<img class=list-logo src=" + imgSrc + " title=" + osTag + "></img>";
......
382 382
                "<span class=status>" + status_string + "</span>"
383 383
            ]);
384 384
        }
385
    });
385
        });
386

  
387
    update_transition_names();
386 388
    update_listview_actions();
389

  
387 390
    $("#machinesview .list > div.large-spinner").hide();
388 391
    // in case there are no data, leave the page empty
389 392
    if ($("#machinesview .list table.list-machines tbody").length > 0) {
......
411 414
    $('#machinesview .list .dataTables_scrollHeadInner th').attr('style','');
412 415
}
413 416

  
417
// define these to avoid exceptions
418
function display_reboot_success() {
419
}
420

  
421
function display_reboot_failure() {
422
}
423

  
424
// append string to transition states
425
function update_transition_names() {
426
    $("td span.status").each(function(index,el){
427
    var tr_text = $(this).text().replace(TRANSITION_STATE_APPEND,"");
428
    if (TRANSITION_STATES.indexOf(tr_text) >= 0) {
429
            $(this).text(tr_text + TRANSITION_STATE_APPEND);
430
        }
431
    })
432
}
433

  
414 434
function display_success(serverID) {
415 435
    // do nothing
416 436
}
b/ui/templates/machines_single.html
314 314
    $(this).parent().hide();
315 315
    $(this).closest('div.action-container').children('div.single-action').removeClass('selected');
316 316
    $(this).parent().parent().find('.state').children('.spinner').show();
317
    update_transition_names();
317 318
    update_confirmations();
318 319
    return false;
319 320
});
......
453 454
            var server_image = "unknown"
454 455
        }
455 456
        // get server status message, if it exists
456
        var current_message = existing.find(".state-label").text();
457
        var current_message = existing.find(".state-label").text().replace(TRANSITION_STATE_APPEND, "");
457 458

  
458 459
        // server already exists in DOM
459 460
        if (existing.length){
......
583 584
            }
584 585
            //show spinner while machine is building or rebooting
585 586
            if (server.status == 'BUILD' ||
586
                [TRANSITIONS['Starting'], TRANSITIONS['Shutting down']].indexOf(existing.find(".status").text()) >= 0 ) {
587
                [TRANSITIONS['Starting'], TRANSITIONS['Shutting down']].indexOf(existing.find(".status").text().replace(TRANSITION_STATE_APPEND, "")) >= 0 ) {
587 588
                machine.find(".column1 .state .spinner").show();
588 589
                machine.find(".connect-border").hide();
589 590
                machine.find(".connect-arrow").hide();
......
641 642
        }
642 643
    });
643 644

  
645
    update_transition_names();
644 646
    fix_v6_addresses();
645 647
    // hide pane spinner
646 648
    $("#machinesview-single.single > div.large-spinner").hide();
......
678 680
    }
679 681
}
680 682

  
683
// define these to avoid exceptions
684
function display_reboot_success() {
685
}
686

  
687
function display_reboot_failure() {
688
}
689

  
690
// append string to transition states
691
function update_transition_names() {
692
    $(".state-label").each(function(index,el){
693
    var tr_text = $(this).text().replace(TRANSITION_STATE_APPEND,"");
694
    if (TRANSITION_STATES.indexOf(tr_text) >= 0) {
695
            $(this).text(tr_text + TRANSITION_STATE_APPEND);
696
        }
697
    })
698
}
699

  
681 700
//get currently displayed serverId
682 701
function current_serverId() {
683 702
    return $("#machinesview-single.single").find("div.single-container:visible").attr("id");

Also available in: Unified diff