Revision 69c64a4c snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/models/vm.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/models/vm.js | ||
---|---|---|
1 |
/*TODO: |
|
2 |
Add tags to Vm model*/ |
|
3 |
|
|
4 |
|
|
5 |
var statussActionsVm = { |
|
6 |
'off' : { |
|
7 |
enabledActions : ['start', 'destroy'], |
|
8 |
}, |
|
9 |
'error' : { |
|
10 |
enabledActions : ['destroy'], |
|
11 |
}, |
|
12 |
'building' : { |
|
13 |
enabledActions : [], |
|
14 |
}, |
|
15 |
'running' : { |
|
16 |
enabledActions : ['reboot', 'shutdown', 'destroy'], |
|
17 |
}, |
|
18 |
'rebooting' : { |
|
19 |
enabledActions : ['destroy'], |
|
20 |
}, |
|
21 |
'starting' : { |
|
22 |
enabledActions : ['destroy'], |
|
23 |
}, |
|
24 |
'shutting' : { |
|
25 |
enabledActions : ['destroy'], |
|
26 |
}, |
|
27 |
}; |
|
28 |
|
|
29 |
|
|
30 |
// the model for a Vm |
|
31 | 1 |
App.Vm = DS.Model.extend({ |
2 |
|
|
32 | 3 |
name : DS.attr(), |
33 | 4 |
status : DS.attr(), |
34 | 5 |
os : DS.attr(), |
35 | 6 |
link : DS.attr(), |
36 | 7 |
created : DS.attr('date'), |
37 | 8 |
updated : DS.attr('date'), |
38 |
/*flavor : DS.attr('raw'),*/ |
|
39 |
networks : DS.hasMany('network', { async:true }), |
|
9 |
network : DS.belongsTo('network', { async:true }), |
|
40 | 10 |
tags : DS.hasMany('tag', { async:true }), |
11 |
volumes : DS.hasMany('volume', { async:true}), |
|
12 |
|
|
13 |
/*flavor : DS.attr('raw'),*/ |
|
41 | 14 |
|
42 | 15 |
enabledActions: function() { |
43 |
return statussActionsVm[this.get('status')].enabledActions;
|
|
16 |
return statusActionsVm[this.get('status')].enabledActions; |
|
44 | 17 |
}.property('status'), |
18 |
|
|
45 | 19 |
}); |
46 | 20 |
|
47 | 21 |
|
48 | 22 |
App.Vm.FIXTURES = [ |
49 | 23 |
{ |
50 |
|
|
51 | 24 |
created: '2011-04-19T10:18:52.085737+00:00', |
52 |
id: 42,
|
|
25 |
id: 1,
|
|
53 | 26 |
metadata: { foo: "bar"}, |
54 |
name: "My Server",
|
|
27 |
name: "The answer to everything",
|
|
55 | 28 |
os: 'windows', |
56 | 29 |
status: "running", |
57 | 30 |
link: 'http://www.in.gr', |
58 | 31 |
updated: "2011-05-29T14:07:07.037602+00:00", |
59 |
networks: [1,2],
|
|
32 |
network: 1,
|
|
60 | 33 |
tags: [1,2,3], |
34 |
volumes: [1,2], |
|
61 | 35 |
}, |
62 | 36 |
{ |
63 | 37 |
id: 2, |
... | ... | |
65 | 39 |
status: 'error', |
66 | 40 |
os: 'unknown', |
67 | 41 |
link: 'http://www.in.gr', |
68 |
networks:[3], |
|
42 |
updated: "2011-05-29T14:07:07.037602+00:00", |
|
43 |
networks: 1, |
|
69 | 44 |
tags: [1,2,3,4], |
45 |
volumes: [3], |
|
70 | 46 |
}, |
71 | 47 |
{ |
72 | 48 |
id: 3, |
... | ... | |
74 | 50 |
status: 'building', |
75 | 51 |
os: 'windows', |
76 | 52 |
link: 'http://www.in.gr', |
53 |
network: 2, |
|
77 | 54 |
tags: [1], |
78 | 55 |
}, |
79 | 56 |
{ |
Also available in: Unified diff