Skip to content

Commit c6055a2

Browse files
authored
api, ui: return default ui pagesize as part of capability response (apache#5432)
listConfigurations is not available for all roles and therefore not fit to use in UI for a generic functionality. This PR makes default ui pagesize a part for listCapabilities API response to make it available for UI across different role accounts. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 8baf384 commit c6055a2

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.cloudstack.api.APICommand;
2222
import org.apache.cloudstack.api.BaseCmd;
2323
import org.apache.cloudstack.api.response.CapabilitiesResponse;
24+
import org.apache.cloudstack.config.ApiServiceConfiguration;
2425
import org.apache.log4j.Logger;
2526

2627
import com.cloud.user.Account;
@@ -69,6 +70,7 @@ public void execute() {
6970
if (capabilities.containsKey("apiLimitMax")) {
7071
response.setApiLimitMax((Integer)capabilities.get("apiLimitMax"));
7172
}
73+
response.setDefaultUiPageSize((Long)capabilities.get(ApiServiceConfiguration.DefaultUIPageSize.key()));
7274
response.setObjectName("capability");
7375
response.setResponseName(getCommandName());
7476
this.setResponseObject(response);

api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public class CapabilitiesResponse extends BaseResponse {
100100
@Param(description = "true if experimental features for Kubernetes cluster such as Docker private registry are enabled, false otherwise")
101101
private boolean kubernetesClusterExperimentalFeaturesEnabled;
102102

103+
@SerializedName("defaultuipagesize")
104+
@Param(description = "default page size in the UI for various views, value set in the configurations", since = "4.15.2")
105+
private Long defaultUiPageSize;
106+
103107
public void setSecurityGroupsEnabled(boolean securityGroupsEnabled) {
104108
this.securityGroupsEnabled = securityGroupsEnabled;
105109
}
@@ -175,4 +179,8 @@ public void setKubernetesServiceEnabled(boolean kubernetesServiceEnabled) {
175179
public void setKubernetesClusterExperimentalFeaturesEnabled(boolean kubernetesClusterExperimentalFeaturesEnabled) {
176180
this.kubernetesClusterExperimentalFeaturesEnabled = kubernetesClusterExperimentalFeaturesEnabled;
177181
}
182+
183+
public void setDefaultUiPageSize(Long defaultUiPageSize) {
184+
this.defaultUiPageSize = defaultUiPageSize;
185+
}
178186
}

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@
538538
import org.apache.cloudstack.api.command.user.vpn.UpdateVpnCustomerGatewayCmd;
539539
import org.apache.cloudstack.api.command.user.vpn.UpdateVpnGatewayCmd;
540540
import org.apache.cloudstack.api.command.user.zone.ListZonesCmd;
541+
import org.apache.cloudstack.config.ApiServiceConfiguration;
541542
import org.apache.cloudstack.config.Configuration;
542543
import org.apache.cloudstack.context.CallContext;
543544
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
@@ -3858,6 +3859,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
38583859
capabilities.put("allowUserViewAllDomainAccounts", allowUserViewAllDomainAccounts);
38593860
capabilities.put("kubernetesServiceEnabled", kubernetesServiceEnabled);
38603861
capabilities.put("kubernetesClusterExperimentalFeaturesEnabled", kubernetesClusterExperimentalFeaturesEnabled);
3862+
capabilities.put(ApiServiceConfiguration.DefaultUIPageSize.key(), ApiServiceConfiguration.DefaultUIPageSize.value());
38613863
if (apiLimitEnabled) {
38623864
capabilities.put("apiLimitInterval", apiLimitInterval);
38633865
capabilities.put("apiLimitMax", apiLimitMax);

ui/src/store/modules/user.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,9 @@ const user = {
255255
api('listCapabilities').then(response => {
256256
const result = response.listcapabilitiesresponse.capability
257257
commit('SET_FEATURES', result)
258-
}).catch(error => {
259-
reject(error)
260-
})
261-
262-
api('listConfigurations', { name: 'default.ui.page.size' }).then(response => {
263-
const defaultListViewPageSize = parseInt(response.listconfigurationsresponse.configuration[0].value)
264-
commit('SET_DEFAULT_LISTVIEW_PAGE_SIZE', defaultListViewPageSize)
258+
if (result && result.defaultuipagesize) {
259+
commit('SET_DEFAULT_LISTVIEW_PAGE_SIZE', result.defaultuipagesize)
260+
}
265261
}).catch(error => {
266262
reject(error)
267263
})

0 commit comments

Comments
 (0)