Revision be5195f3

b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/components/reveal-modal.js
1 1
App.RevealModalComponent = Ember.Component.extend({
2
    classNames: ['inner-modal'],
2 3
    actions: {
3 4
        ok: function () {
4 5
            this.sendAction("ok", this.get('param'));
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/controllers/item.js
14 14

  
15 15
    hasTags: true,
16 16

  
17
    hasConnect: false,
18

  
17 19
    codeNameParent: function() {
18 20
        return this.codeName+'s';
19 21
    }.property(),
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/controllers/network.js
17 17
            'icon': 'snf-pc-outline',
18 18
        },
19 19
    ],
20

  
20
    actions: {
21
        destroyNetwork: function(){
22
            this.get('model').deleteRecord();
23
            this.get('model').save();
24
            this.transitionToRoute('networks.grid-view');
25
        },
26
    }
21 27
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/controllers/vm.js
1 1
App.VmController =App.ItemsItemController.extend({
2 2
    icon: 'snf-pc-full',
3 3

  
4
    hasConnect: true,
5

  
4 6
    actionsMeta: function() {
5 7
        var enabledActions = this.get('model').get('enabledActions');
6 8
        return _.map(enabledActions, function(val,key) { return actionsMetaVm[val]; });      
......
31 33
            volume.get('vm').get('volumes').removeObject(volume);
32 34
        },
33 35

  
34
        modalConnect: function(){
35
            var component = Ember.View.views["modal-connect"];
36
            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
37
            component.set('okCallback', _.bind(function() {
38
                alert("restarting " + this.get('model').get('name'));
39
            }, this));
40
            $("#modal-connect").foundation('reveal', 'open');
41
        },
42

  
43
        modalStart: function(){
44
            $("#modal-start").foundation('reveal', 'open');
36
        rebootVm: function(){
37
            this.get('model').set('status','rebooting');
38
            var that = this;
39
            setTimeout(function(){
40
                that.get('model').set('status','running'); 
41
            },3000);
45 42
        },
46 43

  
47
        modalShutdown: function(){
48
            $("#modal-shutdown").foundation('reveal', 'open');
44
        destroyVm: function(){
45
            this.get('model').deleteRecord();
46
            this.get('model').save();
47
            this.transitionToRoute('vms.grid-view');
49 48
        },
50 49

  
51
        modalReboot: function(){
52
            $("#modal-reboot").foundation('reveal', 'open');
53
            var component = Ember.View.views["modal-reboot"];
54
            component.set('message', '<p>Are you sure you want to reboot you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>');
55
            component.set('okCallback', _.bind(function() {
56
                this.get('model').set('state','rebooting');
57
                $("#modal-reboot").foundation('reveal','close');
58
            }, this));
50
        shutdownVm: function(){
51
            this.get('model').set('status','shutting');
52
            var that = this;
53
            setTimeout(function(){
54
                that.get('model').set('status','off'); 
55
            },3000);
59 56
        },
60 57

  
61
        modalDestroy: function(){
62
            $("#modal-destroy").foundation('reveal', 'open');
63
            var component = Ember.View.views["modal-destroy"];
64
            component.set('message', '<p>Are you sure you want to delete you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>');
65
            component.set('okCallback', _.bind(function() {
66
                this.get('model').deleteRecord();
67
                this.get('model').save();
68
                $("#modal-destroy").foundation('reveal','close');
69
            }, this));
58
        startVm: function(){
59
            this.get('model').set('status','running');
70 60
        },
71

  
72 61
    },
73 62
});
74 63

  
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/controllers/volume.js
21 21
        dettachVolume: function(volume){
22 22
            volume.get('vm').get('volumes').removeObject(volume);
23 23
        },
24
        destroyVolume: function(){
25
            this.get('model').deleteRecord();
26
            this.get('model').save();
27
            this.transitionToRoute('volumes/grid-view');
28
        },
24 29
    }
25 30
});
26 31

  
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/metadata.js
1 1
var actionsMetaNetwork = {
2
    'start': {
3
        title: 'start',
4
        act: 'modalStart',
5
        spanCls: 'snf-switch',
6
    },
7 2
    'destroy': {
8 3
        title: 'destroy',
9
        act: 'modalDestroy',
10
        spanCls: 'snf-trash-outline',
11
    },
12
    'reboot': {
13
        title: 'reboot',
14
        act: 'modalReboot',
15
        spanCls: 'snf-refresh-outline',
16
    },
17
    'shutdown': {
18
        title: 'shutdown',
19
        act: 'modalShutdown',
20
        spanCls: 'snf-pc-broken-full',
4
        act: 'destroy-network-modal',
5
        spanCls: 'snf-switch',
6
        controller: 'network'
21 7
    },
8

  
22 9
};
23 10

  
24 11
var actionsMetaVm = {
25 12
    'start': {
26 13
        title: 'start me now',
27
        act: 'modalStart',
14
        act: 'start-vm-modal',
28 15
        spanCls: 'snf-switch',
16
        controller: 'vm',
29 17
    },
30 18
    'destroy': {
31 19
        title: 'destroy',
32
        act: 'modalDestroy',
20
        act: 'destroy-vm-modal',
33 21
        spanCls: 'snf-trash-outline',
22
        controller: 'vm',
34 23
    },
35 24
    'reboot': {
36 25
        title: 'reboot',
37
        act: 'modalReboot',
26
        act: 'reboot-vm-modal',
38 27
        spanCls: 'snf-refresh-outline',
28
        controller: 'vm',
39 29
    },
40 30
    'shutdown': {
41 31
        title: 'shutdown',
42
        act: 'modalShutdown',
32
        act: 'shutdown-vm-modal',
43 33
        spanCls: 'snf-pc-broken-full',
34
        controller: 'vm',
44 35
    },
45 36
};
46 37

  
47 38
var actionsMetaVolume = {
48
    'start': {
49
        title: 'start me now',
50
        act: 'modalStart',
51
        spanCls: 'snf-switch',
52
    },
53 39
    'destroy': {
54 40
        title: 'destroy',
55
        act: 'modalDestroy',
56
        spanCls: 'snf-trash-outline',
57
    },
58
    'reboot': {
59
        title: 'reboot',
60
        act: 'modalReboot',
61
        spanCls: 'snf-refresh-outline',
62
    },
63
    'shutdown': {
64
        title: 'shutdown',
65
        act: 'modalShutdown',
66
        spanCls: 'snf-pc-broken-full',
41
        act: 'destroy-volume-modal',
42
        spanCls: 'snf-switch',
43
        controller: 'volume'
67 44
    },
68 45
};
69 46

  
......
106 83

  
107 84
var statusActionsNetwork = {
108 85
    'off'      : {
109
        enabledActions : ['start', 'destroy'],
86
        enabledActions : ['destroy'],
110 87
    },
111 88
    'error'      : {
112 89
        enabledActions : ['destroy'],
......
115 92
        enabledActions : [],
116 93
    },
117 94
    'running'      : {
118
        enabledActions : ['reboot', 'shutdown', 'destroy'],
119
    },
120
    'rebooting'      : {
121 95
        enabledActions : ['destroy'],
122 96
    },
123 97
    'starting'      : {
......
131 105

  
132 106
var statusActionsVolume = {
133 107
    'off'      : {
134
        enabledActions : ['start', 'destroy'],
108
        enabledActions : ['destroy'],
135 109
    },
136 110
    'error'      : {
137 111
        enabledActions : ['destroy'],
......
140 114
        enabledActions : [],
141 115
    },
142 116
    'running'      : {
143
        enabledActions : ['reboot', 'shutdown', 'destroy'],
144
    },
145
    'rebooting'      : {
146 117
        enabledActions : ['destroy'],
147 118
    },
148 119
    'starting'      : {
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/models/vm.js
60 60
    {
61 61
        id: 4,
62 62
        name: 'So awesome VM 4',
63
        status: 'running',
63
        status: 'off',
64 64
        os: 'fedora',
65 65
        link: 'www.france24.fr',
66 66
        tags: [8],
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/routes/application.js
3 3
        openModal: function(modalName, controller, model) {
4 4

  
5 5
            this.controllerFor(controller).set("model", model);
6
            this.render(modalName, {
6
            this.render('modals/'+modalName, {
7 7
                into: 'application',
8 8
                outlet: 'modal',
9 9
                controller: controller,
/dev/null
1
<section class="overlay-area-reveal">
2
{{outlet modal}}
3
{{!-- 	{{reveal-modal id="modal-connect"}}
4
	{{reveal-modal id="modal-start" hasButtons="true"}}
5
	{{reveal-modal id="modal-reboot" hasButtons="true"}}
6
	{{reveal-modal id="modal-shutdown" hasButtons="true"}}
7
	{{reveal-modal id="modal-destroy" hasButtons="true"}}
8
 --}}
9
    
10

  
11
</section>
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/destroy-vm-modal.hbs
1
{{#reveal-modal id="destroy-vm-modal" hasButtons="true" ok="destroyVm" class="modal-reboot"}}
2
    <p>Are you sure you want to destroy the VM <strong>{{model.name}}</strong>?</p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/details.hbs
18 18
                    <ul>
19 19
                        {{#each item in actionsMeta}}
20 20
                            <li>
21
                                <a href="#" {{action "item.act"}} {{bind-attr title="item.title"}}>{{item.title}}</span></a>
21
                                <a href="#" {{action 'openModal' item.act item.controller model}}>{{item.title}}</span></a>
22 22
                            </li>
23 23
                        {{/each}}
24 24
                    </ul>
/dev/null
1
{{#reveal-modal id="dettach-volume-modal" hasButtons="true" ok="dettachVolume" param=model}}
2
    <p>Are you sure you want to dettach this Volume? </p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/item.hbs
14 14
		<div class= "status">
15 15
			<span class="state">{{status-to-text this.status}}</span>
16 16
		</div>
17
{{!-- {{codeNameParent}} kai edw vlepei ton controller--}}
18 17
		{{view App.tagsListView}}
19 18

  
20 19
	</div>
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/connect-vm-modal.hbs
1
{{#reveal-modal id="connect-vm-modal"}}
2
    You can connect to your {{model.name}} VM using this stuff:
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/destroy-network-modal.hbs
1
{{#reveal-modal id="destroy-network-modal" hasButtons="true" ok="destroyNetwork"}}
2
    <p>Are you sure you want to destroy the network {{model.name}}? </p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/destroy-vm-modal.hbs
1
{{#reveal-modal id="destroy-vm-modal" hasButtons="true" ok="destroyVm" class="modal-reboot"}}
2
    <p>Are you sure you want to destroy the VM <strong>{{model.name}}</strong>?</p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/destroy-volume-modal.hbs
1
{{#reveal-modal id="destroy-volume-modal" hasButtons="true" ok="destroyVolume"}}
2
    <p>Are you sure you want to destroy the volume {{model.name}}? </p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/dettach-volume-modal.hbs
1
{{#reveal-modal id="dettach-volume-modal" hasButtons="true" ok="dettachVolume" param=model}}
2
    <p>Are you sure you want to dettach this Volume? </p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/reboot-vm-modal.hbs
1
{{#reveal-modal id="reboot-vm-modal" hasButtons="true" ok="rebootVm" class="modal-reboot"}}
2
    <p>Are you sure you want to reboot the VM <strong>{{model.name}}</strong>?</p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/shutdown-vm-modal.hbs
1
{{#reveal-modal id="shutdown-vm-modal" hasButtons="true" ok="shutdownVm" param=model}}
2
    <p>Are you sure you want to shutdown <strong>{{model.name}}</strong>? </p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/modals/start-vm-modal.hbs
1
{{#reveal-modal id="start-vm-modal" hasButtons="true" ok="startVm" class="modal-start"}}
2
    <p>Are you sure you want to start the VM <strong>{{model.name}}</strong>?</p>
3
{{/reveal-modal}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/app/templates/side-actions.hbs
1
<li>{{#link-to codeName this}}i{{/link-to}}</li>
2
{{#if hasConnect}}
1 3
<li>
2
	{{#link-to codeName this}}i{{/link-to}}
4
	<a {{action 'openModal' 'connect-vm-modal' 'vm' model}} title="connect"><span class="snf-thunder-full"></span></a>
3 5
</li>
4
<li>
5
	<a href="#" {{action "modalConnect"}} title="connect"><span class="snf-thunder-full"></span></a>
6
</li>
7
<!--https://github.com/emberjs/ember.js/pull/3936-->
6
{{/if}}
7

  
8 8
{{#each item in actionsMeta}}
9 9
<li>
10
	<a href="#" {{action item.act}} {{bind-attr title="item.title"}}><span {{bind-attr class="item.spanCls"}}></span></a>
10
	<a {{action 'openModal' item.act item.controller model}} {{bind-attr class="item.title"}}><span {{bind-attr class="item.spanCls"}}></span></a>
11 11
</li>
12 12
{{/each}}

Also available in: Unified diff