Revision 47eca5c5 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
4 4

  
5 5
var statesActionsVm = {
6 6
    'off'      : {
7
    	enabledActions : ['start', 'destroy'],
7
        enabledActions : ['start', 'destroy'],
8 8
    },
9 9
    'error'      : {
10
    	enabledActions : ['destroy'],
10
        enabledActions : ['destroy'],
11 11
    },
12 12
    'building'      : {
13
    	enabledActions : [],
13
        enabledActions : [],
14 14
    },
15 15
    'running'      : {
16
    	enabledActions : ['reboot', 'shutdown', 'destroy'],
16
        enabledActions : ['reboot', 'shutdown', 'destroy'],
17 17
    },
18 18
    'rebooting'      : {
19
    	enabledActions : ['destroy'],
19
        enabledActions : ['destroy'],
20 20
    },
21 21
    'starting'      : {
22
    	enabledActions : ['destroy'],
22
        enabledActions : ['destroy'],
23 23
    },
24 24
    'shutting'      : {
25
    	enabledActions : ['destroy'],
25
        enabledActions : ['destroy'],
26 26
    },
27 27
};
28 28

  
29 29

  
30

  
31 30
// the model for a Vm
32 31
App.Vm = DS.Model.extend({
33 32
    name     : DS.attr(),
34 33
    state    : DS.attr(),
35
    os     	 : DS.attr(),
34
    os       : DS.attr(),
36 35
    link     : DS.attr(),
36
    flavor   : DS.attr('raw'),
37 37
    networks : DS.hasMany('network', { async:true }),
38 38

  
39 39
    enabledActions: function() {
40
	    return statesActionsVm[this.get('state')].enabledActions;
41
	}.property('state'),
40
        return statesActionsVm[this.get('state')].enabledActions;
41
    }.property('state'),
42 42
});
43 43

  
44 44

  
45 45
App.Vm.FIXTURES = [
46
	{
47
	    id: 1,
48
	    name: 'My cool VM 1',
49
	    state: 'off',
50
	    os: 'kubuntu',
51
	    link: 'http://www.in.gr',
52
	    networks:[1,2],
53
	},
54
	{
55
	    id: 2,
56
	    name: 'My even cooler VM 2 that has a long name',
57
	    state: 'error',
58
	    os: 'unknown',
59
  	    link: 'http://www.in.gr',
60
	    networks:[3],
61
	},
62
	{
63
	    id: 3,
64
	    name: 'My cool VM 3',
65
	    state: 'building',
66
	    os: 'windows',
67
	    link: 'http://www.in.gr',
68
	},
69
	{
70
	    id: 4,
71
	    name: 'So awesome VM 4',
72
	    state: 'running',
73
	    os: 'fedora',
74
	    link: 'www.france24.fr',
75
	},
76
	{
77
	    id: 5,
78
	    name: 'olga',
79
	    state: 'rebooting',
80
	    os: 'kubuntu',
81
	    link: 'http://www.in.gr',
82
	},
83
	{
84
	    id: 6,
85
	    name: 'athina',
86
	    state: 'starting',
87
	    os: 'kubuntu',
88
	    link: 'http://www.in.gr',
89
	},
90
	{
91
	    id: 7,
92
	    name: 'kpap',
93
	    state: 'shutting',
94
	    os: 'kubuntu',
95
	    link: 'http://www.in.gr',
96
	},
97
]
46
    {
47
        id: 1,
48
        name: 'My cool VM 1',
49
        state: 'off',
50
        os: 'kubuntu',
51
        link: 'http://www.in.gr',
52
        networks:[1,2],
53
        flavor: {
54
            ram: 1,
55
            cpu: 2,
56
        },
57
    },
58
    {
59
        id: 2,
60
        name: 'My even cooler VM 2 that has a long name',
61
        state: 'error',
62
        os: 'unknown',
63
        link: 'http://www.in.gr',
64
        networks:[3],
65
    },
66
    {
67
        id: 3,
68
        name: 'My cool VM 3',
69
        state: 'building',
70
        os: 'windows',
71
        link: 'http://www.in.gr',
72
    },
73
    {
74
        id: 4,
75
        name: 'So awesome VM 4',
76
        state: 'running',
77
        os: 'fedora',
78
        link: 'www.france24.fr',
79
    },
80
    {
81
        id: 5,
82
        name: 'olga',
83
        state: 'rebooting',
84
        os: 'kubuntu',
85
        link: 'http://www.in.gr',
86
    },
87
    {
88
        id: 6,
89
        name: 'athina',
90
        state: 'starting',
91
        os: 'kubuntu',
92
        link: 'http://www.in.gr',
93
    },
94
    {
95
        id: 7,
96
        name: 'kpap',
97
        state: 'shutting',
98
        os: 'kubuntu',
99
        link: 'http://www.in.gr',
100
    },
101
];

Also available in: Unified diff