root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / ember / controllers / network.js @ e4a6c3b8
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 |
|
43 |
alert("restarting " + this.get('model').get('name')) |
44 |
}, this));
|
45 |
$("#modal-connect").foundation('reveal', 'open'); |
46 |
}, |
47 |
|
48 |
modalStart: function(){ |
49 |
$("#modal-start").foundation('reveal', 'open'); |
50 |
}, |
51 |
|
52 |
modalShutdown: function(){ |
53 |
$("#modal-shutdown").foundation('reveal', 'open'); |
54 |
}, |
55 |
|
56 |
modalReboot: function(){ |
57 |
$("#modal-reboot").foundation('reveal', 'open'); |
58 |
var component = Ember.View.views["modal-reboot"]; |
59 |
component.set('message', '<p>Are you sure you want to reboot you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>'); |
60 |
component.set('okCallback', _.bind(function() { |
61 |
this.get('model').set('state','rebooting'); |
62 |
$("#modal-reboot").foundation('reveal','close'); |
63 |
}, this));
|
64 |
}, |
65 |
|
66 |
modalDestroy: function(){ |
67 |
$("#modal-destroy").foundation('reveal', 'open'); |
68 |
var component = Ember.View.views["modal-destroy"]; |
69 |
component.set('message', '<p>Are you sure you want to delete you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>'); |
70 |
component.set('okCallback', _.bind(function() { |
71 |
this.get('model').deleteRecord(); |
72 |
this.get('model').save(); |
73 |
$("#modal-destroy").foundation('reveal','close'); |
74 |
}, this));
|
75 |
}, |
76 |
|
77 |
}, |
78 |
}); |