Skip to content

Instantly share code, notes, and snippets.

@Cyreex
Last active March 7, 2017 14:44
Show Gist options
  • Save Cyreex/012f4bce29a4f861820bb16c1898e3c5 to your computer and use it in GitHub Desktop.
Save Cyreex/012f4bce29a4f861820bb16c1898e3c5 to your computer and use it in GitHub Desktop.
function _updateNetworks() {
var that = this,
sortedNetworkList;
if (this.vmData.subscriptionId) {
$.observable(this.virtualNetworks).refresh([loadingEntryItem]);
global.VMExtension.Model.Ajax.getNetworksWithSubnets(this.vmData.subscriptionId)
.done(function(response) {
sortedNetworkList = response ? response.sort(global.VMExtension.Utilities.dynamicMultiSort([{ propertyName: "displayName", isDescending: false }])) : [];
$.observable(that.virtualNetworks).refresh(sortedNetworkList);
if (that.virtualNetworks.length === 0) {
$.observable(that.virtualNetworks).refresh([notConnectedNetworkItem]);
} else {
$.observable(that.virtualNetworks).insert(0, notConnectedNetworkItem);
that.vmData.network = that.virtualNetworks[0].id;
$(that.vmData).triggerHandler("propertyChange", { path: "network", value: that.virtualNetworks[0].id });
}
});
} else {
$.observable(this.virtualNetworks).refresh([noEntryItem]);
}
this.vmData.vmNetworks = this.virtualNetworks;
this.vmData.stampId = global.Spf.Service.getSubscriptionInfo(this.vmData.subscriptionId).stampId;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment