commit a6c6857cbb33cb69815859ba2c2a818470f108f2
Author: Olga Brani <olgabrani@grnet.gr>
Date:   Fri Feb 21 12:36:05 2014 +0200

    uinext: One ItemsItemController

diff --git a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
index f1ef6ce..2779a8b 100644
--- a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
+++ b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
@@ -1,4 +1,17 @@
 /*
+* These functions are used throughout ember
+*/
+
+
+
+
+/* ---------------------- */
+/* END OF EMBER FUNCTIONS */
+
+
+
+
+/*
 * Various functions that will be used throughout all templates
 * are inside ui Object
 */
@@ -803,4 +816,11 @@ $(window).resize(function(e){
     ui.setCustomScrollBar();
     ui.setElmaxHeight($('.storage-progress'));
 
-})
\ No newline at end of file
+});
+
+
+_.mixin({
+  capitalize: function(string) {
+    return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
+  }
+});
\ No newline at end of file
diff --git a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/item.js b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/item.js
new file mode 100644
index 0000000..64d5a2f
--- /dev/null
+++ b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/item.js
@@ -0,0 +1,39 @@
+App.ItemsItemController = Ember.ObjectController.extend({
+
+    codeName: 'vm',
+
+    needs: function() {
+
+        var needs = [];
+/*
+        App.Vm.eachRelationship(function(name, meta) {
+            if (meta.kind == 'hasMany') {
+                needs.push(name);
+            }
+        });*/
+        needs.push(this.codeName+'s');
+        return needs;
+
+    }.property(),
+
+    hasViewCls: true,
+
+    // i would like to get it from parent controller ????
+    icon:  function () {
+        var item = this.codeName;
+        return 'snf-'+item+'-full';
+    }.property(),
+
+    hasTags: true,
+
+    codeNameParent: function() {
+        return this.codeName+'s';
+    }.property(),
+
+    codeNameChildInit: function() {
+        return this.codeName+'init';
+    }.property(),
+    
+
+
+});
\ No newline at end of file
diff --git a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/items.js b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/items.js
index cc04faa..ca20194 100644
--- a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/items.js
+++ b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/items.js
@@ -65,4 +65,6 @@ App.VmsController = App.ItemsListController.extend({
 
 App.VolumesController = App.ItemsListController.extend({
     codeName : 'volumes',
-});
\ No newline at end of file
+});
+
+App.TagsController = Ember.ArrayController.extend();
\ No newline at end of file
diff --git a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/network.js b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/network.js
index 834d816..c7a48a9 100644
--- a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/network.js
+++ b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/network.js
@@ -1,7 +1,5 @@
-App.NetworkController = Ember.ObjectController.extend({
+App.NetworkController = App.ItemsItemController.extend({
 
-    icon: 'snf-network-full',
-    
     codeName: 'network',
     
     actionsMeta: function() {
@@ -9,45 +7,4 @@ App.NetworkController = Ember.ObjectController.extend({
         return _.map(enabledActions, function(val,key) { return actionsMetaNetwork[val]; });      
     }.property('model.enabledActions'),
 
-    actions: {
-        
-        modalConnect: function(){
-            var component = Ember.View.views["modal-connect"];
-            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
-            component.set('okCallback', _.bind(function() {
-                alert("restarting " + this.get('model').get('name'));
-            }, this));
-            $("#modal-connect").foundation('reveal', 'open');
-        },
-
-        modalStart: function(){
-            $("#modal-start").foundation('reveal', 'open');
-        },
-
-        modalShutdown: function(){
-            $("#modal-shutdown").foundation('reveal', 'open');
-        },
-
-        modalReboot: function(){
-            $("#modal-reboot").foundation('reveal', 'open');
-            var component = Ember.View.views["modal-reboot"];
-            component.set('message', '<p>Are you sure you want to reboot you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>');
-            component.set('okCallback', _.bind(function() {
-                this.get('model').set('state','rebooting');
-                $("#modal-reboot").foundation('reveal','close');
-            }, this));
-        },
-
-        modalDestroy: function(){
-            $("#modal-destroy").foundation('reveal', 'open');
-            var component = Ember.View.views["modal-destroy"];
-            component.set('message', '<p>Are you sure you want to delete you VM <strong>' + this.get('model').get('name')+'</strong> ?</p>');
-            component.set('okCallback', _.bind(function() {
-                this.get('model').deleteRecord();
-                this.get('model').save();
-                $("#modal-destroy").foundation('reveal','close');
-            }, this));
-        },
-
-    },
 });
\ No newline at end of file
diff --git a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js
index 0b9ba53..b253219 100644
--- a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js
+++ b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js
@@ -1,32 +1,11 @@
-App.VmController = Ember.ObjectController.extend({
-
-    needs: ['vms'],
-    
-    hasViewCls: true,
-    
-    /*icon: function () {
-        return this.get('parentController').get('iconCls');
-    }.property(),*/
-
+App.VmController =App.ItemsItemController.extend({
     icon: 'snf-pc-full',
 
-    codeName: 'vm',
-
-    hasTags: true,
-
-    codeNameParent: function() {
-        return this.codeName+'s';
-    }.property(),
-
-    codeNameChildInit: function() {
-        return this.codeName+'init';
-    }.property(),
-    
     actionsMeta: function() {
         var enabledActions = this.get('model').get('enabledActions');
-        return _.map(enabledActions, function(val,key) {return actionsMetaVm[val]; });      
+        return _.map(enabledActions, function(val,key) { return actionsMetaVm[val]; });      
     }.property('model.enabledActions'),
-
+    
     actions: {
 
         deleteTag: function(tag) {
@@ -72,9 +51,6 @@ App.VmController = Ember.ObjectController.extend({
             }, this));
         },
 
-    },
-});
-
-
-App.VmInfoController = App.VmController.extend({
+    }
 });
+App.VmInfoController = App.VmController.extend();
diff --git a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/volume.js b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/volume.js
index 4173456..5e5bac5 100644
--- a/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/volume.js
+++ b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/volume.js
@@ -1,6 +1,4 @@
-App.VolumeController = Ember.ObjectController.extend({
-
-    icon: 'snf-volume-full',
+App.VolumeController = App.ItemsItemController.extend({
 
     codeName: 'volume',
     
@@ -9,46 +7,5 @@ App.VolumeController = Ember.ObjectController.extend({
         return _.map(enabledActions, function(val,key) {return actionsMetaVolume[val]; });      
     }.property('model.enabledActions'),
 
-    actions: {
-        
-        modalConnect: function(){
-            var component = Ember.View.views["modal-connect"];
-            component.set('message', 'connect to your <3 ' + this.get('model').get('name'));
-            component.set('okCallback', _.bind(function() {
-
-                alert("restarting " + this.get('model').get('name'));
-            }, this));
-            $("#modal-connect").foundation('reveal', 'open');
-        },
-
-        modalStart: function(){
-            $("#modal-start").foundation('reveal', 'open');
-        },
-
-        modalShutdown: function(){
-            $("#modal-shutdown").foundation('reveal', 'open');
-        },
-
-        modalReboot: function(){
-            $("#modal-reboot").foundation('reveal', 'open');
-            var component = Ember.View.views["modal-reboot"];
-            component.set('message', '<p>Are you sure you want to reboot you Volume <strong>' + this.get('model').get('name')+'</strong> ?</p>');
-            component.set('okCallback', _.bind(function() {
-                this.get('model').set('state','rebooting');
-                $("#modal-reboot").foundation('reveal','close');
-            }, this));
-        },
-
-        modalDestroy: function(){
-            $("#modal-destroy").foundation('reveal', 'open');
-            var component = Ember.View.views["modal-destroy"];
-            component.set('message', '<p>Are you sure you want to delete you Volume <strong>' + this.get('model').get('name')+'</strong> ?</p>');
-            component.set('okCallback', _.bind(function() {
-                this.get('model').deleteRecord();
-                this.get('model').save();
-                $("#modal-destroy").foundation('reveal','close');
-            }, this));
-        },
 
-    },
 });
\ No newline at end of file
