Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (1.7 kB)

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

    
4
    hasConnect: true,
5

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

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

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

    
32
        dettachVolume: function(volume){
33
            volume.get('vm').get('volumes').removeObject(volume);
34
        },
35

    
36
        rebootVm: function(){
37
            this.get('model').set('status','rebooting');
38
            var that = this;
39
            setTimeout(function(){
40
                that.get('model').set('status','running'); 
41
            },3000);
42
        },
43

    
44
        destroyVm: function(){
45
            this.get('model').deleteRecord();
46
            this.get('model').save();
47
            this.transitionToRoute('vms.grid-view');
48
        },
49

    
50
        shutdownVm: function(){
51
            this.get('model').set('status','shutting');
52
            var that = this;
53
            setTimeout(function(){
54
                that.get('model').set('status','off'); 
55
            },3000);
56
        },
57

    
58
        startVm: function(){
59
            this.get('model').set('status','running');
60
        },
61
    },
62
});
63

    
64
App.VmInfoController = App.VmController.extend();
65

    
66
App.VmDiskConnectedController = App.VmController.extend();
67