root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / okeanos-ember / controllers.js @ 0467b6cd
History | View | Annotate | Download (4.2 kB)
1 |
/* Controllers */
|
---|---|
2 |
|
3 |
Synnefo.ApplicationController = Ember.Controller.extend({ |
4 |
updateCurrentPath: function() { |
5 |
// we need the set because ElemsController gets the value of current path in every transition
|
6 |
Synnefo.set('currentPath', this.get('currentPath')) |
7 |
return this.get('currentPath'); |
8 |
}.observes('currentPath'),
|
9 |
|
10 |
pageTitle : function() { |
11 |
var currentPath =this.get('currentPath'); |
12 |
if(currentPath!== 'index') return Synnefo.conf.sectors.findBy('destination', this.get('currentPath')).title; |
13 |
else return 'Home'; |
14 |
}.property('currentPath'),
|
15 |
|
16 |
// name: "okeanos application",
|
17 |
}); |
18 |
|
19 |
|
20 |
/* Items Controllers */
|
21 |
|
22 |
Synnefo.ElemsController = Ember.ArrayController.extend({ |
23 |
type: undefined, |
24 |
itemController: function(){ |
25 |
var type = this.type; |
26 |
return type.substring(0, type.length - 1); |
27 |
}.property(), |
28 |
icon: function() { |
29 |
// should this be placed in ElemsView?
|
30 |
return Synnefo.conf.sectors.findBy('destination', this.get('type')).icon.replace('outline', 'full'); |
31 |
}.property(), |
32 |
hasOS: function(){ |
33 |
if(Synnefo.get('currentPath') === "vms" || Synnefo.get('currentPath') === "vms.index") |
34 |
return true; |
35 |
else return false; |
36 |
}.property(), |
37 |
hasTags: function(){ |
38 |
if(Synnefo.get('currentPath') == "vms" || Synnefo.get('currentPath') === "vms.index") |
39 |
return true; |
40 |
else return false; |
41 |
}.property(), |
42 |
}); |
43 |
|
44 |
Synnefo.VmsController = Synnefo.ElemsController.extend({ |
45 |
type: 'vms' |
46 |
}); |
47 |
|
48 |
|
49 |
Synnefo.NetworksController = Synnefo.ElemsController.extend({ |
50 |
type: 'networks' |
51 |
}); |
52 |
|
53 |
Synnefo.VolumesController = Synnefo.ElemsController.extend({ |
54 |
type: 'volumes' |
55 |
}); |
56 |
|
57 |
|
58 |
Synnefo.SnapshotsController = Synnefo.ElemsController.extend({ |
59 |
type: 'snapshots' |
60 |
}); |
61 |
|
62 |
Synnefo.ImagesController = Synnefo.ElemsController.extend({ |
63 |
type: 'images' |
64 |
}); |
65 |
|
66 |
|
67 |
/* Controllers for each Item */
|
68 |
|
69 |
Synnefo.ElemController = Ember.ObjectController.extend({ |
70 |
needs: [],
|
71 |
actionsList: Synnefo.conf.userActions,
|
72 |
setAvailableActions: function() { |
73 |
var parent = this.needs; |
74 |
var self = this; |
75 |
return this.actionsList.filter(function(el) { |
76 |
return _.contains(el['snf-components'], self.get('controllers.'+parent).type) &&( _.contains(el['enabled-status'], self.get('model.status')) || _.contains(el['enabled-status'], 'all')); |
77 |
}) |
78 |
}.property(), |
79 |
createBtn: false, |
80 |
actions: {
|
81 |
shutdown: function(param) { |
82 |
this.set('model.status', 'shutting'); |
83 |
}, |
84 |
destroyElement: function(param) { |
85 |
var element = this.get('model'); |
86 |
element.deleteRecord(); |
87 |
element.save(); |
88 |
} |
89 |
} |
90 |
}); |
91 |
|
92 |
Synnefo.VmController = Synnefo.ElemController.extend({ |
93 |
needs: ['vms'] |
94 |
}); |
95 |
|
96 |
Synnefo.NetworkController = Synnefo.ElemController.extend({ |
97 |
needs: ['networks'] |
98 |
}); |
99 |
|
100 |
Synnefo.VolumeController = Synnefo.ElemController.extend({ |
101 |
needs: ['volumes'] |
102 |
}); |
103 |
|
104 |
Synnefo.SnapshotController = Synnefo.ElemController.extend({ |
105 |
needs: ['snapshots'] |
106 |
}); |
107 |
|
108 |
Synnefo.ImageController = Synnefo.ElemController.extend({ |
109 |
needs: ['images'] |
110 |
}); |
111 |
|
112 |
|
113 |
/* Controllers for Wizards */
|
114 |
|
115 |
Synnefo.CreateController = Ember.Controller.extend({ |
116 |
currentStep: 1, |
117 |
totalSteps: function() { |
118 |
return 4;//this.get('stepsContent').length; |
119 |
}.property(), |
120 |
|
121 |
btnLeftLabel: function(){ |
122 |
return (this.get('currentStep') === 1)?'CANCEL':'PREVIOUS'; |
123 |
}.property('currentStep'),
|
124 |
|
125 |
btnRightLabel: function(){ |
126 |
return (this.get('currentStep') === this.get('totalSteps'))?'CREATE':'NEXT'; |
127 |
}.property('currentStep'),
|
128 |
|
129 |
onMove: false, |
130 |
directionMove: undefined, |
131 |
init: function() { |
132 |
this._super();
|
133 |
this.set('currentStep', 1); |
134 |
this.set('onMove', false); |
135 |
this.set('directionMove', undefined); |
136 |
}, |
137 |
actions: {
|
138 |
moveNext: function() { |
139 |
console.log('[CreateController moveNext]');
|
140 |
if(!this.get('onMove')) { |
141 |
if(this.get('currentStep') === this.get('totalSteps')) |
142 |
this.resetClose();
|
143 |
else {
|
144 |
this.set('directionMove', 'next'); |
145 |
this.set('onMove', true); |
146 |
} |
147 |
} |
148 |
}, |
149 |
moveBack: function() { |
150 |
console.log('[CreateController moveBack]');
|
151 |
if(!this.get('onMove')) { |
152 |
if(this.get('currentStep') === 1) |
153 |
this.resetClose();
|
154 |
else {
|
155 |
this.set('directionMove', 'prev'); |
156 |
this.set('onMove', true); |
157 |
} |
158 |
} |
159 |
}, |
160 |
}, |
161 |
resetClose: function() { |
162 |
console.log('[CreateController resetClose]');
|
163 |
this.get('target').send('closeWizard'); |
164 |
this.init();
|
165 |
} |
166 |
}); |
167 |
|
168 |
|
169 |
Synnefo.VmsCreateController = Synnefo.CreateController.extend(); |
170 |
|
171 |
Synnefo.WizardVmStep1Controller = Ember.Controller.extend(); |