Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / controllers / vm.js @ 82189820

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
            alert('I am now dettaching this volume');
32
            //this.get('model').get('volumes').removeObject(volume);
33
        },
34

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

    
44
        modalStart: function(){
45
            $("#modal-start").foundation('reveal', 'open');
46
        },
47

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

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

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

    
73
    },
74
});
75

    
76
App.VmInfoController = App.VmController.extend();
77

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