Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (2.5 kB)

1
App.VmController = Ember.ObjectController.extend({
2

    
3
    needs: ['vms'],
4
    
5
    hasViewCls: true,
6
    
7
    /*icon: function () {
8
        return this.get('parentController').get('iconCls');
9
    }.property(),*/
10

    
11
    icon: 'snf-pc-full',
12

    
13
    codeName: 'vm',
14

    
15
    hasTags: true,
16

    
17
    codeNameParent: function() {
18
        return this.codeName+'s';
19
    }.property(),
20

    
21
    codeNameChildInit: function() {
22
        return this.codeName+'init';
23
    }.property(),
24
    
25
    actionsMeta: function() {
26
        var enabledActions = this.get('model').get('enabledActions');
27
        return _.map(enabledActions, function(val,key) {return actionsMetaVm[val]; });      
28
    }.property('model.enabledActions'),
29

    
30
    actions: {
31

    
32
        deleteTag: function(tag) {
33
            this.get('model').get('tags').removeObject(tag);
34
        },
35

    
36
        modalConnect: function(){
37
            var component = Ember.View.views["modal-connect"];
38
            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
39
            component.set('okCallback', _.bind(function() {
40

    
41
                alert("restarting " + this.get('model').get('name'));
42
            }, this));
43
            $("#modal-connect").foundation('reveal', 'open');
44
        },
45

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

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

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

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

    
75
    },
76
});
77

    
78

    
79
App.VmInfoController = App.VmController.extend({
80
});