root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / controllers / vm.js @ 7b3c3bd6
History | View | Annotate | Download (2.5 kB)
1 |
var actionsMetaVm = {
|
---|---|
2 |
'start': {
|
3 |
title: 'start me now', |
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.VmController = Ember.ObjectController.extend({ |
26 |
|
27 |
needs: ['vms'], |
28 |
hasViewCls: true, |
29 |
icon: 'snf-pc-full', |
30 |
|
31 |
codeName: 'vm', |
32 |
|
33 |
actionsMeta: function() { |
34 |
var enabledActions = this.get('model').get('enabledActions'); |
35 |
return _.map(enabledActions, function(val,key) {return actionsMetaVm[val]; }); |
36 |
}.property('model.enabledActions'),
|
37 |
|
38 |
actions: {
|
39 |
|
40 |
modalConnect: function(){ |
41 |
var component = Ember.View.views["modal-connect"]; |
42 |
component.set('message', 'connect to your <3 ' + this.get('model').get('name')); |
43 |
component.set('okCallback', _.bind(function() { |
44 |
|
45 |
alert("restarting " + this.get('model').get('name')); |
46 |
}, this));
|
47 |
$("#modal-connect").foundation('reveal', 'open'); |
48 |
}, |
49 |
|
50 |
modalStart: function(){ |
51 |
$("#modal-start").foundation('reveal', 'open'); |
52 |
}, |
53 |
|
54 |
modalShutdown: function(){ |
55 |
$("#modal-shutdown").foundation('reveal', 'open'); |
56 |
}, |
57 |
|
58 |
modalReboot: function(){ |
59 |
$("#modal-reboot").foundation('reveal', 'open'); |
60 |
var component = Ember.View.views["modal-reboot"]; |
61 |
component.set('message', '<p>Are you sure you want to reboot you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>'); |
62 |
component.set('okCallback', _.bind(function() { |
63 |
this.get('model').set('state','rebooting'); |
64 |
$("#modal-reboot").foundation('reveal','close'); |
65 |
}, this));
|
66 |
}, |
67 |
|
68 |
modalDestroy: function(){ |
69 |
$("#modal-destroy").foundation('reveal', 'open'); |
70 |
var component = Ember.View.views["modal-destroy"]; |
71 |
component.set('message', '<p>Are you sure you want to delete you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>'); |
72 |
component.set('okCallback', _.bind(function() { |
73 |
this.get('model').deleteRecord(); |
74 |
this.get('model').save(); |
75 |
$("#modal-destroy").foundation('reveal','close'); |
76 |
}, this));
|
77 |
}, |
78 |
|
79 |
}, |
80 |
}); |