Revision 47eca5c5

b/snf-cyclades-app/synnefo/ui/new_ui/ui/Gruntfile.js
30 30
      emberTemplates: {
31 31
        files: 'javascripts/templates/**/*.hbs',
32 32
        tasks: ['emberTemplates']
33
      },
34
      jshint: {
35
        files: ['javascripts/ember/**/*.js'],
36
        tasks: ['jshint'],
33 37
      }
34 38
    },
35 39
    compass: {
......
54 58
        dest: 'dist/ember.js',
55 59
      }
56 60
    },
61
    jshint: {
62
      beforeconcat: ['javascripts/ember/**/*.js'],
63
    },
57 64
  });
58 65

  
59 66
  grunt.loadNpmTasks('grunt-contrib-compass');
60 67
  grunt.loadNpmTasks('grunt-contrib-watch');
61 68
  grunt.loadNpmTasks('grunt-contrib-concat');
62 69
  grunt.loadNpmTasks('grunt-ember-templates');
70
  grunt.loadNpmTasks('grunt-contrib-jshint');
63 71

  
64 72
  // Default task(s).
65
  grunt.registerTask('default', ['concat',  'emberTemplates','watch']);
73
  grunt.registerTask('default', ['jshint','concat',  'emberTemplates','watch']);
66 74

  
67 75
};
b/snf-cyclades-app/synnefo/ui/new_ui/ui/index.html
1 1
<!DOCTYPE html>
2 2
    <!--[if lte IE 7]><script src="javascripts/lte-ie7.js"></script><![endif]-->
3
<!--[if IE 8]> 				 <html class="no-js lt-ie9" lang="en"> <![endif]-->
3
<!--[if IE 8]>               <html class="no-js lt-ie9" lang="en"> <![endif]-->
4 4
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
5 5

  
6 6
<head>
7
	<meta charset="utf-8" />
7
    <meta charset="utf-8" />
8 8
    <meta name="viewport" content="width=device-width" />
9 9
    <title>Ember UI</title>
10 10
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&amp;subset=latin,greek-ext,greek' rel='stylesheet' type='text/css'>
......
15 15
    <link rel="stylesheet" href="stylesheets/jquery.jscrollpane.css" media="all" />
16 16
    <link rel="stylesheet" href="stylesheets/magnific-popup.css" />
17 17
</head>
18
<body>	
18
<body>  
19 19

  
20
	<script src="dist/vendor.js"></script>
20
    <script src="dist/vendor.js"></script>
21 21

  
22
	<script src="javascripts/foundation/foundation.js"></script>
23
	<script src="javascripts/foundation/foundation.alerts.js"></script>
24
	<script src="javascripts/foundation/foundation.clearing.js"></script>
25
	<script src="javascripts/foundation/foundation.cookie.js"></script>
26
	<script src="javascripts/foundation/foundation.dropdown.js"></script>
27
	<script src="javascripts/foundation/foundation.forms.js"></script>
28
	<script src="javascripts/foundation/foundation.joyride.js"></script>
29
	<script src="javascripts/foundation/foundation.magellan.js"></script>
30
	<script src="javascripts/foundation/foundation.orbit.js"></script>
31
	<script src="javascripts/foundation/foundation.placeholder.js"></script>
32
	<script src="javascripts/foundation/foundation.reveal.js"></script>
33
	<script src="javascripts/foundation/foundation.section.js"></script>
34
	<script src="javascripts/foundation/foundation.tooltips.js"></script>
35
	<script src="javascripts/foundation/foundation.topbar.js"></script>
36
	<script type="text/javascript" src="javascripts/jquery.easing.1.3.js"></script>
37
	<script src="javascripts/common.js"></script>
38
	<script src="javascripts/app.js"></script>
39
	<script src="dist/ember.js"></script>
40
	<script src="javascripts/templates.js"></script>
41
	<script src="javascripts/router.js"></script>
42
		
22
    <script src="javascripts/foundation/foundation.js"></script>
23
    <script src="javascripts/foundation/foundation.alerts.js"></script>
24
    <script src="javascripts/foundation/foundation.clearing.js"></script>
