Revision 9ac432ec ui/templates/machines_single.html

b/ui/templates/machines_single.html
198 198

  
199 199
// handle connect machine image states
200 200
$("div.connect-arrow, .single-image").live('mouseenter',
201
    function() {
201
function() {
202
        has_ip = vm_has_public_ip(singleview_closest_vm(this));
202 203
        // ugly check to see if machine is running
203
        if ($(this).parent().find(".connect-arrow:visible").length == 0) { return };
204
        if ($(this).parent().find(".connect-arrow:visible").length == 0 || !has_ip) { return };
204 205
        set_machine_os_image($(this).parent().parent(), "single", "hover", undefined, 1);
205 206
        var parent = $(this).parent().parent();
206 207
        parent.find(".connect-arrow").show().addClass('border-hover');
......
208 209

  
209 210
$("div.connect-arrow, .single-image").live('mouseleave',
210 211
    function() {
211
        if ($(this).parent().find(".connect-arrow:visible").length == 0) { return };
212
        has_ip = vm_has_public_ip(singleview_closest_vm(this));
213
        if ($(this).parent().find(".connect-arrow:visible").length == 0 || !has_ip) { return };
212 214
        set_machine_os_image($(this).parent().parent(), "single", "hover", undefined, 1, "hover");
213 215
        set_machine_os_image($(this).parent().parent(), "single", "click", undefined, 1, "click");
214 216
        var parent = $(this).parent().parent();
......
217 219

  
218 220
$("div.connect-arrow, .single-image").live('mousedown',
219 221
    function() {
220
        if ($(this).parent().find(".connect-arrow:visible").length == 0) { return };
222
        has_ip = vm_has_public_ip(singleview_closest_vm(this));
223
        if ($(this).parent().find(".connect-arrow:visible").length == 0 || !has_ip) { return };
221 224
        set_machine_os_image($(this).parent().parent(), "single", "click", undefined, 1);
222 225
    });
223 226

  
224 227
$("div.connect-arrow, .single-image").live('mouseup',
225 228
    function() {
226
        if ($(this).parent().find(".connect-arrow:visible").length == 0) { return };
229
        has_ip = vm_has_public_ip(singleview_closest_vm(this));
230
        if ($(this).parent().find(".connect-arrow:visible").length == 0 || !has_ip) { return };
227 231
        set_machine_os_image($(this).parent().parent(), "single", "click", undefined, 1, "click");
228 232
    });
229 233

  
......
415 419
// connect to machine on machine logo click
416 420
$("#machinesview-single.single div.single-image").live('click', function(){
417 421
    if ($(this).parent().find(".connect-arrow:visible").length == 0) { return };
422
    has_ip = vm_has_public_ip(singleview_closest_vm(this));
423
    if (!has_ip) { return }
418 424
    var serverID = $(this).closest(".single-container").attr("id");
419 425
    machine_connect([machine_connect, serverID]);
420 426
    return false;
......
512 518
                    log_server_status_change(existing, server.status);
513 519
                    set_machine_os_image(existing, "single", "on", server_image);
514 520
                    existing.find(".column1 .state-label").text(STATUSES[server.status]);
515
                    existing.find(".connect-border").show();
516
                    existing.find(".connect-arrow").show();
521

  
522
                    vm = get_machine(existing.attr("id"));
523
                    has_ip = vm_has_public_ip(vm);
524

  
525
                    if (has_ip) {
526
                        existing.find(".connect-border").show();
527
                        existing.find(".connect-arrow").show();
528
                    } else {
529
                        existing.find(".connect-border").hide();
530
                        existing.find(".connect-arrow").hide();
531
                    }
532

  
517 533
                    existing.find(".column1 .state .spinner").hide();
518 534
                    existing.find(' .wave').attr('src','static/icons/indicators/medium/wave.gif').show();
519 535
                    existing.find(".column1 .state").removeClass().addClass("state running-state");
......
529 545
                        // if it has been rebooted or just created
530 546
                        log_server_status_change(existing, server.status);
531 547
                        existing.find(".column1 .state-label").text(STATUSES[server.status]);
532
                        existing.find(".connect-border").show();
533
                        existing.find(".connect-arrow").show();
548
                        vm = get_machine(existing.attr("id"));
549
                        has_ip = vm_has_public_ip(vm);
550

  
551
                        if (has_ip) {
552
                            existing.find(".connect-border").show();
553
                            existing.find(".connect-arrow").show();
554
                        } else {
555
                            existing.find(".connect-border").hide();
556
                            existing.find(".connect-arrow").hide();
557
                        }
534 558
                        existing.find(".column1 .state .spinner").hide();
535 559
                        existing.find(".column1 .state").attr('src','static/icons/indicators/medium/wave.gif').show();
536 560
                        existing.find(".column1 .state").removeClass().addClass("state running-state");
......
622 646
            if (server.status == 'ACTIVE') {
623 647
                $('#machinesview-single.single div.#' + server.id + ' div.action-console').show();
624 648
                $('#machinesview-single.single div.#' + server.id + ' div.action-start').hide();
625
                machine.find(".connect-border").show();
626
                machine.find(".connect-arrow").show();
649

  
650
                vm = get_machine(machine.attr("id"));
651
                has_ip = vm_has_public_ip(vm);
652

  
653
                if (has_ip) {
654
                    machine.find(".connect-border").show();
655
                    machine.find(".connect-arrow").show();
656
                } else {
657
                    machine.find(".connect-border").hide();
658
                    machine.find(".connect-arrow").hide();
659
                }
660

  
627 661
            } else if (server.status == 'REBOOT'){
628 662
                $('#machinesview-single.single div.#' + server.id + ' div.action-console').hide();
629 663
            } else {

Also available in: Unified diff