Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / new_ui / ui / app / controllers / vm.js @ faad3c72

History | View | Annotate | Download (2.7 kB)

1
App.VmController =App.ItemsItemController.extend({
2
    icon: 'snf-pc-full',
3

    
4
    actionsMeta: function() {
5
        var enabledActions = this.get('model').get('enabledActions');
6
        return _.map(enabledActions, function(val,key) { return actionsMetaVm[val]; });      
7
    }.property('model.enabledActions'),
8

    
9
    submenu: [
10
        {
11
            'link': 'vm.info',
12
            'icon': 'snf-info-outline',
13
        },
14
        {
15
            'link': 'vm.disk-connected',
16
            'icon': 'snf-volume-outline',
17
        },
18
        {
19
            'link': 'vm.network-connected',
20
            'icon': 'snf-network-outline',
21
        }
22
    ],
23
    
24
    actions: {
25

    
26
        deleteTag: function(tag) {
27
            this.get('model').get('tags').removeObject(tag);
28
        },
29

    
30
        dettachVolume: function(volume){
31
            this.get('model').get('volumes').removeObject(volume);
32
        },
33

    
34
        saveModel: function(){
35
            this.get('model').save();
36
        },
37

    
38

    
39
        modalConnect: function(){
40
            var component = Ember.View.views["modal-connect"];
41
            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
42
            component.set('okCallback', _.bind(function() {
43
                alert("restarting " + this.get('model').get('name'));
44
            }, this));
45
            $("#modal-connect").foundation('reveal', 'open');
46
        },
47

    
48
        modalStart: function(){
49
            $("#modal-start").foundation('reveal', 'open');
50
        },
51

    
52
        modalShutdown: function(){
53
            $("#modal-shutdown").foundation('reveal', 'open');
54
        },
55

    
56
        modalReboot: function(){
57
            $("#modal-reboot").foundation('reveal', 'open');
58
            var component = Ember.View.views["modal-reboot"];
59
            component.set('message', '<p>Are you sure you want to reboot you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>');
60
            component.set('okCallback', _.bind(function() {
61
                this.get('model').set('state','rebooting');
62
                $("#modal-reboot").foundation('reveal','close');
63
            }, this));
64
        },
65

    
66
        modalDestroy: function(){
67
            $("#modal-destroy").foundation('reveal', 'open');
68
            var component = Ember.View.views["modal-destroy"];
69
            component.set('message', '<p>Are you sure you want to delete you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>');
70
            component.set('okCallback', _.bind(function() {
71
                this.get('model').deleteRecord();
72
                this.get('model').save();
73
                $("#modal-destroy").foundation('reveal','close');
74
            }, this));
75
        },
76

    
77
    },
78
});
79

    
80
App.VmInfoController = App.VmController.extend();
81

    
82
App.VmDiskConnectedController = App.VmController.extend();