25
    <script src="javascripts/foundation/foundation.cookie.js"></script>
26
    <script src="javascripts/foundation/foundation.dropdown.js"></script>
27
    <script src="javascripts/foundation/foundation.forms.js"></script>
28
    <script src="javascripts/foundation/foundation.joyride.js"></script>
29
    <script src="javascripts/foundation/foundation.magellan.js"></script>
30
    <script src="javascripts/foundation/foundation.orbit.js"></script>
31
    <script src="javascripts/foundation/foundation.placeholder.js"></script>
32
    <script src="javascripts/foundation/foundation.reveal.js"></script>
33
    <script src="javascripts/foundation/foundation.section.js"></script>
34
    <script src="javascripts/foundation/foundation.tooltips.js"></script>
35
    <script src="javascripts/foundation/foundation.topbar.js"></script>
36
    <script type="text/javascript" src="javascripts/jquery.easing.1.3.js"></script>
37
    <script src="javascripts/common.js"></script>
38
    <script src="javascripts/app.js"></script>
39
    <script src="dist/ember.js"></script>
40
    <script src="javascripts/templates.js"></script>
41
    <script src="javascripts/router.js"></script>
42
        
43 43
  <script>
44 44
    $(document).foundation();
45 45
  </script>
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/app.js
7 7
});
8 8

  
9 9
App.ApplicationAdapter = DS.FixtureAdapter;
10

  
11
App.RawTransform = DS.Transform.extend({
12
  deserialize: function(serialized) {
13
    return serialized;
14
  },
15
  serialize: function(deserialized) {
16
    return deserialized;
17
  }
18
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/components/reveal-modal.js
1 1
App.RevealModalComponent = Ember.Component.extend({
2 2
    classNames: ['reveal-modal', 'medium'],
3 3
    actions: {
4
    	ok: function () {
5
    		this.get("okCallback")();
6
    	},
7
    	close: function () {
8
    		//Kpap ??
9
    		$(this.$()[0]).foundation('reveal', 'close');		
10
    	},
4
        ok: function () {
5
            this.get("okCallback")();
6
        },
7
        close: function () {
8
            $(this.$()[0]).foundation('reveal', 'close');		
9
        },
11 10
    },
12 11
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/network.js
30 30
    
31 31
    actionsMeta: function() {
32 32
        var enabledActions = this.get('model').get('enabledActions');
33
        return _.map(enabledActions, function(val,key) {return actionsMetaNetwork[val]});      
33
        return _.map(enabledActions, function(val,key) { return actionsMetaNetwork[val]; });      
34 34
    }.property('model.enabledActions'),
35 35

  
36 36
    actions: {
......
39 39
            var component = Ember.View.views["modal-connect"];
40 40
            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
41 41
            component.set('okCallback', _.bind(function() {
42

  
43
                alert("restarting " + this.get('model').get('name'))
42
                alert("restarting " + this.get('model').get('name'));
44 43
            }, this));
45 44
            $("#modal-connect").foundation('reveal', 'open');
46 45
        },
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js
30 30
    
31 31
    actionsMeta: function() {
32 32
        var enabledActions = this.get('model').get('enabledActions');
33
        return _.map(enabledActions, function(val,key) {return actionsMetaVm[val]});      
33
        return _.map(enabledActions, function(val,key) {return actionsMetaVm[val]; });      
34 34
    }.property('model.enabledActions'),
35 35

  
36 36
    actions: {
......
40 40
            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
41 41
            component.set('okCallback', _.bind(function() {
42 42

  
43
                alert("restarting " + this.get('model').get('name'))
43
                alert("restarting " + this.get('model').get('name'));
44 44
            }, this));
45 45
            $("#modal-connect").foundation('reveal', 'open');
46 46
        },
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/helpers/helpers.js
25 25
  }
26 26
  // call ember render helper
27 27
  return Ember.Handlebars.helpers.render.call(this, name, contextString, options);
28
});
28
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/models/network.js
4 4

  
5 5
var statesActionsNetwork = {
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

  
......
35 35
    vm     : DS.belongsTo('vm', { async:true }),
36 36

  
37 37
    enabledActions: function() {
38
	    return statesActionsNetwork[this.get('state')].enabledActions;
39
	}.property('state'),
38
        return statesActionsNetwork[this.get('state')].enabledActions;
39
    }.property('state'),
40 40
});
41 41

  
42 42

  
43 43
App.Network.FIXTURES = [
44
	{
45
	    id: 1,
46
	    name: 'Network 1',
47
	    state: 'running',
44
    {
45
        id: 1,
46
        name: 'Network 1',
47
        state: 'running',
48 48
        vm: '1',
49
	},
50
	{
51
	    id: 2,
52
	    name: 'Network 2',
53
	    state: 'building',
49
    },
50
    {
51
        id: 2,
52
        name: 'Network 2',
53
        state: 'building',
54 54
        vm: '1',
55
	},
56
	{
57
	    id: 3,
58
	    name: 'Network 3',
59
	    state: 'off',
55
    },
56
    {
57
        id: 3,
58
        name: 'Network 3',
59
        state: 'off',
60 60
        vm: '2',
61
	},
62
]
61
    },
