commit 1392518253767475847ebc8418da542c47f2427d
Author: Kostas Papadimitriou <kpap@grnet.gr>
Date:   Thu Nov 7 18:40:12 2013 +0200

    ui: Display resize in vm actions list

diff --git a/snf-cyclades-app/synnefo/ui/static/snf/css/main.css b/snf-cyclades-app/synnefo/ui/static/snf/css/main.css
index 97f8880..7eb1ea0 100644
--- a/snf-cyclades-app/synnefo/ui/static/snf/css/main.css
+++ b/snf-cyclades-app/synnefo/ui/static/snf/css/main.css
@@ -876,7 +876,7 @@ div.image-container {
 }
 
 .icon .machine-info {
-    padding: 10px 0;
+    padding: 20px 0;
 }
 
 .icon .machine-details .name {
@@ -913,7 +913,7 @@ div.image-container {
 
 .icon .vm-actions, .network .vm-actions {
     width: 180px;
-    height: 76px;
+    height: 96px;
     float: left;
 }
 
@@ -970,6 +970,16 @@ div.image-container {
 div.list div.actions a.enabled.destroy {
 }
 
+.vm-actions .action-container.inactive a {
+  color: #aaa;
+}
+
+.vm-actions .action-container.inactive a:hover{
+  background-color: transparent !important;
+  border: none !important;
+  padding-left: 8px;
+}
+
 .vm-actions .action-container.destroy {
     position: absolute;
     bottom: -1px;
@@ -1070,7 +1080,7 @@ div.connect-arrow {
     display: none;
     left: -3px;
     position: absolute;
-    top: 9px;
+    top: 22px;
 }
 
 div.connect-arrow:hover, div.connect-arrow.border-hover, div.connect-arrow-ie, div.connect-arrow.border-ie {
@@ -1098,7 +1108,7 @@ div.connect-border:hover {
     display: none;
     left: -15px;
     position: absolute;
-    top: 9px;
+    top: 22px;
 }
 
 .standard .machine .logo {
@@ -3561,7 +3571,7 @@ div.machine a.manage-metadata:hover {
 
 .single .single-actions {
     width: 150px;
-    height: 60px;
+    height: 77px;
     margin-bottom: 45px;
     margin-left: -10px;
 }
@@ -4099,6 +4109,9 @@ div.state .console, tbody.machines .console {
 div.state .start, tbody.machines .start {
     background-image: url("../images/icons/actions/medium/start.png");
 }
+div.state .resize, tbody.machines .resize {
+    background-image: url("../images/icons/actions/medium/resize.png");
+}
 div.state .reboot, tbody.machines .reboot {
     background-image: url("../images/icons/actions/medium/reboot.png");
 }
diff --git a/snf-cyclades-app/synnefo/ui/static/snf/js/models.js b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
index 0ff4edc..91b7e1f 100644
--- a/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
+++ b/snf-cyclades-app/synnefo/ui/static/snf/js/models.js
@@ -1556,8 +1556,8 @@
         'UNKNWON'       : ['destroy'],
         'BUILD'         : ['destroy'],
         'REBOOT'        : ['destroy'],
-        'STOPPED'       : ['start', 'destroy'],
-        'ACTIVE'        : ['shutdown', 'destroy', 'reboot', 'console'],
+        'STOPPED'       : ['start', 'destroy', 'resize'],
+        'ACTIVE'        : ['shutdown', 'destroy', 'reboot', 'console', 'resize'],
         'ERROR'         : ['destroy'],
         'DELETED'       : ['destroy'],
         'DESTROY'       : ['destroy'],
@@ -1567,6 +1567,10 @@
         'DISCONNECT'    : ['destroy'],
         'RESIZE'        : ['destroy']
     }
+    
+    models.VM.AVAILABLE_ACTIONS_INACTIVE = {
+      'resize': ['ACTIVE']
+    }
 
     // api status values
     models.VM.STATUSES = [
diff --git a/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_vms_base_view.js b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_vms_base_view.js
index 60d70c7..6a6fd82 100644
--- a/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_vms_base_view.js
+++ b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_vms_base_view.js
@@ -551,6 +551,14 @@
             _.each(models.VM.ACTIONS, function(action, index) {
                 if (actions.indexOf(action) > -1) {
                     this.action(action).removeClass("disabled");
+                    var inactive = models.VM.AVAILABLE_ACTIONS_INACTIVE[action];
+
+                    if (inactive && _.contains(inactive, this.vm.get('status'))) {
+                      this.action(action).addClass("inactive");
+                    } else {
+                      this.action(action).removeClass("inactive");
+                    }
+
                     if (this.selected_action == action) {
                         this.action_confirm_cont(action).css('display', 'block');
                         this.action_confirm(action).show();
@@ -619,7 +627,14 @@
                 // action links click events
                 $(this.el).find(".action-container."+action+" a").click(function(ev) {
                     ev.preventDefault();
-                    self.set(action);
+                    if ($(ev.currentTarget).parent().hasClass("inactive")) {
+                      return;
+                    }
+                    if (action == "resize") {
+                        ui.main.vm_resize_view.show(self.vm);
+                    } else {
+                        self.set(action);
+                    }
                 }).data("action", action);
 
                 // confirms
@@ -672,6 +687,7 @@
         'shutdown':      ['UNKOWN', 'ACTIVE', 'REBOOT'],
         'console':       ['ACTIVE'],
         'start':         ['UNKOWN', 'STOPPED'],
+        'resize':        ['UNKOWN', 'ACTIVE', 'STOPPED', 'REBOOT', 'ERROR', 'BUILD'],
         'destroy':       ['UNKOWN', 'ACTIVE', 'STOPPED', 'REBOOT', 'ERROR', 'BUILD']
     };
 
diff --git a/snf-cyclades-app/synnefo/ui/templates/partials/machines_icon.html b/snf-cyclades-app/synnefo/ui/templates/partials/machines_icon.html
index 33e21df..82eb9f4 100644
--- a/snf-cyclades-app/synnefo/ui/templates/partials/machines_icon.html
+++ b/snf-cyclades-app/synnefo/ui/templates/partials/machines_icon.html
@@ -135,6 +135,13 @@
                         <button class="no">X</button>
                     </div>
                 </div>
+                <div class="action-container resize">
+                    <a href="#" class="action-resize">{% trans "Resize" %}</a>
+                    <div class="confirm_single">
+                        <button class="yes">{% trans "Confirm" %}</button>
+                        <button class="no">X</button>
+                    </div>
+                </div>
                 <div class="action-container destroy">
                     <a href="#" class="action-destroy">{% trans "Destroy" %}</a>
                     <div class="confirm_single">
diff --git a/snf-cyclades-app/synnefo/ui/templates/partials/machines_single.html b/snf-cyclades-app/synnefo/ui/templates/partials/machines_single.html
index 76f84f2..debe33d 100644
--- a/snf-cyclades-app/synnefo/ui/templates/partials/machines_single.html
+++ b/snf-cyclades-app/synnefo/ui/templates/partials/machines_single.html
@@ -100,6 +100,13 @@
                             <button class="no">X</button>
                         </div>
                     </div>
+                    <div class="action-container resize">
+                        <a class="single-action action-resize">{% trans "Resize" %}</a>
+                        <div class="confirm_single">
+                            <button class="yes">{% trans "Confirm" %}</button>
+                            <button class="no">X</button>
+                        </div>
+                    </div>
                     <div class="action-container destroy">
                         <a class="single-action action-destroy">{% trans "Destroy" %}</a>
                         <div class="confirm_single">
