Revision b3523ce4 snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/okeanos-ember.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/okeanos-ember.js | ||
---|---|---|
5 | 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 | 6 |
}); |
7 | 7 |
|
8 |
Okeanos.ApplicationAdapter = DS.FixtureAdapter.extend(); |
|
8 |
Okeanos.ApplicationAdapter = DS.FixtureAdapter.extend();;
|
|
9 | 9 |
|
10 |
/* Mapping */ |
|
10 |
Okeanos.Account = DS.Model.extend({ |
|
11 |
email: DS.attr('string') |
|
12 |
}); |
|
13 |
|
|
14 |
// CHECK can i use a single obj and not an array of obj |
|
15 |
Okeanos.Account.FIXTURES = [{ |
|
16 |
id: 001, |
|
17 |
email: "athina@mail.com" |
|
18 |
}]; |
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
Okeanos.Vm = DS.Model.extend({ |
|
23 |
// id: DS.attr('number'), we do not define it ;) |
|
24 |
name: DS.attr('string'), |
|
25 |
hostname: DS.attr('string'), |
|
26 |
status: DS.attr('string'), |
|
27 |
os: DS.attr() |
|
28 |
}); |
|
29 |
|
|
30 |
Okeanos.Vm.FIXTURES = |
|
31 |
[{ |
|
32 |
id: 125355, |
|
33 |
name: "web-server", |
|
34 |
hostname: "user@snf-38389.vm.okeanos.grnet.gr", |
|
35 |
status: "running", |
|
36 |
os: "kubuntu" |
|
37 |
}, |
|
38 |
{ |
|
39 |
id: 12, |
|
40 |
name: "another-server", |
|
41 |
hostname: "user@snf-33333.vm.okeanos.grnet.gr", |
|
42 |
status: "off", |
|
43 |
os: "fedora" |
|
44 |
}]; |
|
45 |
|
|
46 |
Okeanos.Net = DS.Model.extend({ |
|
47 |
name: DS.attr('string'), |
|
48 |
status: DS.attr('string'), |
|
49 |
vms: DS.attr(), |
|
50 |
ips: DS.attr() |
|
51 |
}); |
|
52 |
|
|
53 |
Okeanos.Net.FIXTURES = |
|
54 |
[{ |
|
55 |
|
|
56 |
}]; |
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
Okeanos.places = [{ |
|
62 |
destination: "vms", |
|
63 |
title: "Virtual Machines", |
|
64 |
icon: "snf-pc-outline" |
|
65 |
}, |
|
66 |
{ |
|
67 |
destination: "nets", |
|
68 |
title: "Network", |
|
69 |
icon: "snf-network-outline" |
|
70 |
|
|
71 |
}, |
|
72 |
{ |
|
73 |
destination: "volumes", |
|
74 |
title: "Volumes", |
|
75 |
icon: "snf-volume-outline" |
|
76 |
}, |
|
77 |
{ |
|
78 |
destination: "pithos", |
|
79 |
title: "Pithos", |
|
80 |
icon: "snf-pithos-outline" |
|
81 |
}, |
|
82 |
{ |
|
83 |
destination: "images", |
|
84 |
title: "Images", |
|
85 |
icon: "snf-image-outline" |
|
86 |
}, |
|
87 |
{ |
|
88 |
destination: "snapshots", |
|
89 |
title: "Snapshots", |
|
90 |
icon: "snf-snapshot-outline" |
|
91 |
}, |
|
92 |
{ |
|
93 |
destination: "ips", |
|
94 |
title: "IPs", |
|
95 |
icon: "snf-nic-outline" |
|
96 |
}, |
|
97 |
{ |
|
98 |
destination: "sshkeys", |
|
99 |
title: "SSh Keys", |
|
100 |
icon: "snf-key-outline" |
|
101 |
}]; |
|
102 |
|
|
103 |
|
|
104 |
Okeanos.AllActions = [{ |
|
105 |
description:'start', |
|
106 |
'snf-components':['vms'], |
|
107 |
'enabled-status': ['off'], |
|
108 |
action: 'is this a function?' |
|
109 |
}, |
|
110 |
{ |
|
111 |
description:'destroyElement', |
|
112 |
'snf-components': ['vms', 'nets'], |
|
113 |
'enabled-status': ['all'], |
|
114 |
action: 'is this a function?', |
|
115 |
}, |
|
116 |
{ |
|
117 |
description:'shutdown', |
|
118 |
'snf-components': ['vms'], |
|
119 |
'enabled-status': ['running'], |
|
120 |
action: 'is this a function?' |
|
121 |
}, |
|
122 |
{ |
|
123 |
description:'add machine', |
|
124 |
'snf-components': ['nets'], |
|
125 |
'enabled-status': ['active'], |
|
126 |
action: 'is this a function?' |
|
127 |
}, |
|
128 |
{ |
|
129 |
description:'action for all', |
|
130 |
'snf-components': ['vms', 'nets'], |
|
131 |
'enabled-status': ['all'], |
|
132 |
action: 'is this a function?' |
|
133 |
}];/* Mapping */ |
|
11 | 134 |
|
12 | 135 |
Okeanos.Router.map(function() { |
13 | 136 |
|
... | ... | |
80 | 203 |
icon: function() { |
81 | 204 |
return Okeanos.places.findBy('destination', this.get('type')).icon.replace('outline', 'full'); |
82 | 205 |
}.property(), |
83 |
iconCreate: function() { |
|
84 |
return this.icon.replace('full', 'create-full') |
|
85 |
}.property(), |
|
86 | 206 |
hasOS: function(){ |
87 | 207 |
if(Okeanos.get('currentPath') == "vms") |
88 | 208 |
return true; |
89 | 209 |
else return false; |
90 | 210 |
}.property(), |
211 |
hasTags: function(){ |
|
212 |
if(Okeanos.get('currentPath') == "vms") |
|
213 |
return true; |
|
214 |
else return false; |
|
215 |
}.property(), |
|
91 | 216 |
}); |
92 | 217 |
|
93 | 218 |
Okeanos.VmsController = Okeanos.ElemsController.extend({ |
... | ... | |
163 | 288 |
|
164 | 289 |
Okeanos.ElemView = Ember.View.extend({ |
165 | 290 |
// templateName: 'elem', |
291 |
addNewBtn: false, |
|
166 | 292 |
template: Ember.TEMPLATES['snfElem'], |
167 | 293 |
tagName: 'li', |
168 | 294 |
classNameBindings: ['status'], |
... | ... | |
173 | 299 |
status: function() { |
174 | 300 |
return this.get('controller.status'); |
175 | 301 |
}.property('controller.status') |
176 |
}) |
|
302 |
});
|
|
177 | 303 |
|
178 | 304 |
|
179 | 305 |
/* Components */ |
... | ... | |
185 | 311 |
} |
186 | 312 |
}); |
187 | 313 |
|
314 |
Okeanos.AddNewComponent = Ember.Component.extend({ |
|
315 |
template: Ember.TEMPLATES['snfElem'], |
|
316 |
addNewBtn: true, |
|
317 |
icon: function() { |
|
318 |
baseIcon = Okeanos.places.findBy('destination', this.get('type')).icon; |
|
319 |
return baseIcon.replace('outline', 'create-full'); |
|
320 |
}.property(), |
|
321 |
tagName: 'li', |
|
322 |
status: 'add-new', |
|
323 |
classNameBindings: ['status'], |
|
324 |
attributeBindings: ['data-status'], |
|
325 |
'data-status': function() { |
|
326 |
return this.status; |
|
327 |
}.property(), |
|
328 |
name: function() { |
|
329 |
var msg = 'Add New '; |
|
330 |
var btnType = this.get('type') |
|
331 |
if(btnType === 'vms') |
|
332 |
return msg + 'Machine'; |
|
333 |
else if(btnType === 'nets') |
|
334 |
return msg + 'Network'; |
|
335 |
}.property() |
|
336 |
|
|
337 |
}) |
|
188 | 338 |
|
189 | 339 |
Okeanos.LoginMenuComponent = Ember.Component.extend({ |
190 | 340 |
classNames: ['login'], |
... | ... | |
200 | 350 |
|
201 | 351 |
} |
202 | 352 |
}); |
203 |
|
|
204 |
; |
|
205 |
|
|
206 |
Okeanos.Account = DS.Model.extend({ |
|
207 |
email: DS.attr('string') |
|
208 |
}); |
|
209 |
|
|
210 |
// CHECK can i use a single obj and not an array of obj |
|
211 |
Okeanos.Account.FIXTURES = [{ |
|
212 |
id: 001, |
|
213 |
email: "athina@mail.com" |
|
214 |
}]; |
|
215 |
|
|
216 |
|
|
217 |
|
|
218 |
Okeanos.Vm = DS.Model.extend({ |
|
219 |
// id: DS.attr('number'), we do not define it ;) |
|
220 |
name: DS.attr('string'), |
|
221 |
hostname: DS.attr('string'), |
|
222 |
status: DS.attr('string'), |
|
223 |
os: DS.attr() |
|
224 |
}); |
|
225 |
|
|
226 |
Okeanos.Vm.FIXTURES = |
|
227 |
[{ |
|
228 |
id: 125355, |
|
229 |
name: "web-server", |
|
230 |
hostname: "user@snf-38389.vm.okeanos.grnet.gr", |
|
231 |
status: "running", |
|
232 |
os: "kubuntu" |
|
233 |
}, |
|
234 |
{ |
|
235 |
id: 12, |
|
236 |
name: "another-server", |
|
237 |
hostname: "user@snf-33333.vm.okeanos.grnet.gr", |
|
238 |
status: "off", |
|
239 |
os: "fedora" |
|
240 |
}]; |
|
241 |
|
|
242 |
Okeanos.Net = DS.Model.extend({ |
|
243 |
name: DS.attr('string'), |
|
244 |
status: DS.attr('string'), |
|
245 |
vms: DS.attr(), |
|
246 |
ips: DS.attr() |
|
247 |
}); |
|
248 |
|
|
249 |
Okeanos.Net.FIXTURES = |
|
250 |
[{ |
|
251 |
|
|
252 |
}]; |
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
Okeanos.places = [{ |
|
258 |
destination: "vms", |
|
259 |
title: "Virtual Machines", |
|
260 |
icon: "snf-pc-outline" |
|
261 |
}, |
|
262 |
{ |
|
263 |
destination: "nets", |
|
264 |
title: "Network", |
|
265 |
icon: "snf-network-outline" |
|
266 |
}, |
|
267 |
{ |
|
268 |
destination: "volumes", |
|
269 |
title: "Volumes", |
|
270 |
icon: "snf-volume-outline" |
|
271 |
}, |
|
272 |
{ |
|
273 |
destination: "pithos", |
|
274 |
title: "Pithos", |
|
275 |
icon: "snf-pithos-outline" |
|
276 |
}, |
|
277 |
{ |
|
278 |
destination: "images", |
|
279 |
title: "Images", |
|
280 |
icon: "snf-image-outline" |
|
281 |
}, |
|
282 |
{ |
|
283 |
destination: "snapshots", |
|
284 |
title: "Snapshots", |
|
285 |
icon: "snf-snapshot-outline" |
|
286 |
}, |
|
287 |
{ |
|
288 |
destination: "ips", |
|
289 |
title: "IPs", |
|
290 |
icon: "snf-nic-outline" |
|
291 |
}, |
|
292 |
{ |
|
293 |
destination: "sshkeys", |
|
294 |
title: "SSh Keys", |
|
295 |
icon: "snf-key-outline" |
|
296 |
}]; |
|
297 |
|
|
298 |
|
|
299 |
Okeanos.AllActions = [{ |
|
300 |
description:'start', |
|
301 |
'snf-components':['vms'], |
|
302 |
'enabled-status': ['off'], |
|
303 |
action: 'is this a function?' |
|
304 |
}, |
|
305 |
{ |
|
306 |
description:'destroyElement', |
|
307 |
'snf-components': ['vms', 'nets'], |
|
308 |
'enabled-status': ['all'], |
|
309 |
action: 'is this a function?', |
|
310 |
}, |
|
311 |
{ |
|
312 |
description:'shutdown', |
|
313 |
'snf-components': ['vms'], |
|
314 |
'enabled-status': ['running'], |
|
315 |
action: 'is this a function?' |
|
316 |
}, |
|
317 |
{ |
|
318 |
description:'add machine', |
|
319 |
'snf-components': ['nets'], |
|
320 |
'enabled-status': ['active'], |
|
321 |
action: 'is this a function?' |
|
322 |
}, |
|
323 |
{ |
|
324 |
description:'action for all', |
|
325 |
'snf-components': ['vms', 'nets'], |
|
326 |
'enabled-status': ['all'], |
|
327 |
action: 'is this a function?' |
|
328 |
}] |
Also available in: Unified diff