62
];
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
];
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/network.js
1 1
App.NetworkRoute = Ember.Route.extend({
2 2
    redirect: function() {
3
   		this.transitionTo('network.info'); 
4
  	}
3
           this.transitionTo('network.info'); 
4
      }
5 5
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/networkDetails.js
1 1
App.NetworkInfoRoute = Ember.Route.extend({
2
 	renderTemplate: function() {
2
     renderTemplate: function() {
3 3
        this.render('details/info');
4 4
    },
5 5
});
6 6

  
7 7
App.NetworkVmConnectedRoute = Ember.Route.extend({
8
 	renderTemplate: function() {
8
     renderTemplate: function() {
9 9
        this.render('details/disk-connected');
10 10
    },
11 11
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/networks.js
1 1
App.NetworksRoute = Ember.Route.extend({
2 2
    
3 3
    model: function(params){
4
      	this.set( 'viewCls', params.view_cls );
5
      	var controller = this.get("controller");
4
        this.set( 'viewCls', params.view_cls );
5
        var controller = this.get("controller");
6 6

  
7
      	// Ember checks if controller is already set, and if so, does not set it
8
      	// up again. Hence, the following hack:
9
      	if (controller) {
10
      		controller.set("viewCls", params.view_cls);
11
      	}
7
        // Ember checks if controller is already set, and if so, does not set it
8
        // up again. Hence, the following hack:
9
        if (controller) {
10
            controller.set("viewCls", params.view_cls);
11
        }
12 12

  
13
      	// end of hack
14
      	return this.store.find('network');
13
        // end of hack
14
        return this.store.find('network');
15 15
    },
16 16
    renderTemplate: function() {
17 17
        this.render('items');
18 18
    },
19 19

  
20 20
    setupController: function(controller, model) {
21
   		controller.set('model', model);
22
   		controller.set("viewCls", this.get("viewCls"));
23
      controller.set('modelName', 'network');
24
   	},
25

  
21
        controller.set('model', model);
22
        controller.set("viewCls", this.get("viewCls"));
23
        controller.set('modelName', 'network');
24
    },
26 25
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/vm.js
1 1
App.VmRoute = Ember.Route.extend({
2 2
    redirect: function() {
3
   		this.transitionTo('vm.info'); 
4
  	}
3
           this.transitionTo('vm.info'); 
4
      }
5 5
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/vmDetails.js
1 1
App.VmInfoRoute = Ember.Route.extend({
2
 	renderTemplate: function() {
2
     renderTemplate: function() {
3 3
        this.render('details/info');
4 4
    },
5 5
});
6 6

  
7 7
App.VmDiskConnectedRoute = Ember.Route.extend({
8
 	renderTemplate: function() {
8
     renderTemplate: function() {
9 9
        this.render('details/disk-connected');
10 10
    },
11 11
});
12 12

  
13 13
App.VmNetworkConnectedRoute = Ember.Route.extend({
14
 	renderTemplate: function() {
14
     renderTemplate: function() {
15 15
        this.render('details/network-connected');
16 16
    },
17 17
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/vms.js
1 1
App.VmsRoute = Ember.Route.extend({
2 2
    
3 3
    model: function(params){
4
      	this.set( 'viewCls', params.view_cls );
5
      	var controller = this.get("controller");
4
          this.set( 'viewCls', params.view_cls );
5
          var controller = this.get("controller");
6 6

  
7
      	// Ember checks if controller is already set, and if so, does not set it
8
      	// up again. Hence, the following hack:
9
      	if (controller) {
10
      		controller.set("viewCls", params.view_cls);
11
      	}
7
          // Ember checks if controller is already set, and if so, does not set it
8
          // up again. Hence, the following hack:
9
          if (controller) {
10
              controller.set("viewCls", params.view_cls);
11
          }
12 12

  
13
      	// end of hack
14
      	return this.store.find('vm');
13
          // end of hack
14
          return this.store.find('vm');
15 15
    },
16 16
    renderTemplate: function() {
17 17
        this.render('items');
18 18
    },
19 19
   
20 20
    setupController: function(controller, model) {
21
   		controller.set('model', model);
22
   		controller.set("viewCls", this.get("viewCls"));
21
           controller.set('model', model);
22
           controller.set("viewCls", this.get("viewCls"));
23 23
      controller.set('modelName', 'vm');
24
   	},
24
       },
25 25

  
26 26
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/views/side-actions.js
1 1
App.sideActionsView = Ember.View.extend({
2
	tagName: 'ul',
3
  	classNames: ['side-actions'],
4
  	templateName: 'side-actions',
2
    tagName: 'ul',
3
      classNames: ['side-actions'],
4
      templateName: 'side-actions',
5 5
});
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates.js
413 413
  
414 414
  var buffer = '';
415 415
  data.buffer.push("\n<li>\n	<a href=\"#\" ");
416
  data.buffer.push(escapeExpression(helpers.action.call(depth0, "item.act", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data})));
416
  data.buffer.push(escapeExpression(helpers.action.call(depth0, "item.act", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data})));
417 417
  data.buffer.push(" ");
418 418
  data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{
419 419
    'title': ("item.title")
......
431 431
  if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
432 432
  data.buffer.push("\n</li>\n<li>\n	<a href=\"#\" ");
433 433
  data.buffer.push(escapeExpression(helpers.action.call(depth0, "modalConnect", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data})));
434
  data.buffer.push(" title=\"connect\"><span class=\"snf-thunder-full\"></span></a>\n</li>\n\n");
434
  data.buffer.push(" title=\"connect\"><span class=\"snf-thunder-full\"></span></a>\n</li>\n<!--https://github.com/emberjs/ember.js/pull/3936-->\n");
435 435
  stack1 = helpers.each.call(depth0, "item", "in", "actionsMeta", {hash:{},hashTypes:{},hashContexts:{},inverse:self.noop,fn:self.program(3, program3, data),contexts:[depth0,depth0,depth0],types:["ID","ID","ID"],data:data});
436 436
  if(stack1 || stack1 === 0) { data.buffer.push(stack1); }
437 437
  data.buffer.push("\n");
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/side-actions.hbs
4 4
<li>
5 5
	<a href="#" {{action "modalConnect"}} title="connect"><span class="snf-thunder-full"></span></a>
6 6
</li>
7

  
7
<!--https://github.com/emberjs/ember.js/pull/3936-->
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 href="#" {{action item.act}} {{bind-attr title="item.title"}}><span {{bind-attr class="item.spanCls"}}></span></a>
11 11
</li>
12 12
{{/each}}
b/snf-cyclades-app/synnefo/ui/new_ui/ui/package.json
13 13
    "grunt-contrib-watch": "~0.5.3",
14 14
    "grunt-contrib-compass": "~0.7.0",
15 15
    "grunt-contrib-concat": "~0.3.0",
16
    "grunt-ember-templates": "~0.4.18"
16
    "grunt-ember-templates": "~0.4.18",
17
    "grunt-contrib-jshint": "~0.8.0"
17 18
  }
18 19
}

Also available in: Unified diff