Commit 0f84ef48 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

ui: Public networks fixes

- 'Internet' instead of 'Public'
- Common prefix 'Internet' for both IPv4 IPv6 network names in vm wizard
- Loading indicator when creating a new floating ip from vm wizard
parent e510c72b
......@@ -6707,6 +6707,10 @@ input.has-errors {
.collection span.no-available {
}
.collection span.no-available {
float: right;
}
.collection .no-available {
font-size: 0.8em;
color: #f00;
......
......@@ -359,6 +359,9 @@
if (!model) return false;
var success = options.success;
options.success = function(nextModel, resp, xhr) {
if (coll.add_on_create) {
coll.add(nextModel, options);
}
if (success) success(nextModel, resp, xhr);
};
model.save(null, options);
......
......@@ -29,7 +29,8 @@
api_type: 'network',
details: true,
noUpdate: true,
updateEntries: true
updateEntries: true,
add_on_create: true
});
// Subnet model
......@@ -49,6 +50,10 @@
models.Network = models.NetworkModel.extend({
path: 'networks',
parse: function(obj) {
return obj.network;
},
// Available network actions.
// connect:
model_actions: {
......@@ -224,7 +229,7 @@
defaults: {
'admin_state_up': true,
'id': 'snf-combined-public-network',
'name': 'Public',
'name': 'Internet',
'status': 'ACTIVE',
'router:external': true,
'shared': false,
......@@ -311,6 +316,9 @@
models.Port = models.NetworkModel.extend({
path: 'ports',
parse: function(obj) {
return obj.port;
},
initialize: function() {
models.Port.__super__.initialize.apply(this, arguments);
var ips = new models.FixedIPs();
......@@ -439,6 +447,11 @@
models.FloatingIP = models.NetworkModel.extend({
path: 'floatingips',
parse: function(obj) {
return obj.floatingip;
},
storage_attrs: {
'port_id': ['ports', 'port'],
'floating_network_id': ['networks', 'network'],
......@@ -494,7 +507,7 @@
}
]
},
disconnect: function(cb) {
this.get('port').disconnect(cb);
}
......
......@@ -47,6 +47,7 @@
vm_style: function() {
var style = "background-image: url('{0}')";
if (!this.model.get('vm')) { return }
return style.format(this.get_vm_icon_path(this.model.get('vm'),
'medium'));
},
......
......@@ -455,7 +455,7 @@
}
if (this.model.id == "snf-combined-public-network" && !_.contains(
["CONNECTING", "DISCONNECTING"], status)) {
return "Internet"
return "Public connectivity"
}
return this.status_map[status];
......@@ -574,7 +574,6 @@
get_vm_icon: function() {
return $(snf.ui.helpers.vm_icon_tag(this.model, "small")).attr("src")
},
status_cls: function() {
return (views.IconView.STATE_CLASSES[this.model.get("state")] || []).join(" ") + " status clearfix"
},
......@@ -753,13 +752,6 @@
classes: 'public-network',
post_init_element: function() {
views.NetworkSelectPublicNetwork.__super__.post_init_element.apply(this);
//$(this.el).attr('title', 'Public network tooltip');
//$(this.el).tooltip({
//'tipClass': 'tooltip',
//'position': 'top center',
//'offset': [-5, 0]
//});
}
});
......@@ -836,7 +828,7 @@
e.preventDefault();
self.create_ip();
});
this.update_available();
this.reset_creating();
},
hide_parent: function() {
......@@ -877,7 +869,7 @@
no_available_el.show();
} else {
// available floating ip
var available_text = "{0} IP's available.".format(
var available_text = "".format(
this.collection.length + this.quota.get_available());
available_el.removeClass("hidden").text(available_text).show();
available_el.show();
......@@ -893,15 +885,20 @@
} else {
// no available quota
create.addClass("no-available");
create.show();
create.hide();
create_link.hide();
create_no_available.show();
//create_no_available.show();
}
//
this.update_selected();
},
update_selected: function() {
_.each(this.selected_ips.length, function(ip) {
if (!this.collection.get(ip.id)) {
this.selected_ips = _.without(this.selected_ips, ip);
}
}, this);
if (this.selected_ips.length) {
this.parent_view.input.attr("checked", true);
this.parent_view.item.addClass("selected");
......@@ -919,11 +916,31 @@
},
handle_create_error: function() {},
set_creating: function() {
var create_link = this.$(".create a");
var create_no_available = this.$(".create .no-available");
var loading = this.$(".create .loading");
create_link.hide();
loading.show();
},
reset_creating: function() {
var loading = this.$(".create .loading");
loading.hide();
this.update_available();
},
create_ip: function() {
if (!this.quota.get_available()) { return }
var self = this;
this.set_creating();
synnefo.storage.floating_ips.create({floatingip:{}}, {
error: _.bind(this.handle_create_error, this),
complete: function() {
synnefo.storage.quotas.fetch();
self.reset_creating();
},
skip_api_error: true
});
},
......@@ -975,8 +992,8 @@
select_public: true,
forced_values_title_map: {
"SNF:ANY_PUBLIC_IPV6": "Public IPv6 Network",
"SNF:ANY_PUBLIC_IPV4": "Public IPv4 Network"
"SNF:ANY_PUBLIC_IPV6": "Internet (public IPv6)",
"SNF:ANY_PUBLIC_IPV4": "Internet (public IPv4)"
},
initialize: function(options) {
......@@ -1019,7 +1036,9 @@
// combined public
this.combined_public = new models.networks.CombinedPublicNetwork();
this.combined_public.set({noselect: true, name: 'Internet', forced: false});
this.combined_public.set({noselect: true,
name: 'Internet (public IPv4)',
forced: false});
this.public_networks.add(this.combined_public);
model_attrs = {
......
......@@ -702,6 +702,13 @@
synnefo.config.system_images_owners = {{ system_images_owners|safe }};
synnefo.ui.init();
synnefo.ui.main.bind("ready", function(){
$("#machines-pane-top #create").click();
window.setTimeout(function() {
$("#type-select-public").click();
$("#untrusted-image-confirm").click();
$(".form-action.next").click();
$(".form-action.next").click();
}, 400);
});
});
</script>
......
......@@ -257,11 +257,12 @@
<div class="collection">
<div class="items-list floating-ips clearfix">
</div>
<div class="create model-item select-item floating-ip">
<div class="create model-item select-item floating-ip clearfix">
<span class="empty-list hidden" style="padding-left:0;">
{% trans "No ip addresses available" %}
</span>
<a href="#">create new...</a>
<span class="loading">creating...</span>
<span class="no-available hidden">{% trans "IP's limit reached." %}</span>
</div>
</div>
......
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