root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / okeanos-ember.js @ 1933ffd6
History | View | Annotate | Download (18.8 kB)
1 |
/* Init Application */
|
---|---|
2 |
|
3 |
window.Synnefo = Ember.Application.create({ |
4 |
currentPath: 'vms', |
5 |
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 |
}); |
7 |
|
8 |
Synnefo.ApplicationAdapter = DS.FixtureAdapter.extend();;/* Objects */
|
9 |
|
10 |
Ember.Inflector.inflector.uncountable('account');
|
11 |
|
12 |
Synnefo.Account = DS.Model.extend({ |
13 |
email: DS.attr('string') |
14 |
}); |
15 |
|
16 |
// CHECK can i use a single obj and not an array of obj
|
17 |
Synnefo.Account.FIXTURES = { |
18 |
id: 001, |
19 |
email: "athina@mail.com" |
20 |
}; |
21 |
|
22 |
|
23 |
|
24 |
Synnefo.Vm = DS.Model.extend({ |
25 |
// id: DS.attr('number'), we do not define it ;)
|
26 |
name: DS.attr('string'), |
27 |
hostname: DS.attr('string'), |
28 |
status: DS.attr('string'), |
29 |
os: DS.attr()
|
30 |
}); |
31 |
|
32 |
Synnefo.Vm.FIXTURES = |
33 |
[{ |
34 |
id: 125355, |
35 |
name: "web-server", |
36 |
hostname: "user@snf-38389.vm.okeanos.grnet.gr", |
37 |
status: "running", |
38 |
os: "kubuntu" |
39 |
}, |
40 |
{ |
41 |
id: 12, |
42 |
name: "another-server", |
43 |
hostname: "user@snf-33333.vm.okeanos.grnet.gr", |
44 |
status: "off", |
45 |
os: "fedora" |
46 |
}]; |
47 |
|
48 |
Synnefo.Network = DS.Model.extend({ |
49 |
name: DS.attr('string'), |
50 |
status: DS.attr('string'), |
51 |
}); |
52 |
|
53 |
Synnefo.Network.FIXTURES = |
54 |
[{ |
55 |
id: 11, |
56 |
name: 'Network-1', |
57 |
status: 'running' |
58 |
}, |
59 |
{ |
60 |
id: 22, |
61 |
name: 'Network-2', |
62 |
status: 'error' |
63 |
}]; |
64 |
|
65 |
|
66 |
Synnefo.Volume = DS.Model.extend({ |
67 |
name: DS.attr('string'), |
68 |
status: DS.attr('string'), |
69 |
}); |
70 |
|
71 |
Synnefo.Volume.FIXTURES = |
72 |
[{ |
73 |
id: 111, |
74 |
name: 'Volume-1', |
75 |
status: 'running' |
76 |
}, |
77 |
{ |
78 |
id: 222, |
79 |
name: 'Volume-2', |
80 |
status: 'building' |
81 |
}]; |
82 |
|
83 |
Synnefo.Snapshot = DS.Model.extend({ |
84 |
name: DS.attr('string'), |
85 |
status: DS.attr('string'), |
86 |
}); |
87 |
|
88 |
Synnefo.Snapshot.FIXTURES = |
89 |
[{ |
90 |
id: 33, |
91 |
name: 'Snapshot-1', |
92 |
status: 'running' |
93 |
}, |
94 |
{ |
95 |
id: 44, |
96 |
name: 'Snapshot-2', |
97 |
status: 'building' |
98 |
}]; |
99 |
|
100 |
|
101 |
Synnefo.UserImage = DS.Model.extend({ |
102 |
name: DS.attr('string'), |
103 |
status: DS.attr('string'), |
104 |
}); |
105 |
|
106 |
Synnefo.UserImage.FIXTURES = |
107 |
[{ |
108 |
id: 55, |
109 |
name: 'Image-1', |
110 |
status: 'running' |
111 |
}, |
112 |
{ |
113 |
id: 66, |
114 |
name: 'Image-2', |
115 |
status: 'running' |
116 |
}]; |
117 |
|
118 |
|
119 |
Synnefo.conf = { |
120 |
sectors: [{
|
121 |
destination: "vms", |
122 |
title: "Virtual Machines", |
123 |
icon: "snf-pc-outline" |
124 |
}, |
125 |
{ |
126 |
destination: "networks", |
127 |
title: "Network", |
128 |
icon: "snf-network-outline" |
129 |
|
130 |
}, |
131 |
{ |
132 |
destination: "volumes", |
133 |
title: "Volumes", |
134 |
icon: "snf-volume-outline" |
135 |
}, |
136 |
{ |
137 |
destination: "pithos", |
138 |
title: "Pithos", |
139 |
icon: "snf-pithos-outline" |
140 |
}, |
141 |
{ |
142 |
destination: "images", |
143 |
title: "Images", |
144 |
icon: "snf-image-outline" |
145 |
}, |
146 |
{ |
147 |
destination: "snapshots", |
148 |
title: "Snapshots", |
149 |
icon: "snf-snapshot-outline" |
150 |
}, |
151 |
{ |
152 |
destination: "ips", |
153 |
title: "IPs", |
154 |
icon: "snf-nic-outline" |
155 |
}, |
156 |
{ |
157 |
destination: "sshkeys", |
158 |
title: "SSh Keys", |
159 |
icon: "snf-key-outline" |
160 |
}], |
161 |
|
162 |
userActions: [{
|
163 |
description:'start', |
164 |
'snf-components':['vms'], |
165 |
'enabled-status': ['off'], |
166 |
action: 'is this a function?' |
167 |
}, |
168 |
{ |
169 |
description:'destroyElement', |
170 |
'snf-components': ['vms', 'networks'], |
171 |
'enabled-status': ['all'], |
172 |
action: 'is this a function?', |
173 |
}, |
174 |
{ |
175 |
description:'shutdown', |
176 |
'snf-components': ['vms'], |
177 |
'enabled-status': ['running'], |
178 |
action: 'is this a function?' |
179 |
}, |
180 |
{ |
181 |
description:'add machine', |
182 |
'snf-components': ['networks'], |
183 |
'enabled-status': ['active'], |
184 |
action: 'is this a function?' |
185 |
}, |
186 |
{ |
187 |
description:'action for all', |
188 |
'snf-components': ['vms', 'networks'], |
189 |
'enabled-status': ['all'], |
190 |
action: 'is this a function?' |
191 |
}] |
192 |
}; |
193 |
|
194 |
Synnefo.wizards = { |
195 |
vmWizard: {
|
196 |
// each step must have a headline
|
197 |
stepsHeadlines: [
|
198 |
{ |
199 |
title:'Select an OS', |
200 |
subtitle:'Choose your preferred image' |
201 |
}, |
202 |
{ |
203 |
title:'Select CPUs, RAM and Disk Size', |
204 |
subtitle:'Available options are filtered based on the selected image' |
205 |
}, |
206 |
{ |
207 |
title:'Virtual machine custom options', |
208 |
subtitle:'tba' |
209 |
}, |
210 |
{ |
211 |
title:'Confirm your settings', |
212 |
subtitle:'Confirm that the options you have selected are correct' |
213 |
}, |
214 |
], |
215 |
stepsContent: ['step-1', 'step-2', 'step-3', 'step-4'] |
216 |
}, |
217 |
networkWizard: {}
|
218 |
};/* Mapping */
|
219 |
|
220 |
Synnefo.Router.map(function() {
|
221 |
// I defined the above resource to extend its Route
|
222 |
this.resource('sections', {'path':'/'}); |
223 |
for(var i=0; i<Synnefo.conf.sectors.length; i++) |
224 |
this.resource(Synnefo.conf.sectors[i].destination, function() { |
225 |
// this.route('grid');
|
226 |
// this.route('list');
|
227 |
this.route('create'); |
228 |
}); |
229 |
}); |
230 |
|
231 |
|
232 |
/* Routes */
|
233 |
|
234 |
Synnefo.ApplicationRoute = Ember.Route.extend({ |
235 |
model: function() { |
236 |
return {email: 'athina@mail.com'}; |
237 |
}, |
238 |
redirect: function() { |
239 |
// have to set vm navigation icon full
|
240 |
this.transitionTo('vms'); |
241 |
}, |
242 |
}); |
243 |
|
244 |
|
245 |
/* Items Routes */
|
246 |
|
247 |
Synnefo.SectionsRoute = Ember.Route.extend({ |
248 |
modelName: undefined, |
249 |
model: function() { |
250 |
return this.store.find(this.modelName); |
251 |
}, |
252 |
renderTemplate: function(controller) { |
253 |
this.render('snfElems', {controller: controller}); |
254 |
}, |
255 |
actions: {
|
256 |
openWizard: function() { |
257 |
var wizardType = this.routeName; |
258 |
this.transitionTo(wizardType+'.create') |
259 |
} |
260 |
} |
261 |
}); |
262 |
|
263 |
|
264 |
Synnefo.VmsRoute = Synnefo.SectionsRoute.extend({ |
265 |
modelName: 'vm' |
266 |
}); |
267 |
|
268 |
Synnefo.NetworksRoute = Synnefo.SectionsRoute.extend({ |
269 |
modelName: 'network' |
270 |
}); |
271 |
|
272 |
Synnefo.VolumesRoute = Synnefo.SectionsRoute.extend({ |
273 |
modelName: 'volume' |
274 |
}); |
275 |
|
276 |
Synnefo.SnapshotsRoute = Synnefo.SectionsRoute.extend({ |
277 |
modelName: 'snapshot' |
278 |
}); |
279 |
|
280 |
Synnefo.ImagesRoute = Synnefo.SectionsRoute.extend({ |
281 |
modelName: 'userImage' |
282 |
}); |
283 |
|
284 |
|
285 |
/* Wizards Routes */
|
286 |
|
287 |
Synnefo.CreateRoute = Ember.Route.extend({ |
288 |
model: function(){ |
289 |
return [{name: 'vm-wizard'}] |
290 |
}, |
291 |
renderTemplate: function(controller) { |
292 |
this.render('wizard',{controller: controller}); |
293 |
}, |
294 |
/* beforeModel: function() {
|
295 |
this._super();
|
296 |
console.log('beforeModel ',this.get('router.url'))
|
297 |
this.previousRoute = this.get('router.url'); // should return the current path but some times it returns the path where the user was before (when i dont type the url of the wizard)
|
298 |
},
|
299 |
previousRoute: undefined,*/
|
300 |
actions: {
|
301 |
closeWizard: function() { |
302 |
history.back(); |
303 |
} |
304 |
} |
305 |
}); |
306 |
|
307 |
Synnefo.VmsCreateRoute = Synnefo.CreateRoute.extend({ |
308 |
model: function() { |
309 |
return Synnefo.wizards.vmWizard;
|
310 |
} |
311 |
}); |
312 |
|
313 |
Synnefo.NetworksCreateRoute = Synnefo.CreateRoute.extend(); |
314 |
|
315 |
Synnefo.VolumesCreateRoute = Synnefo.CreateRoute.extend(); |
316 |
|
317 |
Synnefo.SnapshotsCreateRoute = Synnefo.CreateRoute.extend(); |
318 |
|
319 |
Synnefo.ImagesCreateRoute = Synnefo.CreateRoute.extend({});;/* Controllers */
|
320 |
|
321 |
Synnefo.ApplicationController = Ember.Controller.extend({ |
322 |
updateCurrentPath: function() { |
323 |
// we need the set because ElemsController gets the value of current path in every transition
|
324 |
Synnefo.set('currentPath', this.get('currentPath')) |
325 |
return this.get('currentPath'); |
326 |
}.observes('currentPath'),
|
327 |
|
328 |
pageTitle : function() { |
329 |
var currentPath =this.get('currentPath'); |
330 |
if(currentPath!== 'index') return Synnefo.conf.sectors.findBy('destination', this.get('currentPath')).title; |
331 |
else return 'Home'; |
332 |
}.property('currentPath'),
|
333 |
|
334 |
// name: "okeanos application",
|
335 |
}); |
336 |
|
337 |
|
338 |
/* Items Controllers */
|
339 |
|
340 |
Synnefo.ElemsController = Ember.ArrayController.extend({ |
341 |
type: undefined, |
342 |
itemController: function(){ |
343 |
var type = this.type; |
344 |
return type.substring(0, type.length - 1); |
345 |
}.property(), |
346 |
icon: function() { |
347 |
// should this be placed in ElemsView?
|
348 |
return Synnefo.conf.sectors.findBy('destination', this.get('type')).icon.replace('outline', 'full'); |
349 |
}.property(), |
350 |
hasOS: function(){ |
351 |
if(Synnefo.get('currentPath') === "vms" || Synnefo.get('currentPath') === "vms.index") |
352 |
return true; |
353 |
else return false; |
354 |
}.property(), |
355 |
hasTags: function(){ |
356 |
if(Synnefo.get('currentPath') == "vms" || Synnefo.get('currentPath') === "vms.index") |
357 |
return true; |
358 |
else return false; |
359 |
}.property(), |
360 |
}); |
361 |
|
362 |
Synnefo.VmsController = Synnefo.ElemsController.extend({ |
363 |
type: 'vms' |
364 |
}); |
365 |
|
366 |
|
367 |
Synnefo.NetworksController = Synnefo.ElemsController.extend({ |
368 |
type: 'networks' |
369 |
}); |
370 |
|
371 |
Synnefo.VolumesController = Synnefo.ElemsController.extend({ |
372 |
type: 'volumes' |
373 |
}); |
374 |
|
375 |
|
376 |
Synnefo.SnapshotsController = Synnefo.ElemsController.extend({ |
377 |
type: 'snapshots' |
378 |
}); |
379 |
|
380 |
Synnefo.ImagesController = Synnefo.ElemsController.extend({ |
381 |
type: 'images' |
382 |
}); |
383 |
|
384 |
|
385 |
/* Controllers for each Item */
|
386 |
|
387 |
Synnefo.ElemController = Ember.ObjectController.extend({ |
388 |
needs: [],
|
389 |
actionsList: Synnefo.conf.userActions,
|
390 |
setAvailableActions: function() { |
391 |
var parent = this.needs; |
392 |
var self = this; |
393 |
return this.actionsList.filter(function(el) { |
394 |
return _.contains(el['snf-components'], self.get('controllers.'+parent).type) &&( _.contains(el['enabled-status'], self.get('model.status')) || _.contains(el['enabled-status'], 'all')); |
395 |
}) |
396 |
}.property(), |
397 |
createBtn: false, |
398 |
actions: {
|
399 |
shutdown: function(param) { |
400 |
this.set('model.status', 'shutting'); |
401 |
}, |
402 |
destroyElement: function(param) { |
403 |
var element = this.get('model'); |
404 |
element.deleteRecord(); |
405 |
element.save(); |
406 |
} |
407 |
} |
408 |
}); |
409 |
|
410 |
Synnefo.VmController = Synnefo.ElemController.extend({ |
411 |
needs: ['vms'] |
412 |
}); |
413 |
|
414 |
Synnefo.NetworkController = Synnefo.ElemController.extend({ |
415 |
needs: ['networks'] |
416 |
}); |
417 |
|
418 |
Synnefo.VolumeController = Synnefo.ElemController.extend({ |
419 |
needs: ['volumes'] |
420 |
}); |
421 |
|
422 |
Synnefo.SnapshotController = Synnefo.ElemController.extend({ |
423 |
needs: ['snapshots'] |
424 |
}); |
425 |
|
426 |
Synnefo.ImageController = Synnefo.ElemController.extend({ |
427 |
needs: ['images'] |
428 |
}); |
429 |
|
430 |
|
431 |
/* Controllers for Wizards */
|
432 |
|
433 |
Synnefo.CreateController = Ember.ObjectController.extend({ |
434 |
currentStep: undefined, |
435 |
|
436 |
totalStep: function() { |
437 |
return this.get('stepsContent').length; |
438 |
}.property(), |
439 |
|
440 |
init: function() { |
441 |
this._super();
|
442 |
this.set('currentStep', 1) |
443 |
}, |
444 |
btnLeftLabel: function(){ |
445 |
return (this.get('currentStep') === 1)?'CANCEL':'PREVIOUS'; |
446 |
}.property('currentStep'),
|
447 |
|
448 |
btnRightLabel: function(){ |
449 |
return (this.get('currentStep') === this.get('totalStep'))?'CREATE':'NEXT'; |
450 |
}.property('currentStep'),
|
451 |
|
452 |
actions: {
|
453 |
moveNext: function() { |
454 |
var self = this; |
455 |
var step = this.get('currentStep'); |
456 |
|
457 |
if(step!== this.get('totalStep')) { |
458 |
step++; |
459 |
this.set('currentStep', step); |
460 |
} |
461 |
else
|
462 |
this.get('target').send('closeWizard'); |
463 |
}, |
464 |
moveBack: function() { |
465 |
var step = this.get('currentStep'); |
466 |
|
467 |
if(step === 1) { |
468 |
this.get('target').send('closeWizard'); |
469 |
} |
470 |
else {
|
471 |
step--; |
472 |
this.set('currentStep', step); |
473 |
} |
474 |
} |
475 |
}, |
476 |
}); |
477 |
|
478 |
Synnefo.VmsCreateController =Synnefo.CreateController.extend({ |
479 |
|
480 |
});; /* Views */
|
481 |
|
482 |
Synnefo.ApplicationView = Ember.View.extend({ |
483 |
classNames: ['content'] |
484 |
}); |
485 |
|
486 |
|
487 |
/* Navigation Menu */
|
488 |
|
489 |
Synnefo.NavIconView = Ember.View.extend({ |
490 |
tagName: 'span', |
491 |
click: function() { |
492 |
var parentEl = this.$().parent('a'); |
493 |
var currentEl = this.$().parents('li').siblings('li').find('a.current'); |
494 |
|
495 |
ui.replaceClass(currentEl, 'full', 'outline', 'snf-'); |
496 |
ui.replaceClass(parentEl, 'outline', 'full', 'snf-'); |
497 |
} |
498 |
|
499 |
}); |
500 |
|
501 |
Synnefo.NavigationView = Ember.CollectionView.extend({ |
502 |
tagName: "ul", |
503 |
classNames: ['icons-nav'], |
504 |
|
505 |
content: Synnefo.conf.sectors,
|
506 |
itemViewClass: Ember.View.extend({
|
507 |
templateName: "navigationItem" |
508 |
}), |
509 |
}); |
510 |
|
511 |
|
512 |
/* Items Parts */
|
513 |
|
514 |
Synnefo.ElemView = Ember.View.extend({ |
515 |
// templateName: 'elem',
|
516 |
addNewBtn: false, |
517 |
templateName: 'snfElem', |
518 |
tagName: 'li', |
519 |
selectable: true, |
520 |
initSelect: 'unchecked', |
521 |
classNameBindings: ['status'], |
522 |
attributeBindings: ['data-status'], |
523 |
'data-status': function() { |
524 |
return this.status; |
525 |
}.property(), |
526 |
status: function() { |
527 |
return this.get('controller.status'); |
528 |
}.property('controller.status')
|
529 |
}); |
530 |
|
531 |
Synnefo.ImgWrapView = Ember.View.extend({ |
532 |
templateName: 'img-wrap', |
533 |
classNames: ['img-wrap'], |
534 |
icon: function() { |
535 |
var parentView = this.get('parentView'); |
536 |
var addNewBtn = parentView.get('addNewBtn'); |
537 |
if(addNewBtn)
|
538 |
return parentView.get('icon'); |
539 |
else
|
540 |
return parentView.get('controller').get('parentController').get('icon'); |
541 |
}.property() |
542 |
}); |
543 |
|
544 |
Synnefo.NameView = Ember.View.extend({ |
545 |
templateName: 'name', |
546 |
tagName: 'h4', |
547 |
name: function() { |
548 |
// the name may be defined inside the parent view or in its model or controller
|
549 |
return this.get('parentView').get('controller').get('name'); |
550 |
}.property() |
551 |
}); |
552 |
|
553 |
// to be changed
|
554 |
Synnefo.ImmediateActionView = Ember.View.extend({ |
555 |
templateName: 'actions', |
556 |
classNames: ['actions'] |
557 |
}); |
558 |
|
559 |
|
560 |
/* Wizard */
|
561 |
|
562 |
Synnefo.WizardHeadersView = Ember.CollectionView.extend({ |
563 |
tagName: 'ul', |
564 |
classNames:['nums'], |
565 |
content: Synnefo.wizards.vmWizard.stepsHeadlines,
|
566 |
counter: 0, |
567 |
setCurrentHeader: function() { |
568 |
step = this.get('controller').get('currentStep'); |
569 |
console.log('* step', step);
|
570 |
return step;
|
571 |
}.property('controller.currentStep'),
|
572 |
didInsertElement: function() { |
573 |
console.log('collecton inserted');
|
574 |
this.setCurrentHeader;
|
575 |
}, |
576 |
itemViewClass: Ember.View.extend({
|
577 |
templateName: 'wizardStepHeader', |
578 |
classNameBindings: ['isCurrent:current::', 'isFirst:preselected', 'isPast:past::'], |
579 |
index: undefined, |
580 |
isCurrent: false, |
581 |
isFirst: false, |
582 |
init: function() { |
583 |
this._super();
|
584 |
console.log('init');
|
585 |
var prevIndex = this.get('parentView').get('counter'); |
586 |
prevIndex++; |
587 |
console.log('prevIndex', prevIndex)
|
588 |
this.get('parentView').set('counter', prevIndex); |
589 |
this.set('index', prevIndex); |
590 |
if(prevIndex === 1) { |
591 |
this.set('isFirst', true); |
592 |
// this.set('isCurrent', true);
|
593 |
} |
594 |
console.log('current', this.isVisible) |
595 |
}, |
596 |
isCurrent: function() { |
597 |
return this.index === this.get('controller').get('currentStep'); |
598 |
}.property('controller.currentStep'),
|
599 |
|
600 |
isPast: function() { |
601 |
return this.index < this.get('controller').get('currentStep'); |
602 |
}.property('controller.currentStep'),
|
603 |
|
604 |
didInsertElement: function() { |
605 |
} |
606 |
}), |
607 |
}); |
608 |
|
609 |
// The only buttons that are views are the buttons that move the wizard
|
610 |
// The reason is that they shouldn't be isolated from the surrounding
|
611 |
// (Their labels changes depanding the current step)
|
612 |
Synnefo.WizardBtnBackView = Ember.View.extend({ |
613 |
classNames: ['nav', 'prev'], |
614 |
tagName: 'a', |
615 |
templateName: 'components/btns-span', |
616 |
content: function(){ |
617 |
return this.get('controller').get('btnLeftLabel'); |
618 |
}.property('controller.btnLeftLabel'),
|
619 |
click: function() { |
620 |
this.get('controller').send('moveBack'); |
621 |
} |
622 |
}); |
623 |
|
624 |
Synnefo.WizardBtnNextView = Ember.View.extend({ |
625 |
classNames: ['nav', 'next'], |
626 |
tagName: 'a', |
627 |
templateName: 'components/btns-span', |
628 |
content: function(){ |
629 |
return this.get('controller').get('btnRightLabel'); |
630 |
}.property('controller.btnRightLabel'),
|
631 |
click: function() { |
632 |
this.get('controller').send('moveNext'); |
633 |
} |
634 |
}); |
635 |
|
636 |
;/* Components */
|
637 |
|
638 |
Synnefo.Btn1Component = Ember.Component.extend({ |
639 |
tagName: 'a', |
640 |
click: function() { |
641 |
this.sendAction("action", this.get('param')); |
642 |
}, |
643 |
content: undefined // will be set if we want to print a message inside the span |
644 |
}); |
645 |
|
646 |
Synnefo.BtnsSpanComponent = Ember.Component.extend({ |
647 |
tagName: 'a', |
648 |
templateName: 'components/btns-span', |
649 |
click: function() { |
650 |
this.sendAction("action"); |
651 |
} |
652 |
}); |
653 |
|
654 |
|
655 |
/* Wizard Buttons */
|
656 |
|
657 |
Synnefo.Close1Component = Synnefo.BtnsSpanComponent.extend({ |
658 |
classNames: ['close'], |
659 |
spanClass: 'snf-close' // has to be modified to array of strings |
660 |
}); |
661 |
// there's another close icon to confirm/info modals
|
662 |
|
663 |
|
664 |
/*
|
665 |
|
666 |
Back and Next buttons are constructed as views and not as components
|
667 |
|
668 |
{{cancel-1 action="moveBack" step=currentStep minStep=1}}
|
669 |
{{next-1 action="moveNext" step=currentStep maxStep=totalStep}}
|
670 |
|
671 |
Synnefo.Cancel1Component = Synnefo.BtnsSpanComponent.extend({
|
672 |
// classNameBindings: ['el3'], the element that should be focused when the user goes to the next step
|
673 |
content: 'CANCEL',
|
674 |
click: function(){
|
675 |
var currentStep =this.get('step');
|
676 |
var minStep =this.get('minStep');
|
677 |
console.log('minStep ', minStep);
|
678 |
this.sendAction();
|
679 |
if(currentStep === minStep)
|
680 |
this.set('content', 'CANCEL');
|
681 |
else
|
682 |
this.set('content', 'PREVIOUS');
|
683 |
|
684 |
}
|
685 |
});
|
686 |
|
687 |
Synnefo.Next1Component = Synnefo.BtnsSpanComponent.extend({
|
688 |
classNames: ['nav', 'next'],
|
689 |
// classNameBindings: ['el3'], the element that should be focused when the user goes to the next step
|
690 |
content: 'NEXT',
|
691 |
click: function() {
|
692 |
var currentStep =this.get('step');
|
693 |
var maxStep =this.get('maxStep');
|
694 |
this.sendAction('action');
|
695 |
if(currentStep === maxStep)
|
696 |
this.set('content', 'CREATE');
|
697 |
else
|
698 |
this.set('content', 'NEXT');
|
699 |
}
|
700 |
}); */
|
701 |
|
702 |
|
703 |
/* Add New Item */
|
704 |
|
705 |
Synnefo.AddNewComponent = Ember.Component.extend({ |
706 |
templateName: 'snfElem', |
707 |
addNewBtn: true, |
708 |
selectable: false, |
709 |
icon: function() { |
710 |
baseIcon = Synnefo.conf.sectors.findBy('destination', this.get('type')).icon; |
711 |
return baseIcon.replace('outline', 'create-full'); |
712 |
}.property(), |
713 |
tagName: 'li', |
714 |
status: 'add-new', |
715 |
classNameBindings: ['status'], |
716 |
attributeBindings: ['data-status, data-reveal-id'], |
717 |
'data-reveal-id': function(){ |
718 |
if(addNewBtn)
|
719 |
return /*this.get('type').substring(0, type.length - 1)+*/'-wizard'; |
720 |
else
|
721 |
return undefined; |
722 |
}.property(), |
723 |
'data-status': function() { |
724 |
return this.status; |
725 |
}.property(), |
726 |
name: function() { |
727 |
var msg = 'Create New '; |
728 |
var btnType = this.get('type') |
729 |
switch(btnType){
|
730 |
case 'vms': |
731 |
return msg + 'Machine'; |
732 |
case 'networks': |
733 |
return msg + 'Network'; |
734 |
case 'volumes': |
735 |
return msg + 'Volume'; |
736 |
case 'snapshots': |
737 |
return msg + 'Snapshot'; |
738 |
case 'images': |
739 |
return '+ Upload New Image'; |
740 |
} |
741 |
}.property(), |
742 |
click: function () { |
743 |
this.sendAction('action'); |
744 |
} |
745 |
}); |
746 |
|
747 |
|
748 |
/* Login Menu */
|
749 |
|
750 |
Synnefo.LoginMenuComponent = Ember.Component.extend({ |
751 |
classNames: ['login'], |
752 |
didInsertElement: function() { |
753 |
var self = this.$(); |
754 |
self.mouseenter(function(e){
|
755 |
self.find('ul').stop(true, true).slideDown(200); |
756 |
}); |
757 |
self.mouseleave(function(e){
|
758 |
self.find('ul').stop(true, true).slideUp(200); |
759 |
}); |
760 |
|
761 |
} |
762 |
}); |
763 |
|
764 |
|
765 |
/* Checkboxes and Radiobuttons */
|
766 |
|
767 |
Synnefo.SnfCheckboxComponent = Ember.Component.extend({ |
768 |
tagName: 'a', |
769 |
classNames: ['check'], |
770 |
templateName: 'components/select-btn', |
771 |
initState: function() { |
772 |
return this.get('initState'); |
773 |
}.property(), |
774 |
didInsertElement: function() { |
775 |
var el = this.$(); |
776 |
var self =this; |
777 |
this.setInitClasses();
|
778 |
el.click(function(e) {
|
779 |
e.preventDefault(); |
780 |
e.stopPropagation(); |
781 |
self.changeState(el); |
782 |
// ui.entitiesActionsEnabled();
|
783 |
}); |
784 |
}, |
785 |
setInitClasses: function() { |
786 |
var self =this.$(); |
787 |
switch(this.initState){ |
788 |
case 'unchecked': { |
789 |
this.uncheck(self);
|
790 |
break;
|
791 |
} |
792 |
case 'prechecked': { |
793 |
self.find('span').addClass('prechecked') |
794 |
this.check(self);
|
795 |
break;
|
796 |
} |
797 |
} |
798 |
}, |
799 |
// used to be in ui.checkbox
|
800 |
changeState : function(checkbox_link) { |
801 |
$(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked'); |
802 |
$(checkbox_link).closest('li').toggleClass('selected'); |
803 |
}, |
804 |
check : function(checkbox_link) { |
805 |
$(checkbox_link).find('span').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
806 |
$(checkbox_link).closest('li').addClass('selected'); |
807 |
}, |
808 |
uncheck : function(checkbox_link) { |
809 |
$(checkbox_link).find('span').removeClass('snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
810 |
$(checkbox_link).closest('li').removeClass('selected'); |
811 |
}, |
812 |
|
813 |
reset: function(area) { |
814 |
$(area).find('.snf-radio-checked').not('.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
815 |
$(area).find('.snf-radio-unchecked.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
816 |
}, |
817 |
}); |