Commit 0568caec authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

UI create machine improvements

- Display remaining resources
- Predefined flavors display fix
parent fb2c4559
......@@ -32,6 +32,9 @@ pre {
font-family: monospace;
}
h4.error .title {
color: red !important;
}
#okeanos-image {
position: absolute;
bottom: -0px;
......@@ -5479,6 +5482,12 @@ table.list-machines .wave {
margin-left: 2px;
}
.create-vm .flavor-options span.available {
font-size: 0.8em;
font-weight: normal;
margin-left: 5px;
}
.create-vm .flavor-options span.title {
color: #444;
}
......
......@@ -152,6 +152,17 @@
can_consume: function(key, value) {
return (this.get_available(key) - parseInt(value)) >= 0
},
get_available_readable: function(key) {
var value;
if (this.is_bytes(key)) {
var value = this.get_available(key);
if (!value) { return 0 }
return snf.util.readablizeBytes(value);
} else {
return this.get_available(key);
}
}
});
......
......@@ -531,7 +531,6 @@
}, this));
this.predefined = this.$(".predefined-list");
this.update_predefined_flavors();
},
handle_image_change: function(data) {
......@@ -539,6 +538,7 @@
this.update_valid_predefined();
this.current_flavor = undefined;
this.update_flavors_data();
this.update_predefined_flavors();
this.reset_flavors();
this.update_layout();
},
......@@ -578,6 +578,18 @@
select_valid_flavor: function() {
var found = false;
var self = this;
_.each(["cpu", "mem", "disk"], function(t) {
var el = $(".flavor-options."+t);
var all = el.find(".flavor-opts-list li").length;
var disabled = el.find(".flavor-opts-list li.disabled").length;
if (disabled >= all) {
el.find("h4").addClass("error");
} else {
el.find("h4").removeClass("error");
}
})
_.each(this.flavors, function(flv) {
if (self.flavor_is_valid(flv)) {
found = flv;
......@@ -925,6 +937,26 @@
this.update_disabled_flavors();
this.validate();
this.validate_selected_flavor();
this.update_quota_display();
},
update_quota_display: function() {
if (!snf.user.quota || !snf.user.quota.data) { return };
_.each(["disk", "ram", "cpu"], function(type) {
var available_dsp = snf.user.quota.get_available_readable(type);
var available = snf.user.quota.get_available(type);
var content = "({0} left)".format(available_dsp);
if (available <= 0) { content = "(None left)" }
if (type == "ram") { type = "mem" }
$(".flavor-options."+type+" h4 .available").text(content);
if (available <= 0) {
$(".flavor-options."+type+" h4 .available").addClass("error");
} else {
$(".flavor-options."+type+" h4 .available").removeClass("error");
}
})
},
reset: function() {
......
......@@ -776,6 +776,7 @@
if (!snf.user.quota) {
snf.user.quota = new snf.quota.Quota("cyclades");
main_view.init_quotas_handlers();
}
snf.api.sync('read', undefined, {
......
......@@ -149,7 +149,8 @@
<div class="flavor-options-inner-cont clearfix"
id="create-vm-flavor-options">
<div class="flavor-options cpu clearfix">
<h4 class="clearfix"><span class="title">{% trans "CPUs" %}</span>
<h4 class="clearfix"><span class="title">{% trans "CPUs" %}</span>
<span class="available"></span>
<span class="desc">{% trans "Choose number of CPU cores" %}</span>
</h4>
<ul class="flavors-cpu-list flavor-opts-list clearfix">
......@@ -157,6 +158,7 @@
</div>
<div class="flavor-options mem clearfix">
<h4 class="clearfix"><span class="title">{% trans "Memory size" %}</span>
<span class="available"></span>
<span class="desc">{% trans "Choose memory size" %}</span>
</h4>
<ul class="flavors-mem-list flavor-opts-list clearfix">
......@@ -164,6 +166,7 @@
</div>
<div class="flavor-options disk clearfix">
<h4 class="clearfix"><span class="title">{% trans "Disk size" %}</span>
<span class="available"></span>
<span class="desc">{% trans "Choose disk size" %}</span>
</h4>
<ul class="flavors-disk-list flavor-opts-list clearfix">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment