root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / okeanos-ember.js @ e0d90534
History | View | Annotate | Download (12.4 kB)
1 | d0fe8c12 | Athina Bekakou | /* Init Application */
|
---|---|---|---|
2 | d0fe8c12 | Athina Bekakou | |
3 | b058f1fe | Athina Bekakou | window.Synnefo = Ember.Application.create({ |
4 | d0fe8c12 | Athina Bekakou | currentPath: 'vms', |
5 | d0fe8c12 | Athina Bekakou | LOG_TRANSITIONS: true, // To have Ember write out transition events to the log (it can be helpful to see exactly what is going on with the router) |
6 | d0fe8c12 | Athina Bekakou | }); |
7 | d0fe8c12 | Athina Bekakou | |
8 | b058f1fe | Athina Bekakou | Synnefo.ApplicationAdapter = DS.FixtureAdapter.extend();;Ember.Inflector.inflector.uncountable('account');
|
9 | d0fe8c12 | Athina Bekakou | |
10 | b058f1fe | Athina Bekakou | Synnefo.Account = DS.Model.extend({ |
11 | b3523ce4 | Athina Bekakou | email: DS.attr('string') |
12 | b3523ce4 | Athina Bekakou | }); |
13 | b3523ce4 | Athina Bekakou | |
14 | b3523ce4 | Athina Bekakou | // CHECK can i use a single obj and not an array of obj
|
15 | b058f1fe | Athina Bekakou | Synnefo.Account.FIXTURES = { |
16 | b3523ce4 | Athina Bekakou | id: 001, |
17 | b3523ce4 | Athina Bekakou | email: "athina@mail.com" |
18 | 13de11ea | Athina Bekakou | }; |
19 | b3523ce4 | Athina Bekakou | |
20 | b3523ce4 | Athina Bekakou | |
21 | b3523ce4 | Athina Bekakou | |
22 | b058f1fe | Athina Bekakou | Synnefo.Vm = DS.Model.extend({ |
23 | b3523ce4 | Athina Bekakou | // id: DS.attr('number'), we do not define it ;)
|
24 | b3523ce4 | Athina Bekakou | name: DS.attr('string'), |
25 | b3523ce4 | Athina Bekakou | hostname: DS.attr('string'), |
26 | b3523ce4 | Athina Bekakou | status: DS.attr('string'), |
27 | b3523ce4 | Athina Bekakou | os: DS.attr()
|
28 | b3523ce4 | Athina Bekakou | }); |
29 | b3523ce4 | Athina Bekakou | |
30 | b058f1fe | Athina Bekakou | Synnefo.Vm.FIXTURES = |
31 | b3523ce4 | Athina Bekakou | [{ |
32 | b3523ce4 | Athina Bekakou | id: 125355, |
33 | b3523ce4 | Athina Bekakou | name: "web-server", |
34 | b3523ce4 | Athina Bekakou | hostname: "user@snf-38389.vm.okeanos.grnet.gr", |
35 | b3523ce4 | Athina Bekakou | status: "running", |
36 | b3523ce4 | Athina Bekakou | os: "kubuntu" |
37 | b3523ce4 | Athina Bekakou | }, |
38 | b3523ce4 | Athina Bekakou | { |
39 | b3523ce4 | Athina Bekakou | id: 12, |
40 | b3523ce4 | Athina Bekakou | name: "another-server", |
41 | b3523ce4 | Athina Bekakou | hostname: "user@snf-33333.vm.okeanos.grnet.gr", |
42 | b3523ce4 | Athina Bekakou | status: "off", |
43 | b3523ce4 | Athina Bekakou | os: "fedora" |
44 | b3523ce4 | Athina Bekakou | }]; |
45 | b3523ce4 | Athina Bekakou | |
46 | b058f1fe | Athina Bekakou | Synnefo.Network = DS.Model.extend({ |
47 | b3523ce4 | Athina Bekakou | name: DS.attr('string'), |
48 | b3523ce4 | Athina Bekakou | status: DS.attr('string'), |
49 | b3523ce4 | Athina Bekakou | }); |
50 | b3523ce4 | Athina Bekakou | |
51 | b058f1fe | Athina Bekakou | Synnefo.Network.FIXTURES = |
52 | b3523ce4 | Athina Bekakou | [{ |
53 | b058f1fe | Athina Bekakou | id: 11, |
54 | b058f1fe | Athina Bekakou | name: 'Network-1', |
55 | b058f1fe | Athina Bekakou | status: 'running' |
56 | b058f1fe | Athina Bekakou | }, |
57 | b058f1fe | Athina Bekakou | { |
58 | b058f1fe | Athina Bekakou | id: 22, |
59 | b058f1fe | Athina Bekakou | name: 'Network-2', |
60 | b058f1fe | Athina Bekakou | status: 'error' |
61 | b058f1fe | Athina Bekakou | }]; |
62 | b058f1fe | Athina Bekakou | |
63 | b058f1fe | Athina Bekakou | |
64 | b058f1fe | Athina Bekakou | Synnefo.Volume = DS.Model.extend({ |
65 | b058f1fe | Athina Bekakou | name: DS.attr('string'), |
66 | b058f1fe | Athina Bekakou | status: DS.attr('string'), |
67 | b058f1fe | Athina Bekakou | }); |
68 | b058f1fe | Athina Bekakou | |
69 | b058f1fe | Athina Bekakou | Synnefo.Volume.FIXTURES = |
70 | b058f1fe | Athina Bekakou | [{ |
71 | b058f1fe | Athina Bekakou | id: 111, |
72 | b058f1fe | Athina Bekakou | name: 'Volume-1', |
73 | b058f1fe | Athina Bekakou | status: 'running' |
74 | b058f1fe | Athina Bekakou | }, |
75 | b058f1fe | Athina Bekakou | { |
76 | b058f1fe | Athina Bekakou | id: 222, |
77 | b058f1fe | Athina Bekakou | name: 'Volume-2', |
78 | b058f1fe | Athina Bekakou | status: 'building' |
79 | b058f1fe | Athina Bekakou | }]; |
80 | b058f1fe | Athina Bekakou | |
81 | b058f1fe | Athina Bekakou | Synnefo.Snapshot = DS.Model.extend({ |
82 | b058f1fe | Athina Bekakou | name: DS.attr('string'), |
83 | b058f1fe | Athina Bekakou | status: DS.attr('string'), |
84 | b058f1fe | Athina Bekakou | }); |
85 | b058f1fe | Athina Bekakou | |
86 | b058f1fe | Athina Bekakou | Synnefo.Snapshot.FIXTURES = |
87 | b058f1fe | Athina Bekakou | [{ |
88 | b058f1fe | Athina Bekakou | id: 33, |
89 | b058f1fe | Athina Bekakou | name: 'Snapshot-1', |
90 | b058f1fe | Athina Bekakou | status: 'running' |
91 | b058f1fe | Athina Bekakou | }, |
92 | b058f1fe | Athina Bekakou | { |
93 | b058f1fe | Athina Bekakou | id: 44, |
94 | b058f1fe | Athina Bekakou | name: 'Snapshot-2', |
95 | b058f1fe | Athina Bekakou | status: 'building' |
96 | b3523ce4 | Athina Bekakou | }]; |
97 | b3523ce4 | Athina Bekakou | |
98 | b3523ce4 | Athina Bekakou | |
99 | b058f1fe | Athina Bekakou | Synnefo.UserImage = DS.Model.extend({ |
100 | b058f1fe | Athina Bekakou | name: DS.attr('string'), |
101 | b058f1fe | Athina Bekakou | status: DS.attr('string'), |
102 | b058f1fe | Athina Bekakou | }); |
103 | b058f1fe | Athina Bekakou | |
104 | b058f1fe | Athina Bekakou | Synnefo.UserImage.FIXTURES = |
105 | b058f1fe | Athina Bekakou | [{ |
106 | b058f1fe | Athina Bekakou | id: 55, |
107 | b058f1fe | Athina Bekakou | name: 'Image-1', |
108 | b058f1fe | Athina Bekakou | status: 'running' |
109 | b058f1fe | Athina Bekakou | }, |
110 | b058f1fe | Athina Bekakou | { |
111 | b058f1fe | Athina Bekakou | id: 66, |
112 | b058f1fe | Athina Bekakou | name: 'Image-2', |
113 | b058f1fe | Athina Bekakou | status: 'running' |
114 | b058f1fe | Athina Bekakou | }]; |
115 | b3523ce4 | Athina Bekakou | |
116 | b3523ce4 | Athina Bekakou | |
117 | b058f1fe | Athina Bekakou | Synnefo.conf = { |
118 | b058f1fe | Athina Bekakou | sectors: [{
|
119 | b3523ce4 | Athina Bekakou | destination: "vms", |
120 | b3523ce4 | Athina Bekakou | title: "Virtual Machines", |
121 | b3523ce4 | Athina Bekakou | icon: "snf-pc-outline" |
122 | b3523ce4 | Athina Bekakou | }, |
123 | b3523ce4 | Athina Bekakou | { |
124 | e0d90534 | Athina Bekakou | destination: "networks", |
125 | e0d90534 | Athina Bekakou | title: "Network", |
126 | b3523ce4 | Athina Bekakou | icon: "snf-network-outline" |
127 | b3523ce4 | Athina Bekakou | |
128 | b3523ce4 | Athina Bekakou | }, |
129 | b3523ce4 | Athina Bekakou | { |
130 | b3523ce4 | Athina Bekakou | destination: "volumes", |
131 | b3523ce4 | Athina Bekakou | title: "Volumes", |
132 | b3523ce4 | Athina Bekakou | icon: "snf-volume-outline" |
133 | b3523ce4 | Athina Bekakou | }, |
134 | b3523ce4 | Athina Bekakou | { |
135 | b3523ce4 | Athina Bekakou | destination: "pithos", |
136 | b3523ce4 | Athina Bekakou | title: "Pithos", |
137 | b3523ce4 | Athina Bekakou | icon: "snf-pithos-outline" |
138 | b3523ce4 | Athina Bekakou | }, |
139 | b3523ce4 | Athina Bekakou | { |
140 | b3523ce4 | Athina Bekakou | destination: "images", |
141 | b3523ce4 | Athina Bekakou | title: "Images", |
142 | b3523ce4 | Athina Bekakou | icon: "snf-image-outline" |
143 | b3523ce4 | Athina Bekakou | }, |
144 | b3523ce4 | Athina Bekakou | { |
145 | b3523ce4 | Athina Bekakou | destination: "snapshots", |
146 | b3523ce4 | Athina Bekakou | title: "Snapshots", |
147 | b3523ce4 | Athina Bekakou | icon: "snf-snapshot-outline" |
148 | b3523ce4 | Athina Bekakou | }, |
149 | b3523ce4 | Athina Bekakou | { |
150 | b3523ce4 | Athina Bekakou | destination: "ips", |
151 | b3523ce4 | Athina Bekakou | title: "IPs", |
152 | b3523ce4 | Athina Bekakou | icon: "snf-nic-outline" |
153 | b3523ce4 | Athina Bekakou | }, |
154 | b3523ce4 | Athina Bekakou | { |
155 | b3523ce4 | Athina Bekakou | destination: "sshkeys", |
156 | b3523ce4 | Athina Bekakou | title: "SSh Keys", |
157 | b3523ce4 | Athina Bekakou | icon: "snf-key-outline" |
158 | b058f1fe | Athina Bekakou | }], |
159 | e0d90534 | Athina Bekakou | |
160 | b058f1fe | Athina Bekakou | userActions: [{
|
161 | b058f1fe | Athina Bekakou | description:'start', |
162 | b058f1fe | Athina Bekakou | 'snf-components':['vms'], |
163 | b058f1fe | Athina Bekakou | 'enabled-status': ['off'], |
164 | b058f1fe | Athina Bekakou | action: 'is this a function?' |
165 | b058f1fe | Athina Bekakou | }, |
166 | b058f1fe | Athina Bekakou | { |
167 | b058f1fe | Athina Bekakou | description:'destroyElement', |
168 | e0d90534 | Athina Bekakou | 'snf-components': ['vms', 'networks'], |
169 | b058f1fe | Athina Bekakou | 'enabled-status': ['all'], |
170 | b058f1fe | Athina Bekakou | action: 'is this a function?', |
171 | b058f1fe | Athina Bekakou | }, |
172 | b058f1fe | Athina Bekakou | { |
173 | b058f1fe | Athina Bekakou | description:'shutdown', |
174 | b058f1fe | Athina Bekakou | 'snf-components': ['vms'], |
175 | b058f1fe | Athina Bekakou | 'enabled-status': ['running'], |
176 | b058f1fe | Athina Bekakou | action: 'is this a function?' |
177 | b058f1fe | Athina Bekakou | }, |
178 | b058f1fe | Athina Bekakou | { |
179 | b058f1fe | Athina Bekakou | description:'add machine', |
180 | e0d90534 | Athina Bekakou | 'snf-components': ['networks'], |
181 | b058f1fe | Athina Bekakou | 'enabled-status': ['active'], |
182 | b058f1fe | Athina Bekakou | action: 'is this a function?' |
183 | b058f1fe | Athina Bekakou | }, |
184 | b058f1fe | Athina Bekakou | { |
185 | b058f1fe | Athina Bekakou | description:'action for all', |
186 | e0d90534 | Athina Bekakou | 'snf-components': ['vms', 'networks'], |
187 | b058f1fe | Athina Bekakou | 'enabled-status': ['all'], |
188 | b058f1fe | Athina Bekakou | action: 'is this a function?' |
189 | b058f1fe | Athina Bekakou | }] |
190 | b058f1fe | Athina Bekakou | }; |
191 | b058f1fe | Athina Bekakou | ;/* Mapping */
|
192 | b058f1fe | Athina Bekakou | |
193 | b058f1fe | Athina Bekakou | Synnefo.Router.map(function() {
|
194 | b058f1fe | Athina Bekakou | // I defined the above resource to extend its Route
|
195 | b058f1fe | Athina Bekakou | this.resource('sections', {'path':'/'}); |
196 | b058f1fe | Athina Bekakou | for(var i=0; i<Synnefo.conf.sectors.length; i++) |
197 | b058f1fe | Athina Bekakou | this.resource(Synnefo.conf.sectors[i].destination/*, function() { |
198 | b058f1fe | Athina Bekakou | this.route('grid');
|
199 | b058f1fe | Athina Bekakou | this.route('list');
|
200 | b058f1fe | Athina Bekakou | }*/);
|
201 | d0fe8c12 | Athina Bekakou | }); |
202 | d0fe8c12 | Athina Bekakou | |
203 | d0fe8c12 | Athina Bekakou | |
204 | d0fe8c12 | Athina Bekakou | /* Routes */
|
205 | d0fe8c12 | Athina Bekakou | |
206 | b058f1fe | Athina Bekakou | Synnefo.ApplicationRoute = Ember.Route.extend({ |
207 | d0fe8c12 | Athina Bekakou | model: function() { |
208 | d0fe8c12 | Athina Bekakou | return {email: 'athina@mail.com'}; |
209 | b058f1fe | Athina Bekakou | }, |
210 | b058f1fe | Athina Bekakou | redirect: function() { |
211 | b058f1fe | Athina Bekakou | // have to set vm navigation icon full
|
212 | b058f1fe | Athina Bekakou | this.transitionTo('vms'); |
213 | d0fe8c12 | Athina Bekakou | } |
214 | d0fe8c12 | Athina Bekakou | }); |
215 | d0fe8c12 | Athina Bekakou | |
216 | b058f1fe | Athina Bekakou | Synnefo.SectionsRoute = Ember.Route.extend({ |
217 | b058f1fe | Athina Bekakou | modelName: undefined, |
218 | d0fe8c12 | Athina Bekakou | model: function() { |
219 | b058f1fe | Athina Bekakou | return this.store.find(this.modelName); |
220 | d0fe8c12 | Athina Bekakou | }, |
221 | d0fe8c12 | Athina Bekakou | renderTemplate: function(controller) { |
222 | b058f1fe | Athina Bekakou | this.render('snfElems', {controller: controller}); |
223 | d0fe8c12 | Athina Bekakou | } |
224 | d0fe8c12 | Athina Bekakou | }); |
225 | d0fe8c12 | Athina Bekakou | |
226 | e0d90534 | Athina Bekakou | |
227 | b058f1fe | Athina Bekakou | Synnefo.VmsRoute = Synnefo.SectionsRoute.extend({ |
228 | b058f1fe | Athina Bekakou | modelName: 'vm' |
229 | b058f1fe | Athina Bekakou | }); |
230 | b058f1fe | Athina Bekakou | |
231 | e0d90534 | Athina Bekakou | Synnefo.NetworksRoute = Synnefo.SectionsRoute.extend({ |
232 | b058f1fe | Athina Bekakou | modelName: 'network' |
233 | b058f1fe | Athina Bekakou | }); |
234 | b058f1fe | Athina Bekakou | |
235 | b058f1fe | Athina Bekakou | Synnefo.VolumesRoute = Synnefo.SectionsRoute.extend({ |
236 | b058f1fe | Athina Bekakou | modelName: 'volume' |
237 | b058f1fe | Athina Bekakou | }); |
238 | b058f1fe | Athina Bekakou | |
239 | b058f1fe | Athina Bekakou | Synnefo.SnapshotsRoute = Synnefo.SectionsRoute.extend({ |
240 | b058f1fe | Athina Bekakou | modelName: 'snapshot' |
241 | b058f1fe | Athina Bekakou | }); |
242 | b058f1fe | Athina Bekakou | |
243 | b058f1fe | Athina Bekakou | Synnefo.ImagesRoute = Synnefo.SectionsRoute.extend({ |
244 | b058f1fe | Athina Bekakou | modelName: 'userImage' |
245 | d0fe8c12 | Athina Bekakou | }); |
246 | d0fe8c12 | Athina Bekakou | |
247 | d0fe8c12 | Athina Bekakou | |
248 | b058f1fe | Athina Bekakou | |
249 | b058f1fe | Athina Bekakou | |
250 | b058f1fe | Athina Bekakou | |
251 | d0fe8c12 | Athina Bekakou | /* Controllers */
|
252 | d0fe8c12 | Athina Bekakou | |
253 | b058f1fe | Athina Bekakou | Synnefo.ApplicationController = Ember.Controller.extend({ |
254 | d0fe8c12 | Athina Bekakou | updateCurrentPath: function() { |
255 | 3342f8ce | Athina Bekakou | // we need the set because ElemsController gets the value of current path in every transition
|
256 | b058f1fe | Athina Bekakou | Synnefo.set('currentPath', this.get('currentPath')) |
257 | d0fe8c12 | Athina Bekakou | return this.get('currentPath'); |
258 | d0fe8c12 | Athina Bekakou | }.observes('currentPath'),
|
259 | d0fe8c12 | Athina Bekakou | actions: {
|
260 | d0fe8c12 | Athina Bekakou | test: function() { |
261 | b058f1fe | Athina Bekakou | console.log('This is test from Synnefo.ApplicationController');
|
262 | d0fe8c12 | Athina Bekakou | return 0; |
263 | d0fe8c12 | Athina Bekakou | } |
264 | d0fe8c12 | Athina Bekakou | }, |
265 | d0fe8c12 | Athina Bekakou | |
266 | d0fe8c12 | Athina Bekakou | pageTitle : function() { |
267 | d0fe8c12 | Athina Bekakou | var currentPath =this.get('currentPath'); |
268 | b058f1fe | Athina Bekakou | if(currentPath!== 'index') return Synnefo.conf.sectors.findBy('destination', this.get('currentPath')).title; |
269 | d0fe8c12 | Athina Bekakou | else return 'Home'; |
270 | d0fe8c12 | Athina Bekakou | }.property('currentPath'),
|
271 | d0fe8c12 | Athina Bekakou | |
272 | d0fe8c12 | Athina Bekakou | // name: "okeanos application",
|
273 | d0fe8c12 | Athina Bekakou | }); |
274 | d0fe8c12 | Athina Bekakou | |
275 | d0fe8c12 | Athina Bekakou | |
276 | b058f1fe | Athina Bekakou | |
277 | b058f1fe | Athina Bekakou | Synnefo.ElemsController = Ember.ArrayController.extend({ |
278 | d0fe8c12 | Athina Bekakou | type: undefined, |
279 | d0fe8c12 | Athina Bekakou | itemController: function(){ |
280 | d0fe8c12 | Athina Bekakou | var type = this.type; |
281 | d0fe8c12 | Athina Bekakou | return type.substring(0, type.length - 1); |
282 | d0fe8c12 | Athina Bekakou | }.property(), |
283 | d0fe8c12 | Athina Bekakou | icon: function() { |
284 | b058f1fe | Athina Bekakou | // should this be placed in ElemsView?
|
285 | b058f1fe | Athina Bekakou | return Synnefo.conf.sectors.findBy('destination', this.get('type')).icon.replace('outline', 'full'); |
286 | d0fe8c12 | Athina Bekakou | }.property(), |
287 | d0fe8c12 | Athina Bekakou | hasOS: function(){ |
288 | b058f1fe | Athina Bekakou | if(Synnefo.get('currentPath') == "vms") |
289 | d0fe8c12 | Athina Bekakou | return true; |
290 | d0fe8c12 | Athina Bekakou | else return false; |
291 | d0fe8c12 | Athina Bekakou | }.property(), |
292 | b3523ce4 | Athina Bekakou | hasTags: function(){ |
293 | b058f1fe | Athina Bekakou | if(Synnefo.get('currentPath') == "vms") |
294 | b3523ce4 | Athina Bekakou | return true; |
295 | b3523ce4 | Athina Bekakou | else return false; |
296 | b3523ce4 | Athina Bekakou | }.property(), |
297 | d0fe8c12 | Athina Bekakou | }); |
298 | d0fe8c12 | Athina Bekakou | |
299 | b058f1fe | Athina Bekakou | Synnefo.VmsController = Synnefo.ElemsController.extend({ |
300 | d0fe8c12 | Athina Bekakou | type: 'vms' |
301 | d0fe8c12 | Athina Bekakou | }); |
302 | d0fe8c12 | Athina Bekakou | |
303 | d0fe8c12 | Athina Bekakou | |
304 | e0d90534 | Athina Bekakou | Synnefo.NetworksController = Synnefo.ElemsController.extend({ |
305 | e0d90534 | Athina Bekakou | type: 'networks' |
306 | d0fe8c12 | Athina Bekakou | }); |
307 | d0fe8c12 | Athina Bekakou | |
308 | b058f1fe | Athina Bekakou | Synnefo.VolumesController = Synnefo.ElemsController.extend({ |
309 | b058f1fe | Athina Bekakou | type: 'volumes' |
310 | b058f1fe | Athina Bekakou | }); |
311 | b058f1fe | Athina Bekakou | |
312 | b058f1fe | Athina Bekakou | |
313 | b058f1fe | Athina Bekakou | Synnefo.SnapshotsController = Synnefo.ElemsController.extend({ |
314 | b058f1fe | Athina Bekakou | type: 'snapshots' |
315 | b058f1fe | Athina Bekakou | }); |
316 | b058f1fe | Athina Bekakou | |
317 | b058f1fe | Athina Bekakou | Synnefo.ImagesController = Synnefo.ElemsController.extend({ |
318 | b058f1fe | Athina Bekakou | type: 'images' |
319 | b058f1fe | Athina Bekakou | }); |
320 | b058f1fe | Athina Bekakou | |
321 | b058f1fe | Athina Bekakou | |
322 | d0fe8c12 | Athina Bekakou | |
323 | b058f1fe | Athina Bekakou | Synnefo.ElemController = Ember.ObjectController.extend({ |
324 | d0fe8c12 | Athina Bekakou | needs: [],
|
325 | b058f1fe | Athina Bekakou | actionsList: Synnefo.conf.userActions,
|
326 | d0fe8c12 | Athina Bekakou | setAvailableActions: function() { |
327 | d0fe8c12 | Athina Bekakou | var parent = this.needs; |
328 | d0fe8c12 | Athina Bekakou | var self = this; |
329 | d0fe8c12 | Athina Bekakou | return this.actionsList.filter(function(el) { |
330 | d0fe8c12 | Athina Bekakou | return _.contains(el['snf-components'], self.get('controllers.'+parent).type) &&( _.contains(el['enabled-status'], self.get('model.status')) || _.contains(el['enabled-status'], 'all')); |
331 | d0fe8c12 | Athina Bekakou | }) |
332 | d0fe8c12 | Athina Bekakou | }.property(), |
333 | d0fe8c12 | Athina Bekakou | createBtn: false, |
334 | d0fe8c12 | Athina Bekakou | actions: {
|
335 | d0fe8c12 | Athina Bekakou | shutdown: function(param) { |
336 | d0fe8c12 | Athina Bekakou | console.log(this.get('model.status')); |
337 | 3342f8ce | Athina Bekakou | this.set('model.status', 'shutting'); |
338 | d0fe8c12 | Athina Bekakou | }, |
339 | d0fe8c12 | Athina Bekakou | destroyElement: function(param) { |
340 | d0fe8c12 | Athina Bekakou | var element = this.get('model'); |
341 | d0fe8c12 | Athina Bekakou | element.deleteRecord(); |
342 | d0fe8c12 | Athina Bekakou | element.save(); |
343 | d0fe8c12 | Athina Bekakou | } |
344 | d0fe8c12 | Athina Bekakou | } |
345 | d0fe8c12 | Athina Bekakou | }); |
346 | d0fe8c12 | Athina Bekakou | |
347 | b058f1fe | Athina Bekakou | Synnefo.VmController = Synnefo.ElemController.extend({ |
348 | d0fe8c12 | Athina Bekakou | needs: ['vms'] |
349 | d0fe8c12 | Athina Bekakou | }); |
350 | d0fe8c12 | Athina Bekakou | |
351 | e0d90534 | Athina Bekakou | Synnefo.NetworkController = Synnefo.ElemController.extend({ |
352 | e0d90534 | Athina Bekakou | needs: ['networks'] |
353 | d0fe8c12 | Athina Bekakou | }); |
354 | d0fe8c12 | Athina Bekakou | |
355 | b058f1fe | Athina Bekakou | Synnefo.VolumeController = Synnefo.ElemController.extend({ |
356 | b058f1fe | Athina Bekakou | needs: ['volumes'] |
357 | b058f1fe | Athina Bekakou | }); |
358 | b058f1fe | Athina Bekakou | |
359 | b058f1fe | Athina Bekakou | Synnefo.SnapshotController = Synnefo.ElemController.extend({ |
360 | b058f1fe | Athina Bekakou | needs: ['snapshots'] |
361 | b058f1fe | Athina Bekakou | }); |
362 | b058f1fe | Athina Bekakou | |
363 | b058f1fe | Athina Bekakou | Synnefo.ImageController = Synnefo.ElemController.extend({ |
364 | b058f1fe | Athina Bekakou | needs: ['images'] |
365 | b058f1fe | Athina Bekakou | }); |
366 | b058f1fe | Athina Bekakou | |
367 | d0fe8c12 | Athina Bekakou | |
368 | d0fe8c12 | Athina Bekakou | /* Views */
|
369 | d0fe8c12 | Athina Bekakou | |
370 | b058f1fe | Athina Bekakou | Synnefo.NavIconView = Ember.View.extend({ |
371 | d0fe8c12 | Athina Bekakou | tagName: 'span', |
372 | d0fe8c12 | Athina Bekakou | click: function(e) { |
373 | d0fe8c12 | Athina Bekakou | var parentEl = this.$().parent('a'); |
374 | d0fe8c12 | Athina Bekakou | var currentEl = this.$().parents('li').siblings('li').find('a.current'); |
375 | d0fe8c12 | Athina Bekakou | |
376 | d0fe8c12 | Athina Bekakou | ui.replaceClass(currentEl, 'full', 'outline', 'snf-'); |
377 | d0fe8c12 | Athina Bekakou | ui.replaceClass(parentEl, 'outline', 'full', 'snf-'); |
378 | d0fe8c12 | Athina Bekakou | } |
379 | d0fe8c12 | Athina Bekakou | |
380 | d0fe8c12 | Athina Bekakou | }); |
381 | d0fe8c12 | Athina Bekakou | |
382 | b058f1fe | Athina Bekakou | Synnefo.NavigationView = Ember.CollectionView.extend({ |
383 | d0fe8c12 | Athina Bekakou | tagName: "ul", |
384 | d0fe8c12 | Athina Bekakou | classNames: ['icons-nav'], |
385 | d0fe8c12 | Athina Bekakou | |
386 | b058f1fe | Athina Bekakou | content: Synnefo.conf.sectors,
|
387 | d0fe8c12 | Athina Bekakou | itemViewClass: Ember.View.extend({
|
388 | b058f1fe | Athina Bekakou | templateName: "navigationItem" |
389 | d0fe8c12 | Athina Bekakou | }), |
390 | d0fe8c12 | Athina Bekakou | }); |
391 | d0fe8c12 | Athina Bekakou | |
392 | d0fe8c12 | Athina Bekakou | |
393 | b058f1fe | Athina Bekakou | Synnefo.ElemView = Ember.View.extend({ |
394 | d0fe8c12 | Athina Bekakou | // templateName: 'elem',
|
395 | b3523ce4 | Athina Bekakou | addNewBtn: false, |
396 | b058f1fe | Athina Bekakou | templateName: 'snfElem', |
397 | d0fe8c12 | Athina Bekakou | tagName: 'li', |
398 | 1b6dd4b5 | Athina Bekakou | selectable: true, |
399 | 1b6dd4b5 | Athina Bekakou | initSelect: 'unchecked', |
400 | d0fe8c12 | Athina Bekakou | classNameBindings: ['status'], |
401 | d0fe8c12 | Athina Bekakou | attributeBindings: ['data-status'], |
402 | d0fe8c12 | Athina Bekakou | 'data-status': function() { |
403 | d0fe8c12 | Athina Bekakou | return this.status; |
404 | d0fe8c12 | Athina Bekakou | }.property(), |
405 | d0fe8c12 | Athina Bekakou | status: function() { |
406 | d0fe8c12 | Athina Bekakou | return this.get('controller.status'); |
407 | d0fe8c12 | Athina Bekakou | }.property('controller.status')
|
408 | b3523ce4 | Athina Bekakou | }); |
409 | d0fe8c12 | Athina Bekakou | |
410 | b058f1fe | Athina Bekakou | Synnefo.ImgWrapView = Ember.View.extend({ |
411 | b058f1fe | Athina Bekakou | templateName: 'img-wrap', |
412 | 3342f8ce | Athina Bekakou | classNames: ['img-wrap'], |
413 | 3342f8ce | Athina Bekakou | icon: function() { |
414 | b058f1fe | Athina Bekakou | var parentView = this.get('parentView'); |
415 | b058f1fe | Athina Bekakou | var addNewBtn = parentView.get('addNewBtn'); |
416 | 3342f8ce | Athina Bekakou | if(addNewBtn)
|
417 | b058f1fe | Athina Bekakou | return parentView.get('icon'); |
418 | 3342f8ce | Athina Bekakou | else
|
419 | b058f1fe | Athina Bekakou | return parentView.get('controller').get('parentController').get('icon'); |
420 | 3342f8ce | Athina Bekakou | }.property() |
421 | 3342f8ce | Athina Bekakou | }); |
422 | 3342f8ce | Athina Bekakou | |
423 | b058f1fe | Athina Bekakou | Synnefo.NameView = Ember.View.extend({ |
424 | b058f1fe | Athina Bekakou | templateName: 'name', |
425 | b058f1fe | Athina Bekakou | tagName: 'h4', |
426 | b058f1fe | Athina Bekakou | name: function() { |
427 | b058f1fe | Athina Bekakou | // the name may be defined inside the parent view or in its model or controller
|
428 | b058f1fe | Athina Bekakou | return this.get('parentView').get('controller').get('name'); |
429 | b058f1fe | Athina Bekakou | }.property() |
430 | 1b6dd4b5 | Athina Bekakou | }); |
431 | 1b6dd4b5 | Athina Bekakou | |
432 | b058f1fe | Athina Bekakou | // to be changed
|
433 | b058f1fe | Athina Bekakou | Synnefo.ImmediateActionView = Ember.View.extend({ |
434 | b058f1fe | Athina Bekakou | templateName: 'actions', |
435 | b058f1fe | Athina Bekakou | classNames: ['actions'] |
436 | b058f1fe | Athina Bekakou | }) |
437 | b058f1fe | Athina Bekakou | |
438 | d0fe8c12 | Athina Bekakou | /* Components */
|
439 | d0fe8c12 | Athina Bekakou | |
440 | b058f1fe | Athina Bekakou | Synnefo.Btn1Component = Ember.Component.extend({ |
441 | d0fe8c12 | Athina Bekakou | tagName: 'a', |
442 | d0fe8c12 | Athina Bekakou | click: function() { |
443 | d0fe8c12 | Athina Bekakou | this.sendAction("action", this.get('param')); |
444 | d0fe8c12 | Athina Bekakou | } |
445 | d0fe8c12 | Athina Bekakou | }); |
446 | d0fe8c12 | Athina Bekakou | |
447 | b058f1fe | Athina Bekakou | Synnefo.AddNewComponent = Ember.Component.extend({ |
448 | b058f1fe | Athina Bekakou | templateName: 'snfElem', |
449 | b3523ce4 | Athina Bekakou | addNewBtn: true, |
450 | 1b6dd4b5 | Athina Bekakou | selectable: false, |
451 | b3523ce4 | Athina Bekakou | icon: function() { |
452 | b058f1fe | Athina Bekakou | baseIcon = Synnefo.conf.sectors.findBy('destination', this.get('type')).icon; |
453 | b3523ce4 | Athina Bekakou | return baseIcon.replace('outline', 'create-full'); |
454 | b3523ce4 | Athina Bekakou | }.property(), |
455 | b3523ce4 | Athina Bekakou | tagName: 'li', |
456 | b3523ce4 | Athina Bekakou | status: 'add-new', |
457 | b3523ce4 | Athina Bekakou | classNameBindings: ['status'], |
458 | b058f1fe | Athina Bekakou | attributeBindings: ['data-status, data-reveal-id'], |
459 | b058f1fe | Athina Bekakou | 'data-reveal-id': function(){ |
460 | b058f1fe | Athina Bekakou | if(addNewBtn)
|
461 | b058f1fe | Athina Bekakou | return /*this.get('type').substring(0, type.length - 1)+*/'-wizard'; |
462 | b058f1fe | Athina Bekakou | else
|
463 | b058f1fe | Athina Bekakou | return undefined; |
464 | b058f1fe | Athina Bekakou | }.property(), |
465 | b3523ce4 | Athina Bekakou | 'data-status': function() { |
466 | b3523ce4 | Athina Bekakou | return this.status; |
467 | b3523ce4 | Athina Bekakou | }.property(), |
468 | b3523ce4 | Athina Bekakou | name: function() { |
469 | b058f1fe | Athina Bekakou | var msg = 'Create New '; |
470 | b3523ce4 | Athina Bekakou | var btnType = this.get('type') |
471 | b058f1fe | Athina Bekakou | switch(btnType){
|
472 | b058f1fe | Athina Bekakou | case 'vms': |
473 | b058f1fe | Athina Bekakou | return msg + 'Machine'; |
474 | e0d90534 | Athina Bekakou | case 'networks': |
475 | b058f1fe | Athina Bekakou | return msg + 'Network'; |
476 | b058f1fe | Athina Bekakou | case 'volumes': |
477 | b058f1fe | Athina Bekakou | return msg + 'Volume'; |
478 | b058f1fe | Athina Bekakou | case 'snapshots': |
479 | b058f1fe | Athina Bekakou | return msg + 'Snapshot'; |
480 | b058f1fe | Athina Bekakou | case 'images': |
481 | b058f1fe | Athina Bekakou | return '+ Upload New Image'; |
482 | b058f1fe | Athina Bekakou | } |
483 | b058f1fe | Athina Bekakou | }.property(), |
484 | b058f1fe | Athina Bekakou | click: function (e) { |
485 | b058f1fe | Athina Bekakou | e.preventDefault(); |
486 | e0d90534 | Athina Bekakou | var wizardID = '#'+ this.get('type').substring(0, type.length - 1)+'-wizard' |
487 | b058f1fe | Athina Bekakou | $('.overlay-area-custom').fadeIn(100); |
488 | b058f1fe | Athina Bekakou | $('body').addClass('with-overlay'); |
489 | e0d90534 | Athina Bekakou | $(wizardID).fadeIn('slow'); |
490 | b058f1fe | Athina Bekakou | } |
491 | 1b6dd4b5 | Athina Bekakou | }); |
492 | d0fe8c12 | Athina Bekakou | |
493 | b058f1fe | Athina Bekakou | Synnefo.LoginMenuComponent = Ember.Component.extend({ |
494 | d0fe8c12 | Athina Bekakou | classNames: ['login'], |
495 | d0fe8c12 | Athina Bekakou | didInsertElement: function() { |
496 | d0fe8c12 | Athina Bekakou | console.log('didInsertElement');
|
497 | d0fe8c12 | Athina Bekakou | var self = this.$(); |
498 | d0fe8c12 | Athina Bekakou | self.mouseenter(function(e){
|
499 | d0fe8c12 | Athina Bekakou | self.find('ul').stop(true, true).slideDown(200); |
500 | d0fe8c12 | Athina Bekakou | }); |
501 | d0fe8c12 | Athina Bekakou | self.mouseleave(function(e){
|
502 | d0fe8c12 | Athina Bekakou | self.find('ul').stop(true, true).slideUp(200); |
503 | d0fe8c12 | Athina Bekakou | }); |
504 | d0fe8c12 | Athina Bekakou | |
505 | d0fe8c12 | Athina Bekakou | } |
506 | d0fe8c12 | Athina Bekakou | }); |
507 | 1b6dd4b5 | Athina Bekakou | |
508 | b058f1fe | Athina Bekakou | Synnefo.SnfCheckboxComponent = Ember.Component.extend({ |
509 | 1b6dd4b5 | Athina Bekakou | tagName: 'a', |
510 | 1b6dd4b5 | Athina Bekakou | classNames: ['check'], |
511 | b058f1fe | Athina Bekakou | templateName: 'components/select-btn', |
512 | 1b6dd4b5 | Athina Bekakou | initState: function() { |
513 | 1b6dd4b5 | Athina Bekakou | return this.get('initState'); |
514 | 1b6dd4b5 | Athina Bekakou | }.property(), |
515 | 1b6dd4b5 | Athina Bekakou | didInsertElement: function() { |
516 | b058f1fe | Athina Bekakou | var el = this.$(); |
517 | 1b6dd4b5 | Athina Bekakou | var self =this; |
518 | 1b6dd4b5 | Athina Bekakou | this.setInitClasses();
|
519 | b058f1fe | Athina Bekakou | el.click(function(e) {
|
520 | 1b6dd4b5 | Athina Bekakou | e.preventDefault(); |
521 | 1b6dd4b5 | Athina Bekakou | e.stopPropagation(); |
522 | b058f1fe | Athina Bekakou | self.changeState(el); |
523 | 1b6dd4b5 | Athina Bekakou | // ui.entitiesActionsEnabled();
|
524 | 1b6dd4b5 | Athina Bekakou | }); |
525 | 1b6dd4b5 | Athina Bekakou | }, |
526 | 1b6dd4b5 | Athina Bekakou | setInitClasses: function() { |
527 | 1b6dd4b5 | Athina Bekakou | var self =this.$(); |
528 | 1b6dd4b5 | Athina Bekakou | switch(this.initState){ |
529 | 1b6dd4b5 | Athina Bekakou | case 'unchecked': { |
530 | 1b6dd4b5 | Athina Bekakou | this.uncheck(self);
|
531 | 1b6dd4b5 | Athina Bekakou | break;
|
532 | 1b6dd4b5 | Athina Bekakou | } |
533 | 1b6dd4b5 | Athina Bekakou | case 'prechecked': { |
534 | 1b6dd4b5 | Athina Bekakou | self.find('span').addClass('prechecked') |
535 | 1b6dd4b5 | Athina Bekakou | this.check(self);
|
536 | 1b6dd4b5 | Athina Bekakou | break;
|
537 | 1b6dd4b5 | Athina Bekakou | } |
538 | 1b6dd4b5 | Athina Bekakou | } |
539 | 1b6dd4b5 | Athina Bekakou | }, |
540 | 1b6dd4b5 | Athina Bekakou | // used to be in ui.checkbox
|
541 | 1b6dd4b5 | Athina Bekakou | changeState : function(checkbox_link) { |
542 | 1b6dd4b5 | Athina Bekakou | $(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked'); |
543 | 1b6dd4b5 | Athina Bekakou | $(checkbox_link).closest('li').toggleClass('selected'); |
544 | 1b6dd4b5 | Athina Bekakou | }, |
545 | 1b6dd4b5 | Athina Bekakou | check : function(checkbox_link) { |
546 | 1b6dd4b5 | Athina Bekakou | $(checkbox_link).find('span').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
547 | 1b6dd4b5 | Athina Bekakou | $(checkbox_link).closest('li').addClass('selected'); |
548 | 1b6dd4b5 | Athina Bekakou | }, |
549 | 1b6dd4b5 | Athina Bekakou | uncheck : function(checkbox_link) { |
550 | 1b6dd4b5 | Athina Bekakou | $(checkbox_link).find('span').removeClass('snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
551 | 1b6dd4b5 | Athina Bekakou | $(checkbox_link).closest('li').removeClass('selected'); |
552 | 1b6dd4b5 | Athina Bekakou | }, |
553 | 1b6dd4b5 | Athina Bekakou | |
554 | 1b6dd4b5 | Athina Bekakou | reset: function(area) { |
555 | 1b6dd4b5 | Athina Bekakou | $(area).find('.snf-radio-checked').not('.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
556 | 1b6dd4b5 | Athina Bekakou | $(area).find('.snf-radio-unchecked.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
557 | 1b6dd4b5 | Athina Bekakou | }, |
558 | b058f1fe | Athina Bekakou | }); |