Skip to content

Commit

Permalink
Merge pull request #671 from MissionCriticalCloud/add/response-names-…
Browse files Browse the repository at this point in the history
…to-prevent-extra-api-calls

Add/response names to prevent extra api calls
  • Loading branch information
Boris Schrijver authored Apr 6, 2018
2 parents ef69dc2 + a650e06 commit be27a2f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
37 changes: 16 additions & 21 deletions cosmic-client/src/main/webapp/scripts/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -3668,20 +3668,15 @@
title: 'label.details',
preFilter: function (args) {
var hiddenFields = [];
var zoneObj;
$.ajax({
url: createURL("listZones&id=" + args.context.ipAddresses[0].zoneid),
dataType: "json",
async: false,
success: function (json) {
zoneObj = json.listzonesresponse.zone[0];
}
});
if (zoneObj.networktype == "Advanced") {
hiddenFields.push("issystem");
hiddenFields.push("purpose");
if (typeof args.context.ipAddresses[0].vmipaddress == "undefined") {
hiddenFields.push("vmipaddress");
}
if (typeof args.context.ipAddresses[0].virtualmachinedisplayname == "undefined") {
hiddenFields.push("virtualmachinedisplayname");
}
if (typeof args.context.ipAddresses[0].associatednetworkid == "undefined") {
hiddenFields.push("associatednetworkid")
}

if (!isAdmin()) {
hiddenFields.push("vlanname");
}
Expand All @@ -3707,6 +3702,9 @@
aclid: {
label: 'label.acl.id'
},
aclname: {
label: 'label.acl.name'
},
networkid: {
label: 'label.network.id'
},
Expand All @@ -3721,13 +3719,6 @@
vmipaddress: {
label: 'label.vm.ip'
},
issystem: {
label: 'label.is.system',
converter: cloudStack.converters.toBooleanText
}, //(basic zone only)
purpose: {
label: 'label.purpose'
}, //(basic zone only) When an IP is system-generated, the purpose it serves can be Lb or static nat.
virtualmachinedisplayname: {
label: 'label.vm.name'
},
Expand Down Expand Up @@ -6326,7 +6317,11 @@

var data = [];
$(algorithms).each(function () {
data.push({id: this.valueOf(), name: this.valueOf(), description: _l('label.lb.algorithm.' + this.valueOf())});
data.push({
id: this.valueOf(),
name: this.valueOf(),
description: _l('label.lb.algorithm.' + this.valueOf())
});
});

return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ public class ApiConstants {
public static final String AFFINITY_GROUP_NAME = "affinitygroupname";
public static final String DEPLOYMENT_PLANNER = "deploymentplanner";
public static final String ACL_ID = "aclid";
public static final String ACL_NAME = "aclname";
public static final String NUMBER = "number";
public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
public static final String ROUTING = "isrouting";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
@Param(description = "the ID of the ACL applied to this IP")
private String aclId;

@SerializedName(ApiConstants.ACL_NAME)
@Param(description = "the name of the ACL applied to this IP")
private String aclName;

@SerializedName(ApiConstants.STATE)
@Param(description = "State of the ip address. Can be: Allocatin, Allocated and Releasing")
private String state;
Expand Down Expand Up @@ -272,4 +276,8 @@ public void setAssociatedNetworkName(final String associatedNetworkName) {
public void setForDisplay(final Boolean forDisplay) {
this.forDisplay = forDisplay;
}

public void setAclName(final String aclName) {
this.aclName = aclName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@Param(description = "ACL Id associated with the VPC network")
private String aclId;

@SerializedName(ApiConstants.ACL_NAME)
@Param(description = "the name of the ACL applied to this IP")
private String aclName;

@SerializedName(ApiConstants.STRECHED_L2_SUBNET)
@Param(description = "true if network can span multiple zones", since = "4.4")
private Boolean strechedL2Subnet;
Expand Down Expand Up @@ -428,4 +432,8 @@ public void setStrechedL2Subnet(final Boolean strechedL2Subnet) {
public void setNetworkSpannedZones(final Set<String> networkSpannedZones) {
this.networkSpannedZones = networkSpannedZones;
}

public void setAclName(final String aclName) {
this.aclName = aclName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,15 @@ public IPAddressResponse createIPAddressResponse(final ResponseView view, final
final NetworkVO nw = ApiDBUtils.findNetworkById(networkId);
if (nw != null) {
ipResponse.setNetworkId(nw.getUuid());
ipResponse.setAssociatedNetworkName(nw.getName());
}
}
ipResponse.setState(ipAddr.getState().toString());

final NetworkACL acl = ApiDBUtils.findByNetworkACLId(ipAddr.getIpACLId());
if (acl != null) {
ipResponse.setAclId(acl.getUuid());
ipResponse.setAclName(acl.getName());
}

if (ipAddr.getPhysicalNetworkId() != null) {
Expand Down Expand Up @@ -1910,6 +1912,7 @@ public NetworkResponse createNetworkResponse(final ResponseView view, final Netw
final NetworkACL acl = ApiDBUtils.findByNetworkACLId(network.getNetworkACLId());
if (acl != null) {
response.setAclId(acl.getUuid());
response.setAclName(acl.getName());
}
}

Expand Down

0 comments on commit be27a2f

Please sign in to comment.