Statistics
| Branch: | Tag: | Revision:

root / ui / static / snf / js / ui / web / ui_connect_view.js @ 53287ead

History | View | Annotate | Download (2.3 kB)

1
;(function(root){
2

    
3
    // root
4
    var root = root;
5
    
6
    // setup namepsaces
7
    var snf = root.synnefo = root.synnefo || {};
8
    var models = snf.models = snf.models || {}
9
    var storage = snf.storage = snf.storage || {};
10
    var ui = snf.ui = snf.ui || {};
11
    var util = snf.util = snf.util || {};
12

    
13
    var views = snf.views = snf.views || {}
14

    
15
    // shortcuts
16
    var bb = root.Backbone;
17

    
18

    
19
    views.VMConnectView = views.VMOverlay.extend({
20
        
21
        view_id: "connect_view",
22
        content_selector: "#vm-connect-overlay-content",
23
        css_class: 'overlay-vmconnect overlay-info',
24
        overlay_id: "vmconnect-overlay",
25

    
26
        subtitle: "",
27
        title: "Connect to machine",
28

    
29
        initialize: function(options) {
30
            views.VMConnectView.__super__.initialize.apply(this);
31
            _.bindAll(this, "handle_success", "handle_error");
32

    
33
            this.error = this.$("div.error");
34
            this.info = this.$("div.connection-info");
35
            this.description = this.info.find(".description p");
36
            this.connect = this.info.find(".connect p");
37
            this.subinfo = this.info.find(".subinfo");
38
        },
39

    
40
        handle_success: function(data) {
41
            this.error.hide();
42
            this.info.show();
43
            this.description.html(data.info);
44
            if (data.ssh) {
45
                this.connect.html(data.link.title);
46
            } else {
47
                this.connect.html('<a href="{0}">{1}</a>'.format(data.link.url, data.link.title))
48
            }
49

    
50
            this.subinfo.html(data.subinfo).show();
51
            if (!data.subinfo) { this.subinfo.hide() };
52

    
53
        },
54

    
55
        handle_error: function() {
56
            this.error.show();
57
            this.info.hide();
58
        },
59

    
60
        handle_vm_change: function(vm) {
61
            if (!this.vm) { this.vm = undefined; return; }
62
            if (this.vm.state() == "DESTROY") {
63
                this.hide();
64
            }
65
            this._update_vm_details();
66
        },
67
        
68
        update_vm_details: function() {
69
        },
70

    
71
        show: function() {
72
            views.VMConnectView.__super__.show.apply(this, arguments);
73
            
74
            this.error.hide();
75
            this.info.hide();
76

    
77
            this.vm.get_connection_info($.client.os, this.handle_success, this.handle_error)
78
        }
79

    
80
    });
81
    
82
})(this);