Revision 8c923194

b/ui/static/main.css
2432 2432
}
2433 2433

  
2434 2434
div.private-networks div.network-placeholder {
2435
    border-left: 3px solid #FF7F2A;
2436 2435
}
2437 2436

  
2438 2437
div.network-cable {
b/ui/static/snf/js/tests/functional.js
5 5
flavors = synnefo.storage.flavors;
6 6
api = synnefo.api;
7 7
ui = synnefo.ui;
8
models = synnefo.models;
8 9

  
10
SERVERS_CREATED = 0;
9 11
utils = {
10 12
    main: function() { return ui.main },
11
    current: function() { return ui.main.current_view }
13
    current: function() { return ui.main.current_view },
14
    nets: function() { return ui.main.views['networks']},
15
    
16
    rnd: function (lst) {
17
        var i = Math.floor((lst.length)*Math.random());
18
        return lst[i];
19
    },
20

  
21
    rvms: function(count, st, data) {
22
        while (count) {
23
            utils.rvm(st, data)
24
            count--;
25
        }
26
    },
27

  
28
    // random vm
29
    rvm: function(st, data) {
30
        if (!data) { data = {} };
31
        if (st) { data['status'] = st };
32

  
33
        var s = new models.VM();
34
        s.set(_.extend({
35
            'name': "server " + (SERVERS_CREATED + 1),
36
            'created': "2011-08-31T12:38:05.183738+00:00",
37
            'flavorRef': utils.rnd([1,2,3,4,5,6,7,8,9,10,11,12,13,14]),
38
            'imageRef': utils.rnd([1,2,3,4]),
39
            'progress': 100,
40
            'status': utils.rnd(['BUILD', 'ACTIVE', 'ERROR']),
41
            'updated': '2011-08-31T12:38:14.746141+00:00',
42
            'metadata': {'values':{ 'OS': utils.rnd(["debian", "fedora", "windows"])}},
43
            'id': vms.length + 100
44
        }, data));
45

  
46
        SERVERS_CREATED++;
47
        vms.add(s);
48
        return s;
49
    }
50

  
12 51
}
13 52

  
14 53
function test_create_view() {
15 54
    utils.main().create_vm_view.show();   
16 55
}
17 56

  
57
function test_nets_border() {
58
    utils.rvms(1);
59

  
60
    //vms.each(function(vm) {
61
        //utils.nets().network_views['public'].create_vm(vm);
62
        //utils.nets().network_views[2].create_vm(vm);
63
    //})
64
    utils.nets().network_views['public'].create_vm(vms.at(0));
65
    utils.nets().network_views[2].create_vm(vms.at(0));
66

  
67
    utils.nets().network_views['public'].$(".cont-toggler").click();
68
    utils.nets().network_views[2].vms_list.show();
69
    $(window).trigger("resize");
70
}
71

  
18 72

  
19
TEST = test_create_view;
73
TEST = test_nets_border;
74
//TEST = false;
b/ui/static/snf/js/ui/web/ui_networks_view.js
558 558
            this.$(".empty-network-slot").hide();
559 559
        },
560 560

  
561
        // fix left border position
562
        fix_left_border: function() {
563
            var imgheight = 2783;
564
            var contents = this.$(".network-contents");
565
            var last_vm = this.$(".network-machine:last")
566
            var bgpos = imgheight - contents.height() + last_vm.height() - 30;
567
            this.$(".network-contents").css({'background-position':'33px ' + (-bgpos) + 'px'});
568
        },
569

  
570

  
561 571
        init_handlers: function() {
562 572
            var self = this;
563 573

  
......
609 619
                this.$(".confirm_single").hide();
610 620
                this.$("a.selected").removeClass("selected");
611 621
            }, this));
622

  
623
            $(window).bind("resize", _.bind(function() {
624
                this.fix_left_border();
625
            }, this));
612 626
        },
613 627

  
614 628
        show_connect_vms: function() {
......
698 712
                }
699 713
            }
700 714
        },
715
        
716
        create_vm: function(vm) {
717
            vm_el = $(this.vm_tpl).clone().attr({id:this.get_vm_id(vm).replace("#","")});
718
            this.vms_list.append(vm_el);
719
            this.post_vm_add(vm);
720

  
721
            if (!this.vm_views[vm.id]) {
722
                vm_view = this.vm_views[vm.id] = new views.NetworkVMView(vm, this, this.firewall, vm_el);
723
            }
724
        },
701 725

  
702 726
        add_or_update_vm: function(vm) {
703 727
            if (!vm || !this.network.contains_vm(vm)) { return };
......
706 730
            var vm_view = this.vm_views[vm.id];
707 731

  
708 732
            if (vm_el.length == 0) {
709
                vm_el = $(this.vm_tpl).clone().attr({id:this.get_vm_id(vm).replace("#","")});
710
                this.vms_list.append(vm_el);
711
                this.post_vm_add(vm);
712

  
713
                if (!this.vm_views[vm.id]) {
714
                    vm_view = this.vm_views[vm.id] = new views.NetworkVMView(vm, this, this.firewall, vm_el);
715
                }
733
                this.create_vm(vm);
716 734
            }
717 735
            
718 736
            if (vm_view) { vm_view.update_layout() };
......
848 866
            return new views.PrivateNetworkView(net, this);
849 867
        },
850 868
        
851
        // fix left border position
852
        fix_left_border: function() {
853
            var vms = this.$(".network-machine:not(:last-child)");
854
            var opened = vms.find(".firewall-content:visible").length;
855
            var bgpos = -2584 + (opened * 72);
856
            this.$(".network-contents").css({'background-position-y':bgpos + 'px'});
857
        },
858

  
859 869
        init_handlers: function() {
860 870
            storage.networks.bind("add", _.bind(this.network_added_handler, this, "add"));
861 871
            storage.networks.bind("change", _.bind(this.network_changed_handler, this, "change"));
......
867 877
                this.create_view.show();
868 878
            }, this));
869 879
            
870
            $(window).bind("resize", _.bind(function() {
871
                this.fix_left_border();
872
            }, this));
873 880
        },
874 881

  
875 882
        update_networks: function(nets) {

Also available in: Unified diff