Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / controllers / network.js @ 47eca5c5

History | View | Annotate | Download (2.5 kB)

1
var actionsMetaNetwork = {
2
    'start': {
3
        title: 'start',
4
        act: 'modalStart',
5
        spanCls: 'snf-switch',
6
    },
7
    'destroy': {
8
        title: 'destroy',
9
        act: 'modalDestroy',
10
        spanCls: 'snf-trash-outline',
11
    },
12
    'reboot': {
13
        title: 'reboot',
14
        act: 'modalReboot',
15
        spanCls: 'snf-refresh-outline',
16
    },
17
    'shutdown': {
18
        title: 'shutdown',
19
        act: 'modalShutdown',
20
        spanCls: 'snf-pc-broken-full',
21
    },
22
};
23

    
24

    
25
App.NetworkController = Ember.ObjectController.extend({
26

    
27
    icon: 'snf-network-full',
28
    
29
    codeName: 'network',
30
    
31
    actionsMeta: function() {
32
        var enabledActions = this.get('model').get('enabledActions');
33
        return _.map(enabledActions, function(val,key) { return actionsMetaNetwork[val]; });      
34
    }.property('model.enabledActions'),
35

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

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

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

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

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

    
76
    },
77
});