root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / okeanos-ember / ember-all.js @ 1b6dd4b5
History | View | Annotate | Download (7.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 |
selectable: true, |
163 |
initSelect: 'unchecked', |
164 |
classNameBindings: ['status'], |
165 |
attributeBindings: ['data-status'], |
166 |
'data-status': function() { |
167 |
return this.status; |
168 |
}.property(), |
169 |
status: function() { |
170 |
return this.get('controller.status'); |
171 |
}.property('controller.status')
|
172 |
}); |
173 |
|
174 |
|
175 |
// to evala ws view gt thelw na kanw diaxeirisi tou interaction tou xristi
|
176 |
Okeanos.ElementSidebarView = Ember.View.extend({ |
177 |
tagName: 'ul', |
178 |
classNames: ['side-actions'], |
179 |
template: Ember.TEMPLATES['elementSidebar'] |
180 |
}); |
181 |
|
182 |
/* Components */
|
183 |
|
184 |
Okeanos.Btn1Component = Ember.Component.extend({ |
185 |
tagName: 'a', |
186 |
click: function() { |
187 |
this.sendAction("action", this.get('param')); |
188 |
} |
189 |
}); |
190 |
|
191 |
Okeanos.AddNewComponent = Ember.Component.extend({ |
192 |
template: Ember.TEMPLATES['snfElem'], |
193 |
addNewBtn: true, |
194 |
selectable: false, |
195 |
icon: function() { |
196 |
baseIcon = Okeanos.places.findBy('destination', this.get('type')).icon; |
197 |
return baseIcon.replace('outline', 'create-full'); |
198 |
}.property(), |
199 |
tagName: 'li', |
200 |
status: 'add-new', |
201 |
classNameBindings: ['status'], |
202 |
attributeBindings: ['data-status'], |
203 |
'data-status': function() { |
204 |
return this.status; |
205 |
}.property(), |
206 |
name: function() { |
207 |
var msg = 'Add New '; |
208 |
var btnType = this.get('type') |
209 |
if(btnType === 'vms') |
210 |
return msg + 'Machine'; |
211 |
else if(btnType === 'nets') |
212 |
return msg + 'Network'; |
213 |
}.property() |
214 |
|
215 |
}); |
216 |
|
217 |
Okeanos.LoginMenuComponent = Ember.Component.extend({ |
218 |
classNames: ['login'], |
219 |
didInsertElement: function() { |
220 |
console.log('didInsertElement');
|
221 |
var self = this.$(); |
222 |
self.mouseenter(function(e){
|
223 |
self.find('ul').stop(true, true).slideDown(200); |
224 |
}); |
225 |
self.mouseleave(function(e){
|
226 |
self.find('ul').stop(true, true).slideUp(200); |
227 |
}); |
228 |
|
229 |
} |
230 |
}); |
231 |
|
232 |
Okeanos.SnfCheckboxComponent = Ember.Component.extend({ |
233 |
tagName: 'a', |
234 |
classNames: ['check'], |
235 |
initState: function() { |
236 |
return this.get('initState'); |
237 |
}.property(), |
238 |
template: Ember.TEMPLATES['snf-checkbox'], |
239 |
didInsertElement: function() { |
240 |
var domRef = this.$(); |
241 |
var self =this; |
242 |
this.setInitClasses();
|
243 |
domRef.click(function(e) {
|
244 |
e.preventDefault(); |
245 |
e.stopPropagation(); |
246 |
self.changeState(domRef); |
247 |
// ui.entitiesActionsEnabled();
|
248 |
console.log(self.get('elementID'))
|
249 |
}); |
250 |
}, |
251 |
setInitClasses: function() { |
252 |
var self =this.$(); |
253 |
switch(this.initState){ |
254 |
case 'unchecked': { |
255 |
this.uncheck(self);
|
256 |
break;
|
257 |
} |
258 |
case 'prechecked': { |
259 |
self.find('span').addClass('prechecked') |
260 |
this.check(self);
|
261 |
break;
|
262 |
} |
263 |
} |
264 |
}, |
265 |
// used to be in ui.checkbox
|
266 |
changeState : function(checkbox_link) { |
267 |
$(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked'); |
268 |
$(checkbox_link).closest('li').toggleClass('selected'); |
269 |
}, |
270 |
check : function(checkbox_link) { |
271 |
$(checkbox_link).find('span').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
272 |
$(checkbox_link).closest('li').addClass('selected'); |
273 |
}, |
274 |
uncheck : function(checkbox_link) { |
275 |
$(checkbox_link).find('span').removeClass('snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
276 |
$(checkbox_link).closest('li').removeClass('selected'); |
277 |
}, |
278 |
|
279 |
reset: function(area) { |
280 |
$(area).find('.snf-radio-checked').not('.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
281 |
$(area).find('.snf-radio-unchecked.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
282 |
}, |
283 |
}); |