root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / okeanos-ember / ember-all.js @ 13de11ea
History | View | Annotate | Download (5.2 kB)
1 |
/* Mapping */
|
---|---|
2 |
|
3 |
Okeanos.Router.map(function() {
|
4 |
|
5 |
for(var i=0; i<Okeanos.places.length; i++) |
6 |
this.resource(Okeanos.places[i].destination);
|
7 |
}); |
8 |
|
9 |
|
10 |
/* Routes */
|
11 |
|
12 |
Okeanos.ApplicationRoute = Ember.Route.extend({ |
13 |
model: function() { |
14 |
|
15 |
return {email: 'athina@mail.com'}; |
16 |
} |
17 |
}); |
18 |
|
19 |
Okeanos.VmsRoute = Ember.Route.extend({ |
20 |
model: function() { |
21 |
return this.store.find('vm'); |
22 |
}, |
23 |
renderTemplate: function(controller) { |
24 |
this.render('snfElems', {controller: controller}) |
25 |
} |
26 |
}); |
27 |
|
28 |
Okeanos.NetsRoute = Ember.Route.extend({ |
29 |
model: function() { |
30 |
return [{id: '1', name:'net1', status: 'active'}, {id: '2', name:'net2', status: 'error'}]; |
31 |
}, |
32 |
renderTemplate: function(controller) { |
33 |
this.render('snfElems', {controller: controller}) |
34 |
} |
35 |
}); |
36 |
|
37 |
|
38 |
/* Controllers */
|
39 |
|
40 |
Okeanos.ApplicationController = Ember.Controller.extend({ |
41 |
updateCurrentPath: function() { |
42 |
// Okeanos.set('currentPath', this.get('currentPath'))
|
43 |
// console.log('AppController: CurrentPath ->', this.get('currentPath'));
|
44 |
return this.get('currentPath'); |
45 |
}.observes('currentPath'),
|
46 |
actions: {
|
47 |
test: function() { |
48 |
console.log('This is test from Okeanos.ApplicationController');
|
49 |
return 0; |
50 |
} |
51 |
}, |
52 |
|
53 |
pageTitle : function() { |
54 |
var currentPath =this.get('currentPath'); |
55 |
if(currentPath!== 'index') return Okeanos.places.findBy('destination', this.get('currentPath')).title; |
56 |
else return 'Home'; |
57 |
}.property('currentPath'),
|
58 |
|
59 |
// name: "okeanos application",
|
60 |
}); |
61 |
|
62 |
|
63 |
Okeanos.ElemsController = Ember.ArrayController.extend({ |
64 |
// ElementController: 'vm',
|
65 |
type: undefined, |
66 |
itemController: function(){ |
67 |
var type = this.type; |
68 |
console.log('type ', type.substring(0, type.length - 1)) |
69 |
return type.substring(0, type.length - 1); |
70 |
}.property(), |
71 |
icon: function() { |
72 |
return Okeanos.places.findBy('destination', this.get('type')).icon.replace('outline', 'full'); |
73 |
}.property(), |
74 |
hasOS: function(){ |
75 |
if(Okeanos.get('currentPath') == "vms") |
76 |
return true; |
77 |
else return false; |
78 |
}.property(), |
79 |
hasTags: function(){ |
80 |
if(Okeanos.get('currentPath') == "vms") |
81 |
return true; |
82 |
else return false; |
83 |
}.property(), |
84 |
}); |
85 |
|
86 |
Okeanos.VmsController = Okeanos.ElemsController.extend({ |
87 |
type: 'vms' |
88 |
}); |
89 |
|
90 |
|
91 |
Okeanos.NetsController = Okeanos.ElemsController.extend({ |
92 |
type: 'nets' |
93 |
}); |
94 |
|
95 |
|
96 |
Okeanos.ElemController = Ember.ObjectController.extend({ |
97 |
needs: [],
|
98 |
actionsList: Okeanos.AllActions,
|
99 |
setAvailableActions: function() { |
100 |
var parent = this.needs; |
101 |
var self = this; |
102 |
return this.actionsList.filter(function(el) { |
103 |
return _.contains(el['snf-components'], self.get('controllers.'+parent).type) &&( _.contains(el['enabled-status'], self.get('model.status')) || _.contains(el['enabled-status'], 'all')); |
104 |
}) |
105 |
// return this.actionsList
|
106 |
}.property(), |
107 |
createBtn: false, |
108 |
actions: {
|
109 |
shutdown: function(param) { |
110 |
console.log(this.get('model.status')); |
111 |
this.set('model.status', 'shutting') |
112 |
console.log(this.get('model.status')); |
113 |
// this.set('building')
|
114 |
}, |
115 |
destroyElement: function(param) { |
116 |
var element = this.get('model'); |
117 |
element.deleteRecord(); |
118 |
element.save(); |
119 |
} |
120 |
} |
121 |
}); |
122 |
|
123 |
Okeanos.VmController = Okeanos.ElemController.extend({ |
124 |
needs: ['vms'] |
125 |
}); |
126 |
|
127 |
Okeanos.NetController = Okeanos.ElemController.extend({ |
128 |
needs: ['nets'] |
129 |
}); |
130 |
|
131 |
|
132 |
/* Views */
|
133 |
|
134 |
Okeanos.NavIconView = Ember.View.extend({ |
135 |
tagName: 'span', |
136 |
click: function(e) { |
137 |
var parentEl = this.$().parent('a'); |
138 |
var currentEl = this.$().parents('li').siblings('li').find('a.current'); |
139 |
|
140 |
ui.replaceClass(currentEl, 'full', 'outline', 'snf-'); |
141 |
ui.replaceClass(parentEl, 'outline', 'full', 'snf-'); |
142 |
} |
143 |
|
144 |
}); |
145 |
|
146 |
Okeanos.NavigationView = Ember.CollectionView.extend({ |
147 |
tagName: "ul", |
148 |
classNames: ['icons-nav'], |
149 |
|
150 |
content: Okeanos.places,
|
151 |
itemViewClass: Ember.View.extend({
|
152 |
template: Ember.TEMPLATES["navigationItem"] |
153 |
}), |
154 |
}); |
155 |
|
156 |
|
157 |
Okeanos.ElemView = Ember.View.extend({ |
158 |
// templateName: 'elem',
|
159 |
addNewBtn: false, |
160 |
template: Ember.TEMPLATES['snfElem'], |
161 |
tagName: 'li', |
162 |
classNameBindings: ['status'], |
163 |
attributeBindings: ['data-status'], |
164 |
'data-status': function() { |
165 |
return this.status; |
166 |
}.property(), |
167 |
status: function() { |
168 |
return this.get('controller.status'); |
169 |
}.property('controller.status')
|
170 |
}); |
171 |
|
172 |
|
173 |
/* Components */
|
174 |
|
175 |
Okeanos.Btn1Component = Ember.Component.extend({ |
176 |
tagName: 'a', |
177 |
click: function() { |
178 |
this.sendAction("action", this.get('param')); |
179 |
} |
180 |
}); |
181 |
|
182 |
Okeanos.AddNewComponent = Ember.Component.extend({ |
183 |
template: Ember.TEMPLATES['snfElem'], |
184 |
addNewBtn: true, |
185 |
icon: function() { |
186 |
baseIcon = Okeanos.places.findBy('destination', this.get('type')).icon; |
187 |
return baseIcon.replace('outline', 'create-full'); |
188 |
}.property(), |
189 |
tagName: 'li', |
190 |
status: 'add-new', |
191 |
classNameBindings: ['status'], |
192 |
attributeBindings: ['data-status'], |
193 |
'data-status': function() { |
194 |
return this.status; |
195 |
}.property(), |
196 |
name: function() { |
197 |
var msg = 'Add New '; |
198 |
var btnType = this.get('type') |
199 |
if(btnType === 'vms') |
200 |
return msg + 'Machine'; |
201 |
else if(btnType === 'nets') |
202 |
return msg + 'Network'; |
203 |
}.property() |
204 |
|
205 |
}) |
206 |
|
207 |
Okeanos.LoginMenuComponent = Ember.Component.extend({ |
208 |
classNames: ['login'], |
209 |
didInsertElement: function() { |
210 |
console.log('didInsertElement');
|
211 |
var self = this.$(); |
212 |
self.mouseenter(function(e){
|
213 |
self.find('ul').stop(true, true).slideDown(200); |
214 |
}); |
215 |
self.mouseleave(function(e){
|
216 |
self.find('ul').stop(true, true).slideUp(200); |
217 |
}); |
218 |
|
219 |
} |
220 |
}); |